mutation.go 891 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208
  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/workexperience"
  33. "wechat-api/ent/wx"
  34. "wechat-api/ent/wxcard"
  35. "wechat-api/ent/wxcarduser"
  36. "wechat-api/ent/wxcardvisit"
  37. "entgo.io/ent"
  38. "entgo.io/ent/dialect/sql"
  39. )
  40. const (
  41. // Operation types.
  42. OpCreate = ent.OpCreate
  43. OpDelete = ent.OpDelete
  44. OpDeleteOne = ent.OpDeleteOne
  45. OpUpdate = ent.OpUpdate
  46. OpUpdateOne = ent.OpUpdateOne
  47. // Node types.
  48. TypeAgent = "Agent"
  49. TypeAgentBase = "AgentBase"
  50. TypeAliyunAvatar = "AliyunAvatar"
  51. TypeBatchMsg = "BatchMsg"
  52. TypeCategory = "Category"
  53. TypeChatRecords = "ChatRecords"
  54. TypeChatSession = "ChatSession"
  55. TypeContact = "Contact"
  56. TypeEmployee = "Employee"
  57. TypeEmployeeConfig = "EmployeeConfig"
  58. TypeLabel = "Label"
  59. TypeLabelRelationship = "LabelRelationship"
  60. TypeMessage = "Message"
  61. TypeMessageRecords = "MessageRecords"
  62. TypeMsg = "Msg"
  63. TypeServer = "Server"
  64. TypeSopNode = "SopNode"
  65. TypeSopStage = "SopStage"
  66. TypeSopTask = "SopTask"
  67. TypeToken = "Token"
  68. TypeTutorial = "Tutorial"
  69. TypeWorkExperience = "WorkExperience"
  70. TypeWx = "Wx"
  71. TypeWxCard = "WxCard"
  72. TypeWxCardUser = "WxCardUser"
  73. TypeWxCardVisit = "WxCardVisit"
  74. )
  75. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  76. type AgentMutation struct {
  77. config
  78. op Op
  79. typ string
  80. id *uint64
  81. created_at *time.Time
  82. updated_at *time.Time
  83. deleted_at *time.Time
  84. name *string
  85. role *string
  86. status *int
  87. addstatus *int
  88. background *string
  89. examples *string
  90. organization_id *uint64
  91. addorganization_id *int64
  92. dataset_id *string
  93. collection_id *string
  94. clearedFields map[string]struct{}
  95. wx_agent map[uint64]struct{}
  96. removedwx_agent map[uint64]struct{}
  97. clearedwx_agent bool
  98. token_agent map[uint64]struct{}
  99. removedtoken_agent map[uint64]struct{}
  100. clearedtoken_agent bool
  101. done bool
  102. oldValue func(context.Context) (*Agent, error)
  103. predicates []predicate.Agent
  104. }
  105. var _ ent.Mutation = (*AgentMutation)(nil)
  106. // agentOption allows management of the mutation configuration using functional options.
  107. type agentOption func(*AgentMutation)
  108. // newAgentMutation creates new mutation for the Agent entity.
  109. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  110. m := &AgentMutation{
  111. config: c,
  112. op: op,
  113. typ: TypeAgent,
  114. clearedFields: make(map[string]struct{}),
  115. }
  116. for _, opt := range opts {
  117. opt(m)
  118. }
  119. return m
  120. }
  121. // withAgentID sets the ID field of the mutation.
  122. func withAgentID(id uint64) agentOption {
  123. return func(m *AgentMutation) {
  124. var (
  125. err error
  126. once sync.Once
  127. value *Agent
  128. )
  129. m.oldValue = func(ctx context.Context) (*Agent, error) {
  130. once.Do(func() {
  131. if m.done {
  132. err = errors.New("querying old values post mutation is not allowed")
  133. } else {
  134. value, err = m.Client().Agent.Get(ctx, id)
  135. }
  136. })
  137. return value, err
  138. }
  139. m.id = &id
  140. }
  141. }
  142. // withAgent sets the old Agent of the mutation.
  143. func withAgent(node *Agent) agentOption {
  144. return func(m *AgentMutation) {
  145. m.oldValue = func(context.Context) (*Agent, error) {
  146. return node, nil
  147. }
  148. m.id = &node.ID
  149. }
  150. }
  151. // Client returns a new `ent.Client` from the mutation. If the mutation was
  152. // executed in a transaction (ent.Tx), a transactional client is returned.
  153. func (m AgentMutation) Client() *Client {
  154. client := &Client{config: m.config}
  155. client.init()
  156. return client
  157. }
  158. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  159. // it returns an error otherwise.
  160. func (m AgentMutation) Tx() (*Tx, error) {
  161. if _, ok := m.driver.(*txDriver); !ok {
  162. return nil, errors.New("ent: mutation is not running in a transaction")
  163. }
  164. tx := &Tx{config: m.config}
  165. tx.init()
  166. return tx, nil
  167. }
  168. // SetID sets the value of the id field. Note that this
  169. // operation is only accepted on creation of Agent entities.
  170. func (m *AgentMutation) SetID(id uint64) {
  171. m.id = &id
  172. }
  173. // ID returns the ID value in the mutation. Note that the ID is only available
  174. // if it was provided to the builder or after it was returned from the database.
  175. func (m *AgentMutation) ID() (id uint64, exists bool) {
  176. if m.id == nil {
  177. return
  178. }
  179. return *m.id, true
  180. }
  181. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  182. // That means, if the mutation is applied within a transaction with an isolation level such
  183. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  184. // or updated by the mutation.
  185. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  186. switch {
  187. case m.op.Is(OpUpdateOne | OpDeleteOne):
  188. id, exists := m.ID()
  189. if exists {
  190. return []uint64{id}, nil
  191. }
  192. fallthrough
  193. case m.op.Is(OpUpdate | OpDelete):
  194. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  195. default:
  196. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  197. }
  198. }
  199. // SetCreatedAt sets the "created_at" field.
  200. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  201. m.created_at = &t
  202. }
  203. // CreatedAt returns the value of the "created_at" field in the mutation.
  204. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  205. v := m.created_at
  206. if v == nil {
  207. return
  208. }
  209. return *v, true
  210. }
  211. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  212. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  214. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  215. if !m.op.Is(OpUpdateOne) {
  216. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  217. }
  218. if m.id == nil || m.oldValue == nil {
  219. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  220. }
  221. oldValue, err := m.oldValue(ctx)
  222. if err != nil {
  223. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  224. }
  225. return oldValue.CreatedAt, nil
  226. }
  227. // ResetCreatedAt resets all changes to the "created_at" field.
  228. func (m *AgentMutation) ResetCreatedAt() {
  229. m.created_at = nil
  230. }
  231. // SetUpdatedAt sets the "updated_at" field.
  232. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  233. m.updated_at = &t
  234. }
  235. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  236. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  237. v := m.updated_at
  238. if v == nil {
  239. return
  240. }
  241. return *v, true
  242. }
  243. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  244. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  246. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  247. if !m.op.Is(OpUpdateOne) {
  248. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  249. }
  250. if m.id == nil || m.oldValue == nil {
  251. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  252. }
  253. oldValue, err := m.oldValue(ctx)
  254. if err != nil {
  255. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  256. }
  257. return oldValue.UpdatedAt, nil
  258. }
  259. // ResetUpdatedAt resets all changes to the "updated_at" field.
  260. func (m *AgentMutation) ResetUpdatedAt() {
  261. m.updated_at = nil
  262. }
  263. // SetDeletedAt sets the "deleted_at" field.
  264. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  265. m.deleted_at = &t
  266. }
  267. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  268. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  269. v := m.deleted_at
  270. if v == nil {
  271. return
  272. }
  273. return *v, true
  274. }
  275. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  276. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  278. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  279. if !m.op.Is(OpUpdateOne) {
  280. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  281. }
  282. if m.id == nil || m.oldValue == nil {
  283. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  284. }
  285. oldValue, err := m.oldValue(ctx)
  286. if err != nil {
  287. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  288. }
  289. return oldValue.DeletedAt, nil
  290. }
  291. // ClearDeletedAt clears the value of the "deleted_at" field.
  292. func (m *AgentMutation) ClearDeletedAt() {
  293. m.deleted_at = nil
  294. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  295. }
  296. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  297. func (m *AgentMutation) DeletedAtCleared() bool {
  298. _, ok := m.clearedFields[agent.FieldDeletedAt]
  299. return ok
  300. }
  301. // ResetDeletedAt resets all changes to the "deleted_at" field.
  302. func (m *AgentMutation) ResetDeletedAt() {
  303. m.deleted_at = nil
  304. delete(m.clearedFields, agent.FieldDeletedAt)
  305. }
  306. // SetName sets the "name" field.
  307. func (m *AgentMutation) SetName(s string) {
  308. m.name = &s
  309. }
  310. // Name returns the value of the "name" field in the mutation.
  311. func (m *AgentMutation) Name() (r string, exists bool) {
  312. v := m.name
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldName returns the old "name" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldName is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldName requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldName: %w", err)
  331. }
  332. return oldValue.Name, nil
  333. }
  334. // ResetName resets all changes to the "name" field.
  335. func (m *AgentMutation) ResetName() {
  336. m.name = nil
  337. }
  338. // SetRole sets the "role" field.
  339. func (m *AgentMutation) SetRole(s string) {
  340. m.role = &s
  341. }
  342. // Role returns the value of the "role" field in the mutation.
  343. func (m *AgentMutation) Role() (r string, exists bool) {
  344. v := m.role
  345. if v == nil {
  346. return
  347. }
  348. return *v, true
  349. }
  350. // OldRole returns the old "role" field's value of the Agent entity.
  351. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  353. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  354. if !m.op.Is(OpUpdateOne) {
  355. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  356. }
  357. if m.id == nil || m.oldValue == nil {
  358. return v, errors.New("OldRole requires an ID field in the mutation")
  359. }
  360. oldValue, err := m.oldValue(ctx)
  361. if err != nil {
  362. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  363. }
  364. return oldValue.Role, nil
  365. }
  366. // ResetRole resets all changes to the "role" field.
  367. func (m *AgentMutation) ResetRole() {
  368. m.role = nil
  369. }
  370. // SetStatus sets the "status" field.
  371. func (m *AgentMutation) SetStatus(i int) {
  372. m.status = &i
  373. m.addstatus = nil
  374. }
  375. // Status returns the value of the "status" field in the mutation.
  376. func (m *AgentMutation) Status() (r int, exists bool) {
  377. v := m.status
  378. if v == nil {
  379. return
  380. }
  381. return *v, true
  382. }
  383. // OldStatus returns the old "status" field's value of the Agent entity.
  384. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  386. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  387. if !m.op.Is(OpUpdateOne) {
  388. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  389. }
  390. if m.id == nil || m.oldValue == nil {
  391. return v, errors.New("OldStatus requires an ID field in the mutation")
  392. }
  393. oldValue, err := m.oldValue(ctx)
  394. if err != nil {
  395. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  396. }
  397. return oldValue.Status, nil
  398. }
  399. // AddStatus adds i to the "status" field.
  400. func (m *AgentMutation) AddStatus(i int) {
  401. if m.addstatus != nil {
  402. *m.addstatus += i
  403. } else {
  404. m.addstatus = &i
  405. }
  406. }
  407. // AddedStatus returns the value that was added to the "status" field in this mutation.
  408. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  409. v := m.addstatus
  410. if v == nil {
  411. return
  412. }
  413. return *v, true
  414. }
  415. // ClearStatus clears the value of the "status" field.
  416. func (m *AgentMutation) ClearStatus() {
  417. m.status = nil
  418. m.addstatus = nil
  419. m.clearedFields[agent.FieldStatus] = struct{}{}
  420. }
  421. // StatusCleared returns if the "status" field was cleared in this mutation.
  422. func (m *AgentMutation) StatusCleared() bool {
  423. _, ok := m.clearedFields[agent.FieldStatus]
  424. return ok
  425. }
  426. // ResetStatus resets all changes to the "status" field.
  427. func (m *AgentMutation) ResetStatus() {
  428. m.status = nil
  429. m.addstatus = nil
  430. delete(m.clearedFields, agent.FieldStatus)
  431. }
  432. // SetBackground sets the "background" field.
  433. func (m *AgentMutation) SetBackground(s string) {
  434. m.background = &s
  435. }
  436. // Background returns the value of the "background" field in the mutation.
  437. func (m *AgentMutation) Background() (r string, exists bool) {
  438. v := m.background
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldBackground returns the old "background" field's value of the Agent entity.
  445. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldBackground requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  457. }
  458. return oldValue.Background, nil
  459. }
  460. // ClearBackground clears the value of the "background" field.
  461. func (m *AgentMutation) ClearBackground() {
  462. m.background = nil
  463. m.clearedFields[agent.FieldBackground] = struct{}{}
  464. }
  465. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  466. func (m *AgentMutation) BackgroundCleared() bool {
  467. _, ok := m.clearedFields[agent.FieldBackground]
  468. return ok
  469. }
  470. // ResetBackground resets all changes to the "background" field.
  471. func (m *AgentMutation) ResetBackground() {
  472. m.background = nil
  473. delete(m.clearedFields, agent.FieldBackground)
  474. }
  475. // SetExamples sets the "examples" field.
  476. func (m *AgentMutation) SetExamples(s string) {
  477. m.examples = &s
  478. }
  479. // Examples returns the value of the "examples" field in the mutation.
  480. func (m *AgentMutation) Examples() (r string, exists bool) {
  481. v := m.examples
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldExamples returns the old "examples" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldExamples requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  500. }
  501. return oldValue.Examples, nil
  502. }
  503. // ClearExamples clears the value of the "examples" field.
  504. func (m *AgentMutation) ClearExamples() {
  505. m.examples = nil
  506. m.clearedFields[agent.FieldExamples] = struct{}{}
  507. }
  508. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  509. func (m *AgentMutation) ExamplesCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldExamples]
  511. return ok
  512. }
  513. // ResetExamples resets all changes to the "examples" field.
  514. func (m *AgentMutation) ResetExamples() {
  515. m.examples = nil
  516. delete(m.clearedFields, agent.FieldExamples)
  517. }
  518. // SetOrganizationID sets the "organization_id" field.
  519. func (m *AgentMutation) SetOrganizationID(u uint64) {
  520. m.organization_id = &u
  521. m.addorganization_id = nil
  522. }
  523. // OrganizationID returns the value of the "organization_id" field in the mutation.
  524. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  525. v := m.organization_id
  526. if v == nil {
  527. return
  528. }
  529. return *v, true
  530. }
  531. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  532. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  534. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  535. if !m.op.Is(OpUpdateOne) {
  536. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  537. }
  538. if m.id == nil || m.oldValue == nil {
  539. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  540. }
  541. oldValue, err := m.oldValue(ctx)
  542. if err != nil {
  543. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  544. }
  545. return oldValue.OrganizationID, nil
  546. }
  547. // AddOrganizationID adds u to the "organization_id" field.
  548. func (m *AgentMutation) AddOrganizationID(u int64) {
  549. if m.addorganization_id != nil {
  550. *m.addorganization_id += u
  551. } else {
  552. m.addorganization_id = &u
  553. }
  554. }
  555. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  556. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  557. v := m.addorganization_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // ResetOrganizationID resets all changes to the "organization_id" field.
  564. func (m *AgentMutation) ResetOrganizationID() {
  565. m.organization_id = nil
  566. m.addorganization_id = nil
  567. }
  568. // SetDatasetID sets the "dataset_id" field.
  569. func (m *AgentMutation) SetDatasetID(s string) {
  570. m.dataset_id = &s
  571. }
  572. // DatasetID returns the value of the "dataset_id" field in the mutation.
  573. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  574. v := m.dataset_id
  575. if v == nil {
  576. return
  577. }
  578. return *v, true
  579. }
  580. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  581. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  583. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  584. if !m.op.Is(OpUpdateOne) {
  585. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  586. }
  587. if m.id == nil || m.oldValue == nil {
  588. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  589. }
  590. oldValue, err := m.oldValue(ctx)
  591. if err != nil {
  592. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  593. }
  594. return oldValue.DatasetID, nil
  595. }
  596. // ResetDatasetID resets all changes to the "dataset_id" field.
  597. func (m *AgentMutation) ResetDatasetID() {
  598. m.dataset_id = nil
  599. }
  600. // SetCollectionID sets the "collection_id" field.
  601. func (m *AgentMutation) SetCollectionID(s string) {
  602. m.collection_id = &s
  603. }
  604. // CollectionID returns the value of the "collection_id" field in the mutation.
  605. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  606. v := m.collection_id
  607. if v == nil {
  608. return
  609. }
  610. return *v, true
  611. }
  612. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  613. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  615. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  616. if !m.op.Is(OpUpdateOne) {
  617. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  618. }
  619. if m.id == nil || m.oldValue == nil {
  620. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  621. }
  622. oldValue, err := m.oldValue(ctx)
  623. if err != nil {
  624. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  625. }
  626. return oldValue.CollectionID, nil
  627. }
  628. // ResetCollectionID resets all changes to the "collection_id" field.
  629. func (m *AgentMutation) ResetCollectionID() {
  630. m.collection_id = nil
  631. }
  632. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  633. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  634. if m.wx_agent == nil {
  635. m.wx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. m.wx_agent[ids[i]] = struct{}{}
  639. }
  640. }
  641. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  642. func (m *AgentMutation) ClearWxAgent() {
  643. m.clearedwx_agent = true
  644. }
  645. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  646. func (m *AgentMutation) WxAgentCleared() bool {
  647. return m.clearedwx_agent
  648. }
  649. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  650. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  651. if m.removedwx_agent == nil {
  652. m.removedwx_agent = make(map[uint64]struct{})
  653. }
  654. for i := range ids {
  655. delete(m.wx_agent, ids[i])
  656. m.removedwx_agent[ids[i]] = struct{}{}
  657. }
  658. }
  659. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  660. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  661. for id := range m.removedwx_agent {
  662. ids = append(ids, id)
  663. }
  664. return
  665. }
  666. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  667. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  668. for id := range m.wx_agent {
  669. ids = append(ids, id)
  670. }
  671. return
  672. }
  673. // ResetWxAgent resets all changes to the "wx_agent" edge.
  674. func (m *AgentMutation) ResetWxAgent() {
  675. m.wx_agent = nil
  676. m.clearedwx_agent = false
  677. m.removedwx_agent = nil
  678. }
  679. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  680. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  681. if m.token_agent == nil {
  682. m.token_agent = make(map[uint64]struct{})
  683. }
  684. for i := range ids {
  685. m.token_agent[ids[i]] = struct{}{}
  686. }
  687. }
  688. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  689. func (m *AgentMutation) ClearTokenAgent() {
  690. m.clearedtoken_agent = true
  691. }
  692. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  693. func (m *AgentMutation) TokenAgentCleared() bool {
  694. return m.clearedtoken_agent
  695. }
  696. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  697. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  698. if m.removedtoken_agent == nil {
  699. m.removedtoken_agent = make(map[uint64]struct{})
  700. }
  701. for i := range ids {
  702. delete(m.token_agent, ids[i])
  703. m.removedtoken_agent[ids[i]] = struct{}{}
  704. }
  705. }
  706. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  707. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  708. for id := range m.removedtoken_agent {
  709. ids = append(ids, id)
  710. }
  711. return
  712. }
  713. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  714. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  715. for id := range m.token_agent {
  716. ids = append(ids, id)
  717. }
  718. return
  719. }
  720. // ResetTokenAgent resets all changes to the "token_agent" edge.
  721. func (m *AgentMutation) ResetTokenAgent() {
  722. m.token_agent = nil
  723. m.clearedtoken_agent = false
  724. m.removedtoken_agent = nil
  725. }
  726. // Where appends a list predicates to the AgentMutation builder.
  727. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  728. m.predicates = append(m.predicates, ps...)
  729. }
  730. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  731. // users can use type-assertion to append predicates that do not depend on any generated package.
  732. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  733. p := make([]predicate.Agent, len(ps))
  734. for i := range ps {
  735. p[i] = ps[i]
  736. }
  737. m.Where(p...)
  738. }
  739. // Op returns the operation name.
  740. func (m *AgentMutation) Op() Op {
  741. return m.op
  742. }
  743. // SetOp allows setting the mutation operation.
  744. func (m *AgentMutation) SetOp(op Op) {
  745. m.op = op
  746. }
  747. // Type returns the node type of this mutation (Agent).
  748. func (m *AgentMutation) Type() string {
  749. return m.typ
  750. }
  751. // Fields returns all fields that were changed during this mutation. Note that in
  752. // order to get all numeric fields that were incremented/decremented, call
  753. // AddedFields().
  754. func (m *AgentMutation) Fields() []string {
  755. fields := make([]string, 0, 11)
  756. if m.created_at != nil {
  757. fields = append(fields, agent.FieldCreatedAt)
  758. }
  759. if m.updated_at != nil {
  760. fields = append(fields, agent.FieldUpdatedAt)
  761. }
  762. if m.deleted_at != nil {
  763. fields = append(fields, agent.FieldDeletedAt)
  764. }
  765. if m.name != nil {
  766. fields = append(fields, agent.FieldName)
  767. }
  768. if m.role != nil {
  769. fields = append(fields, agent.FieldRole)
  770. }
  771. if m.status != nil {
  772. fields = append(fields, agent.FieldStatus)
  773. }
  774. if m.background != nil {
  775. fields = append(fields, agent.FieldBackground)
  776. }
  777. if m.examples != nil {
  778. fields = append(fields, agent.FieldExamples)
  779. }
  780. if m.organization_id != nil {
  781. fields = append(fields, agent.FieldOrganizationID)
  782. }
  783. if m.dataset_id != nil {
  784. fields = append(fields, agent.FieldDatasetID)
  785. }
  786. if m.collection_id != nil {
  787. fields = append(fields, agent.FieldCollectionID)
  788. }
  789. return fields
  790. }
  791. // Field returns the value of a field with the given name. The second boolean
  792. // return value indicates that this field was not set, or was not defined in the
  793. // schema.
  794. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  795. switch name {
  796. case agent.FieldCreatedAt:
  797. return m.CreatedAt()
  798. case agent.FieldUpdatedAt:
  799. return m.UpdatedAt()
  800. case agent.FieldDeletedAt:
  801. return m.DeletedAt()
  802. case agent.FieldName:
  803. return m.Name()
  804. case agent.FieldRole:
  805. return m.Role()
  806. case agent.FieldStatus:
  807. return m.Status()
  808. case agent.FieldBackground:
  809. return m.Background()
  810. case agent.FieldExamples:
  811. return m.Examples()
  812. case agent.FieldOrganizationID:
  813. return m.OrganizationID()
  814. case agent.FieldDatasetID:
  815. return m.DatasetID()
  816. case agent.FieldCollectionID:
  817. return m.CollectionID()
  818. }
  819. return nil, false
  820. }
  821. // OldField returns the old value of the field from the database. An error is
  822. // returned if the mutation operation is not UpdateOne, or the query to the
  823. // database failed.
  824. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  825. switch name {
  826. case agent.FieldCreatedAt:
  827. return m.OldCreatedAt(ctx)
  828. case agent.FieldUpdatedAt:
  829. return m.OldUpdatedAt(ctx)
  830. case agent.FieldDeletedAt:
  831. return m.OldDeletedAt(ctx)
  832. case agent.FieldName:
  833. return m.OldName(ctx)
  834. case agent.FieldRole:
  835. return m.OldRole(ctx)
  836. case agent.FieldStatus:
  837. return m.OldStatus(ctx)
  838. case agent.FieldBackground:
  839. return m.OldBackground(ctx)
  840. case agent.FieldExamples:
  841. return m.OldExamples(ctx)
  842. case agent.FieldOrganizationID:
  843. return m.OldOrganizationID(ctx)
  844. case agent.FieldDatasetID:
  845. return m.OldDatasetID(ctx)
  846. case agent.FieldCollectionID:
  847. return m.OldCollectionID(ctx)
  848. }
  849. return nil, fmt.Errorf("unknown Agent field %s", name)
  850. }
  851. // SetField sets the value of a field with the given name. It returns an error if
  852. // the field is not defined in the schema, or if the type mismatched the field
  853. // type.
  854. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  855. switch name {
  856. case agent.FieldCreatedAt:
  857. v, ok := value.(time.Time)
  858. if !ok {
  859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  860. }
  861. m.SetCreatedAt(v)
  862. return nil
  863. case agent.FieldUpdatedAt:
  864. v, ok := value.(time.Time)
  865. if !ok {
  866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  867. }
  868. m.SetUpdatedAt(v)
  869. return nil
  870. case agent.FieldDeletedAt:
  871. v, ok := value.(time.Time)
  872. if !ok {
  873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  874. }
  875. m.SetDeletedAt(v)
  876. return nil
  877. case agent.FieldName:
  878. v, ok := value.(string)
  879. if !ok {
  880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  881. }
  882. m.SetName(v)
  883. return nil
  884. case agent.FieldRole:
  885. v, ok := value.(string)
  886. if !ok {
  887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  888. }
  889. m.SetRole(v)
  890. return nil
  891. case agent.FieldStatus:
  892. v, ok := value.(int)
  893. if !ok {
  894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  895. }
  896. m.SetStatus(v)
  897. return nil
  898. case agent.FieldBackground:
  899. v, ok := value.(string)
  900. if !ok {
  901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  902. }
  903. m.SetBackground(v)
  904. return nil
  905. case agent.FieldExamples:
  906. v, ok := value.(string)
  907. if !ok {
  908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  909. }
  910. m.SetExamples(v)
  911. return nil
  912. case agent.FieldOrganizationID:
  913. v, ok := value.(uint64)
  914. if !ok {
  915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  916. }
  917. m.SetOrganizationID(v)
  918. return nil
  919. case agent.FieldDatasetID:
  920. v, ok := value.(string)
  921. if !ok {
  922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  923. }
  924. m.SetDatasetID(v)
  925. return nil
  926. case agent.FieldCollectionID:
  927. v, ok := value.(string)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetCollectionID(v)
  932. return nil
  933. }
  934. return fmt.Errorf("unknown Agent field %s", name)
  935. }
  936. // AddedFields returns all numeric fields that were incremented/decremented during
  937. // this mutation.
  938. func (m *AgentMutation) AddedFields() []string {
  939. var fields []string
  940. if m.addstatus != nil {
  941. fields = append(fields, agent.FieldStatus)
  942. }
  943. if m.addorganization_id != nil {
  944. fields = append(fields, agent.FieldOrganizationID)
  945. }
  946. return fields
  947. }
  948. // AddedField returns the numeric value that was incremented/decremented on a field
  949. // with the given name. The second boolean return value indicates that this field
  950. // was not set, or was not defined in the schema.
  951. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  952. switch name {
  953. case agent.FieldStatus:
  954. return m.AddedStatus()
  955. case agent.FieldOrganizationID:
  956. return m.AddedOrganizationID()
  957. }
  958. return nil, false
  959. }
  960. // AddField adds the value to the field with the given name. It returns an error if
  961. // the field is not defined in the schema, or if the type mismatched the field
  962. // type.
  963. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  964. switch name {
  965. case agent.FieldStatus:
  966. v, ok := value.(int)
  967. if !ok {
  968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  969. }
  970. m.AddStatus(v)
  971. return nil
  972. case agent.FieldOrganizationID:
  973. v, ok := value.(int64)
  974. if !ok {
  975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  976. }
  977. m.AddOrganizationID(v)
  978. return nil
  979. }
  980. return fmt.Errorf("unknown Agent numeric field %s", name)
  981. }
  982. // ClearedFields returns all nullable fields that were cleared during this
  983. // mutation.
  984. func (m *AgentMutation) ClearedFields() []string {
  985. var fields []string
  986. if m.FieldCleared(agent.FieldDeletedAt) {
  987. fields = append(fields, agent.FieldDeletedAt)
  988. }
  989. if m.FieldCleared(agent.FieldStatus) {
  990. fields = append(fields, agent.FieldStatus)
  991. }
  992. if m.FieldCleared(agent.FieldBackground) {
  993. fields = append(fields, agent.FieldBackground)
  994. }
  995. if m.FieldCleared(agent.FieldExamples) {
  996. fields = append(fields, agent.FieldExamples)
  997. }
  998. return fields
  999. }
  1000. // FieldCleared returns a boolean indicating if a field with the given name was
  1001. // cleared in this mutation.
  1002. func (m *AgentMutation) FieldCleared(name string) bool {
  1003. _, ok := m.clearedFields[name]
  1004. return ok
  1005. }
  1006. // ClearField clears the value of the field with the given name. It returns an
  1007. // error if the field is not defined in the schema.
  1008. func (m *AgentMutation) ClearField(name string) error {
  1009. switch name {
  1010. case agent.FieldDeletedAt:
  1011. m.ClearDeletedAt()
  1012. return nil
  1013. case agent.FieldStatus:
  1014. m.ClearStatus()
  1015. return nil
  1016. case agent.FieldBackground:
  1017. m.ClearBackground()
  1018. return nil
  1019. case agent.FieldExamples:
  1020. m.ClearExamples()
  1021. return nil
  1022. }
  1023. return fmt.Errorf("unknown Agent nullable field %s", name)
  1024. }
  1025. // ResetField resets all changes in the mutation for the field with the given name.
  1026. // It returns an error if the field is not defined in the schema.
  1027. func (m *AgentMutation) ResetField(name string) error {
  1028. switch name {
  1029. case agent.FieldCreatedAt:
  1030. m.ResetCreatedAt()
  1031. return nil
  1032. case agent.FieldUpdatedAt:
  1033. m.ResetUpdatedAt()
  1034. return nil
  1035. case agent.FieldDeletedAt:
  1036. m.ResetDeletedAt()
  1037. return nil
  1038. case agent.FieldName:
  1039. m.ResetName()
  1040. return nil
  1041. case agent.FieldRole:
  1042. m.ResetRole()
  1043. return nil
  1044. case agent.FieldStatus:
  1045. m.ResetStatus()
  1046. return nil
  1047. case agent.FieldBackground:
  1048. m.ResetBackground()
  1049. return nil
  1050. case agent.FieldExamples:
  1051. m.ResetExamples()
  1052. return nil
  1053. case agent.FieldOrganizationID:
  1054. m.ResetOrganizationID()
  1055. return nil
  1056. case agent.FieldDatasetID:
  1057. m.ResetDatasetID()
  1058. return nil
  1059. case agent.FieldCollectionID:
  1060. m.ResetCollectionID()
  1061. return nil
  1062. }
  1063. return fmt.Errorf("unknown Agent field %s", name)
  1064. }
  1065. // AddedEdges returns all edge names that were set/added in this mutation.
  1066. func (m *AgentMutation) AddedEdges() []string {
  1067. edges := make([]string, 0, 2)
  1068. if m.wx_agent != nil {
  1069. edges = append(edges, agent.EdgeWxAgent)
  1070. }
  1071. if m.token_agent != nil {
  1072. edges = append(edges, agent.EdgeTokenAgent)
  1073. }
  1074. return edges
  1075. }
  1076. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1077. // name in this mutation.
  1078. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1079. switch name {
  1080. case agent.EdgeWxAgent:
  1081. ids := make([]ent.Value, 0, len(m.wx_agent))
  1082. for id := range m.wx_agent {
  1083. ids = append(ids, id)
  1084. }
  1085. return ids
  1086. case agent.EdgeTokenAgent:
  1087. ids := make([]ent.Value, 0, len(m.token_agent))
  1088. for id := range m.token_agent {
  1089. ids = append(ids, id)
  1090. }
  1091. return ids
  1092. }
  1093. return nil
  1094. }
  1095. // RemovedEdges returns all edge names that were removed in this mutation.
  1096. func (m *AgentMutation) RemovedEdges() []string {
  1097. edges := make([]string, 0, 2)
  1098. if m.removedwx_agent != nil {
  1099. edges = append(edges, agent.EdgeWxAgent)
  1100. }
  1101. if m.removedtoken_agent != nil {
  1102. edges = append(edges, agent.EdgeTokenAgent)
  1103. }
  1104. return edges
  1105. }
  1106. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1107. // the given name in this mutation.
  1108. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1109. switch name {
  1110. case agent.EdgeWxAgent:
  1111. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1112. for id := range m.removedwx_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return ids
  1116. case agent.EdgeTokenAgent:
  1117. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1118. for id := range m.removedtoken_agent {
  1119. ids = append(ids, id)
  1120. }
  1121. return ids
  1122. }
  1123. return nil
  1124. }
  1125. // ClearedEdges returns all edge names that were cleared in this mutation.
  1126. func (m *AgentMutation) ClearedEdges() []string {
  1127. edges := make([]string, 0, 2)
  1128. if m.clearedwx_agent {
  1129. edges = append(edges, agent.EdgeWxAgent)
  1130. }
  1131. if m.clearedtoken_agent {
  1132. edges = append(edges, agent.EdgeTokenAgent)
  1133. }
  1134. return edges
  1135. }
  1136. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1137. // was cleared in this mutation.
  1138. func (m *AgentMutation) EdgeCleared(name string) bool {
  1139. switch name {
  1140. case agent.EdgeWxAgent:
  1141. return m.clearedwx_agent
  1142. case agent.EdgeTokenAgent:
  1143. return m.clearedtoken_agent
  1144. }
  1145. return false
  1146. }
  1147. // ClearEdge clears the value of the edge with the given name. It returns an error
  1148. // if that edge is not defined in the schema.
  1149. func (m *AgentMutation) ClearEdge(name string) error {
  1150. switch name {
  1151. }
  1152. return fmt.Errorf("unknown Agent unique edge %s", name)
  1153. }
  1154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1155. // It returns an error if the edge is not defined in the schema.
  1156. func (m *AgentMutation) ResetEdge(name string) error {
  1157. switch name {
  1158. case agent.EdgeWxAgent:
  1159. m.ResetWxAgent()
  1160. return nil
  1161. case agent.EdgeTokenAgent:
  1162. m.ResetTokenAgent()
  1163. return nil
  1164. }
  1165. return fmt.Errorf("unknown Agent edge %s", name)
  1166. }
  1167. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1168. type AgentBaseMutation struct {
  1169. config
  1170. op Op
  1171. typ string
  1172. id *string
  1173. q *string
  1174. a *string
  1175. chunk_index *uint64
  1176. addchunk_index *int64
  1177. indexes *[]string
  1178. appendindexes []string
  1179. dataset_id *string
  1180. collection_id *string
  1181. source_name *string
  1182. can_write *[]bool
  1183. appendcan_write []bool
  1184. is_owner *[]bool
  1185. appendis_owner []bool
  1186. clearedFields map[string]struct{}
  1187. wx_agent map[uint64]struct{}
  1188. removedwx_agent map[uint64]struct{}
  1189. clearedwx_agent bool
  1190. done bool
  1191. oldValue func(context.Context) (*AgentBase, error)
  1192. predicates []predicate.AgentBase
  1193. }
  1194. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1195. // agentbaseOption allows management of the mutation configuration using functional options.
  1196. type agentbaseOption func(*AgentBaseMutation)
  1197. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1198. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1199. m := &AgentBaseMutation{
  1200. config: c,
  1201. op: op,
  1202. typ: TypeAgentBase,
  1203. clearedFields: make(map[string]struct{}),
  1204. }
  1205. for _, opt := range opts {
  1206. opt(m)
  1207. }
  1208. return m
  1209. }
  1210. // withAgentBaseID sets the ID field of the mutation.
  1211. func withAgentBaseID(id string) agentbaseOption {
  1212. return func(m *AgentBaseMutation) {
  1213. var (
  1214. err error
  1215. once sync.Once
  1216. value *AgentBase
  1217. )
  1218. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1219. once.Do(func() {
  1220. if m.done {
  1221. err = errors.New("querying old values post mutation is not allowed")
  1222. } else {
  1223. value, err = m.Client().AgentBase.Get(ctx, id)
  1224. }
  1225. })
  1226. return value, err
  1227. }
  1228. m.id = &id
  1229. }
  1230. }
  1231. // withAgentBase sets the old AgentBase of the mutation.
  1232. func withAgentBase(node *AgentBase) agentbaseOption {
  1233. return func(m *AgentBaseMutation) {
  1234. m.oldValue = func(context.Context) (*AgentBase, error) {
  1235. return node, nil
  1236. }
  1237. m.id = &node.ID
  1238. }
  1239. }
  1240. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1241. // executed in a transaction (ent.Tx), a transactional client is returned.
  1242. func (m AgentBaseMutation) Client() *Client {
  1243. client := &Client{config: m.config}
  1244. client.init()
  1245. return client
  1246. }
  1247. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1248. // it returns an error otherwise.
  1249. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1250. if _, ok := m.driver.(*txDriver); !ok {
  1251. return nil, errors.New("ent: mutation is not running in a transaction")
  1252. }
  1253. tx := &Tx{config: m.config}
  1254. tx.init()
  1255. return tx, nil
  1256. }
  1257. // SetID sets the value of the id field. Note that this
  1258. // operation is only accepted on creation of AgentBase entities.
  1259. func (m *AgentBaseMutation) SetID(id string) {
  1260. m.id = &id
  1261. }
  1262. // ID returns the ID value in the mutation. Note that the ID is only available
  1263. // if it was provided to the builder or after it was returned from the database.
  1264. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1265. if m.id == nil {
  1266. return
  1267. }
  1268. return *m.id, true
  1269. }
  1270. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1271. // That means, if the mutation is applied within a transaction with an isolation level such
  1272. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1273. // or updated by the mutation.
  1274. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1275. switch {
  1276. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1277. id, exists := m.ID()
  1278. if exists {
  1279. return []string{id}, nil
  1280. }
  1281. fallthrough
  1282. case m.op.Is(OpUpdate | OpDelete):
  1283. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1284. default:
  1285. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1286. }
  1287. }
  1288. // SetQ sets the "q" field.
  1289. func (m *AgentBaseMutation) SetQ(s string) {
  1290. m.q = &s
  1291. }
  1292. // Q returns the value of the "q" field in the mutation.
  1293. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1294. v := m.q
  1295. if v == nil {
  1296. return
  1297. }
  1298. return *v, true
  1299. }
  1300. // OldQ returns the old "q" field's value of the AgentBase entity.
  1301. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1303. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1304. if !m.op.Is(OpUpdateOne) {
  1305. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1306. }
  1307. if m.id == nil || m.oldValue == nil {
  1308. return v, errors.New("OldQ requires an ID field in the mutation")
  1309. }
  1310. oldValue, err := m.oldValue(ctx)
  1311. if err != nil {
  1312. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1313. }
  1314. return oldValue.Q, nil
  1315. }
  1316. // ClearQ clears the value of the "q" field.
  1317. func (m *AgentBaseMutation) ClearQ() {
  1318. m.q = nil
  1319. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1320. }
  1321. // QCleared returns if the "q" field was cleared in this mutation.
  1322. func (m *AgentBaseMutation) QCleared() bool {
  1323. _, ok := m.clearedFields[agentbase.FieldQ]
  1324. return ok
  1325. }
  1326. // ResetQ resets all changes to the "q" field.
  1327. func (m *AgentBaseMutation) ResetQ() {
  1328. m.q = nil
  1329. delete(m.clearedFields, agentbase.FieldQ)
  1330. }
  1331. // SetA sets the "a" field.
  1332. func (m *AgentBaseMutation) SetA(s string) {
  1333. m.a = &s
  1334. }
  1335. // A returns the value of the "a" field in the mutation.
  1336. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1337. v := m.a
  1338. if v == nil {
  1339. return
  1340. }
  1341. return *v, true
  1342. }
  1343. // OldA returns the old "a" field's value of the AgentBase entity.
  1344. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1346. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1347. if !m.op.Is(OpUpdateOne) {
  1348. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1349. }
  1350. if m.id == nil || m.oldValue == nil {
  1351. return v, errors.New("OldA requires an ID field in the mutation")
  1352. }
  1353. oldValue, err := m.oldValue(ctx)
  1354. if err != nil {
  1355. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1356. }
  1357. return oldValue.A, nil
  1358. }
  1359. // ClearA clears the value of the "a" field.
  1360. func (m *AgentBaseMutation) ClearA() {
  1361. m.a = nil
  1362. m.clearedFields[agentbase.FieldA] = struct{}{}
  1363. }
  1364. // ACleared returns if the "a" field was cleared in this mutation.
  1365. func (m *AgentBaseMutation) ACleared() bool {
  1366. _, ok := m.clearedFields[agentbase.FieldA]
  1367. return ok
  1368. }
  1369. // ResetA resets all changes to the "a" field.
  1370. func (m *AgentBaseMutation) ResetA() {
  1371. m.a = nil
  1372. delete(m.clearedFields, agentbase.FieldA)
  1373. }
  1374. // SetChunkIndex sets the "chunk_index" field.
  1375. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1376. m.chunk_index = &u
  1377. m.addchunk_index = nil
  1378. }
  1379. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1380. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1381. v := m.chunk_index
  1382. if v == nil {
  1383. return
  1384. }
  1385. return *v, true
  1386. }
  1387. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1388. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1390. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1391. if !m.op.Is(OpUpdateOne) {
  1392. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1393. }
  1394. if m.id == nil || m.oldValue == nil {
  1395. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1396. }
  1397. oldValue, err := m.oldValue(ctx)
  1398. if err != nil {
  1399. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1400. }
  1401. return oldValue.ChunkIndex, nil
  1402. }
  1403. // AddChunkIndex adds u to the "chunk_index" field.
  1404. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1405. if m.addchunk_index != nil {
  1406. *m.addchunk_index += u
  1407. } else {
  1408. m.addchunk_index = &u
  1409. }
  1410. }
  1411. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1412. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1413. v := m.addchunk_index
  1414. if v == nil {
  1415. return
  1416. }
  1417. return *v, true
  1418. }
  1419. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1420. func (m *AgentBaseMutation) ResetChunkIndex() {
  1421. m.chunk_index = nil
  1422. m.addchunk_index = nil
  1423. }
  1424. // SetIndexes sets the "indexes" field.
  1425. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1426. m.indexes = &s
  1427. m.appendindexes = nil
  1428. }
  1429. // Indexes returns the value of the "indexes" field in the mutation.
  1430. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1431. v := m.indexes
  1432. if v == nil {
  1433. return
  1434. }
  1435. return *v, true
  1436. }
  1437. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1438. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1440. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1441. if !m.op.Is(OpUpdateOne) {
  1442. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1443. }
  1444. if m.id == nil || m.oldValue == nil {
  1445. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1446. }
  1447. oldValue, err := m.oldValue(ctx)
  1448. if err != nil {
  1449. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1450. }
  1451. return oldValue.Indexes, nil
  1452. }
  1453. // AppendIndexes adds s to the "indexes" field.
  1454. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1455. m.appendindexes = append(m.appendindexes, s...)
  1456. }
  1457. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1458. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1459. if len(m.appendindexes) == 0 {
  1460. return nil, false
  1461. }
  1462. return m.appendindexes, true
  1463. }
  1464. // ClearIndexes clears the value of the "indexes" field.
  1465. func (m *AgentBaseMutation) ClearIndexes() {
  1466. m.indexes = nil
  1467. m.appendindexes = nil
  1468. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1469. }
  1470. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1471. func (m *AgentBaseMutation) IndexesCleared() bool {
  1472. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1473. return ok
  1474. }
  1475. // ResetIndexes resets all changes to the "indexes" field.
  1476. func (m *AgentBaseMutation) ResetIndexes() {
  1477. m.indexes = nil
  1478. m.appendindexes = nil
  1479. delete(m.clearedFields, agentbase.FieldIndexes)
  1480. }
  1481. // SetDatasetID sets the "dataset_id" field.
  1482. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1483. m.dataset_id = &s
  1484. }
  1485. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1486. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1487. v := m.dataset_id
  1488. if v == nil {
  1489. return
  1490. }
  1491. return *v, true
  1492. }
  1493. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1494. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1496. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1497. if !m.op.Is(OpUpdateOne) {
  1498. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1499. }
  1500. if m.id == nil || m.oldValue == nil {
  1501. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1502. }
  1503. oldValue, err := m.oldValue(ctx)
  1504. if err != nil {
  1505. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1506. }
  1507. return oldValue.DatasetID, nil
  1508. }
  1509. // ClearDatasetID clears the value of the "dataset_id" field.
  1510. func (m *AgentBaseMutation) ClearDatasetID() {
  1511. m.dataset_id = nil
  1512. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1513. }
  1514. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1515. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1516. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1517. return ok
  1518. }
  1519. // ResetDatasetID resets all changes to the "dataset_id" field.
  1520. func (m *AgentBaseMutation) ResetDatasetID() {
  1521. m.dataset_id = nil
  1522. delete(m.clearedFields, agentbase.FieldDatasetID)
  1523. }
  1524. // SetCollectionID sets the "collection_id" field.
  1525. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1526. m.collection_id = &s
  1527. }
  1528. // CollectionID returns the value of the "collection_id" field in the mutation.
  1529. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1530. v := m.collection_id
  1531. if v == nil {
  1532. return
  1533. }
  1534. return *v, true
  1535. }
  1536. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1537. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1539. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1540. if !m.op.Is(OpUpdateOne) {
  1541. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1542. }
  1543. if m.id == nil || m.oldValue == nil {
  1544. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1545. }
  1546. oldValue, err := m.oldValue(ctx)
  1547. if err != nil {
  1548. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1549. }
  1550. return oldValue.CollectionID, nil
  1551. }
  1552. // ClearCollectionID clears the value of the "collection_id" field.
  1553. func (m *AgentBaseMutation) ClearCollectionID() {
  1554. m.collection_id = nil
  1555. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1556. }
  1557. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1558. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1559. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1560. return ok
  1561. }
  1562. // ResetCollectionID resets all changes to the "collection_id" field.
  1563. func (m *AgentBaseMutation) ResetCollectionID() {
  1564. m.collection_id = nil
  1565. delete(m.clearedFields, agentbase.FieldCollectionID)
  1566. }
  1567. // SetSourceName sets the "source_name" field.
  1568. func (m *AgentBaseMutation) SetSourceName(s string) {
  1569. m.source_name = &s
  1570. }
  1571. // SourceName returns the value of the "source_name" field in the mutation.
  1572. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1573. v := m.source_name
  1574. if v == nil {
  1575. return
  1576. }
  1577. return *v, true
  1578. }
  1579. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1580. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1582. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1583. if !m.op.Is(OpUpdateOne) {
  1584. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1585. }
  1586. if m.id == nil || m.oldValue == nil {
  1587. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1588. }
  1589. oldValue, err := m.oldValue(ctx)
  1590. if err != nil {
  1591. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1592. }
  1593. return oldValue.SourceName, nil
  1594. }
  1595. // ClearSourceName clears the value of the "source_name" field.
  1596. func (m *AgentBaseMutation) ClearSourceName() {
  1597. m.source_name = nil
  1598. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1599. }
  1600. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1601. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1602. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1603. return ok
  1604. }
  1605. // ResetSourceName resets all changes to the "source_name" field.
  1606. func (m *AgentBaseMutation) ResetSourceName() {
  1607. m.source_name = nil
  1608. delete(m.clearedFields, agentbase.FieldSourceName)
  1609. }
  1610. // SetCanWrite sets the "can_write" field.
  1611. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1612. m.can_write = &b
  1613. m.appendcan_write = nil
  1614. }
  1615. // CanWrite returns the value of the "can_write" field in the mutation.
  1616. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1617. v := m.can_write
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1624. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1636. }
  1637. return oldValue.CanWrite, nil
  1638. }
  1639. // AppendCanWrite adds b to the "can_write" field.
  1640. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1641. m.appendcan_write = append(m.appendcan_write, b...)
  1642. }
  1643. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1644. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1645. if len(m.appendcan_write) == 0 {
  1646. return nil, false
  1647. }
  1648. return m.appendcan_write, true
  1649. }
  1650. // ClearCanWrite clears the value of the "can_write" field.
  1651. func (m *AgentBaseMutation) ClearCanWrite() {
  1652. m.can_write = nil
  1653. m.appendcan_write = nil
  1654. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1655. }
  1656. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1657. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1658. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1659. return ok
  1660. }
  1661. // ResetCanWrite resets all changes to the "can_write" field.
  1662. func (m *AgentBaseMutation) ResetCanWrite() {
  1663. m.can_write = nil
  1664. m.appendcan_write = nil
  1665. delete(m.clearedFields, agentbase.FieldCanWrite)
  1666. }
  1667. // SetIsOwner sets the "is_owner" field.
  1668. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1669. m.is_owner = &b
  1670. m.appendis_owner = nil
  1671. }
  1672. // IsOwner returns the value of the "is_owner" field in the mutation.
  1673. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1674. v := m.is_owner
  1675. if v == nil {
  1676. return
  1677. }
  1678. return *v, true
  1679. }
  1680. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1681. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1683. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1684. if !m.op.Is(OpUpdateOne) {
  1685. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1686. }
  1687. if m.id == nil || m.oldValue == nil {
  1688. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1689. }
  1690. oldValue, err := m.oldValue(ctx)
  1691. if err != nil {
  1692. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1693. }
  1694. return oldValue.IsOwner, nil
  1695. }
  1696. // AppendIsOwner adds b to the "is_owner" field.
  1697. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1698. m.appendis_owner = append(m.appendis_owner, b...)
  1699. }
  1700. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1701. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1702. if len(m.appendis_owner) == 0 {
  1703. return nil, false
  1704. }
  1705. return m.appendis_owner, true
  1706. }
  1707. // ClearIsOwner clears the value of the "is_owner" field.
  1708. func (m *AgentBaseMutation) ClearIsOwner() {
  1709. m.is_owner = nil
  1710. m.appendis_owner = nil
  1711. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1712. }
  1713. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1714. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1715. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1716. return ok
  1717. }
  1718. // ResetIsOwner resets all changes to the "is_owner" field.
  1719. func (m *AgentBaseMutation) ResetIsOwner() {
  1720. m.is_owner = nil
  1721. m.appendis_owner = nil
  1722. delete(m.clearedFields, agentbase.FieldIsOwner)
  1723. }
  1724. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1725. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1726. if m.wx_agent == nil {
  1727. m.wx_agent = make(map[uint64]struct{})
  1728. }
  1729. for i := range ids {
  1730. m.wx_agent[ids[i]] = struct{}{}
  1731. }
  1732. }
  1733. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1734. func (m *AgentBaseMutation) ClearWxAgent() {
  1735. m.clearedwx_agent = true
  1736. }
  1737. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1738. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1739. return m.clearedwx_agent
  1740. }
  1741. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1742. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1743. if m.removedwx_agent == nil {
  1744. m.removedwx_agent = make(map[uint64]struct{})
  1745. }
  1746. for i := range ids {
  1747. delete(m.wx_agent, ids[i])
  1748. m.removedwx_agent[ids[i]] = struct{}{}
  1749. }
  1750. }
  1751. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1752. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1753. for id := range m.removedwx_agent {
  1754. ids = append(ids, id)
  1755. }
  1756. return
  1757. }
  1758. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1759. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1760. for id := range m.wx_agent {
  1761. ids = append(ids, id)
  1762. }
  1763. return
  1764. }
  1765. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1766. func (m *AgentBaseMutation) ResetWxAgent() {
  1767. m.wx_agent = nil
  1768. m.clearedwx_agent = false
  1769. m.removedwx_agent = nil
  1770. }
  1771. // Where appends a list predicates to the AgentBaseMutation builder.
  1772. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1773. m.predicates = append(m.predicates, ps...)
  1774. }
  1775. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1776. // users can use type-assertion to append predicates that do not depend on any generated package.
  1777. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1778. p := make([]predicate.AgentBase, len(ps))
  1779. for i := range ps {
  1780. p[i] = ps[i]
  1781. }
  1782. m.Where(p...)
  1783. }
  1784. // Op returns the operation name.
  1785. func (m *AgentBaseMutation) Op() Op {
  1786. return m.op
  1787. }
  1788. // SetOp allows setting the mutation operation.
  1789. func (m *AgentBaseMutation) SetOp(op Op) {
  1790. m.op = op
  1791. }
  1792. // Type returns the node type of this mutation (AgentBase).
  1793. func (m *AgentBaseMutation) Type() string {
  1794. return m.typ
  1795. }
  1796. // Fields returns all fields that were changed during this mutation. Note that in
  1797. // order to get all numeric fields that were incremented/decremented, call
  1798. // AddedFields().
  1799. func (m *AgentBaseMutation) Fields() []string {
  1800. fields := make([]string, 0, 9)
  1801. if m.q != nil {
  1802. fields = append(fields, agentbase.FieldQ)
  1803. }
  1804. if m.a != nil {
  1805. fields = append(fields, agentbase.FieldA)
  1806. }
  1807. if m.chunk_index != nil {
  1808. fields = append(fields, agentbase.FieldChunkIndex)
  1809. }
  1810. if m.indexes != nil {
  1811. fields = append(fields, agentbase.FieldIndexes)
  1812. }
  1813. if m.dataset_id != nil {
  1814. fields = append(fields, agentbase.FieldDatasetID)
  1815. }
  1816. if m.collection_id != nil {
  1817. fields = append(fields, agentbase.FieldCollectionID)
  1818. }
  1819. if m.source_name != nil {
  1820. fields = append(fields, agentbase.FieldSourceName)
  1821. }
  1822. if m.can_write != nil {
  1823. fields = append(fields, agentbase.FieldCanWrite)
  1824. }
  1825. if m.is_owner != nil {
  1826. fields = append(fields, agentbase.FieldIsOwner)
  1827. }
  1828. return fields
  1829. }
  1830. // Field returns the value of a field with the given name. The second boolean
  1831. // return value indicates that this field was not set, or was not defined in the
  1832. // schema.
  1833. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1834. switch name {
  1835. case agentbase.FieldQ:
  1836. return m.Q()
  1837. case agentbase.FieldA:
  1838. return m.A()
  1839. case agentbase.FieldChunkIndex:
  1840. return m.ChunkIndex()
  1841. case agentbase.FieldIndexes:
  1842. return m.Indexes()
  1843. case agentbase.FieldDatasetID:
  1844. return m.DatasetID()
  1845. case agentbase.FieldCollectionID:
  1846. return m.CollectionID()
  1847. case agentbase.FieldSourceName:
  1848. return m.SourceName()
  1849. case agentbase.FieldCanWrite:
  1850. return m.CanWrite()
  1851. case agentbase.FieldIsOwner:
  1852. return m.IsOwner()
  1853. }
  1854. return nil, false
  1855. }
  1856. // OldField returns the old value of the field from the database. An error is
  1857. // returned if the mutation operation is not UpdateOne, or the query to the
  1858. // database failed.
  1859. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1860. switch name {
  1861. case agentbase.FieldQ:
  1862. return m.OldQ(ctx)
  1863. case agentbase.FieldA:
  1864. return m.OldA(ctx)
  1865. case agentbase.FieldChunkIndex:
  1866. return m.OldChunkIndex(ctx)
  1867. case agentbase.FieldIndexes:
  1868. return m.OldIndexes(ctx)
  1869. case agentbase.FieldDatasetID:
  1870. return m.OldDatasetID(ctx)
  1871. case agentbase.FieldCollectionID:
  1872. return m.OldCollectionID(ctx)
  1873. case agentbase.FieldSourceName:
  1874. return m.OldSourceName(ctx)
  1875. case agentbase.FieldCanWrite:
  1876. return m.OldCanWrite(ctx)
  1877. case agentbase.FieldIsOwner:
  1878. return m.OldIsOwner(ctx)
  1879. }
  1880. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1881. }
  1882. // SetField sets the value of a field with the given name. It returns an error if
  1883. // the field is not defined in the schema, or if the type mismatched the field
  1884. // type.
  1885. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1886. switch name {
  1887. case agentbase.FieldQ:
  1888. v, ok := value.(string)
  1889. if !ok {
  1890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1891. }
  1892. m.SetQ(v)
  1893. return nil
  1894. case agentbase.FieldA:
  1895. v, ok := value.(string)
  1896. if !ok {
  1897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1898. }
  1899. m.SetA(v)
  1900. return nil
  1901. case agentbase.FieldChunkIndex:
  1902. v, ok := value.(uint64)
  1903. if !ok {
  1904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1905. }
  1906. m.SetChunkIndex(v)
  1907. return nil
  1908. case agentbase.FieldIndexes:
  1909. v, ok := value.([]string)
  1910. if !ok {
  1911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1912. }
  1913. m.SetIndexes(v)
  1914. return nil
  1915. case agentbase.FieldDatasetID:
  1916. v, ok := value.(string)
  1917. if !ok {
  1918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1919. }
  1920. m.SetDatasetID(v)
  1921. return nil
  1922. case agentbase.FieldCollectionID:
  1923. v, ok := value.(string)
  1924. if !ok {
  1925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1926. }
  1927. m.SetCollectionID(v)
  1928. return nil
  1929. case agentbase.FieldSourceName:
  1930. v, ok := value.(string)
  1931. if !ok {
  1932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1933. }
  1934. m.SetSourceName(v)
  1935. return nil
  1936. case agentbase.FieldCanWrite:
  1937. v, ok := value.([]bool)
  1938. if !ok {
  1939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1940. }
  1941. m.SetCanWrite(v)
  1942. return nil
  1943. case agentbase.FieldIsOwner:
  1944. v, ok := value.([]bool)
  1945. if !ok {
  1946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1947. }
  1948. m.SetIsOwner(v)
  1949. return nil
  1950. }
  1951. return fmt.Errorf("unknown AgentBase field %s", name)
  1952. }
  1953. // AddedFields returns all numeric fields that were incremented/decremented during
  1954. // this mutation.
  1955. func (m *AgentBaseMutation) AddedFields() []string {
  1956. var fields []string
  1957. if m.addchunk_index != nil {
  1958. fields = append(fields, agentbase.FieldChunkIndex)
  1959. }
  1960. return fields
  1961. }
  1962. // AddedField returns the numeric value that was incremented/decremented on a field
  1963. // with the given name. The second boolean return value indicates that this field
  1964. // was not set, or was not defined in the schema.
  1965. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1966. switch name {
  1967. case agentbase.FieldChunkIndex:
  1968. return m.AddedChunkIndex()
  1969. }
  1970. return nil, false
  1971. }
  1972. // AddField adds the value to the field with the given name. It returns an error if
  1973. // the field is not defined in the schema, or if the type mismatched the field
  1974. // type.
  1975. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1976. switch name {
  1977. case agentbase.FieldChunkIndex:
  1978. v, ok := value.(int64)
  1979. if !ok {
  1980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1981. }
  1982. m.AddChunkIndex(v)
  1983. return nil
  1984. }
  1985. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1986. }
  1987. // ClearedFields returns all nullable fields that were cleared during this
  1988. // mutation.
  1989. func (m *AgentBaseMutation) ClearedFields() []string {
  1990. var fields []string
  1991. if m.FieldCleared(agentbase.FieldQ) {
  1992. fields = append(fields, agentbase.FieldQ)
  1993. }
  1994. if m.FieldCleared(agentbase.FieldA) {
  1995. fields = append(fields, agentbase.FieldA)
  1996. }
  1997. if m.FieldCleared(agentbase.FieldIndexes) {
  1998. fields = append(fields, agentbase.FieldIndexes)
  1999. }
  2000. if m.FieldCleared(agentbase.FieldDatasetID) {
  2001. fields = append(fields, agentbase.FieldDatasetID)
  2002. }
  2003. if m.FieldCleared(agentbase.FieldCollectionID) {
  2004. fields = append(fields, agentbase.FieldCollectionID)
  2005. }
  2006. if m.FieldCleared(agentbase.FieldSourceName) {
  2007. fields = append(fields, agentbase.FieldSourceName)
  2008. }
  2009. if m.FieldCleared(agentbase.FieldCanWrite) {
  2010. fields = append(fields, agentbase.FieldCanWrite)
  2011. }
  2012. if m.FieldCleared(agentbase.FieldIsOwner) {
  2013. fields = append(fields, agentbase.FieldIsOwner)
  2014. }
  2015. return fields
  2016. }
  2017. // FieldCleared returns a boolean indicating if a field with the given name was
  2018. // cleared in this mutation.
  2019. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2020. _, ok := m.clearedFields[name]
  2021. return ok
  2022. }
  2023. // ClearField clears the value of the field with the given name. It returns an
  2024. // error if the field is not defined in the schema.
  2025. func (m *AgentBaseMutation) ClearField(name string) error {
  2026. switch name {
  2027. case agentbase.FieldQ:
  2028. m.ClearQ()
  2029. return nil
  2030. case agentbase.FieldA:
  2031. m.ClearA()
  2032. return nil
  2033. case agentbase.FieldIndexes:
  2034. m.ClearIndexes()
  2035. return nil
  2036. case agentbase.FieldDatasetID:
  2037. m.ClearDatasetID()
  2038. return nil
  2039. case agentbase.FieldCollectionID:
  2040. m.ClearCollectionID()
  2041. return nil
  2042. case agentbase.FieldSourceName:
  2043. m.ClearSourceName()
  2044. return nil
  2045. case agentbase.FieldCanWrite:
  2046. m.ClearCanWrite()
  2047. return nil
  2048. case agentbase.FieldIsOwner:
  2049. m.ClearIsOwner()
  2050. return nil
  2051. }
  2052. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2053. }
  2054. // ResetField resets all changes in the mutation for the field with the given name.
  2055. // It returns an error if the field is not defined in the schema.
  2056. func (m *AgentBaseMutation) ResetField(name string) error {
  2057. switch name {
  2058. case agentbase.FieldQ:
  2059. m.ResetQ()
  2060. return nil
  2061. case agentbase.FieldA:
  2062. m.ResetA()
  2063. return nil
  2064. case agentbase.FieldChunkIndex:
  2065. m.ResetChunkIndex()
  2066. return nil
  2067. case agentbase.FieldIndexes:
  2068. m.ResetIndexes()
  2069. return nil
  2070. case agentbase.FieldDatasetID:
  2071. m.ResetDatasetID()
  2072. return nil
  2073. case agentbase.FieldCollectionID:
  2074. m.ResetCollectionID()
  2075. return nil
  2076. case agentbase.FieldSourceName:
  2077. m.ResetSourceName()
  2078. return nil
  2079. case agentbase.FieldCanWrite:
  2080. m.ResetCanWrite()
  2081. return nil
  2082. case agentbase.FieldIsOwner:
  2083. m.ResetIsOwner()
  2084. return nil
  2085. }
  2086. return fmt.Errorf("unknown AgentBase field %s", name)
  2087. }
  2088. // AddedEdges returns all edge names that were set/added in this mutation.
  2089. func (m *AgentBaseMutation) AddedEdges() []string {
  2090. edges := make([]string, 0, 1)
  2091. if m.wx_agent != nil {
  2092. edges = append(edges, agentbase.EdgeWxAgent)
  2093. }
  2094. return edges
  2095. }
  2096. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2097. // name in this mutation.
  2098. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2099. switch name {
  2100. case agentbase.EdgeWxAgent:
  2101. ids := make([]ent.Value, 0, len(m.wx_agent))
  2102. for id := range m.wx_agent {
  2103. ids = append(ids, id)
  2104. }
  2105. return ids
  2106. }
  2107. return nil
  2108. }
  2109. // RemovedEdges returns all edge names that were removed in this mutation.
  2110. func (m *AgentBaseMutation) RemovedEdges() []string {
  2111. edges := make([]string, 0, 1)
  2112. if m.removedwx_agent != nil {
  2113. edges = append(edges, agentbase.EdgeWxAgent)
  2114. }
  2115. return edges
  2116. }
  2117. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2118. // the given name in this mutation.
  2119. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2120. switch name {
  2121. case agentbase.EdgeWxAgent:
  2122. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2123. for id := range m.removedwx_agent {
  2124. ids = append(ids, id)
  2125. }
  2126. return ids
  2127. }
  2128. return nil
  2129. }
  2130. // ClearedEdges returns all edge names that were cleared in this mutation.
  2131. func (m *AgentBaseMutation) ClearedEdges() []string {
  2132. edges := make([]string, 0, 1)
  2133. if m.clearedwx_agent {
  2134. edges = append(edges, agentbase.EdgeWxAgent)
  2135. }
  2136. return edges
  2137. }
  2138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2139. // was cleared in this mutation.
  2140. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2141. switch name {
  2142. case agentbase.EdgeWxAgent:
  2143. return m.clearedwx_agent
  2144. }
  2145. return false
  2146. }
  2147. // ClearEdge clears the value of the edge with the given name. It returns an error
  2148. // if that edge is not defined in the schema.
  2149. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2150. switch name {
  2151. }
  2152. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2153. }
  2154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2155. // It returns an error if the edge is not defined in the schema.
  2156. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2157. switch name {
  2158. case agentbase.EdgeWxAgent:
  2159. m.ResetWxAgent()
  2160. return nil
  2161. }
  2162. return fmt.Errorf("unknown AgentBase edge %s", name)
  2163. }
  2164. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2165. type AliyunAvatarMutation struct {
  2166. config
  2167. op Op
  2168. typ string
  2169. id *uint64
  2170. created_at *time.Time
  2171. updated_at *time.Time
  2172. deleted_at *time.Time
  2173. user_id *uint64
  2174. adduser_id *int64
  2175. biz_id *string
  2176. access_key_id *string
  2177. access_key_secret *string
  2178. app_id *string
  2179. tenant_id *uint64
  2180. addtenant_id *int64
  2181. response *string
  2182. token *string
  2183. session_id *string
  2184. clearedFields map[string]struct{}
  2185. done bool
  2186. oldValue func(context.Context) (*AliyunAvatar, error)
  2187. predicates []predicate.AliyunAvatar
  2188. }
  2189. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2190. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2191. type aliyunavatarOption func(*AliyunAvatarMutation)
  2192. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2193. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2194. m := &AliyunAvatarMutation{
  2195. config: c,
  2196. op: op,
  2197. typ: TypeAliyunAvatar,
  2198. clearedFields: make(map[string]struct{}),
  2199. }
  2200. for _, opt := range opts {
  2201. opt(m)
  2202. }
  2203. return m
  2204. }
  2205. // withAliyunAvatarID sets the ID field of the mutation.
  2206. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2207. return func(m *AliyunAvatarMutation) {
  2208. var (
  2209. err error
  2210. once sync.Once
  2211. value *AliyunAvatar
  2212. )
  2213. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2214. once.Do(func() {
  2215. if m.done {
  2216. err = errors.New("querying old values post mutation is not allowed")
  2217. } else {
  2218. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2219. }
  2220. })
  2221. return value, err
  2222. }
  2223. m.id = &id
  2224. }
  2225. }
  2226. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2227. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2228. return func(m *AliyunAvatarMutation) {
  2229. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2230. return node, nil
  2231. }
  2232. m.id = &node.ID
  2233. }
  2234. }
  2235. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2236. // executed in a transaction (ent.Tx), a transactional client is returned.
  2237. func (m AliyunAvatarMutation) Client() *Client {
  2238. client := &Client{config: m.config}
  2239. client.init()
  2240. return client
  2241. }
  2242. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2243. // it returns an error otherwise.
  2244. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2245. if _, ok := m.driver.(*txDriver); !ok {
  2246. return nil, errors.New("ent: mutation is not running in a transaction")
  2247. }
  2248. tx := &Tx{config: m.config}
  2249. tx.init()
  2250. return tx, nil
  2251. }
  2252. // SetID sets the value of the id field. Note that this
  2253. // operation is only accepted on creation of AliyunAvatar entities.
  2254. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2255. m.id = &id
  2256. }
  2257. // ID returns the ID value in the mutation. Note that the ID is only available
  2258. // if it was provided to the builder or after it was returned from the database.
  2259. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2260. if m.id == nil {
  2261. return
  2262. }
  2263. return *m.id, true
  2264. }
  2265. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2266. // That means, if the mutation is applied within a transaction with an isolation level such
  2267. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2268. // or updated by the mutation.
  2269. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2270. switch {
  2271. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2272. id, exists := m.ID()
  2273. if exists {
  2274. return []uint64{id}, nil
  2275. }
  2276. fallthrough
  2277. case m.op.Is(OpUpdate | OpDelete):
  2278. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2279. default:
  2280. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2281. }
  2282. }
  2283. // SetCreatedAt sets the "created_at" field.
  2284. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2285. m.created_at = &t
  2286. }
  2287. // CreatedAt returns the value of the "created_at" field in the mutation.
  2288. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2289. v := m.created_at
  2290. if v == nil {
  2291. return
  2292. }
  2293. return *v, true
  2294. }
  2295. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2296. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2298. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2299. if !m.op.Is(OpUpdateOne) {
  2300. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2301. }
  2302. if m.id == nil || m.oldValue == nil {
  2303. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2304. }
  2305. oldValue, err := m.oldValue(ctx)
  2306. if err != nil {
  2307. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2308. }
  2309. return oldValue.CreatedAt, nil
  2310. }
  2311. // ResetCreatedAt resets all changes to the "created_at" field.
  2312. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2313. m.created_at = nil
  2314. }
  2315. // SetUpdatedAt sets the "updated_at" field.
  2316. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2317. m.updated_at = &t
  2318. }
  2319. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2320. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2321. v := m.updated_at
  2322. if v == nil {
  2323. return
  2324. }
  2325. return *v, true
  2326. }
  2327. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2328. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2330. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2331. if !m.op.Is(OpUpdateOne) {
  2332. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2333. }
  2334. if m.id == nil || m.oldValue == nil {
  2335. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2336. }
  2337. oldValue, err := m.oldValue(ctx)
  2338. if err != nil {
  2339. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2340. }
  2341. return oldValue.UpdatedAt, nil
  2342. }
  2343. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2344. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2345. m.updated_at = nil
  2346. }
  2347. // SetDeletedAt sets the "deleted_at" field.
  2348. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2349. m.deleted_at = &t
  2350. }
  2351. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2352. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2353. v := m.deleted_at
  2354. if v == nil {
  2355. return
  2356. }
  2357. return *v, true
  2358. }
  2359. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2360. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2362. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2363. if !m.op.Is(OpUpdateOne) {
  2364. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2365. }
  2366. if m.id == nil || m.oldValue == nil {
  2367. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2368. }
  2369. oldValue, err := m.oldValue(ctx)
  2370. if err != nil {
  2371. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2372. }
  2373. return oldValue.DeletedAt, nil
  2374. }
  2375. // ClearDeletedAt clears the value of the "deleted_at" field.
  2376. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2377. m.deleted_at = nil
  2378. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2379. }
  2380. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2381. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2382. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2383. return ok
  2384. }
  2385. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2386. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2387. m.deleted_at = nil
  2388. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2389. }
  2390. // SetUserID sets the "user_id" field.
  2391. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2392. m.user_id = &u
  2393. m.adduser_id = nil
  2394. }
  2395. // UserID returns the value of the "user_id" field in the mutation.
  2396. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2397. v := m.user_id
  2398. if v == nil {
  2399. return
  2400. }
  2401. return *v, true
  2402. }
  2403. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2404. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2406. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2407. if !m.op.Is(OpUpdateOne) {
  2408. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2409. }
  2410. if m.id == nil || m.oldValue == nil {
  2411. return v, errors.New("OldUserID requires an ID field in the mutation")
  2412. }
  2413. oldValue, err := m.oldValue(ctx)
  2414. if err != nil {
  2415. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2416. }
  2417. return oldValue.UserID, nil
  2418. }
  2419. // AddUserID adds u to the "user_id" field.
  2420. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2421. if m.adduser_id != nil {
  2422. *m.adduser_id += u
  2423. } else {
  2424. m.adduser_id = &u
  2425. }
  2426. }
  2427. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2428. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2429. v := m.adduser_id
  2430. if v == nil {
  2431. return
  2432. }
  2433. return *v, true
  2434. }
  2435. // ResetUserID resets all changes to the "user_id" field.
  2436. func (m *AliyunAvatarMutation) ResetUserID() {
  2437. m.user_id = nil
  2438. m.adduser_id = nil
  2439. }
  2440. // SetBizID sets the "biz_id" field.
  2441. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2442. m.biz_id = &s
  2443. }
  2444. // BizID returns the value of the "biz_id" field in the mutation.
  2445. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2446. v := m.biz_id
  2447. if v == nil {
  2448. return
  2449. }
  2450. return *v, true
  2451. }
  2452. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2453. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2455. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2456. if !m.op.Is(OpUpdateOne) {
  2457. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2458. }
  2459. if m.id == nil || m.oldValue == nil {
  2460. return v, errors.New("OldBizID requires an ID field in the mutation")
  2461. }
  2462. oldValue, err := m.oldValue(ctx)
  2463. if err != nil {
  2464. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2465. }
  2466. return oldValue.BizID, nil
  2467. }
  2468. // ResetBizID resets all changes to the "biz_id" field.
  2469. func (m *AliyunAvatarMutation) ResetBizID() {
  2470. m.biz_id = nil
  2471. }
  2472. // SetAccessKeyID sets the "access_key_id" field.
  2473. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2474. m.access_key_id = &s
  2475. }
  2476. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2477. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2478. v := m.access_key_id
  2479. if v == nil {
  2480. return
  2481. }
  2482. return *v, true
  2483. }
  2484. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2485. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2487. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2488. if !m.op.Is(OpUpdateOne) {
  2489. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2490. }
  2491. if m.id == nil || m.oldValue == nil {
  2492. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2493. }
  2494. oldValue, err := m.oldValue(ctx)
  2495. if err != nil {
  2496. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2497. }
  2498. return oldValue.AccessKeyID, nil
  2499. }
  2500. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2501. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2502. m.access_key_id = nil
  2503. }
  2504. // SetAccessKeySecret sets the "access_key_secret" field.
  2505. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2506. m.access_key_secret = &s
  2507. }
  2508. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2509. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2510. v := m.access_key_secret
  2511. if v == nil {
  2512. return
  2513. }
  2514. return *v, true
  2515. }
  2516. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2517. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2519. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2520. if !m.op.Is(OpUpdateOne) {
  2521. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2522. }
  2523. if m.id == nil || m.oldValue == nil {
  2524. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2525. }
  2526. oldValue, err := m.oldValue(ctx)
  2527. if err != nil {
  2528. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2529. }
  2530. return oldValue.AccessKeySecret, nil
  2531. }
  2532. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2533. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2534. m.access_key_secret = nil
  2535. }
  2536. // SetAppID sets the "app_id" field.
  2537. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2538. m.app_id = &s
  2539. }
  2540. // AppID returns the value of the "app_id" field in the mutation.
  2541. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2542. v := m.app_id
  2543. if v == nil {
  2544. return
  2545. }
  2546. return *v, true
  2547. }
  2548. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2549. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2551. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2552. if !m.op.Is(OpUpdateOne) {
  2553. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2554. }
  2555. if m.id == nil || m.oldValue == nil {
  2556. return v, errors.New("OldAppID requires an ID field in the mutation")
  2557. }
  2558. oldValue, err := m.oldValue(ctx)
  2559. if err != nil {
  2560. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2561. }
  2562. return oldValue.AppID, nil
  2563. }
  2564. // ClearAppID clears the value of the "app_id" field.
  2565. func (m *AliyunAvatarMutation) ClearAppID() {
  2566. m.app_id = nil
  2567. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2568. }
  2569. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2570. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2571. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2572. return ok
  2573. }
  2574. // ResetAppID resets all changes to the "app_id" field.
  2575. func (m *AliyunAvatarMutation) ResetAppID() {
  2576. m.app_id = nil
  2577. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2578. }
  2579. // SetTenantID sets the "tenant_id" field.
  2580. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2581. m.tenant_id = &u
  2582. m.addtenant_id = nil
  2583. }
  2584. // TenantID returns the value of the "tenant_id" field in the mutation.
  2585. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2586. v := m.tenant_id
  2587. if v == nil {
  2588. return
  2589. }
  2590. return *v, true
  2591. }
  2592. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2593. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2595. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2596. if !m.op.Is(OpUpdateOne) {
  2597. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2598. }
  2599. if m.id == nil || m.oldValue == nil {
  2600. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2601. }
  2602. oldValue, err := m.oldValue(ctx)
  2603. if err != nil {
  2604. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2605. }
  2606. return oldValue.TenantID, nil
  2607. }
  2608. // AddTenantID adds u to the "tenant_id" field.
  2609. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2610. if m.addtenant_id != nil {
  2611. *m.addtenant_id += u
  2612. } else {
  2613. m.addtenant_id = &u
  2614. }
  2615. }
  2616. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2617. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2618. v := m.addtenant_id
  2619. if v == nil {
  2620. return
  2621. }
  2622. return *v, true
  2623. }
  2624. // ResetTenantID resets all changes to the "tenant_id" field.
  2625. func (m *AliyunAvatarMutation) ResetTenantID() {
  2626. m.tenant_id = nil
  2627. m.addtenant_id = nil
  2628. }
  2629. // SetResponse sets the "response" field.
  2630. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2631. m.response = &s
  2632. }
  2633. // Response returns the value of the "response" field in the mutation.
  2634. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2635. v := m.response
  2636. if v == nil {
  2637. return
  2638. }
  2639. return *v, true
  2640. }
  2641. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2642. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2644. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2645. if !m.op.Is(OpUpdateOne) {
  2646. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2647. }
  2648. if m.id == nil || m.oldValue == nil {
  2649. return v, errors.New("OldResponse requires an ID field in the mutation")
  2650. }
  2651. oldValue, err := m.oldValue(ctx)
  2652. if err != nil {
  2653. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2654. }
  2655. return oldValue.Response, nil
  2656. }
  2657. // ResetResponse resets all changes to the "response" field.
  2658. func (m *AliyunAvatarMutation) ResetResponse() {
  2659. m.response = nil
  2660. }
  2661. // SetToken sets the "token" field.
  2662. func (m *AliyunAvatarMutation) SetToken(s string) {
  2663. m.token = &s
  2664. }
  2665. // Token returns the value of the "token" field in the mutation.
  2666. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2667. v := m.token
  2668. if v == nil {
  2669. return
  2670. }
  2671. return *v, true
  2672. }
  2673. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2674. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2676. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2677. if !m.op.Is(OpUpdateOne) {
  2678. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2679. }
  2680. if m.id == nil || m.oldValue == nil {
  2681. return v, errors.New("OldToken requires an ID field in the mutation")
  2682. }
  2683. oldValue, err := m.oldValue(ctx)
  2684. if err != nil {
  2685. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2686. }
  2687. return oldValue.Token, nil
  2688. }
  2689. // ResetToken resets all changes to the "token" field.
  2690. func (m *AliyunAvatarMutation) ResetToken() {
  2691. m.token = nil
  2692. }
  2693. // SetSessionID sets the "session_id" field.
  2694. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2695. m.session_id = &s
  2696. }
  2697. // SessionID returns the value of the "session_id" field in the mutation.
  2698. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2699. v := m.session_id
  2700. if v == nil {
  2701. return
  2702. }
  2703. return *v, true
  2704. }
  2705. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2706. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2708. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2709. if !m.op.Is(OpUpdateOne) {
  2710. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2711. }
  2712. if m.id == nil || m.oldValue == nil {
  2713. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2714. }
  2715. oldValue, err := m.oldValue(ctx)
  2716. if err != nil {
  2717. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2718. }
  2719. return oldValue.SessionID, nil
  2720. }
  2721. // ResetSessionID resets all changes to the "session_id" field.
  2722. func (m *AliyunAvatarMutation) ResetSessionID() {
  2723. m.session_id = nil
  2724. }
  2725. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2726. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2727. m.predicates = append(m.predicates, ps...)
  2728. }
  2729. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2730. // users can use type-assertion to append predicates that do not depend on any generated package.
  2731. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2732. p := make([]predicate.AliyunAvatar, len(ps))
  2733. for i := range ps {
  2734. p[i] = ps[i]
  2735. }
  2736. m.Where(p...)
  2737. }
  2738. // Op returns the operation name.
  2739. func (m *AliyunAvatarMutation) Op() Op {
  2740. return m.op
  2741. }
  2742. // SetOp allows setting the mutation operation.
  2743. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2744. m.op = op
  2745. }
  2746. // Type returns the node type of this mutation (AliyunAvatar).
  2747. func (m *AliyunAvatarMutation) Type() string {
  2748. return m.typ
  2749. }
  2750. // Fields returns all fields that were changed during this mutation. Note that in
  2751. // order to get all numeric fields that were incremented/decremented, call
  2752. // AddedFields().
  2753. func (m *AliyunAvatarMutation) Fields() []string {
  2754. fields := make([]string, 0, 12)
  2755. if m.created_at != nil {
  2756. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2757. }
  2758. if m.updated_at != nil {
  2759. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2760. }
  2761. if m.deleted_at != nil {
  2762. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2763. }
  2764. if m.user_id != nil {
  2765. fields = append(fields, aliyunavatar.FieldUserID)
  2766. }
  2767. if m.biz_id != nil {
  2768. fields = append(fields, aliyunavatar.FieldBizID)
  2769. }
  2770. if m.access_key_id != nil {
  2771. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2772. }
  2773. if m.access_key_secret != nil {
  2774. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2775. }
  2776. if m.app_id != nil {
  2777. fields = append(fields, aliyunavatar.FieldAppID)
  2778. }
  2779. if m.tenant_id != nil {
  2780. fields = append(fields, aliyunavatar.FieldTenantID)
  2781. }
  2782. if m.response != nil {
  2783. fields = append(fields, aliyunavatar.FieldResponse)
  2784. }
  2785. if m.token != nil {
  2786. fields = append(fields, aliyunavatar.FieldToken)
  2787. }
  2788. if m.session_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldSessionID)
  2790. }
  2791. return fields
  2792. }
  2793. // Field returns the value of a field with the given name. The second boolean
  2794. // return value indicates that this field was not set, or was not defined in the
  2795. // schema.
  2796. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2797. switch name {
  2798. case aliyunavatar.FieldCreatedAt:
  2799. return m.CreatedAt()
  2800. case aliyunavatar.FieldUpdatedAt:
  2801. return m.UpdatedAt()
  2802. case aliyunavatar.FieldDeletedAt:
  2803. return m.DeletedAt()
  2804. case aliyunavatar.FieldUserID:
  2805. return m.UserID()
  2806. case aliyunavatar.FieldBizID:
  2807. return m.BizID()
  2808. case aliyunavatar.FieldAccessKeyID:
  2809. return m.AccessKeyID()
  2810. case aliyunavatar.FieldAccessKeySecret:
  2811. return m.AccessKeySecret()
  2812. case aliyunavatar.FieldAppID:
  2813. return m.AppID()
  2814. case aliyunavatar.FieldTenantID:
  2815. return m.TenantID()
  2816. case aliyunavatar.FieldResponse:
  2817. return m.Response()
  2818. case aliyunavatar.FieldToken:
  2819. return m.Token()
  2820. case aliyunavatar.FieldSessionID:
  2821. return m.SessionID()
  2822. }
  2823. return nil, false
  2824. }
  2825. // OldField returns the old value of the field from the database. An error is
  2826. // returned if the mutation operation is not UpdateOne, or the query to the
  2827. // database failed.
  2828. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2829. switch name {
  2830. case aliyunavatar.FieldCreatedAt:
  2831. return m.OldCreatedAt(ctx)
  2832. case aliyunavatar.FieldUpdatedAt:
  2833. return m.OldUpdatedAt(ctx)
  2834. case aliyunavatar.FieldDeletedAt:
  2835. return m.OldDeletedAt(ctx)
  2836. case aliyunavatar.FieldUserID:
  2837. return m.OldUserID(ctx)
  2838. case aliyunavatar.FieldBizID:
  2839. return m.OldBizID(ctx)
  2840. case aliyunavatar.FieldAccessKeyID:
  2841. return m.OldAccessKeyID(ctx)
  2842. case aliyunavatar.FieldAccessKeySecret:
  2843. return m.OldAccessKeySecret(ctx)
  2844. case aliyunavatar.FieldAppID:
  2845. return m.OldAppID(ctx)
  2846. case aliyunavatar.FieldTenantID:
  2847. return m.OldTenantID(ctx)
  2848. case aliyunavatar.FieldResponse:
  2849. return m.OldResponse(ctx)
  2850. case aliyunavatar.FieldToken:
  2851. return m.OldToken(ctx)
  2852. case aliyunavatar.FieldSessionID:
  2853. return m.OldSessionID(ctx)
  2854. }
  2855. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2856. }
  2857. // SetField sets the value of a field with the given name. It returns an error if
  2858. // the field is not defined in the schema, or if the type mismatched the field
  2859. // type.
  2860. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2861. switch name {
  2862. case aliyunavatar.FieldCreatedAt:
  2863. v, ok := value.(time.Time)
  2864. if !ok {
  2865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2866. }
  2867. m.SetCreatedAt(v)
  2868. return nil
  2869. case aliyunavatar.FieldUpdatedAt:
  2870. v, ok := value.(time.Time)
  2871. if !ok {
  2872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2873. }
  2874. m.SetUpdatedAt(v)
  2875. return nil
  2876. case aliyunavatar.FieldDeletedAt:
  2877. v, ok := value.(time.Time)
  2878. if !ok {
  2879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2880. }
  2881. m.SetDeletedAt(v)
  2882. return nil
  2883. case aliyunavatar.FieldUserID:
  2884. v, ok := value.(uint64)
  2885. if !ok {
  2886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2887. }
  2888. m.SetUserID(v)
  2889. return nil
  2890. case aliyunavatar.FieldBizID:
  2891. v, ok := value.(string)
  2892. if !ok {
  2893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2894. }
  2895. m.SetBizID(v)
  2896. return nil
  2897. case aliyunavatar.FieldAccessKeyID:
  2898. v, ok := value.(string)
  2899. if !ok {
  2900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2901. }
  2902. m.SetAccessKeyID(v)
  2903. return nil
  2904. case aliyunavatar.FieldAccessKeySecret:
  2905. v, ok := value.(string)
  2906. if !ok {
  2907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2908. }
  2909. m.SetAccessKeySecret(v)
  2910. return nil
  2911. case aliyunavatar.FieldAppID:
  2912. v, ok := value.(string)
  2913. if !ok {
  2914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2915. }
  2916. m.SetAppID(v)
  2917. return nil
  2918. case aliyunavatar.FieldTenantID:
  2919. v, ok := value.(uint64)
  2920. if !ok {
  2921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2922. }
  2923. m.SetTenantID(v)
  2924. return nil
  2925. case aliyunavatar.FieldResponse:
  2926. v, ok := value.(string)
  2927. if !ok {
  2928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2929. }
  2930. m.SetResponse(v)
  2931. return nil
  2932. case aliyunavatar.FieldToken:
  2933. v, ok := value.(string)
  2934. if !ok {
  2935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2936. }
  2937. m.SetToken(v)
  2938. return nil
  2939. case aliyunavatar.FieldSessionID:
  2940. v, ok := value.(string)
  2941. if !ok {
  2942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2943. }
  2944. m.SetSessionID(v)
  2945. return nil
  2946. }
  2947. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2948. }
  2949. // AddedFields returns all numeric fields that were incremented/decremented during
  2950. // this mutation.
  2951. func (m *AliyunAvatarMutation) AddedFields() []string {
  2952. var fields []string
  2953. if m.adduser_id != nil {
  2954. fields = append(fields, aliyunavatar.FieldUserID)
  2955. }
  2956. if m.addtenant_id != nil {
  2957. fields = append(fields, aliyunavatar.FieldTenantID)
  2958. }
  2959. return fields
  2960. }
  2961. // AddedField returns the numeric value that was incremented/decremented on a field
  2962. // with the given name. The second boolean return value indicates that this field
  2963. // was not set, or was not defined in the schema.
  2964. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2965. switch name {
  2966. case aliyunavatar.FieldUserID:
  2967. return m.AddedUserID()
  2968. case aliyunavatar.FieldTenantID:
  2969. return m.AddedTenantID()
  2970. }
  2971. return nil, false
  2972. }
  2973. // AddField adds the value to the field with the given name. It returns an error if
  2974. // the field is not defined in the schema, or if the type mismatched the field
  2975. // type.
  2976. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2977. switch name {
  2978. case aliyunavatar.FieldUserID:
  2979. v, ok := value.(int64)
  2980. if !ok {
  2981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2982. }
  2983. m.AddUserID(v)
  2984. return nil
  2985. case aliyunavatar.FieldTenantID:
  2986. v, ok := value.(int64)
  2987. if !ok {
  2988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2989. }
  2990. m.AddTenantID(v)
  2991. return nil
  2992. }
  2993. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  2994. }
  2995. // ClearedFields returns all nullable fields that were cleared during this
  2996. // mutation.
  2997. func (m *AliyunAvatarMutation) ClearedFields() []string {
  2998. var fields []string
  2999. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3000. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3001. }
  3002. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3003. fields = append(fields, aliyunavatar.FieldAppID)
  3004. }
  3005. return fields
  3006. }
  3007. // FieldCleared returns a boolean indicating if a field with the given name was
  3008. // cleared in this mutation.
  3009. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3010. _, ok := m.clearedFields[name]
  3011. return ok
  3012. }
  3013. // ClearField clears the value of the field with the given name. It returns an
  3014. // error if the field is not defined in the schema.
  3015. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3016. switch name {
  3017. case aliyunavatar.FieldDeletedAt:
  3018. m.ClearDeletedAt()
  3019. return nil
  3020. case aliyunavatar.FieldAppID:
  3021. m.ClearAppID()
  3022. return nil
  3023. }
  3024. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3025. }
  3026. // ResetField resets all changes in the mutation for the field with the given name.
  3027. // It returns an error if the field is not defined in the schema.
  3028. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3029. switch name {
  3030. case aliyunavatar.FieldCreatedAt:
  3031. m.ResetCreatedAt()
  3032. return nil
  3033. case aliyunavatar.FieldUpdatedAt:
  3034. m.ResetUpdatedAt()
  3035. return nil
  3036. case aliyunavatar.FieldDeletedAt:
  3037. m.ResetDeletedAt()
  3038. return nil
  3039. case aliyunavatar.FieldUserID:
  3040. m.ResetUserID()
  3041. return nil
  3042. case aliyunavatar.FieldBizID:
  3043. m.ResetBizID()
  3044. return nil
  3045. case aliyunavatar.FieldAccessKeyID:
  3046. m.ResetAccessKeyID()
  3047. return nil
  3048. case aliyunavatar.FieldAccessKeySecret:
  3049. m.ResetAccessKeySecret()
  3050. return nil
  3051. case aliyunavatar.FieldAppID:
  3052. m.ResetAppID()
  3053. return nil
  3054. case aliyunavatar.FieldTenantID:
  3055. m.ResetTenantID()
  3056. return nil
  3057. case aliyunavatar.FieldResponse:
  3058. m.ResetResponse()
  3059. return nil
  3060. case aliyunavatar.FieldToken:
  3061. m.ResetToken()
  3062. return nil
  3063. case aliyunavatar.FieldSessionID:
  3064. m.ResetSessionID()
  3065. return nil
  3066. }
  3067. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3068. }
  3069. // AddedEdges returns all edge names that were set/added in this mutation.
  3070. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3071. edges := make([]string, 0, 0)
  3072. return edges
  3073. }
  3074. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3075. // name in this mutation.
  3076. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3077. return nil
  3078. }
  3079. // RemovedEdges returns all edge names that were removed in this mutation.
  3080. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3081. edges := make([]string, 0, 0)
  3082. return edges
  3083. }
  3084. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3085. // the given name in this mutation.
  3086. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3087. return nil
  3088. }
  3089. // ClearedEdges returns all edge names that were cleared in this mutation.
  3090. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3091. edges := make([]string, 0, 0)
  3092. return edges
  3093. }
  3094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3095. // was cleared in this mutation.
  3096. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3097. return false
  3098. }
  3099. // ClearEdge clears the value of the edge with the given name. It returns an error
  3100. // if that edge is not defined in the schema.
  3101. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3102. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3103. }
  3104. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3105. // It returns an error if the edge is not defined in the schema.
  3106. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3107. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3108. }
  3109. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3110. type BatchMsgMutation struct {
  3111. config
  3112. op Op
  3113. typ string
  3114. id *uint64
  3115. created_at *time.Time
  3116. updated_at *time.Time
  3117. deleted_at *time.Time
  3118. status *uint8
  3119. addstatus *int8
  3120. batch_no *string
  3121. task_name *string
  3122. fromwxid *string
  3123. msg *string
  3124. tag *string
  3125. tagids *string
  3126. total *int32
  3127. addtotal *int32
  3128. success *int32
  3129. addsuccess *int32
  3130. fail *int32
  3131. addfail *int32
  3132. start_time *time.Time
  3133. stop_time *time.Time
  3134. send_time *time.Time
  3135. _type *int32
  3136. add_type *int32
  3137. organization_id *uint64
  3138. addorganization_id *int64
  3139. clearedFields map[string]struct{}
  3140. done bool
  3141. oldValue func(context.Context) (*BatchMsg, error)
  3142. predicates []predicate.BatchMsg
  3143. }
  3144. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3145. // batchmsgOption allows management of the mutation configuration using functional options.
  3146. type batchmsgOption func(*BatchMsgMutation)
  3147. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3148. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3149. m := &BatchMsgMutation{
  3150. config: c,
  3151. op: op,
  3152. typ: TypeBatchMsg,
  3153. clearedFields: make(map[string]struct{}),
  3154. }
  3155. for _, opt := range opts {
  3156. opt(m)
  3157. }
  3158. return m
  3159. }
  3160. // withBatchMsgID sets the ID field of the mutation.
  3161. func withBatchMsgID(id uint64) batchmsgOption {
  3162. return func(m *BatchMsgMutation) {
  3163. var (
  3164. err error
  3165. once sync.Once
  3166. value *BatchMsg
  3167. )
  3168. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3169. once.Do(func() {
  3170. if m.done {
  3171. err = errors.New("querying old values post mutation is not allowed")
  3172. } else {
  3173. value, err = m.Client().BatchMsg.Get(ctx, id)
  3174. }
  3175. })
  3176. return value, err
  3177. }
  3178. m.id = &id
  3179. }
  3180. }
  3181. // withBatchMsg sets the old BatchMsg of the mutation.
  3182. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3183. return func(m *BatchMsgMutation) {
  3184. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3185. return node, nil
  3186. }
  3187. m.id = &node.ID
  3188. }
  3189. }
  3190. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3191. // executed in a transaction (ent.Tx), a transactional client is returned.
  3192. func (m BatchMsgMutation) Client() *Client {
  3193. client := &Client{config: m.config}
  3194. client.init()
  3195. return client
  3196. }
  3197. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3198. // it returns an error otherwise.
  3199. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3200. if _, ok := m.driver.(*txDriver); !ok {
  3201. return nil, errors.New("ent: mutation is not running in a transaction")
  3202. }
  3203. tx := &Tx{config: m.config}
  3204. tx.init()
  3205. return tx, nil
  3206. }
  3207. // SetID sets the value of the id field. Note that this
  3208. // operation is only accepted on creation of BatchMsg entities.
  3209. func (m *BatchMsgMutation) SetID(id uint64) {
  3210. m.id = &id
  3211. }
  3212. // ID returns the ID value in the mutation. Note that the ID is only available
  3213. // if it was provided to the builder or after it was returned from the database.
  3214. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3215. if m.id == nil {
  3216. return
  3217. }
  3218. return *m.id, true
  3219. }
  3220. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3221. // That means, if the mutation is applied within a transaction with an isolation level such
  3222. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3223. // or updated by the mutation.
  3224. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3225. switch {
  3226. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3227. id, exists := m.ID()
  3228. if exists {
  3229. return []uint64{id}, nil
  3230. }
  3231. fallthrough
  3232. case m.op.Is(OpUpdate | OpDelete):
  3233. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3234. default:
  3235. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3236. }
  3237. }
  3238. // SetCreatedAt sets the "created_at" field.
  3239. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3240. m.created_at = &t
  3241. }
  3242. // CreatedAt returns the value of the "created_at" field in the mutation.
  3243. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3244. v := m.created_at
  3245. if v == nil {
  3246. return
  3247. }
  3248. return *v, true
  3249. }
  3250. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3251. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3253. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3254. if !m.op.Is(OpUpdateOne) {
  3255. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3256. }
  3257. if m.id == nil || m.oldValue == nil {
  3258. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3259. }
  3260. oldValue, err := m.oldValue(ctx)
  3261. if err != nil {
  3262. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3263. }
  3264. return oldValue.CreatedAt, nil
  3265. }
  3266. // ResetCreatedAt resets all changes to the "created_at" field.
  3267. func (m *BatchMsgMutation) ResetCreatedAt() {
  3268. m.created_at = nil
  3269. }
  3270. // SetUpdatedAt sets the "updated_at" field.
  3271. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3272. m.updated_at = &t
  3273. }
  3274. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3275. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3276. v := m.updated_at
  3277. if v == nil {
  3278. return
  3279. }
  3280. return *v, true
  3281. }
  3282. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3283. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3285. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3286. if !m.op.Is(OpUpdateOne) {
  3287. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3288. }
  3289. if m.id == nil || m.oldValue == nil {
  3290. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3291. }
  3292. oldValue, err := m.oldValue(ctx)
  3293. if err != nil {
  3294. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3295. }
  3296. return oldValue.UpdatedAt, nil
  3297. }
  3298. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3299. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3300. m.updated_at = nil
  3301. }
  3302. // SetDeletedAt sets the "deleted_at" field.
  3303. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3304. m.deleted_at = &t
  3305. }
  3306. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3307. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3308. v := m.deleted_at
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3315. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3317. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3318. if !m.op.Is(OpUpdateOne) {
  3319. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3320. }
  3321. if m.id == nil || m.oldValue == nil {
  3322. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3323. }
  3324. oldValue, err := m.oldValue(ctx)
  3325. if err != nil {
  3326. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3327. }
  3328. return oldValue.DeletedAt, nil
  3329. }
  3330. // ClearDeletedAt clears the value of the "deleted_at" field.
  3331. func (m *BatchMsgMutation) ClearDeletedAt() {
  3332. m.deleted_at = nil
  3333. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3334. }
  3335. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3336. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3337. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3338. return ok
  3339. }
  3340. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3341. func (m *BatchMsgMutation) ResetDeletedAt() {
  3342. m.deleted_at = nil
  3343. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3344. }
  3345. // SetStatus sets the "status" field.
  3346. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3347. m.status = &u
  3348. m.addstatus = nil
  3349. }
  3350. // Status returns the value of the "status" field in the mutation.
  3351. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3352. v := m.status
  3353. if v == nil {
  3354. return
  3355. }
  3356. return *v, true
  3357. }
  3358. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3361. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3362. if !m.op.Is(OpUpdateOne) {
  3363. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3364. }
  3365. if m.id == nil || m.oldValue == nil {
  3366. return v, errors.New("OldStatus requires an ID field in the mutation")
  3367. }
  3368. oldValue, err := m.oldValue(ctx)
  3369. if err != nil {
  3370. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3371. }
  3372. return oldValue.Status, nil
  3373. }
  3374. // AddStatus adds u to the "status" field.
  3375. func (m *BatchMsgMutation) AddStatus(u int8) {
  3376. if m.addstatus != nil {
  3377. *m.addstatus += u
  3378. } else {
  3379. m.addstatus = &u
  3380. }
  3381. }
  3382. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3383. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3384. v := m.addstatus
  3385. if v == nil {
  3386. return
  3387. }
  3388. return *v, true
  3389. }
  3390. // ClearStatus clears the value of the "status" field.
  3391. func (m *BatchMsgMutation) ClearStatus() {
  3392. m.status = nil
  3393. m.addstatus = nil
  3394. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3395. }
  3396. // StatusCleared returns if the "status" field was cleared in this mutation.
  3397. func (m *BatchMsgMutation) StatusCleared() bool {
  3398. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3399. return ok
  3400. }
  3401. // ResetStatus resets all changes to the "status" field.
  3402. func (m *BatchMsgMutation) ResetStatus() {
  3403. m.status = nil
  3404. m.addstatus = nil
  3405. delete(m.clearedFields, batchmsg.FieldStatus)
  3406. }
  3407. // SetBatchNo sets the "batch_no" field.
  3408. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3409. m.batch_no = &s
  3410. }
  3411. // BatchNo returns the value of the "batch_no" field in the mutation.
  3412. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3413. v := m.batch_no
  3414. if v == nil {
  3415. return
  3416. }
  3417. return *v, true
  3418. }
  3419. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3420. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3422. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3423. if !m.op.Is(OpUpdateOne) {
  3424. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3425. }
  3426. if m.id == nil || m.oldValue == nil {
  3427. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3428. }
  3429. oldValue, err := m.oldValue(ctx)
  3430. if err != nil {
  3431. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3432. }
  3433. return oldValue.BatchNo, nil
  3434. }
  3435. // ClearBatchNo clears the value of the "batch_no" field.
  3436. func (m *BatchMsgMutation) ClearBatchNo() {
  3437. m.batch_no = nil
  3438. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3439. }
  3440. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3441. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3442. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3443. return ok
  3444. }
  3445. // ResetBatchNo resets all changes to the "batch_no" field.
  3446. func (m *BatchMsgMutation) ResetBatchNo() {
  3447. m.batch_no = nil
  3448. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3449. }
  3450. // SetTaskName sets the "task_name" field.
  3451. func (m *BatchMsgMutation) SetTaskName(s string) {
  3452. m.task_name = &s
  3453. }
  3454. // TaskName returns the value of the "task_name" field in the mutation.
  3455. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3456. v := m.task_name
  3457. if v == nil {
  3458. return
  3459. }
  3460. return *v, true
  3461. }
  3462. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3463. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3465. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3466. if !m.op.Is(OpUpdateOne) {
  3467. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3468. }
  3469. if m.id == nil || m.oldValue == nil {
  3470. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3471. }
  3472. oldValue, err := m.oldValue(ctx)
  3473. if err != nil {
  3474. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3475. }
  3476. return oldValue.TaskName, nil
  3477. }
  3478. // ClearTaskName clears the value of the "task_name" field.
  3479. func (m *BatchMsgMutation) ClearTaskName() {
  3480. m.task_name = nil
  3481. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3482. }
  3483. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3484. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3485. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3486. return ok
  3487. }
  3488. // ResetTaskName resets all changes to the "task_name" field.
  3489. func (m *BatchMsgMutation) ResetTaskName() {
  3490. m.task_name = nil
  3491. delete(m.clearedFields, batchmsg.FieldTaskName)
  3492. }
  3493. // SetFromwxid sets the "fromwxid" field.
  3494. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3495. m.fromwxid = &s
  3496. }
  3497. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3498. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3499. v := m.fromwxid
  3500. if v == nil {
  3501. return
  3502. }
  3503. return *v, true
  3504. }
  3505. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3506. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3508. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3509. if !m.op.Is(OpUpdateOne) {
  3510. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3511. }
  3512. if m.id == nil || m.oldValue == nil {
  3513. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3514. }
  3515. oldValue, err := m.oldValue(ctx)
  3516. if err != nil {
  3517. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3518. }
  3519. return oldValue.Fromwxid, nil
  3520. }
  3521. // ClearFromwxid clears the value of the "fromwxid" field.
  3522. func (m *BatchMsgMutation) ClearFromwxid() {
  3523. m.fromwxid = nil
  3524. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3525. }
  3526. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3527. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3528. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3529. return ok
  3530. }
  3531. // ResetFromwxid resets all changes to the "fromwxid" field.
  3532. func (m *BatchMsgMutation) ResetFromwxid() {
  3533. m.fromwxid = nil
  3534. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3535. }
  3536. // SetMsg sets the "msg" field.
  3537. func (m *BatchMsgMutation) SetMsg(s string) {
  3538. m.msg = &s
  3539. }
  3540. // Msg returns the value of the "msg" field in the mutation.
  3541. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3542. v := m.msg
  3543. if v == nil {
  3544. return
  3545. }
  3546. return *v, true
  3547. }
  3548. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3551. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3552. if !m.op.Is(OpUpdateOne) {
  3553. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3554. }
  3555. if m.id == nil || m.oldValue == nil {
  3556. return v, errors.New("OldMsg requires an ID field in the mutation")
  3557. }
  3558. oldValue, err := m.oldValue(ctx)
  3559. if err != nil {
  3560. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3561. }
  3562. return oldValue.Msg, nil
  3563. }
  3564. // ClearMsg clears the value of the "msg" field.
  3565. func (m *BatchMsgMutation) ClearMsg() {
  3566. m.msg = nil
  3567. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3568. }
  3569. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3570. func (m *BatchMsgMutation) MsgCleared() bool {
  3571. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3572. return ok
  3573. }
  3574. // ResetMsg resets all changes to the "msg" field.
  3575. func (m *BatchMsgMutation) ResetMsg() {
  3576. m.msg = nil
  3577. delete(m.clearedFields, batchmsg.FieldMsg)
  3578. }
  3579. // SetTag sets the "tag" field.
  3580. func (m *BatchMsgMutation) SetTag(s string) {
  3581. m.tag = &s
  3582. }
  3583. // Tag returns the value of the "tag" field in the mutation.
  3584. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3585. v := m.tag
  3586. if v == nil {
  3587. return
  3588. }
  3589. return *v, true
  3590. }
  3591. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3592. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3594. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3595. if !m.op.Is(OpUpdateOne) {
  3596. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3597. }
  3598. if m.id == nil || m.oldValue == nil {
  3599. return v, errors.New("OldTag requires an ID field in the mutation")
  3600. }
  3601. oldValue, err := m.oldValue(ctx)
  3602. if err != nil {
  3603. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3604. }
  3605. return oldValue.Tag, nil
  3606. }
  3607. // ClearTag clears the value of the "tag" field.
  3608. func (m *BatchMsgMutation) ClearTag() {
  3609. m.tag = nil
  3610. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3611. }
  3612. // TagCleared returns if the "tag" field was cleared in this mutation.
  3613. func (m *BatchMsgMutation) TagCleared() bool {
  3614. _, ok := m.clearedFields[batchmsg.FieldTag]
  3615. return ok
  3616. }
  3617. // ResetTag resets all changes to the "tag" field.
  3618. func (m *BatchMsgMutation) ResetTag() {
  3619. m.tag = nil
  3620. delete(m.clearedFields, batchmsg.FieldTag)
  3621. }
  3622. // SetTagids sets the "tagids" field.
  3623. func (m *BatchMsgMutation) SetTagids(s string) {
  3624. m.tagids = &s
  3625. }
  3626. // Tagids returns the value of the "tagids" field in the mutation.
  3627. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3628. v := m.tagids
  3629. if v == nil {
  3630. return
  3631. }
  3632. return *v, true
  3633. }
  3634. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3635. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3637. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3638. if !m.op.Is(OpUpdateOne) {
  3639. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3640. }
  3641. if m.id == nil || m.oldValue == nil {
  3642. return v, errors.New("OldTagids requires an ID field in the mutation")
  3643. }
  3644. oldValue, err := m.oldValue(ctx)
  3645. if err != nil {
  3646. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3647. }
  3648. return oldValue.Tagids, nil
  3649. }
  3650. // ClearTagids clears the value of the "tagids" field.
  3651. func (m *BatchMsgMutation) ClearTagids() {
  3652. m.tagids = nil
  3653. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3654. }
  3655. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3656. func (m *BatchMsgMutation) TagidsCleared() bool {
  3657. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3658. return ok
  3659. }
  3660. // ResetTagids resets all changes to the "tagids" field.
  3661. func (m *BatchMsgMutation) ResetTagids() {
  3662. m.tagids = nil
  3663. delete(m.clearedFields, batchmsg.FieldTagids)
  3664. }
  3665. // SetTotal sets the "total" field.
  3666. func (m *BatchMsgMutation) SetTotal(i int32) {
  3667. m.total = &i
  3668. m.addtotal = nil
  3669. }
  3670. // Total returns the value of the "total" field in the mutation.
  3671. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3672. v := m.total
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3679. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldTotal requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3691. }
  3692. return oldValue.Total, nil
  3693. }
  3694. // AddTotal adds i to the "total" field.
  3695. func (m *BatchMsgMutation) AddTotal(i int32) {
  3696. if m.addtotal != nil {
  3697. *m.addtotal += i
  3698. } else {
  3699. m.addtotal = &i
  3700. }
  3701. }
  3702. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3703. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3704. v := m.addtotal
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearTotal clears the value of the "total" field.
  3711. func (m *BatchMsgMutation) ClearTotal() {
  3712. m.total = nil
  3713. m.addtotal = nil
  3714. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3715. }
  3716. // TotalCleared returns if the "total" field was cleared in this mutation.
  3717. func (m *BatchMsgMutation) TotalCleared() bool {
  3718. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3719. return ok
  3720. }
  3721. // ResetTotal resets all changes to the "total" field.
  3722. func (m *BatchMsgMutation) ResetTotal() {
  3723. m.total = nil
  3724. m.addtotal = nil
  3725. delete(m.clearedFields, batchmsg.FieldTotal)
  3726. }
  3727. // SetSuccess sets the "success" field.
  3728. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3729. m.success = &i
  3730. m.addsuccess = nil
  3731. }
  3732. // Success returns the value of the "success" field in the mutation.
  3733. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3734. v := m.success
  3735. if v == nil {
  3736. return
  3737. }
  3738. return *v, true
  3739. }
  3740. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3741. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3743. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3744. if !m.op.Is(OpUpdateOne) {
  3745. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3746. }
  3747. if m.id == nil || m.oldValue == nil {
  3748. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3749. }
  3750. oldValue, err := m.oldValue(ctx)
  3751. if err != nil {
  3752. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3753. }
  3754. return oldValue.Success, nil
  3755. }
  3756. // AddSuccess adds i to the "success" field.
  3757. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3758. if m.addsuccess != nil {
  3759. *m.addsuccess += i
  3760. } else {
  3761. m.addsuccess = &i
  3762. }
  3763. }
  3764. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3765. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3766. v := m.addsuccess
  3767. if v == nil {
  3768. return
  3769. }
  3770. return *v, true
  3771. }
  3772. // ClearSuccess clears the value of the "success" field.
  3773. func (m *BatchMsgMutation) ClearSuccess() {
  3774. m.success = nil
  3775. m.addsuccess = nil
  3776. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3777. }
  3778. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3779. func (m *BatchMsgMutation) SuccessCleared() bool {
  3780. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3781. return ok
  3782. }
  3783. // ResetSuccess resets all changes to the "success" field.
  3784. func (m *BatchMsgMutation) ResetSuccess() {
  3785. m.success = nil
  3786. m.addsuccess = nil
  3787. delete(m.clearedFields, batchmsg.FieldSuccess)
  3788. }
  3789. // SetFail sets the "fail" field.
  3790. func (m *BatchMsgMutation) SetFail(i int32) {
  3791. m.fail = &i
  3792. m.addfail = nil
  3793. }
  3794. // Fail returns the value of the "fail" field in the mutation.
  3795. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3796. v := m.fail
  3797. if v == nil {
  3798. return
  3799. }
  3800. return *v, true
  3801. }
  3802. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3803. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3805. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3806. if !m.op.Is(OpUpdateOne) {
  3807. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3808. }
  3809. if m.id == nil || m.oldValue == nil {
  3810. return v, errors.New("OldFail requires an ID field in the mutation")
  3811. }
  3812. oldValue, err := m.oldValue(ctx)
  3813. if err != nil {
  3814. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3815. }
  3816. return oldValue.Fail, nil
  3817. }
  3818. // AddFail adds i to the "fail" field.
  3819. func (m *BatchMsgMutation) AddFail(i int32) {
  3820. if m.addfail != nil {
  3821. *m.addfail += i
  3822. } else {
  3823. m.addfail = &i
  3824. }
  3825. }
  3826. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3827. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3828. v := m.addfail
  3829. if v == nil {
  3830. return
  3831. }
  3832. return *v, true
  3833. }
  3834. // ClearFail clears the value of the "fail" field.
  3835. func (m *BatchMsgMutation) ClearFail() {
  3836. m.fail = nil
  3837. m.addfail = nil
  3838. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3839. }
  3840. // FailCleared returns if the "fail" field was cleared in this mutation.
  3841. func (m *BatchMsgMutation) FailCleared() bool {
  3842. _, ok := m.clearedFields[batchmsg.FieldFail]
  3843. return ok
  3844. }
  3845. // ResetFail resets all changes to the "fail" field.
  3846. func (m *BatchMsgMutation) ResetFail() {
  3847. m.fail = nil
  3848. m.addfail = nil
  3849. delete(m.clearedFields, batchmsg.FieldFail)
  3850. }
  3851. // SetStartTime sets the "start_time" field.
  3852. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3853. m.start_time = &t
  3854. }
  3855. // StartTime returns the value of the "start_time" field in the mutation.
  3856. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3857. v := m.start_time
  3858. if v == nil {
  3859. return
  3860. }
  3861. return *v, true
  3862. }
  3863. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3864. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3866. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3867. if !m.op.Is(OpUpdateOne) {
  3868. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3869. }
  3870. if m.id == nil || m.oldValue == nil {
  3871. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3872. }
  3873. oldValue, err := m.oldValue(ctx)
  3874. if err != nil {
  3875. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3876. }
  3877. return oldValue.StartTime, nil
  3878. }
  3879. // ClearStartTime clears the value of the "start_time" field.
  3880. func (m *BatchMsgMutation) ClearStartTime() {
  3881. m.start_time = nil
  3882. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3883. }
  3884. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3885. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3886. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3887. return ok
  3888. }
  3889. // ResetStartTime resets all changes to the "start_time" field.
  3890. func (m *BatchMsgMutation) ResetStartTime() {
  3891. m.start_time = nil
  3892. delete(m.clearedFields, batchmsg.FieldStartTime)
  3893. }
  3894. // SetStopTime sets the "stop_time" field.
  3895. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3896. m.stop_time = &t
  3897. }
  3898. // StopTime returns the value of the "stop_time" field in the mutation.
  3899. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3900. v := m.stop_time
  3901. if v == nil {
  3902. return
  3903. }
  3904. return *v, true
  3905. }
  3906. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3907. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3909. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3910. if !m.op.Is(OpUpdateOne) {
  3911. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3912. }
  3913. if m.id == nil || m.oldValue == nil {
  3914. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3915. }
  3916. oldValue, err := m.oldValue(ctx)
  3917. if err != nil {
  3918. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3919. }
  3920. return oldValue.StopTime, nil
  3921. }
  3922. // ClearStopTime clears the value of the "stop_time" field.
  3923. func (m *BatchMsgMutation) ClearStopTime() {
  3924. m.stop_time = nil
  3925. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3926. }
  3927. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3928. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3929. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3930. return ok
  3931. }
  3932. // ResetStopTime resets all changes to the "stop_time" field.
  3933. func (m *BatchMsgMutation) ResetStopTime() {
  3934. m.stop_time = nil
  3935. delete(m.clearedFields, batchmsg.FieldStopTime)
  3936. }
  3937. // SetSendTime sets the "send_time" field.
  3938. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3939. m.send_time = &t
  3940. }
  3941. // SendTime returns the value of the "send_time" field in the mutation.
  3942. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3943. v := m.send_time
  3944. if v == nil {
  3945. return
  3946. }
  3947. return *v, true
  3948. }
  3949. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3950. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3952. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3953. if !m.op.Is(OpUpdateOne) {
  3954. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3955. }
  3956. if m.id == nil || m.oldValue == nil {
  3957. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3958. }
  3959. oldValue, err := m.oldValue(ctx)
  3960. if err != nil {
  3961. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3962. }
  3963. return oldValue.SendTime, nil
  3964. }
  3965. // ClearSendTime clears the value of the "send_time" field.
  3966. func (m *BatchMsgMutation) ClearSendTime() {
  3967. m.send_time = nil
  3968. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3969. }
  3970. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3971. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3972. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3973. return ok
  3974. }
  3975. // ResetSendTime resets all changes to the "send_time" field.
  3976. func (m *BatchMsgMutation) ResetSendTime() {
  3977. m.send_time = nil
  3978. delete(m.clearedFields, batchmsg.FieldSendTime)
  3979. }
  3980. // SetType sets the "type" field.
  3981. func (m *BatchMsgMutation) SetType(i int32) {
  3982. m._type = &i
  3983. m.add_type = nil
  3984. }
  3985. // GetType returns the value of the "type" field in the mutation.
  3986. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3987. v := m._type
  3988. if v == nil {
  3989. return
  3990. }
  3991. return *v, true
  3992. }
  3993. // OldType returns the old "type" field's value of the BatchMsg entity.
  3994. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3996. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  3997. if !m.op.Is(OpUpdateOne) {
  3998. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3999. }
  4000. if m.id == nil || m.oldValue == nil {
  4001. return v, errors.New("OldType requires an ID field in the mutation")
  4002. }
  4003. oldValue, err := m.oldValue(ctx)
  4004. if err != nil {
  4005. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4006. }
  4007. return oldValue.Type, nil
  4008. }
  4009. // AddType adds i to the "type" field.
  4010. func (m *BatchMsgMutation) AddType(i int32) {
  4011. if m.add_type != nil {
  4012. *m.add_type += i
  4013. } else {
  4014. m.add_type = &i
  4015. }
  4016. }
  4017. // AddedType returns the value that was added to the "type" field in this mutation.
  4018. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4019. v := m.add_type
  4020. if v == nil {
  4021. return
  4022. }
  4023. return *v, true
  4024. }
  4025. // ClearType clears the value of the "type" field.
  4026. func (m *BatchMsgMutation) ClearType() {
  4027. m._type = nil
  4028. m.add_type = nil
  4029. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4030. }
  4031. // TypeCleared returns if the "type" field was cleared in this mutation.
  4032. func (m *BatchMsgMutation) TypeCleared() bool {
  4033. _, ok := m.clearedFields[batchmsg.FieldType]
  4034. return ok
  4035. }
  4036. // ResetType resets all changes to the "type" field.
  4037. func (m *BatchMsgMutation) ResetType() {
  4038. m._type = nil
  4039. m.add_type = nil
  4040. delete(m.clearedFields, batchmsg.FieldType)
  4041. }
  4042. // SetOrganizationID sets the "organization_id" field.
  4043. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4044. m.organization_id = &u
  4045. m.addorganization_id = nil
  4046. }
  4047. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4048. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4049. v := m.organization_id
  4050. if v == nil {
  4051. return
  4052. }
  4053. return *v, true
  4054. }
  4055. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4056. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4058. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4059. if !m.op.Is(OpUpdateOne) {
  4060. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4061. }
  4062. if m.id == nil || m.oldValue == nil {
  4063. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4064. }
  4065. oldValue, err := m.oldValue(ctx)
  4066. if err != nil {
  4067. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4068. }
  4069. return oldValue.OrganizationID, nil
  4070. }
  4071. // AddOrganizationID adds u to the "organization_id" field.
  4072. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4073. if m.addorganization_id != nil {
  4074. *m.addorganization_id += u
  4075. } else {
  4076. m.addorganization_id = &u
  4077. }
  4078. }
  4079. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4080. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4081. v := m.addorganization_id
  4082. if v == nil {
  4083. return
  4084. }
  4085. return *v, true
  4086. }
  4087. // ResetOrganizationID resets all changes to the "organization_id" field.
  4088. func (m *BatchMsgMutation) ResetOrganizationID() {
  4089. m.organization_id = nil
  4090. m.addorganization_id = nil
  4091. }
  4092. // Where appends a list predicates to the BatchMsgMutation builder.
  4093. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4094. m.predicates = append(m.predicates, ps...)
  4095. }
  4096. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4097. // users can use type-assertion to append predicates that do not depend on any generated package.
  4098. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4099. p := make([]predicate.BatchMsg, len(ps))
  4100. for i := range ps {
  4101. p[i] = ps[i]
  4102. }
  4103. m.Where(p...)
  4104. }
  4105. // Op returns the operation name.
  4106. func (m *BatchMsgMutation) Op() Op {
  4107. return m.op
  4108. }
  4109. // SetOp allows setting the mutation operation.
  4110. func (m *BatchMsgMutation) SetOp(op Op) {
  4111. m.op = op
  4112. }
  4113. // Type returns the node type of this mutation (BatchMsg).
  4114. func (m *BatchMsgMutation) Type() string {
  4115. return m.typ
  4116. }
  4117. // Fields returns all fields that were changed during this mutation. Note that in
  4118. // order to get all numeric fields that were incremented/decremented, call
  4119. // AddedFields().
  4120. func (m *BatchMsgMutation) Fields() []string {
  4121. fields := make([]string, 0, 18)
  4122. if m.created_at != nil {
  4123. fields = append(fields, batchmsg.FieldCreatedAt)
  4124. }
  4125. if m.updated_at != nil {
  4126. fields = append(fields, batchmsg.FieldUpdatedAt)
  4127. }
  4128. if m.deleted_at != nil {
  4129. fields = append(fields, batchmsg.FieldDeletedAt)
  4130. }
  4131. if m.status != nil {
  4132. fields = append(fields, batchmsg.FieldStatus)
  4133. }
  4134. if m.batch_no != nil {
  4135. fields = append(fields, batchmsg.FieldBatchNo)
  4136. }
  4137. if m.task_name != nil {
  4138. fields = append(fields, batchmsg.FieldTaskName)
  4139. }
  4140. if m.fromwxid != nil {
  4141. fields = append(fields, batchmsg.FieldFromwxid)
  4142. }
  4143. if m.msg != nil {
  4144. fields = append(fields, batchmsg.FieldMsg)
  4145. }
  4146. if m.tag != nil {
  4147. fields = append(fields, batchmsg.FieldTag)
  4148. }
  4149. if m.tagids != nil {
  4150. fields = append(fields, batchmsg.FieldTagids)
  4151. }
  4152. if m.total != nil {
  4153. fields = append(fields, batchmsg.FieldTotal)
  4154. }
  4155. if m.success != nil {
  4156. fields = append(fields, batchmsg.FieldSuccess)
  4157. }
  4158. if m.fail != nil {
  4159. fields = append(fields, batchmsg.FieldFail)
  4160. }
  4161. if m.start_time != nil {
  4162. fields = append(fields, batchmsg.FieldStartTime)
  4163. }
  4164. if m.stop_time != nil {
  4165. fields = append(fields, batchmsg.FieldStopTime)
  4166. }
  4167. if m.send_time != nil {
  4168. fields = append(fields, batchmsg.FieldSendTime)
  4169. }
  4170. if m._type != nil {
  4171. fields = append(fields, batchmsg.FieldType)
  4172. }
  4173. if m.organization_id != nil {
  4174. fields = append(fields, batchmsg.FieldOrganizationID)
  4175. }
  4176. return fields
  4177. }
  4178. // Field returns the value of a field with the given name. The second boolean
  4179. // return value indicates that this field was not set, or was not defined in the
  4180. // schema.
  4181. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4182. switch name {
  4183. case batchmsg.FieldCreatedAt:
  4184. return m.CreatedAt()
  4185. case batchmsg.FieldUpdatedAt:
  4186. return m.UpdatedAt()
  4187. case batchmsg.FieldDeletedAt:
  4188. return m.DeletedAt()
  4189. case batchmsg.FieldStatus:
  4190. return m.Status()
  4191. case batchmsg.FieldBatchNo:
  4192. return m.BatchNo()
  4193. case batchmsg.FieldTaskName:
  4194. return m.TaskName()
  4195. case batchmsg.FieldFromwxid:
  4196. return m.Fromwxid()
  4197. case batchmsg.FieldMsg:
  4198. return m.Msg()
  4199. case batchmsg.FieldTag:
  4200. return m.Tag()
  4201. case batchmsg.FieldTagids:
  4202. return m.Tagids()
  4203. case batchmsg.FieldTotal:
  4204. return m.Total()
  4205. case batchmsg.FieldSuccess:
  4206. return m.Success()
  4207. case batchmsg.FieldFail:
  4208. return m.Fail()
  4209. case batchmsg.FieldStartTime:
  4210. return m.StartTime()
  4211. case batchmsg.FieldStopTime:
  4212. return m.StopTime()
  4213. case batchmsg.FieldSendTime:
  4214. return m.SendTime()
  4215. case batchmsg.FieldType:
  4216. return m.GetType()
  4217. case batchmsg.FieldOrganizationID:
  4218. return m.OrganizationID()
  4219. }
  4220. return nil, false
  4221. }
  4222. // OldField returns the old value of the field from the database. An error is
  4223. // returned if the mutation operation is not UpdateOne, or the query to the
  4224. // database failed.
  4225. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4226. switch name {
  4227. case batchmsg.FieldCreatedAt:
  4228. return m.OldCreatedAt(ctx)
  4229. case batchmsg.FieldUpdatedAt:
  4230. return m.OldUpdatedAt(ctx)
  4231. case batchmsg.FieldDeletedAt:
  4232. return m.OldDeletedAt(ctx)
  4233. case batchmsg.FieldStatus:
  4234. return m.OldStatus(ctx)
  4235. case batchmsg.FieldBatchNo:
  4236. return m.OldBatchNo(ctx)
  4237. case batchmsg.FieldTaskName:
  4238. return m.OldTaskName(ctx)
  4239. case batchmsg.FieldFromwxid:
  4240. return m.OldFromwxid(ctx)
  4241. case batchmsg.FieldMsg:
  4242. return m.OldMsg(ctx)
  4243. case batchmsg.FieldTag:
  4244. return m.OldTag(ctx)
  4245. case batchmsg.FieldTagids:
  4246. return m.OldTagids(ctx)
  4247. case batchmsg.FieldTotal:
  4248. return m.OldTotal(ctx)
  4249. case batchmsg.FieldSuccess:
  4250. return m.OldSuccess(ctx)
  4251. case batchmsg.FieldFail:
  4252. return m.OldFail(ctx)
  4253. case batchmsg.FieldStartTime:
  4254. return m.OldStartTime(ctx)
  4255. case batchmsg.FieldStopTime:
  4256. return m.OldStopTime(ctx)
  4257. case batchmsg.FieldSendTime:
  4258. return m.OldSendTime(ctx)
  4259. case batchmsg.FieldType:
  4260. return m.OldType(ctx)
  4261. case batchmsg.FieldOrganizationID:
  4262. return m.OldOrganizationID(ctx)
  4263. }
  4264. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4265. }
  4266. // SetField sets the value of a field with the given name. It returns an error if
  4267. // the field is not defined in the schema, or if the type mismatched the field
  4268. // type.
  4269. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4270. switch name {
  4271. case batchmsg.FieldCreatedAt:
  4272. v, ok := value.(time.Time)
  4273. if !ok {
  4274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4275. }
  4276. m.SetCreatedAt(v)
  4277. return nil
  4278. case batchmsg.FieldUpdatedAt:
  4279. v, ok := value.(time.Time)
  4280. if !ok {
  4281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4282. }
  4283. m.SetUpdatedAt(v)
  4284. return nil
  4285. case batchmsg.FieldDeletedAt:
  4286. v, ok := value.(time.Time)
  4287. if !ok {
  4288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4289. }
  4290. m.SetDeletedAt(v)
  4291. return nil
  4292. case batchmsg.FieldStatus:
  4293. v, ok := value.(uint8)
  4294. if !ok {
  4295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4296. }
  4297. m.SetStatus(v)
  4298. return nil
  4299. case batchmsg.FieldBatchNo:
  4300. v, ok := value.(string)
  4301. if !ok {
  4302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4303. }
  4304. m.SetBatchNo(v)
  4305. return nil
  4306. case batchmsg.FieldTaskName:
  4307. v, ok := value.(string)
  4308. if !ok {
  4309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4310. }
  4311. m.SetTaskName(v)
  4312. return nil
  4313. case batchmsg.FieldFromwxid:
  4314. v, ok := value.(string)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.SetFromwxid(v)
  4319. return nil
  4320. case batchmsg.FieldMsg:
  4321. v, ok := value.(string)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.SetMsg(v)
  4326. return nil
  4327. case batchmsg.FieldTag:
  4328. v, ok := value.(string)
  4329. if !ok {
  4330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4331. }
  4332. m.SetTag(v)
  4333. return nil
  4334. case batchmsg.FieldTagids:
  4335. v, ok := value.(string)
  4336. if !ok {
  4337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4338. }
  4339. m.SetTagids(v)
  4340. return nil
  4341. case batchmsg.FieldTotal:
  4342. v, ok := value.(int32)
  4343. if !ok {
  4344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4345. }
  4346. m.SetTotal(v)
  4347. return nil
  4348. case batchmsg.FieldSuccess:
  4349. v, ok := value.(int32)
  4350. if !ok {
  4351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4352. }
  4353. m.SetSuccess(v)
  4354. return nil
  4355. case batchmsg.FieldFail:
  4356. v, ok := value.(int32)
  4357. if !ok {
  4358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4359. }
  4360. m.SetFail(v)
  4361. return nil
  4362. case batchmsg.FieldStartTime:
  4363. v, ok := value.(time.Time)
  4364. if !ok {
  4365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4366. }
  4367. m.SetStartTime(v)
  4368. return nil
  4369. case batchmsg.FieldStopTime:
  4370. v, ok := value.(time.Time)
  4371. if !ok {
  4372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4373. }
  4374. m.SetStopTime(v)
  4375. return nil
  4376. case batchmsg.FieldSendTime:
  4377. v, ok := value.(time.Time)
  4378. if !ok {
  4379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4380. }
  4381. m.SetSendTime(v)
  4382. return nil
  4383. case batchmsg.FieldType:
  4384. v, ok := value.(int32)
  4385. if !ok {
  4386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4387. }
  4388. m.SetType(v)
  4389. return nil
  4390. case batchmsg.FieldOrganizationID:
  4391. v, ok := value.(uint64)
  4392. if !ok {
  4393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4394. }
  4395. m.SetOrganizationID(v)
  4396. return nil
  4397. }
  4398. return fmt.Errorf("unknown BatchMsg field %s", name)
  4399. }
  4400. // AddedFields returns all numeric fields that were incremented/decremented during
  4401. // this mutation.
  4402. func (m *BatchMsgMutation) AddedFields() []string {
  4403. var fields []string
  4404. if m.addstatus != nil {
  4405. fields = append(fields, batchmsg.FieldStatus)
  4406. }
  4407. if m.addtotal != nil {
  4408. fields = append(fields, batchmsg.FieldTotal)
  4409. }
  4410. if m.addsuccess != nil {
  4411. fields = append(fields, batchmsg.FieldSuccess)
  4412. }
  4413. if m.addfail != nil {
  4414. fields = append(fields, batchmsg.FieldFail)
  4415. }
  4416. if m.add_type != nil {
  4417. fields = append(fields, batchmsg.FieldType)
  4418. }
  4419. if m.addorganization_id != nil {
  4420. fields = append(fields, batchmsg.FieldOrganizationID)
  4421. }
  4422. return fields
  4423. }
  4424. // AddedField returns the numeric value that was incremented/decremented on a field
  4425. // with the given name. The second boolean return value indicates that this field
  4426. // was not set, or was not defined in the schema.
  4427. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4428. switch name {
  4429. case batchmsg.FieldStatus:
  4430. return m.AddedStatus()
  4431. case batchmsg.FieldTotal:
  4432. return m.AddedTotal()
  4433. case batchmsg.FieldSuccess:
  4434. return m.AddedSuccess()
  4435. case batchmsg.FieldFail:
  4436. return m.AddedFail()
  4437. case batchmsg.FieldType:
  4438. return m.AddedType()
  4439. case batchmsg.FieldOrganizationID:
  4440. return m.AddedOrganizationID()
  4441. }
  4442. return nil, false
  4443. }
  4444. // AddField adds the value to the field with the given name. It returns an error if
  4445. // the field is not defined in the schema, or if the type mismatched the field
  4446. // type.
  4447. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4448. switch name {
  4449. case batchmsg.FieldStatus:
  4450. v, ok := value.(int8)
  4451. if !ok {
  4452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4453. }
  4454. m.AddStatus(v)
  4455. return nil
  4456. case batchmsg.FieldTotal:
  4457. v, ok := value.(int32)
  4458. if !ok {
  4459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4460. }
  4461. m.AddTotal(v)
  4462. return nil
  4463. case batchmsg.FieldSuccess:
  4464. v, ok := value.(int32)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.AddSuccess(v)
  4469. return nil
  4470. case batchmsg.FieldFail:
  4471. v, ok := value.(int32)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.AddFail(v)
  4476. return nil
  4477. case batchmsg.FieldType:
  4478. v, ok := value.(int32)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.AddType(v)
  4483. return nil
  4484. case batchmsg.FieldOrganizationID:
  4485. v, ok := value.(int64)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.AddOrganizationID(v)
  4490. return nil
  4491. }
  4492. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4493. }
  4494. // ClearedFields returns all nullable fields that were cleared during this
  4495. // mutation.
  4496. func (m *BatchMsgMutation) ClearedFields() []string {
  4497. var fields []string
  4498. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4499. fields = append(fields, batchmsg.FieldDeletedAt)
  4500. }
  4501. if m.FieldCleared(batchmsg.FieldStatus) {
  4502. fields = append(fields, batchmsg.FieldStatus)
  4503. }
  4504. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4505. fields = append(fields, batchmsg.FieldBatchNo)
  4506. }
  4507. if m.FieldCleared(batchmsg.FieldTaskName) {
  4508. fields = append(fields, batchmsg.FieldTaskName)
  4509. }
  4510. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4511. fields = append(fields, batchmsg.FieldFromwxid)
  4512. }
  4513. if m.FieldCleared(batchmsg.FieldMsg) {
  4514. fields = append(fields, batchmsg.FieldMsg)
  4515. }
  4516. if m.FieldCleared(batchmsg.FieldTag) {
  4517. fields = append(fields, batchmsg.FieldTag)
  4518. }
  4519. if m.FieldCleared(batchmsg.FieldTagids) {
  4520. fields = append(fields, batchmsg.FieldTagids)
  4521. }
  4522. if m.FieldCleared(batchmsg.FieldTotal) {
  4523. fields = append(fields, batchmsg.FieldTotal)
  4524. }
  4525. if m.FieldCleared(batchmsg.FieldSuccess) {
  4526. fields = append(fields, batchmsg.FieldSuccess)
  4527. }
  4528. if m.FieldCleared(batchmsg.FieldFail) {
  4529. fields = append(fields, batchmsg.FieldFail)
  4530. }
  4531. if m.FieldCleared(batchmsg.FieldStartTime) {
  4532. fields = append(fields, batchmsg.FieldStartTime)
  4533. }
  4534. if m.FieldCleared(batchmsg.FieldStopTime) {
  4535. fields = append(fields, batchmsg.FieldStopTime)
  4536. }
  4537. if m.FieldCleared(batchmsg.FieldSendTime) {
  4538. fields = append(fields, batchmsg.FieldSendTime)
  4539. }
  4540. if m.FieldCleared(batchmsg.FieldType) {
  4541. fields = append(fields, batchmsg.FieldType)
  4542. }
  4543. return fields
  4544. }
  4545. // FieldCleared returns a boolean indicating if a field with the given name was
  4546. // cleared in this mutation.
  4547. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4548. _, ok := m.clearedFields[name]
  4549. return ok
  4550. }
  4551. // ClearField clears the value of the field with the given name. It returns an
  4552. // error if the field is not defined in the schema.
  4553. func (m *BatchMsgMutation) ClearField(name string) error {
  4554. switch name {
  4555. case batchmsg.FieldDeletedAt:
  4556. m.ClearDeletedAt()
  4557. return nil
  4558. case batchmsg.FieldStatus:
  4559. m.ClearStatus()
  4560. return nil
  4561. case batchmsg.FieldBatchNo:
  4562. m.ClearBatchNo()
  4563. return nil
  4564. case batchmsg.FieldTaskName:
  4565. m.ClearTaskName()
  4566. return nil
  4567. case batchmsg.FieldFromwxid:
  4568. m.ClearFromwxid()
  4569. return nil
  4570. case batchmsg.FieldMsg:
  4571. m.ClearMsg()
  4572. return nil
  4573. case batchmsg.FieldTag:
  4574. m.ClearTag()
  4575. return nil
  4576. case batchmsg.FieldTagids:
  4577. m.ClearTagids()
  4578. return nil
  4579. case batchmsg.FieldTotal:
  4580. m.ClearTotal()
  4581. return nil
  4582. case batchmsg.FieldSuccess:
  4583. m.ClearSuccess()
  4584. return nil
  4585. case batchmsg.FieldFail:
  4586. m.ClearFail()
  4587. return nil
  4588. case batchmsg.FieldStartTime:
  4589. m.ClearStartTime()
  4590. return nil
  4591. case batchmsg.FieldStopTime:
  4592. m.ClearStopTime()
  4593. return nil
  4594. case batchmsg.FieldSendTime:
  4595. m.ClearSendTime()
  4596. return nil
  4597. case batchmsg.FieldType:
  4598. m.ClearType()
  4599. return nil
  4600. }
  4601. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4602. }
  4603. // ResetField resets all changes in the mutation for the field with the given name.
  4604. // It returns an error if the field is not defined in the schema.
  4605. func (m *BatchMsgMutation) ResetField(name string) error {
  4606. switch name {
  4607. case batchmsg.FieldCreatedAt:
  4608. m.ResetCreatedAt()
  4609. return nil
  4610. case batchmsg.FieldUpdatedAt:
  4611. m.ResetUpdatedAt()
  4612. return nil
  4613. case batchmsg.FieldDeletedAt:
  4614. m.ResetDeletedAt()
  4615. return nil
  4616. case batchmsg.FieldStatus:
  4617. m.ResetStatus()
  4618. return nil
  4619. case batchmsg.FieldBatchNo:
  4620. m.ResetBatchNo()
  4621. return nil
  4622. case batchmsg.FieldTaskName:
  4623. m.ResetTaskName()
  4624. return nil
  4625. case batchmsg.FieldFromwxid:
  4626. m.ResetFromwxid()
  4627. return nil
  4628. case batchmsg.FieldMsg:
  4629. m.ResetMsg()
  4630. return nil
  4631. case batchmsg.FieldTag:
  4632. m.ResetTag()
  4633. return nil
  4634. case batchmsg.FieldTagids:
  4635. m.ResetTagids()
  4636. return nil
  4637. case batchmsg.FieldTotal:
  4638. m.ResetTotal()
  4639. return nil
  4640. case batchmsg.FieldSuccess:
  4641. m.ResetSuccess()
  4642. return nil
  4643. case batchmsg.FieldFail:
  4644. m.ResetFail()
  4645. return nil
  4646. case batchmsg.FieldStartTime:
  4647. m.ResetStartTime()
  4648. return nil
  4649. case batchmsg.FieldStopTime:
  4650. m.ResetStopTime()
  4651. return nil
  4652. case batchmsg.FieldSendTime:
  4653. m.ResetSendTime()
  4654. return nil
  4655. case batchmsg.FieldType:
  4656. m.ResetType()
  4657. return nil
  4658. case batchmsg.FieldOrganizationID:
  4659. m.ResetOrganizationID()
  4660. return nil
  4661. }
  4662. return fmt.Errorf("unknown BatchMsg field %s", name)
  4663. }
  4664. // AddedEdges returns all edge names that were set/added in this mutation.
  4665. func (m *BatchMsgMutation) AddedEdges() []string {
  4666. edges := make([]string, 0, 0)
  4667. return edges
  4668. }
  4669. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4670. // name in this mutation.
  4671. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4672. return nil
  4673. }
  4674. // RemovedEdges returns all edge names that were removed in this mutation.
  4675. func (m *BatchMsgMutation) RemovedEdges() []string {
  4676. edges := make([]string, 0, 0)
  4677. return edges
  4678. }
  4679. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4680. // the given name in this mutation.
  4681. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4682. return nil
  4683. }
  4684. // ClearedEdges returns all edge names that were cleared in this mutation.
  4685. func (m *BatchMsgMutation) ClearedEdges() []string {
  4686. edges := make([]string, 0, 0)
  4687. return edges
  4688. }
  4689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4690. // was cleared in this mutation.
  4691. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4692. return false
  4693. }
  4694. // ClearEdge clears the value of the edge with the given name. It returns an error
  4695. // if that edge is not defined in the schema.
  4696. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4697. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4698. }
  4699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4700. // It returns an error if the edge is not defined in the schema.
  4701. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4702. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4703. }
  4704. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4705. type CategoryMutation struct {
  4706. config
  4707. op Op
  4708. typ string
  4709. id *uint64
  4710. created_at *time.Time
  4711. updated_at *time.Time
  4712. deleted_at *time.Time
  4713. name *string
  4714. organization_id *uint64
  4715. addorganization_id *int64
  4716. clearedFields map[string]struct{}
  4717. done bool
  4718. oldValue func(context.Context) (*Category, error)
  4719. predicates []predicate.Category
  4720. }
  4721. var _ ent.Mutation = (*CategoryMutation)(nil)
  4722. // categoryOption allows management of the mutation configuration using functional options.
  4723. type categoryOption func(*CategoryMutation)
  4724. // newCategoryMutation creates new mutation for the Category entity.
  4725. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4726. m := &CategoryMutation{
  4727. config: c,
  4728. op: op,
  4729. typ: TypeCategory,
  4730. clearedFields: make(map[string]struct{}),
  4731. }
  4732. for _, opt := range opts {
  4733. opt(m)
  4734. }
  4735. return m
  4736. }
  4737. // withCategoryID sets the ID field of the mutation.
  4738. func withCategoryID(id uint64) categoryOption {
  4739. return func(m *CategoryMutation) {
  4740. var (
  4741. err error
  4742. once sync.Once
  4743. value *Category
  4744. )
  4745. m.oldValue = func(ctx context.Context) (*Category, error) {
  4746. once.Do(func() {
  4747. if m.done {
  4748. err = errors.New("querying old values post mutation is not allowed")
  4749. } else {
  4750. value, err = m.Client().Category.Get(ctx, id)
  4751. }
  4752. })
  4753. return value, err
  4754. }
  4755. m.id = &id
  4756. }
  4757. }
  4758. // withCategory sets the old Category of the mutation.
  4759. func withCategory(node *Category) categoryOption {
  4760. return func(m *CategoryMutation) {
  4761. m.oldValue = func(context.Context) (*Category, error) {
  4762. return node, nil
  4763. }
  4764. m.id = &node.ID
  4765. }
  4766. }
  4767. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4768. // executed in a transaction (ent.Tx), a transactional client is returned.
  4769. func (m CategoryMutation) Client() *Client {
  4770. client := &Client{config: m.config}
  4771. client.init()
  4772. return client
  4773. }
  4774. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4775. // it returns an error otherwise.
  4776. func (m CategoryMutation) Tx() (*Tx, error) {
  4777. if _, ok := m.driver.(*txDriver); !ok {
  4778. return nil, errors.New("ent: mutation is not running in a transaction")
  4779. }
  4780. tx := &Tx{config: m.config}
  4781. tx.init()
  4782. return tx, nil
  4783. }
  4784. // SetID sets the value of the id field. Note that this
  4785. // operation is only accepted on creation of Category entities.
  4786. func (m *CategoryMutation) SetID(id uint64) {
  4787. m.id = &id
  4788. }
  4789. // ID returns the ID value in the mutation. Note that the ID is only available
  4790. // if it was provided to the builder or after it was returned from the database.
  4791. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4792. if m.id == nil {
  4793. return
  4794. }
  4795. return *m.id, true
  4796. }
  4797. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4798. // That means, if the mutation is applied within a transaction with an isolation level such
  4799. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4800. // or updated by the mutation.
  4801. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4802. switch {
  4803. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4804. id, exists := m.ID()
  4805. if exists {
  4806. return []uint64{id}, nil
  4807. }
  4808. fallthrough
  4809. case m.op.Is(OpUpdate | OpDelete):
  4810. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4811. default:
  4812. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4813. }
  4814. }
  4815. // SetCreatedAt sets the "created_at" field.
  4816. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4817. m.created_at = &t
  4818. }
  4819. // CreatedAt returns the value of the "created_at" field in the mutation.
  4820. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4821. v := m.created_at
  4822. if v == nil {
  4823. return
  4824. }
  4825. return *v, true
  4826. }
  4827. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4828. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4830. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4831. if !m.op.Is(OpUpdateOne) {
  4832. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4833. }
  4834. if m.id == nil || m.oldValue == nil {
  4835. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4836. }
  4837. oldValue, err := m.oldValue(ctx)
  4838. if err != nil {
  4839. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4840. }
  4841. return oldValue.CreatedAt, nil
  4842. }
  4843. // ResetCreatedAt resets all changes to the "created_at" field.
  4844. func (m *CategoryMutation) ResetCreatedAt() {
  4845. m.created_at = nil
  4846. }
  4847. // SetUpdatedAt sets the "updated_at" field.
  4848. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4849. m.updated_at = &t
  4850. }
  4851. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4852. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4853. v := m.updated_at
  4854. if v == nil {
  4855. return
  4856. }
  4857. return *v, true
  4858. }
  4859. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4860. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4862. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4863. if !m.op.Is(OpUpdateOne) {
  4864. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4865. }
  4866. if m.id == nil || m.oldValue == nil {
  4867. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4868. }
  4869. oldValue, err := m.oldValue(ctx)
  4870. if err != nil {
  4871. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4872. }
  4873. return oldValue.UpdatedAt, nil
  4874. }
  4875. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4876. func (m *CategoryMutation) ResetUpdatedAt() {
  4877. m.updated_at = nil
  4878. }
  4879. // SetDeletedAt sets the "deleted_at" field.
  4880. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4881. m.deleted_at = &t
  4882. }
  4883. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4884. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4885. v := m.deleted_at
  4886. if v == nil {
  4887. return
  4888. }
  4889. return *v, true
  4890. }
  4891. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4892. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4894. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4895. if !m.op.Is(OpUpdateOne) {
  4896. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4897. }
  4898. if m.id == nil || m.oldValue == nil {
  4899. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4900. }
  4901. oldValue, err := m.oldValue(ctx)
  4902. if err != nil {
  4903. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4904. }
  4905. return oldValue.DeletedAt, nil
  4906. }
  4907. // ClearDeletedAt clears the value of the "deleted_at" field.
  4908. func (m *CategoryMutation) ClearDeletedAt() {
  4909. m.deleted_at = nil
  4910. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4911. }
  4912. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4913. func (m *CategoryMutation) DeletedAtCleared() bool {
  4914. _, ok := m.clearedFields[category.FieldDeletedAt]
  4915. return ok
  4916. }
  4917. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4918. func (m *CategoryMutation) ResetDeletedAt() {
  4919. m.deleted_at = nil
  4920. delete(m.clearedFields, category.FieldDeletedAt)
  4921. }
  4922. // SetName sets the "name" field.
  4923. func (m *CategoryMutation) SetName(s string) {
  4924. m.name = &s
  4925. }
  4926. // Name returns the value of the "name" field in the mutation.
  4927. func (m *CategoryMutation) Name() (r string, exists bool) {
  4928. v := m.name
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // OldName returns the old "name" field's value of the Category entity.
  4935. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4937. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4938. if !m.op.Is(OpUpdateOne) {
  4939. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4940. }
  4941. if m.id == nil || m.oldValue == nil {
  4942. return v, errors.New("OldName requires an ID field in the mutation")
  4943. }
  4944. oldValue, err := m.oldValue(ctx)
  4945. if err != nil {
  4946. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4947. }
  4948. return oldValue.Name, nil
  4949. }
  4950. // ResetName resets all changes to the "name" field.
  4951. func (m *CategoryMutation) ResetName() {
  4952. m.name = nil
  4953. }
  4954. // SetOrganizationID sets the "organization_id" field.
  4955. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4956. m.organization_id = &u
  4957. m.addorganization_id = nil
  4958. }
  4959. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4960. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4961. v := m.organization_id
  4962. if v == nil {
  4963. return
  4964. }
  4965. return *v, true
  4966. }
  4967. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4968. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4970. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4971. if !m.op.Is(OpUpdateOne) {
  4972. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4973. }
  4974. if m.id == nil || m.oldValue == nil {
  4975. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4976. }
  4977. oldValue, err := m.oldValue(ctx)
  4978. if err != nil {
  4979. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4980. }
  4981. return oldValue.OrganizationID, nil
  4982. }
  4983. // AddOrganizationID adds u to the "organization_id" field.
  4984. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4985. if m.addorganization_id != nil {
  4986. *m.addorganization_id += u
  4987. } else {
  4988. m.addorganization_id = &u
  4989. }
  4990. }
  4991. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4992. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  4993. v := m.addorganization_id
  4994. if v == nil {
  4995. return
  4996. }
  4997. return *v, true
  4998. }
  4999. // ResetOrganizationID resets all changes to the "organization_id" field.
  5000. func (m *CategoryMutation) ResetOrganizationID() {
  5001. m.organization_id = nil
  5002. m.addorganization_id = nil
  5003. }
  5004. // Where appends a list predicates to the CategoryMutation builder.
  5005. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5006. m.predicates = append(m.predicates, ps...)
  5007. }
  5008. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5009. // users can use type-assertion to append predicates that do not depend on any generated package.
  5010. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5011. p := make([]predicate.Category, len(ps))
  5012. for i := range ps {
  5013. p[i] = ps[i]
  5014. }
  5015. m.Where(p...)
  5016. }
  5017. // Op returns the operation name.
  5018. func (m *CategoryMutation) Op() Op {
  5019. return m.op
  5020. }
  5021. // SetOp allows setting the mutation operation.
  5022. func (m *CategoryMutation) SetOp(op Op) {
  5023. m.op = op
  5024. }
  5025. // Type returns the node type of this mutation (Category).
  5026. func (m *CategoryMutation) Type() string {
  5027. return m.typ
  5028. }
  5029. // Fields returns all fields that were changed during this mutation. Note that in
  5030. // order to get all numeric fields that were incremented/decremented, call
  5031. // AddedFields().
  5032. func (m *CategoryMutation) Fields() []string {
  5033. fields := make([]string, 0, 5)
  5034. if m.created_at != nil {
  5035. fields = append(fields, category.FieldCreatedAt)
  5036. }
  5037. if m.updated_at != nil {
  5038. fields = append(fields, category.FieldUpdatedAt)
  5039. }
  5040. if m.deleted_at != nil {
  5041. fields = append(fields, category.FieldDeletedAt)
  5042. }
  5043. if m.name != nil {
  5044. fields = append(fields, category.FieldName)
  5045. }
  5046. if m.organization_id != nil {
  5047. fields = append(fields, category.FieldOrganizationID)
  5048. }
  5049. return fields
  5050. }
  5051. // Field returns the value of a field with the given name. The second boolean
  5052. // return value indicates that this field was not set, or was not defined in the
  5053. // schema.
  5054. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5055. switch name {
  5056. case category.FieldCreatedAt:
  5057. return m.CreatedAt()
  5058. case category.FieldUpdatedAt:
  5059. return m.UpdatedAt()
  5060. case category.FieldDeletedAt:
  5061. return m.DeletedAt()
  5062. case category.FieldName:
  5063. return m.Name()
  5064. case category.FieldOrganizationID:
  5065. return m.OrganizationID()
  5066. }
  5067. return nil, false
  5068. }
  5069. // OldField returns the old value of the field from the database. An error is
  5070. // returned if the mutation operation is not UpdateOne, or the query to the
  5071. // database failed.
  5072. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5073. switch name {
  5074. case category.FieldCreatedAt:
  5075. return m.OldCreatedAt(ctx)
  5076. case category.FieldUpdatedAt:
  5077. return m.OldUpdatedAt(ctx)
  5078. case category.FieldDeletedAt:
  5079. return m.OldDeletedAt(ctx)
  5080. case category.FieldName:
  5081. return m.OldName(ctx)
  5082. case category.FieldOrganizationID:
  5083. return m.OldOrganizationID(ctx)
  5084. }
  5085. return nil, fmt.Errorf("unknown Category field %s", name)
  5086. }
  5087. // SetField sets the value of a field with the given name. It returns an error if
  5088. // the field is not defined in the schema, or if the type mismatched the field
  5089. // type.
  5090. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5091. switch name {
  5092. case category.FieldCreatedAt:
  5093. v, ok := value.(time.Time)
  5094. if !ok {
  5095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5096. }
  5097. m.SetCreatedAt(v)
  5098. return nil
  5099. case category.FieldUpdatedAt:
  5100. v, ok := value.(time.Time)
  5101. if !ok {
  5102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5103. }
  5104. m.SetUpdatedAt(v)
  5105. return nil
  5106. case category.FieldDeletedAt:
  5107. v, ok := value.(time.Time)
  5108. if !ok {
  5109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5110. }
  5111. m.SetDeletedAt(v)
  5112. return nil
  5113. case category.FieldName:
  5114. v, ok := value.(string)
  5115. if !ok {
  5116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5117. }
  5118. m.SetName(v)
  5119. return nil
  5120. case category.FieldOrganizationID:
  5121. v, ok := value.(uint64)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetOrganizationID(v)
  5126. return nil
  5127. }
  5128. return fmt.Errorf("unknown Category field %s", name)
  5129. }
  5130. // AddedFields returns all numeric fields that were incremented/decremented during
  5131. // this mutation.
  5132. func (m *CategoryMutation) AddedFields() []string {
  5133. var fields []string
  5134. if m.addorganization_id != nil {
  5135. fields = append(fields, category.FieldOrganizationID)
  5136. }
  5137. return fields
  5138. }
  5139. // AddedField returns the numeric value that was incremented/decremented on a field
  5140. // with the given name. The second boolean return value indicates that this field
  5141. // was not set, or was not defined in the schema.
  5142. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5143. switch name {
  5144. case category.FieldOrganizationID:
  5145. return m.AddedOrganizationID()
  5146. }
  5147. return nil, false
  5148. }
  5149. // AddField adds the value to the field with the given name. It returns an error if
  5150. // the field is not defined in the schema, or if the type mismatched the field
  5151. // type.
  5152. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5153. switch name {
  5154. case category.FieldOrganizationID:
  5155. v, ok := value.(int64)
  5156. if !ok {
  5157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5158. }
  5159. m.AddOrganizationID(v)
  5160. return nil
  5161. }
  5162. return fmt.Errorf("unknown Category numeric field %s", name)
  5163. }
  5164. // ClearedFields returns all nullable fields that were cleared during this
  5165. // mutation.
  5166. func (m *CategoryMutation) ClearedFields() []string {
  5167. var fields []string
  5168. if m.FieldCleared(category.FieldDeletedAt) {
  5169. fields = append(fields, category.FieldDeletedAt)
  5170. }
  5171. return fields
  5172. }
  5173. // FieldCleared returns a boolean indicating if a field with the given name was
  5174. // cleared in this mutation.
  5175. func (m *CategoryMutation) FieldCleared(name string) bool {
  5176. _, ok := m.clearedFields[name]
  5177. return ok
  5178. }
  5179. // ClearField clears the value of the field with the given name. It returns an
  5180. // error if the field is not defined in the schema.
  5181. func (m *CategoryMutation) ClearField(name string) error {
  5182. switch name {
  5183. case category.FieldDeletedAt:
  5184. m.ClearDeletedAt()
  5185. return nil
  5186. }
  5187. return fmt.Errorf("unknown Category nullable field %s", name)
  5188. }
  5189. // ResetField resets all changes in the mutation for the field with the given name.
  5190. // It returns an error if the field is not defined in the schema.
  5191. func (m *CategoryMutation) ResetField(name string) error {
  5192. switch name {
  5193. case category.FieldCreatedAt:
  5194. m.ResetCreatedAt()
  5195. return nil
  5196. case category.FieldUpdatedAt:
  5197. m.ResetUpdatedAt()
  5198. return nil
  5199. case category.FieldDeletedAt:
  5200. m.ResetDeletedAt()
  5201. return nil
  5202. case category.FieldName:
  5203. m.ResetName()
  5204. return nil
  5205. case category.FieldOrganizationID:
  5206. m.ResetOrganizationID()
  5207. return nil
  5208. }
  5209. return fmt.Errorf("unknown Category field %s", name)
  5210. }
  5211. // AddedEdges returns all edge names that were set/added in this mutation.
  5212. func (m *CategoryMutation) AddedEdges() []string {
  5213. edges := make([]string, 0, 0)
  5214. return edges
  5215. }
  5216. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5217. // name in this mutation.
  5218. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5219. return nil
  5220. }
  5221. // RemovedEdges returns all edge names that were removed in this mutation.
  5222. func (m *CategoryMutation) RemovedEdges() []string {
  5223. edges := make([]string, 0, 0)
  5224. return edges
  5225. }
  5226. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5227. // the given name in this mutation.
  5228. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5229. return nil
  5230. }
  5231. // ClearedEdges returns all edge names that were cleared in this mutation.
  5232. func (m *CategoryMutation) ClearedEdges() []string {
  5233. edges := make([]string, 0, 0)
  5234. return edges
  5235. }
  5236. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5237. // was cleared in this mutation.
  5238. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5239. return false
  5240. }
  5241. // ClearEdge clears the value of the edge with the given name. It returns an error
  5242. // if that edge is not defined in the schema.
  5243. func (m *CategoryMutation) ClearEdge(name string) error {
  5244. return fmt.Errorf("unknown Category unique edge %s", name)
  5245. }
  5246. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5247. // It returns an error if the edge is not defined in the schema.
  5248. func (m *CategoryMutation) ResetEdge(name string) error {
  5249. return fmt.Errorf("unknown Category edge %s", name)
  5250. }
  5251. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5252. type ChatRecordsMutation struct {
  5253. config
  5254. op Op
  5255. typ string
  5256. id *uint64
  5257. created_at *time.Time
  5258. updated_at *time.Time
  5259. deleted_at *time.Time
  5260. content *string
  5261. content_type *uint8
  5262. addcontent_type *int8
  5263. session_id *uint64
  5264. addsession_id *int64
  5265. user_id *uint64
  5266. adduser_id *int64
  5267. bot_id *uint64
  5268. addbot_id *int64
  5269. bot_type *uint8
  5270. addbot_type *int8
  5271. clearedFields map[string]struct{}
  5272. done bool
  5273. oldValue func(context.Context) (*ChatRecords, error)
  5274. predicates []predicate.ChatRecords
  5275. }
  5276. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5277. // chatrecordsOption allows management of the mutation configuration using functional options.
  5278. type chatrecordsOption func(*ChatRecordsMutation)
  5279. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5280. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5281. m := &ChatRecordsMutation{
  5282. config: c,
  5283. op: op,
  5284. typ: TypeChatRecords,
  5285. clearedFields: make(map[string]struct{}),
  5286. }
  5287. for _, opt := range opts {
  5288. opt(m)
  5289. }
  5290. return m
  5291. }
  5292. // withChatRecordsID sets the ID field of the mutation.
  5293. func withChatRecordsID(id uint64) chatrecordsOption {
  5294. return func(m *ChatRecordsMutation) {
  5295. var (
  5296. err error
  5297. once sync.Once
  5298. value *ChatRecords
  5299. )
  5300. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5301. once.Do(func() {
  5302. if m.done {
  5303. err = errors.New("querying old values post mutation is not allowed")
  5304. } else {
  5305. value, err = m.Client().ChatRecords.Get(ctx, id)
  5306. }
  5307. })
  5308. return value, err
  5309. }
  5310. m.id = &id
  5311. }
  5312. }
  5313. // withChatRecords sets the old ChatRecords of the mutation.
  5314. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5315. return func(m *ChatRecordsMutation) {
  5316. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5317. return node, nil
  5318. }
  5319. m.id = &node.ID
  5320. }
  5321. }
  5322. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5323. // executed in a transaction (ent.Tx), a transactional client is returned.
  5324. func (m ChatRecordsMutation) Client() *Client {
  5325. client := &Client{config: m.config}
  5326. client.init()
  5327. return client
  5328. }
  5329. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5330. // it returns an error otherwise.
  5331. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5332. if _, ok := m.driver.(*txDriver); !ok {
  5333. return nil, errors.New("ent: mutation is not running in a transaction")
  5334. }
  5335. tx := &Tx{config: m.config}
  5336. tx.init()
  5337. return tx, nil
  5338. }
  5339. // SetID sets the value of the id field. Note that this
  5340. // operation is only accepted on creation of ChatRecords entities.
  5341. func (m *ChatRecordsMutation) SetID(id uint64) {
  5342. m.id = &id
  5343. }
  5344. // ID returns the ID value in the mutation. Note that the ID is only available
  5345. // if it was provided to the builder or after it was returned from the database.
  5346. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5347. if m.id == nil {
  5348. return
  5349. }
  5350. return *m.id, true
  5351. }
  5352. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5353. // That means, if the mutation is applied within a transaction with an isolation level such
  5354. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5355. // or updated by the mutation.
  5356. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5357. switch {
  5358. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5359. id, exists := m.ID()
  5360. if exists {
  5361. return []uint64{id}, nil
  5362. }
  5363. fallthrough
  5364. case m.op.Is(OpUpdate | OpDelete):
  5365. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5366. default:
  5367. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5368. }
  5369. }
  5370. // SetCreatedAt sets the "created_at" field.
  5371. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5372. m.created_at = &t
  5373. }
  5374. // CreatedAt returns the value of the "created_at" field in the mutation.
  5375. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5376. v := m.created_at
  5377. if v == nil {
  5378. return
  5379. }
  5380. return *v, true
  5381. }
  5382. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5383. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5385. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5386. if !m.op.Is(OpUpdateOne) {
  5387. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5388. }
  5389. if m.id == nil || m.oldValue == nil {
  5390. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5391. }
  5392. oldValue, err := m.oldValue(ctx)
  5393. if err != nil {
  5394. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5395. }
  5396. return oldValue.CreatedAt, nil
  5397. }
  5398. // ResetCreatedAt resets all changes to the "created_at" field.
  5399. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5400. m.created_at = nil
  5401. }
  5402. // SetUpdatedAt sets the "updated_at" field.
  5403. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5404. m.updated_at = &t
  5405. }
  5406. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5407. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5408. v := m.updated_at
  5409. if v == nil {
  5410. return
  5411. }
  5412. return *v, true
  5413. }
  5414. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5415. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5417. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5418. if !m.op.Is(OpUpdateOne) {
  5419. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5420. }
  5421. if m.id == nil || m.oldValue == nil {
  5422. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5423. }
  5424. oldValue, err := m.oldValue(ctx)
  5425. if err != nil {
  5426. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5427. }
  5428. return oldValue.UpdatedAt, nil
  5429. }
  5430. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5431. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5432. m.updated_at = nil
  5433. }
  5434. // SetDeletedAt sets the "deleted_at" field.
  5435. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5436. m.deleted_at = &t
  5437. }
  5438. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5439. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5440. v := m.deleted_at
  5441. if v == nil {
  5442. return
  5443. }
  5444. return *v, true
  5445. }
  5446. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5447. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5449. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5450. if !m.op.Is(OpUpdateOne) {
  5451. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5452. }
  5453. if m.id == nil || m.oldValue == nil {
  5454. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5455. }
  5456. oldValue, err := m.oldValue(ctx)
  5457. if err != nil {
  5458. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5459. }
  5460. return oldValue.DeletedAt, nil
  5461. }
  5462. // ClearDeletedAt clears the value of the "deleted_at" field.
  5463. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5464. m.deleted_at = nil
  5465. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5466. }
  5467. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5468. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5469. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5470. return ok
  5471. }
  5472. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5473. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5474. m.deleted_at = nil
  5475. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5476. }
  5477. // SetContent sets the "content" field.
  5478. func (m *ChatRecordsMutation) SetContent(s string) {
  5479. m.content = &s
  5480. }
  5481. // Content returns the value of the "content" field in the mutation.
  5482. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5483. v := m.content
  5484. if v == nil {
  5485. return
  5486. }
  5487. return *v, true
  5488. }
  5489. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5490. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5492. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5493. if !m.op.Is(OpUpdateOne) {
  5494. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5495. }
  5496. if m.id == nil || m.oldValue == nil {
  5497. return v, errors.New("OldContent requires an ID field in the mutation")
  5498. }
  5499. oldValue, err := m.oldValue(ctx)
  5500. if err != nil {
  5501. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5502. }
  5503. return oldValue.Content, nil
  5504. }
  5505. // ResetContent resets all changes to the "content" field.
  5506. func (m *ChatRecordsMutation) ResetContent() {
  5507. m.content = nil
  5508. }
  5509. // SetContentType sets the "content_type" field.
  5510. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5511. m.content_type = &u
  5512. m.addcontent_type = nil
  5513. }
  5514. // ContentType returns the value of the "content_type" field in the mutation.
  5515. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5516. v := m.content_type
  5517. if v == nil {
  5518. return
  5519. }
  5520. return *v, true
  5521. }
  5522. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5523. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5525. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5526. if !m.op.Is(OpUpdateOne) {
  5527. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5528. }
  5529. if m.id == nil || m.oldValue == nil {
  5530. return v, errors.New("OldContentType requires an ID field in the mutation")
  5531. }
  5532. oldValue, err := m.oldValue(ctx)
  5533. if err != nil {
  5534. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5535. }
  5536. return oldValue.ContentType, nil
  5537. }
  5538. // AddContentType adds u to the "content_type" field.
  5539. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5540. if m.addcontent_type != nil {
  5541. *m.addcontent_type += u
  5542. } else {
  5543. m.addcontent_type = &u
  5544. }
  5545. }
  5546. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5547. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5548. v := m.addcontent_type
  5549. if v == nil {
  5550. return
  5551. }
  5552. return *v, true
  5553. }
  5554. // ResetContentType resets all changes to the "content_type" field.
  5555. func (m *ChatRecordsMutation) ResetContentType() {
  5556. m.content_type = nil
  5557. m.addcontent_type = nil
  5558. }
  5559. // SetSessionID sets the "session_id" field.
  5560. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5561. m.session_id = &u
  5562. m.addsession_id = nil
  5563. }
  5564. // SessionID returns the value of the "session_id" field in the mutation.
  5565. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5566. v := m.session_id
  5567. if v == nil {
  5568. return
  5569. }
  5570. return *v, true
  5571. }
  5572. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5573. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5575. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5576. if !m.op.Is(OpUpdateOne) {
  5577. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5578. }
  5579. if m.id == nil || m.oldValue == nil {
  5580. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5581. }
  5582. oldValue, err := m.oldValue(ctx)
  5583. if err != nil {
  5584. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5585. }
  5586. return oldValue.SessionID, nil
  5587. }
  5588. // AddSessionID adds u to the "session_id" field.
  5589. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5590. if m.addsession_id != nil {
  5591. *m.addsession_id += u
  5592. } else {
  5593. m.addsession_id = &u
  5594. }
  5595. }
  5596. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5597. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5598. v := m.addsession_id
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // ResetSessionID resets all changes to the "session_id" field.
  5605. func (m *ChatRecordsMutation) ResetSessionID() {
  5606. m.session_id = nil
  5607. m.addsession_id = nil
  5608. }
  5609. // SetUserID sets the "user_id" field.
  5610. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5611. m.user_id = &u
  5612. m.adduser_id = nil
  5613. }
  5614. // UserID returns the value of the "user_id" field in the mutation.
  5615. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5616. v := m.user_id
  5617. if v == nil {
  5618. return
  5619. }
  5620. return *v, true
  5621. }
  5622. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5623. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5625. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5626. if !m.op.Is(OpUpdateOne) {
  5627. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5628. }
  5629. if m.id == nil || m.oldValue == nil {
  5630. return v, errors.New("OldUserID requires an ID field in the mutation")
  5631. }
  5632. oldValue, err := m.oldValue(ctx)
  5633. if err != nil {
  5634. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5635. }
  5636. return oldValue.UserID, nil
  5637. }
  5638. // AddUserID adds u to the "user_id" field.
  5639. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5640. if m.adduser_id != nil {
  5641. *m.adduser_id += u
  5642. } else {
  5643. m.adduser_id = &u
  5644. }
  5645. }
  5646. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5647. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5648. v := m.adduser_id
  5649. if v == nil {
  5650. return
  5651. }
  5652. return *v, true
  5653. }
  5654. // ResetUserID resets all changes to the "user_id" field.
  5655. func (m *ChatRecordsMutation) ResetUserID() {
  5656. m.user_id = nil
  5657. m.adduser_id = nil
  5658. }
  5659. // SetBotID sets the "bot_id" field.
  5660. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5661. m.bot_id = &u
  5662. m.addbot_id = nil
  5663. }
  5664. // BotID returns the value of the "bot_id" field in the mutation.
  5665. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5666. v := m.bot_id
  5667. if v == nil {
  5668. return
  5669. }
  5670. return *v, true
  5671. }
  5672. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5673. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5675. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5676. if !m.op.Is(OpUpdateOne) {
  5677. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5678. }
  5679. if m.id == nil || m.oldValue == nil {
  5680. return v, errors.New("OldBotID requires an ID field in the mutation")
  5681. }
  5682. oldValue, err := m.oldValue(ctx)
  5683. if err != nil {
  5684. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5685. }
  5686. return oldValue.BotID, nil
  5687. }
  5688. // AddBotID adds u to the "bot_id" field.
  5689. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5690. if m.addbot_id != nil {
  5691. *m.addbot_id += u
  5692. } else {
  5693. m.addbot_id = &u
  5694. }
  5695. }
  5696. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5697. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5698. v := m.addbot_id
  5699. if v == nil {
  5700. return
  5701. }
  5702. return *v, true
  5703. }
  5704. // ResetBotID resets all changes to the "bot_id" field.
  5705. func (m *ChatRecordsMutation) ResetBotID() {
  5706. m.bot_id = nil
  5707. m.addbot_id = nil
  5708. }
  5709. // SetBotType sets the "bot_type" field.
  5710. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5711. m.bot_type = &u
  5712. m.addbot_type = nil
  5713. }
  5714. // BotType returns the value of the "bot_type" field in the mutation.
  5715. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5716. v := m.bot_type
  5717. if v == nil {
  5718. return
  5719. }
  5720. return *v, true
  5721. }
  5722. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5723. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5725. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5726. if !m.op.Is(OpUpdateOne) {
  5727. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5728. }
  5729. if m.id == nil || m.oldValue == nil {
  5730. return v, errors.New("OldBotType requires an ID field in the mutation")
  5731. }
  5732. oldValue, err := m.oldValue(ctx)
  5733. if err != nil {
  5734. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5735. }
  5736. return oldValue.BotType, nil
  5737. }
  5738. // AddBotType adds u to the "bot_type" field.
  5739. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5740. if m.addbot_type != nil {
  5741. *m.addbot_type += u
  5742. } else {
  5743. m.addbot_type = &u
  5744. }
  5745. }
  5746. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5747. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5748. v := m.addbot_type
  5749. if v == nil {
  5750. return
  5751. }
  5752. return *v, true
  5753. }
  5754. // ResetBotType resets all changes to the "bot_type" field.
  5755. func (m *ChatRecordsMutation) ResetBotType() {
  5756. m.bot_type = nil
  5757. m.addbot_type = nil
  5758. }
  5759. // Where appends a list predicates to the ChatRecordsMutation builder.
  5760. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5761. m.predicates = append(m.predicates, ps...)
  5762. }
  5763. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5764. // users can use type-assertion to append predicates that do not depend on any generated package.
  5765. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5766. p := make([]predicate.ChatRecords, len(ps))
  5767. for i := range ps {
  5768. p[i] = ps[i]
  5769. }
  5770. m.Where(p...)
  5771. }
  5772. // Op returns the operation name.
  5773. func (m *ChatRecordsMutation) Op() Op {
  5774. return m.op
  5775. }
  5776. // SetOp allows setting the mutation operation.
  5777. func (m *ChatRecordsMutation) SetOp(op Op) {
  5778. m.op = op
  5779. }
  5780. // Type returns the node type of this mutation (ChatRecords).
  5781. func (m *ChatRecordsMutation) Type() string {
  5782. return m.typ
  5783. }
  5784. // Fields returns all fields that were changed during this mutation. Note that in
  5785. // order to get all numeric fields that were incremented/decremented, call
  5786. // AddedFields().
  5787. func (m *ChatRecordsMutation) Fields() []string {
  5788. fields := make([]string, 0, 9)
  5789. if m.created_at != nil {
  5790. fields = append(fields, chatrecords.FieldCreatedAt)
  5791. }
  5792. if m.updated_at != nil {
  5793. fields = append(fields, chatrecords.FieldUpdatedAt)
  5794. }
  5795. if m.deleted_at != nil {
  5796. fields = append(fields, chatrecords.FieldDeletedAt)
  5797. }
  5798. if m.content != nil {
  5799. fields = append(fields, chatrecords.FieldContent)
  5800. }
  5801. if m.content_type != nil {
  5802. fields = append(fields, chatrecords.FieldContentType)
  5803. }
  5804. if m.session_id != nil {
  5805. fields = append(fields, chatrecords.FieldSessionID)
  5806. }
  5807. if m.user_id != nil {
  5808. fields = append(fields, chatrecords.FieldUserID)
  5809. }
  5810. if m.bot_id != nil {
  5811. fields = append(fields, chatrecords.FieldBotID)
  5812. }
  5813. if m.bot_type != nil {
  5814. fields = append(fields, chatrecords.FieldBotType)
  5815. }
  5816. return fields
  5817. }
  5818. // Field returns the value of a field with the given name. The second boolean
  5819. // return value indicates that this field was not set, or was not defined in the
  5820. // schema.
  5821. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5822. switch name {
  5823. case chatrecords.FieldCreatedAt:
  5824. return m.CreatedAt()
  5825. case chatrecords.FieldUpdatedAt:
  5826. return m.UpdatedAt()
  5827. case chatrecords.FieldDeletedAt:
  5828. return m.DeletedAt()
  5829. case chatrecords.FieldContent:
  5830. return m.Content()
  5831. case chatrecords.FieldContentType:
  5832. return m.ContentType()
  5833. case chatrecords.FieldSessionID:
  5834. return m.SessionID()
  5835. case chatrecords.FieldUserID:
  5836. return m.UserID()
  5837. case chatrecords.FieldBotID:
  5838. return m.BotID()
  5839. case chatrecords.FieldBotType:
  5840. return m.BotType()
  5841. }
  5842. return nil, false
  5843. }
  5844. // OldField returns the old value of the field from the database. An error is
  5845. // returned if the mutation operation is not UpdateOne, or the query to the
  5846. // database failed.
  5847. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5848. switch name {
  5849. case chatrecords.FieldCreatedAt:
  5850. return m.OldCreatedAt(ctx)
  5851. case chatrecords.FieldUpdatedAt:
  5852. return m.OldUpdatedAt(ctx)
  5853. case chatrecords.FieldDeletedAt:
  5854. return m.OldDeletedAt(ctx)
  5855. case chatrecords.FieldContent:
  5856. return m.OldContent(ctx)
  5857. case chatrecords.FieldContentType:
  5858. return m.OldContentType(ctx)
  5859. case chatrecords.FieldSessionID:
  5860. return m.OldSessionID(ctx)
  5861. case chatrecords.FieldUserID:
  5862. return m.OldUserID(ctx)
  5863. case chatrecords.FieldBotID:
  5864. return m.OldBotID(ctx)
  5865. case chatrecords.FieldBotType:
  5866. return m.OldBotType(ctx)
  5867. }
  5868. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5869. }
  5870. // SetField sets the value of a field with the given name. It returns an error if
  5871. // the field is not defined in the schema, or if the type mismatched the field
  5872. // type.
  5873. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5874. switch name {
  5875. case chatrecords.FieldCreatedAt:
  5876. v, ok := value.(time.Time)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetCreatedAt(v)
  5881. return nil
  5882. case chatrecords.FieldUpdatedAt:
  5883. v, ok := value.(time.Time)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetUpdatedAt(v)
  5888. return nil
  5889. case chatrecords.FieldDeletedAt:
  5890. v, ok := value.(time.Time)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetDeletedAt(v)
  5895. return nil
  5896. case chatrecords.FieldContent:
  5897. v, ok := value.(string)
  5898. if !ok {
  5899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5900. }
  5901. m.SetContent(v)
  5902. return nil
  5903. case chatrecords.FieldContentType:
  5904. v, ok := value.(uint8)
  5905. if !ok {
  5906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5907. }
  5908. m.SetContentType(v)
  5909. return nil
  5910. case chatrecords.FieldSessionID:
  5911. v, ok := value.(uint64)
  5912. if !ok {
  5913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5914. }
  5915. m.SetSessionID(v)
  5916. return nil
  5917. case chatrecords.FieldUserID:
  5918. v, ok := value.(uint64)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.SetUserID(v)
  5923. return nil
  5924. case chatrecords.FieldBotID:
  5925. v, ok := value.(uint64)
  5926. if !ok {
  5927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5928. }
  5929. m.SetBotID(v)
  5930. return nil
  5931. case chatrecords.FieldBotType:
  5932. v, ok := value.(uint8)
  5933. if !ok {
  5934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5935. }
  5936. m.SetBotType(v)
  5937. return nil
  5938. }
  5939. return fmt.Errorf("unknown ChatRecords field %s", name)
  5940. }
  5941. // AddedFields returns all numeric fields that were incremented/decremented during
  5942. // this mutation.
  5943. func (m *ChatRecordsMutation) AddedFields() []string {
  5944. var fields []string
  5945. if m.addcontent_type != nil {
  5946. fields = append(fields, chatrecords.FieldContentType)
  5947. }
  5948. if m.addsession_id != nil {
  5949. fields = append(fields, chatrecords.FieldSessionID)
  5950. }
  5951. if m.adduser_id != nil {
  5952. fields = append(fields, chatrecords.FieldUserID)
  5953. }
  5954. if m.addbot_id != nil {
  5955. fields = append(fields, chatrecords.FieldBotID)
  5956. }
  5957. if m.addbot_type != nil {
  5958. fields = append(fields, chatrecords.FieldBotType)
  5959. }
  5960. return fields
  5961. }
  5962. // AddedField returns the numeric value that was incremented/decremented on a field
  5963. // with the given name. The second boolean return value indicates that this field
  5964. // was not set, or was not defined in the schema.
  5965. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5966. switch name {
  5967. case chatrecords.FieldContentType:
  5968. return m.AddedContentType()
  5969. case chatrecords.FieldSessionID:
  5970. return m.AddedSessionID()
  5971. case chatrecords.FieldUserID:
  5972. return m.AddedUserID()
  5973. case chatrecords.FieldBotID:
  5974. return m.AddedBotID()
  5975. case chatrecords.FieldBotType:
  5976. return m.AddedBotType()
  5977. }
  5978. return nil, false
  5979. }
  5980. // AddField adds the value to the field with the given name. It returns an error if
  5981. // the field is not defined in the schema, or if the type mismatched the field
  5982. // type.
  5983. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5984. switch name {
  5985. case chatrecords.FieldContentType:
  5986. v, ok := value.(int8)
  5987. if !ok {
  5988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5989. }
  5990. m.AddContentType(v)
  5991. return nil
  5992. case chatrecords.FieldSessionID:
  5993. v, ok := value.(int64)
  5994. if !ok {
  5995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5996. }
  5997. m.AddSessionID(v)
  5998. return nil
  5999. case chatrecords.FieldUserID:
  6000. v, ok := value.(int64)
  6001. if !ok {
  6002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6003. }
  6004. m.AddUserID(v)
  6005. return nil
  6006. case chatrecords.FieldBotID:
  6007. v, ok := value.(int64)
  6008. if !ok {
  6009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6010. }
  6011. m.AddBotID(v)
  6012. return nil
  6013. case chatrecords.FieldBotType:
  6014. v, ok := value.(int8)
  6015. if !ok {
  6016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6017. }
  6018. m.AddBotType(v)
  6019. return nil
  6020. }
  6021. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6022. }
  6023. // ClearedFields returns all nullable fields that were cleared during this
  6024. // mutation.
  6025. func (m *ChatRecordsMutation) ClearedFields() []string {
  6026. var fields []string
  6027. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6028. fields = append(fields, chatrecords.FieldDeletedAt)
  6029. }
  6030. return fields
  6031. }
  6032. // FieldCleared returns a boolean indicating if a field with the given name was
  6033. // cleared in this mutation.
  6034. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6035. _, ok := m.clearedFields[name]
  6036. return ok
  6037. }
  6038. // ClearField clears the value of the field with the given name. It returns an
  6039. // error if the field is not defined in the schema.
  6040. func (m *ChatRecordsMutation) ClearField(name string) error {
  6041. switch name {
  6042. case chatrecords.FieldDeletedAt:
  6043. m.ClearDeletedAt()
  6044. return nil
  6045. }
  6046. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6047. }
  6048. // ResetField resets all changes in the mutation for the field with the given name.
  6049. // It returns an error if the field is not defined in the schema.
  6050. func (m *ChatRecordsMutation) ResetField(name string) error {
  6051. switch name {
  6052. case chatrecords.FieldCreatedAt:
  6053. m.ResetCreatedAt()
  6054. return nil
  6055. case chatrecords.FieldUpdatedAt:
  6056. m.ResetUpdatedAt()
  6057. return nil
  6058. case chatrecords.FieldDeletedAt:
  6059. m.ResetDeletedAt()
  6060. return nil
  6061. case chatrecords.FieldContent:
  6062. m.ResetContent()
  6063. return nil
  6064. case chatrecords.FieldContentType:
  6065. m.ResetContentType()
  6066. return nil
  6067. case chatrecords.FieldSessionID:
  6068. m.ResetSessionID()
  6069. return nil
  6070. case chatrecords.FieldUserID:
  6071. m.ResetUserID()
  6072. return nil
  6073. case chatrecords.FieldBotID:
  6074. m.ResetBotID()
  6075. return nil
  6076. case chatrecords.FieldBotType:
  6077. m.ResetBotType()
  6078. return nil
  6079. }
  6080. return fmt.Errorf("unknown ChatRecords field %s", name)
  6081. }
  6082. // AddedEdges returns all edge names that were set/added in this mutation.
  6083. func (m *ChatRecordsMutation) AddedEdges() []string {
  6084. edges := make([]string, 0, 0)
  6085. return edges
  6086. }
  6087. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6088. // name in this mutation.
  6089. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6090. return nil
  6091. }
  6092. // RemovedEdges returns all edge names that were removed in this mutation.
  6093. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6094. edges := make([]string, 0, 0)
  6095. return edges
  6096. }
  6097. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6098. // the given name in this mutation.
  6099. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6100. return nil
  6101. }
  6102. // ClearedEdges returns all edge names that were cleared in this mutation.
  6103. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6104. edges := make([]string, 0, 0)
  6105. return edges
  6106. }
  6107. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6108. // was cleared in this mutation.
  6109. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6110. return false
  6111. }
  6112. // ClearEdge clears the value of the edge with the given name. It returns an error
  6113. // if that edge is not defined in the schema.
  6114. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6115. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6116. }
  6117. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6118. // It returns an error if the edge is not defined in the schema.
  6119. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6120. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6121. }
  6122. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6123. type ChatSessionMutation struct {
  6124. config
  6125. op Op
  6126. typ string
  6127. id *uint64
  6128. created_at *time.Time
  6129. updated_at *time.Time
  6130. deleted_at *time.Time
  6131. name *string
  6132. user_id *uint64
  6133. adduser_id *int64
  6134. bot_id *uint64
  6135. addbot_id *int64
  6136. bot_type *uint8
  6137. addbot_type *int8
  6138. clearedFields map[string]struct{}
  6139. done bool
  6140. oldValue func(context.Context) (*ChatSession, error)
  6141. predicates []predicate.ChatSession
  6142. }
  6143. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6144. // chatsessionOption allows management of the mutation configuration using functional options.
  6145. type chatsessionOption func(*ChatSessionMutation)
  6146. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6147. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6148. m := &ChatSessionMutation{
  6149. config: c,
  6150. op: op,
  6151. typ: TypeChatSession,
  6152. clearedFields: make(map[string]struct{}),
  6153. }
  6154. for _, opt := range opts {
  6155. opt(m)
  6156. }
  6157. return m
  6158. }
  6159. // withChatSessionID sets the ID field of the mutation.
  6160. func withChatSessionID(id uint64) chatsessionOption {
  6161. return func(m *ChatSessionMutation) {
  6162. var (
  6163. err error
  6164. once sync.Once
  6165. value *ChatSession
  6166. )
  6167. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6168. once.Do(func() {
  6169. if m.done {
  6170. err = errors.New("querying old values post mutation is not allowed")
  6171. } else {
  6172. value, err = m.Client().ChatSession.Get(ctx, id)
  6173. }
  6174. })
  6175. return value, err
  6176. }
  6177. m.id = &id
  6178. }
  6179. }
  6180. // withChatSession sets the old ChatSession of the mutation.
  6181. func withChatSession(node *ChatSession) chatsessionOption {
  6182. return func(m *ChatSessionMutation) {
  6183. m.oldValue = func(context.Context) (*ChatSession, error) {
  6184. return node, nil
  6185. }
  6186. m.id = &node.ID
  6187. }
  6188. }
  6189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6190. // executed in a transaction (ent.Tx), a transactional client is returned.
  6191. func (m ChatSessionMutation) Client() *Client {
  6192. client := &Client{config: m.config}
  6193. client.init()
  6194. return client
  6195. }
  6196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6197. // it returns an error otherwise.
  6198. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6199. if _, ok := m.driver.(*txDriver); !ok {
  6200. return nil, errors.New("ent: mutation is not running in a transaction")
  6201. }
  6202. tx := &Tx{config: m.config}
  6203. tx.init()
  6204. return tx, nil
  6205. }
  6206. // SetID sets the value of the id field. Note that this
  6207. // operation is only accepted on creation of ChatSession entities.
  6208. func (m *ChatSessionMutation) SetID(id uint64) {
  6209. m.id = &id
  6210. }
  6211. // ID returns the ID value in the mutation. Note that the ID is only available
  6212. // if it was provided to the builder or after it was returned from the database.
  6213. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6214. if m.id == nil {
  6215. return
  6216. }
  6217. return *m.id, true
  6218. }
  6219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6220. // That means, if the mutation is applied within a transaction with an isolation level such
  6221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6222. // or updated by the mutation.
  6223. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6224. switch {
  6225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6226. id, exists := m.ID()
  6227. if exists {
  6228. return []uint64{id}, nil
  6229. }
  6230. fallthrough
  6231. case m.op.Is(OpUpdate | OpDelete):
  6232. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6233. default:
  6234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6235. }
  6236. }
  6237. // SetCreatedAt sets the "created_at" field.
  6238. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6239. m.created_at = &t
  6240. }
  6241. // CreatedAt returns the value of the "created_at" field in the mutation.
  6242. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6243. v := m.created_at
  6244. if v == nil {
  6245. return
  6246. }
  6247. return *v, true
  6248. }
  6249. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6250. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6252. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6253. if !m.op.Is(OpUpdateOne) {
  6254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6255. }
  6256. if m.id == nil || m.oldValue == nil {
  6257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6258. }
  6259. oldValue, err := m.oldValue(ctx)
  6260. if err != nil {
  6261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6262. }
  6263. return oldValue.CreatedAt, nil
  6264. }
  6265. // ResetCreatedAt resets all changes to the "created_at" field.
  6266. func (m *ChatSessionMutation) ResetCreatedAt() {
  6267. m.created_at = nil
  6268. }
  6269. // SetUpdatedAt sets the "updated_at" field.
  6270. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6271. m.updated_at = &t
  6272. }
  6273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6274. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6275. v := m.updated_at
  6276. if v == nil {
  6277. return
  6278. }
  6279. return *v, true
  6280. }
  6281. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6282. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6284. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6285. if !m.op.Is(OpUpdateOne) {
  6286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6287. }
  6288. if m.id == nil || m.oldValue == nil {
  6289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6290. }
  6291. oldValue, err := m.oldValue(ctx)
  6292. if err != nil {
  6293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6294. }
  6295. return oldValue.UpdatedAt, nil
  6296. }
  6297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6298. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6299. m.updated_at = nil
  6300. }
  6301. // SetDeletedAt sets the "deleted_at" field.
  6302. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6303. m.deleted_at = &t
  6304. }
  6305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6306. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6307. v := m.deleted_at
  6308. if v == nil {
  6309. return
  6310. }
  6311. return *v, true
  6312. }
  6313. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6314. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6316. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6317. if !m.op.Is(OpUpdateOne) {
  6318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6319. }
  6320. if m.id == nil || m.oldValue == nil {
  6321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6322. }
  6323. oldValue, err := m.oldValue(ctx)
  6324. if err != nil {
  6325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6326. }
  6327. return oldValue.DeletedAt, nil
  6328. }
  6329. // ClearDeletedAt clears the value of the "deleted_at" field.
  6330. func (m *ChatSessionMutation) ClearDeletedAt() {
  6331. m.deleted_at = nil
  6332. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6333. }
  6334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6335. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6336. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6337. return ok
  6338. }
  6339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6340. func (m *ChatSessionMutation) ResetDeletedAt() {
  6341. m.deleted_at = nil
  6342. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6343. }
  6344. // SetName sets the "name" field.
  6345. func (m *ChatSessionMutation) SetName(s string) {
  6346. m.name = &s
  6347. }
  6348. // Name returns the value of the "name" field in the mutation.
  6349. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6350. v := m.name
  6351. if v == nil {
  6352. return
  6353. }
  6354. return *v, true
  6355. }
  6356. // OldName returns the old "name" field's value of the ChatSession entity.
  6357. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6359. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6360. if !m.op.Is(OpUpdateOne) {
  6361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6362. }
  6363. if m.id == nil || m.oldValue == nil {
  6364. return v, errors.New("OldName requires an ID field in the mutation")
  6365. }
  6366. oldValue, err := m.oldValue(ctx)
  6367. if err != nil {
  6368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6369. }
  6370. return oldValue.Name, nil
  6371. }
  6372. // ResetName resets all changes to the "name" field.
  6373. func (m *ChatSessionMutation) ResetName() {
  6374. m.name = nil
  6375. }
  6376. // SetUserID sets the "user_id" field.
  6377. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6378. m.user_id = &u
  6379. m.adduser_id = nil
  6380. }
  6381. // UserID returns the value of the "user_id" field in the mutation.
  6382. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6383. v := m.user_id
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6390. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6392. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6393. if !m.op.Is(OpUpdateOne) {
  6394. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6395. }
  6396. if m.id == nil || m.oldValue == nil {
  6397. return v, errors.New("OldUserID requires an ID field in the mutation")
  6398. }
  6399. oldValue, err := m.oldValue(ctx)
  6400. if err != nil {
  6401. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6402. }
  6403. return oldValue.UserID, nil
  6404. }
  6405. // AddUserID adds u to the "user_id" field.
  6406. func (m *ChatSessionMutation) AddUserID(u int64) {
  6407. if m.adduser_id != nil {
  6408. *m.adduser_id += u
  6409. } else {
  6410. m.adduser_id = &u
  6411. }
  6412. }
  6413. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6414. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6415. v := m.adduser_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // ResetUserID resets all changes to the "user_id" field.
  6422. func (m *ChatSessionMutation) ResetUserID() {
  6423. m.user_id = nil
  6424. m.adduser_id = nil
  6425. }
  6426. // SetBotID sets the "bot_id" field.
  6427. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6428. m.bot_id = &u
  6429. m.addbot_id = nil
  6430. }
  6431. // BotID returns the value of the "bot_id" field in the mutation.
  6432. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6433. v := m.bot_id
  6434. if v == nil {
  6435. return
  6436. }
  6437. return *v, true
  6438. }
  6439. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6440. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6442. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6443. if !m.op.Is(OpUpdateOne) {
  6444. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6445. }
  6446. if m.id == nil || m.oldValue == nil {
  6447. return v, errors.New("OldBotID requires an ID field in the mutation")
  6448. }
  6449. oldValue, err := m.oldValue(ctx)
  6450. if err != nil {
  6451. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6452. }
  6453. return oldValue.BotID, nil
  6454. }
  6455. // AddBotID adds u to the "bot_id" field.
  6456. func (m *ChatSessionMutation) AddBotID(u int64) {
  6457. if m.addbot_id != nil {
  6458. *m.addbot_id += u
  6459. } else {
  6460. m.addbot_id = &u
  6461. }
  6462. }
  6463. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6464. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6465. v := m.addbot_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // ResetBotID resets all changes to the "bot_id" field.
  6472. func (m *ChatSessionMutation) ResetBotID() {
  6473. m.bot_id = nil
  6474. m.addbot_id = nil
  6475. }
  6476. // SetBotType sets the "bot_type" field.
  6477. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6478. m.bot_type = &u
  6479. m.addbot_type = nil
  6480. }
  6481. // BotType returns the value of the "bot_type" field in the mutation.
  6482. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6483. v := m.bot_type
  6484. if v == nil {
  6485. return
  6486. }
  6487. return *v, true
  6488. }
  6489. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6490. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6492. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6493. if !m.op.Is(OpUpdateOne) {
  6494. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6495. }
  6496. if m.id == nil || m.oldValue == nil {
  6497. return v, errors.New("OldBotType requires an ID field in the mutation")
  6498. }
  6499. oldValue, err := m.oldValue(ctx)
  6500. if err != nil {
  6501. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6502. }
  6503. return oldValue.BotType, nil
  6504. }
  6505. // AddBotType adds u to the "bot_type" field.
  6506. func (m *ChatSessionMutation) AddBotType(u int8) {
  6507. if m.addbot_type != nil {
  6508. *m.addbot_type += u
  6509. } else {
  6510. m.addbot_type = &u
  6511. }
  6512. }
  6513. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6514. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6515. v := m.addbot_type
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // ResetBotType resets all changes to the "bot_type" field.
  6522. func (m *ChatSessionMutation) ResetBotType() {
  6523. m.bot_type = nil
  6524. m.addbot_type = nil
  6525. }
  6526. // Where appends a list predicates to the ChatSessionMutation builder.
  6527. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6528. m.predicates = append(m.predicates, ps...)
  6529. }
  6530. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6531. // users can use type-assertion to append predicates that do not depend on any generated package.
  6532. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6533. p := make([]predicate.ChatSession, len(ps))
  6534. for i := range ps {
  6535. p[i] = ps[i]
  6536. }
  6537. m.Where(p...)
  6538. }
  6539. // Op returns the operation name.
  6540. func (m *ChatSessionMutation) Op() Op {
  6541. return m.op
  6542. }
  6543. // SetOp allows setting the mutation operation.
  6544. func (m *ChatSessionMutation) SetOp(op Op) {
  6545. m.op = op
  6546. }
  6547. // Type returns the node type of this mutation (ChatSession).
  6548. func (m *ChatSessionMutation) Type() string {
  6549. return m.typ
  6550. }
  6551. // Fields returns all fields that were changed during this mutation. Note that in
  6552. // order to get all numeric fields that were incremented/decremented, call
  6553. // AddedFields().
  6554. func (m *ChatSessionMutation) Fields() []string {
  6555. fields := make([]string, 0, 7)
  6556. if m.created_at != nil {
  6557. fields = append(fields, chatsession.FieldCreatedAt)
  6558. }
  6559. if m.updated_at != nil {
  6560. fields = append(fields, chatsession.FieldUpdatedAt)
  6561. }
  6562. if m.deleted_at != nil {
  6563. fields = append(fields, chatsession.FieldDeletedAt)
  6564. }
  6565. if m.name != nil {
  6566. fields = append(fields, chatsession.FieldName)
  6567. }
  6568. if m.user_id != nil {
  6569. fields = append(fields, chatsession.FieldUserID)
  6570. }
  6571. if m.bot_id != nil {
  6572. fields = append(fields, chatsession.FieldBotID)
  6573. }
  6574. if m.bot_type != nil {
  6575. fields = append(fields, chatsession.FieldBotType)
  6576. }
  6577. return fields
  6578. }
  6579. // Field returns the value of a field with the given name. The second boolean
  6580. // return value indicates that this field was not set, or was not defined in the
  6581. // schema.
  6582. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6583. switch name {
  6584. case chatsession.FieldCreatedAt:
  6585. return m.CreatedAt()
  6586. case chatsession.FieldUpdatedAt:
  6587. return m.UpdatedAt()
  6588. case chatsession.FieldDeletedAt:
  6589. return m.DeletedAt()
  6590. case chatsession.FieldName:
  6591. return m.Name()
  6592. case chatsession.FieldUserID:
  6593. return m.UserID()
  6594. case chatsession.FieldBotID:
  6595. return m.BotID()
  6596. case chatsession.FieldBotType:
  6597. return m.BotType()
  6598. }
  6599. return nil, false
  6600. }
  6601. // OldField returns the old value of the field from the database. An error is
  6602. // returned if the mutation operation is not UpdateOne, or the query to the
  6603. // database failed.
  6604. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6605. switch name {
  6606. case chatsession.FieldCreatedAt:
  6607. return m.OldCreatedAt(ctx)
  6608. case chatsession.FieldUpdatedAt:
  6609. return m.OldUpdatedAt(ctx)
  6610. case chatsession.FieldDeletedAt:
  6611. return m.OldDeletedAt(ctx)
  6612. case chatsession.FieldName:
  6613. return m.OldName(ctx)
  6614. case chatsession.FieldUserID:
  6615. return m.OldUserID(ctx)
  6616. case chatsession.FieldBotID:
  6617. return m.OldBotID(ctx)
  6618. case chatsession.FieldBotType:
  6619. return m.OldBotType(ctx)
  6620. }
  6621. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6622. }
  6623. // SetField sets the value of a field with the given name. It returns an error if
  6624. // the field is not defined in the schema, or if the type mismatched the field
  6625. // type.
  6626. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6627. switch name {
  6628. case chatsession.FieldCreatedAt:
  6629. v, ok := value.(time.Time)
  6630. if !ok {
  6631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6632. }
  6633. m.SetCreatedAt(v)
  6634. return nil
  6635. case chatsession.FieldUpdatedAt:
  6636. v, ok := value.(time.Time)
  6637. if !ok {
  6638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6639. }
  6640. m.SetUpdatedAt(v)
  6641. return nil
  6642. case chatsession.FieldDeletedAt:
  6643. v, ok := value.(time.Time)
  6644. if !ok {
  6645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6646. }
  6647. m.SetDeletedAt(v)
  6648. return nil
  6649. case chatsession.FieldName:
  6650. v, ok := value.(string)
  6651. if !ok {
  6652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6653. }
  6654. m.SetName(v)
  6655. return nil
  6656. case chatsession.FieldUserID:
  6657. v, ok := value.(uint64)
  6658. if !ok {
  6659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6660. }
  6661. m.SetUserID(v)
  6662. return nil
  6663. case chatsession.FieldBotID:
  6664. v, ok := value.(uint64)
  6665. if !ok {
  6666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6667. }
  6668. m.SetBotID(v)
  6669. return nil
  6670. case chatsession.FieldBotType:
  6671. v, ok := value.(uint8)
  6672. if !ok {
  6673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6674. }
  6675. m.SetBotType(v)
  6676. return nil
  6677. }
  6678. return fmt.Errorf("unknown ChatSession field %s", name)
  6679. }
  6680. // AddedFields returns all numeric fields that were incremented/decremented during
  6681. // this mutation.
  6682. func (m *ChatSessionMutation) AddedFields() []string {
  6683. var fields []string
  6684. if m.adduser_id != nil {
  6685. fields = append(fields, chatsession.FieldUserID)
  6686. }
  6687. if m.addbot_id != nil {
  6688. fields = append(fields, chatsession.FieldBotID)
  6689. }
  6690. if m.addbot_type != nil {
  6691. fields = append(fields, chatsession.FieldBotType)
  6692. }
  6693. return fields
  6694. }
  6695. // AddedField returns the numeric value that was incremented/decremented on a field
  6696. // with the given name. The second boolean return value indicates that this field
  6697. // was not set, or was not defined in the schema.
  6698. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6699. switch name {
  6700. case chatsession.FieldUserID:
  6701. return m.AddedUserID()
  6702. case chatsession.FieldBotID:
  6703. return m.AddedBotID()
  6704. case chatsession.FieldBotType:
  6705. return m.AddedBotType()
  6706. }
  6707. return nil, false
  6708. }
  6709. // AddField adds the value to the field with the given name. It returns an error if
  6710. // the field is not defined in the schema, or if the type mismatched the field
  6711. // type.
  6712. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6713. switch name {
  6714. case chatsession.FieldUserID:
  6715. v, ok := value.(int64)
  6716. if !ok {
  6717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6718. }
  6719. m.AddUserID(v)
  6720. return nil
  6721. case chatsession.FieldBotID:
  6722. v, ok := value.(int64)
  6723. if !ok {
  6724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6725. }
  6726. m.AddBotID(v)
  6727. return nil
  6728. case chatsession.FieldBotType:
  6729. v, ok := value.(int8)
  6730. if !ok {
  6731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6732. }
  6733. m.AddBotType(v)
  6734. return nil
  6735. }
  6736. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6737. }
  6738. // ClearedFields returns all nullable fields that were cleared during this
  6739. // mutation.
  6740. func (m *ChatSessionMutation) ClearedFields() []string {
  6741. var fields []string
  6742. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6743. fields = append(fields, chatsession.FieldDeletedAt)
  6744. }
  6745. return fields
  6746. }
  6747. // FieldCleared returns a boolean indicating if a field with the given name was
  6748. // cleared in this mutation.
  6749. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6750. _, ok := m.clearedFields[name]
  6751. return ok
  6752. }
  6753. // ClearField clears the value of the field with the given name. It returns an
  6754. // error if the field is not defined in the schema.
  6755. func (m *ChatSessionMutation) ClearField(name string) error {
  6756. switch name {
  6757. case chatsession.FieldDeletedAt:
  6758. m.ClearDeletedAt()
  6759. return nil
  6760. }
  6761. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6762. }
  6763. // ResetField resets all changes in the mutation for the field with the given name.
  6764. // It returns an error if the field is not defined in the schema.
  6765. func (m *ChatSessionMutation) ResetField(name string) error {
  6766. switch name {
  6767. case chatsession.FieldCreatedAt:
  6768. m.ResetCreatedAt()
  6769. return nil
  6770. case chatsession.FieldUpdatedAt:
  6771. m.ResetUpdatedAt()
  6772. return nil
  6773. case chatsession.FieldDeletedAt:
  6774. m.ResetDeletedAt()
  6775. return nil
  6776. case chatsession.FieldName:
  6777. m.ResetName()
  6778. return nil
  6779. case chatsession.FieldUserID:
  6780. m.ResetUserID()
  6781. return nil
  6782. case chatsession.FieldBotID:
  6783. m.ResetBotID()
  6784. return nil
  6785. case chatsession.FieldBotType:
  6786. m.ResetBotType()
  6787. return nil
  6788. }
  6789. return fmt.Errorf("unknown ChatSession field %s", name)
  6790. }
  6791. // AddedEdges returns all edge names that were set/added in this mutation.
  6792. func (m *ChatSessionMutation) AddedEdges() []string {
  6793. edges := make([]string, 0, 0)
  6794. return edges
  6795. }
  6796. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6797. // name in this mutation.
  6798. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6799. return nil
  6800. }
  6801. // RemovedEdges returns all edge names that were removed in this mutation.
  6802. func (m *ChatSessionMutation) RemovedEdges() []string {
  6803. edges := make([]string, 0, 0)
  6804. return edges
  6805. }
  6806. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6807. // the given name in this mutation.
  6808. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6809. return nil
  6810. }
  6811. // ClearedEdges returns all edge names that were cleared in this mutation.
  6812. func (m *ChatSessionMutation) ClearedEdges() []string {
  6813. edges := make([]string, 0, 0)
  6814. return edges
  6815. }
  6816. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6817. // was cleared in this mutation.
  6818. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6819. return false
  6820. }
  6821. // ClearEdge clears the value of the edge with the given name. It returns an error
  6822. // if that edge is not defined in the schema.
  6823. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6824. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6825. }
  6826. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6827. // It returns an error if the edge is not defined in the schema.
  6828. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6829. return fmt.Errorf("unknown ChatSession edge %s", name)
  6830. }
  6831. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6832. type ContactMutation struct {
  6833. config
  6834. op Op
  6835. typ string
  6836. id *uint64
  6837. created_at *time.Time
  6838. updated_at *time.Time
  6839. status *uint8
  6840. addstatus *int8
  6841. deleted_at *time.Time
  6842. wx_wxid *string
  6843. _type *int
  6844. add_type *int
  6845. wxid *string
  6846. account *string
  6847. nickname *string
  6848. markname *string
  6849. headimg *string
  6850. sex *int
  6851. addsex *int
  6852. starrole *string
  6853. dontseeit *int
  6854. adddontseeit *int
  6855. dontseeme *int
  6856. adddontseeme *int
  6857. lag *string
  6858. gid *string
  6859. gname *string
  6860. v3 *string
  6861. organization_id *uint64
  6862. addorganization_id *int64
  6863. clearedFields map[string]struct{}
  6864. contact_relationships map[uint64]struct{}
  6865. removedcontact_relationships map[uint64]struct{}
  6866. clearedcontact_relationships bool
  6867. contact_messages map[uint64]struct{}
  6868. removedcontact_messages map[uint64]struct{}
  6869. clearedcontact_messages bool
  6870. done bool
  6871. oldValue func(context.Context) (*Contact, error)
  6872. predicates []predicate.Contact
  6873. }
  6874. var _ ent.Mutation = (*ContactMutation)(nil)
  6875. // contactOption allows management of the mutation configuration using functional options.
  6876. type contactOption func(*ContactMutation)
  6877. // newContactMutation creates new mutation for the Contact entity.
  6878. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6879. m := &ContactMutation{
  6880. config: c,
  6881. op: op,
  6882. typ: TypeContact,
  6883. clearedFields: make(map[string]struct{}),
  6884. }
  6885. for _, opt := range opts {
  6886. opt(m)
  6887. }
  6888. return m
  6889. }
  6890. // withContactID sets the ID field of the mutation.
  6891. func withContactID(id uint64) contactOption {
  6892. return func(m *ContactMutation) {
  6893. var (
  6894. err error
  6895. once sync.Once
  6896. value *Contact
  6897. )
  6898. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6899. once.Do(func() {
  6900. if m.done {
  6901. err = errors.New("querying old values post mutation is not allowed")
  6902. } else {
  6903. value, err = m.Client().Contact.Get(ctx, id)
  6904. }
  6905. })
  6906. return value, err
  6907. }
  6908. m.id = &id
  6909. }
  6910. }
  6911. // withContact sets the old Contact of the mutation.
  6912. func withContact(node *Contact) contactOption {
  6913. return func(m *ContactMutation) {
  6914. m.oldValue = func(context.Context) (*Contact, error) {
  6915. return node, nil
  6916. }
  6917. m.id = &node.ID
  6918. }
  6919. }
  6920. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6921. // executed in a transaction (ent.Tx), a transactional client is returned.
  6922. func (m ContactMutation) Client() *Client {
  6923. client := &Client{config: m.config}
  6924. client.init()
  6925. return client
  6926. }
  6927. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6928. // it returns an error otherwise.
  6929. func (m ContactMutation) Tx() (*Tx, error) {
  6930. if _, ok := m.driver.(*txDriver); !ok {
  6931. return nil, errors.New("ent: mutation is not running in a transaction")
  6932. }
  6933. tx := &Tx{config: m.config}
  6934. tx.init()
  6935. return tx, nil
  6936. }
  6937. // SetID sets the value of the id field. Note that this
  6938. // operation is only accepted on creation of Contact entities.
  6939. func (m *ContactMutation) SetID(id uint64) {
  6940. m.id = &id
  6941. }
  6942. // ID returns the ID value in the mutation. Note that the ID is only available
  6943. // if it was provided to the builder or after it was returned from the database.
  6944. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6945. if m.id == nil {
  6946. return
  6947. }
  6948. return *m.id, true
  6949. }
  6950. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6951. // That means, if the mutation is applied within a transaction with an isolation level such
  6952. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6953. // or updated by the mutation.
  6954. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6955. switch {
  6956. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6957. id, exists := m.ID()
  6958. if exists {
  6959. return []uint64{id}, nil
  6960. }
  6961. fallthrough
  6962. case m.op.Is(OpUpdate | OpDelete):
  6963. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6964. default:
  6965. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6966. }
  6967. }
  6968. // SetCreatedAt sets the "created_at" field.
  6969. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6970. m.created_at = &t
  6971. }
  6972. // CreatedAt returns the value of the "created_at" field in the mutation.
  6973. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6974. v := m.created_at
  6975. if v == nil {
  6976. return
  6977. }
  6978. return *v, true
  6979. }
  6980. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6981. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6983. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6984. if !m.op.Is(OpUpdateOne) {
  6985. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6986. }
  6987. if m.id == nil || m.oldValue == nil {
  6988. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6989. }
  6990. oldValue, err := m.oldValue(ctx)
  6991. if err != nil {
  6992. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6993. }
  6994. return oldValue.CreatedAt, nil
  6995. }
  6996. // ResetCreatedAt resets all changes to the "created_at" field.
  6997. func (m *ContactMutation) ResetCreatedAt() {
  6998. m.created_at = nil
  6999. }
  7000. // SetUpdatedAt sets the "updated_at" field.
  7001. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7002. m.updated_at = &t
  7003. }
  7004. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7005. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7006. v := m.updated_at
  7007. if v == nil {
  7008. return
  7009. }
  7010. return *v, true
  7011. }
  7012. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7013. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7015. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7016. if !m.op.Is(OpUpdateOne) {
  7017. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7018. }
  7019. if m.id == nil || m.oldValue == nil {
  7020. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7021. }
  7022. oldValue, err := m.oldValue(ctx)
  7023. if err != nil {
  7024. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7025. }
  7026. return oldValue.UpdatedAt, nil
  7027. }
  7028. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7029. func (m *ContactMutation) ResetUpdatedAt() {
  7030. m.updated_at = nil
  7031. }
  7032. // SetStatus sets the "status" field.
  7033. func (m *ContactMutation) SetStatus(u uint8) {
  7034. m.status = &u
  7035. m.addstatus = nil
  7036. }
  7037. // Status returns the value of the "status" field in the mutation.
  7038. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7039. v := m.status
  7040. if v == nil {
  7041. return
  7042. }
  7043. return *v, true
  7044. }
  7045. // OldStatus returns the old "status" field's value of the Contact entity.
  7046. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7048. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7049. if !m.op.Is(OpUpdateOne) {
  7050. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7051. }
  7052. if m.id == nil || m.oldValue == nil {
  7053. return v, errors.New("OldStatus requires an ID field in the mutation")
  7054. }
  7055. oldValue, err := m.oldValue(ctx)
  7056. if err != nil {
  7057. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7058. }
  7059. return oldValue.Status, nil
  7060. }
  7061. // AddStatus adds u to the "status" field.
  7062. func (m *ContactMutation) AddStatus(u int8) {
  7063. if m.addstatus != nil {
  7064. *m.addstatus += u
  7065. } else {
  7066. m.addstatus = &u
  7067. }
  7068. }
  7069. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7070. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7071. v := m.addstatus
  7072. if v == nil {
  7073. return
  7074. }
  7075. return *v, true
  7076. }
  7077. // ClearStatus clears the value of the "status" field.
  7078. func (m *ContactMutation) ClearStatus() {
  7079. m.status = nil
  7080. m.addstatus = nil
  7081. m.clearedFields[contact.FieldStatus] = struct{}{}
  7082. }
  7083. // StatusCleared returns if the "status" field was cleared in this mutation.
  7084. func (m *ContactMutation) StatusCleared() bool {
  7085. _, ok := m.clearedFields[contact.FieldStatus]
  7086. return ok
  7087. }
  7088. // ResetStatus resets all changes to the "status" field.
  7089. func (m *ContactMutation) ResetStatus() {
  7090. m.status = nil
  7091. m.addstatus = nil
  7092. delete(m.clearedFields, contact.FieldStatus)
  7093. }
  7094. // SetDeletedAt sets the "deleted_at" field.
  7095. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7096. m.deleted_at = &t
  7097. }
  7098. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7099. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7100. v := m.deleted_at
  7101. if v == nil {
  7102. return
  7103. }
  7104. return *v, true
  7105. }
  7106. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7107. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7109. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7110. if !m.op.Is(OpUpdateOne) {
  7111. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7112. }
  7113. if m.id == nil || m.oldValue == nil {
  7114. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7115. }
  7116. oldValue, err := m.oldValue(ctx)
  7117. if err != nil {
  7118. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7119. }
  7120. return oldValue.DeletedAt, nil
  7121. }
  7122. // ClearDeletedAt clears the value of the "deleted_at" field.
  7123. func (m *ContactMutation) ClearDeletedAt() {
  7124. m.deleted_at = nil
  7125. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7126. }
  7127. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7128. func (m *ContactMutation) DeletedAtCleared() bool {
  7129. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7130. return ok
  7131. }
  7132. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7133. func (m *ContactMutation) ResetDeletedAt() {
  7134. m.deleted_at = nil
  7135. delete(m.clearedFields, contact.FieldDeletedAt)
  7136. }
  7137. // SetWxWxid sets the "wx_wxid" field.
  7138. func (m *ContactMutation) SetWxWxid(s string) {
  7139. m.wx_wxid = &s
  7140. }
  7141. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7142. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7143. v := m.wx_wxid
  7144. if v == nil {
  7145. return
  7146. }
  7147. return *v, true
  7148. }
  7149. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7150. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7152. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7153. if !m.op.Is(OpUpdateOne) {
  7154. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7155. }
  7156. if m.id == nil || m.oldValue == nil {
  7157. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7158. }
  7159. oldValue, err := m.oldValue(ctx)
  7160. if err != nil {
  7161. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7162. }
  7163. return oldValue.WxWxid, nil
  7164. }
  7165. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7166. func (m *ContactMutation) ResetWxWxid() {
  7167. m.wx_wxid = nil
  7168. }
  7169. // SetType sets the "type" field.
  7170. func (m *ContactMutation) SetType(i int) {
  7171. m._type = &i
  7172. m.add_type = nil
  7173. }
  7174. // GetType returns the value of the "type" field in the mutation.
  7175. func (m *ContactMutation) GetType() (r int, exists bool) {
  7176. v := m._type
  7177. if v == nil {
  7178. return
  7179. }
  7180. return *v, true
  7181. }
  7182. // OldType returns the old "type" field's value of the Contact entity.
  7183. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7185. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7186. if !m.op.Is(OpUpdateOne) {
  7187. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7188. }
  7189. if m.id == nil || m.oldValue == nil {
  7190. return v, errors.New("OldType requires an ID field in the mutation")
  7191. }
  7192. oldValue, err := m.oldValue(ctx)
  7193. if err != nil {
  7194. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7195. }
  7196. return oldValue.Type, nil
  7197. }
  7198. // AddType adds i to the "type" field.
  7199. func (m *ContactMutation) AddType(i int) {
  7200. if m.add_type != nil {
  7201. *m.add_type += i
  7202. } else {
  7203. m.add_type = &i
  7204. }
  7205. }
  7206. // AddedType returns the value that was added to the "type" field in this mutation.
  7207. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7208. v := m.add_type
  7209. if v == nil {
  7210. return
  7211. }
  7212. return *v, true
  7213. }
  7214. // ClearType clears the value of the "type" field.
  7215. func (m *ContactMutation) ClearType() {
  7216. m._type = nil
  7217. m.add_type = nil
  7218. m.clearedFields[contact.FieldType] = struct{}{}
  7219. }
  7220. // TypeCleared returns if the "type" field was cleared in this mutation.
  7221. func (m *ContactMutation) TypeCleared() bool {
  7222. _, ok := m.clearedFields[contact.FieldType]
  7223. return ok
  7224. }
  7225. // ResetType resets all changes to the "type" field.
  7226. func (m *ContactMutation) ResetType() {
  7227. m._type = nil
  7228. m.add_type = nil
  7229. delete(m.clearedFields, contact.FieldType)
  7230. }
  7231. // SetWxid sets the "wxid" field.
  7232. func (m *ContactMutation) SetWxid(s string) {
  7233. m.wxid = &s
  7234. }
  7235. // Wxid returns the value of the "wxid" field in the mutation.
  7236. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7237. v := m.wxid
  7238. if v == nil {
  7239. return
  7240. }
  7241. return *v, true
  7242. }
  7243. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7244. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7246. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7247. if !m.op.Is(OpUpdateOne) {
  7248. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7249. }
  7250. if m.id == nil || m.oldValue == nil {
  7251. return v, errors.New("OldWxid requires an ID field in the mutation")
  7252. }
  7253. oldValue, err := m.oldValue(ctx)
  7254. if err != nil {
  7255. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7256. }
  7257. return oldValue.Wxid, nil
  7258. }
  7259. // ResetWxid resets all changes to the "wxid" field.
  7260. func (m *ContactMutation) ResetWxid() {
  7261. m.wxid = nil
  7262. }
  7263. // SetAccount sets the "account" field.
  7264. func (m *ContactMutation) SetAccount(s string) {
  7265. m.account = &s
  7266. }
  7267. // Account returns the value of the "account" field in the mutation.
  7268. func (m *ContactMutation) Account() (r string, exists bool) {
  7269. v := m.account
  7270. if v == nil {
  7271. return
  7272. }
  7273. return *v, true
  7274. }
  7275. // OldAccount returns the old "account" field's value of the Contact entity.
  7276. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7278. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7279. if !m.op.Is(OpUpdateOne) {
  7280. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7281. }
  7282. if m.id == nil || m.oldValue == nil {
  7283. return v, errors.New("OldAccount requires an ID field in the mutation")
  7284. }
  7285. oldValue, err := m.oldValue(ctx)
  7286. if err != nil {
  7287. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7288. }
  7289. return oldValue.Account, nil
  7290. }
  7291. // ResetAccount resets all changes to the "account" field.
  7292. func (m *ContactMutation) ResetAccount() {
  7293. m.account = nil
  7294. }
  7295. // SetNickname sets the "nickname" field.
  7296. func (m *ContactMutation) SetNickname(s string) {
  7297. m.nickname = &s
  7298. }
  7299. // Nickname returns the value of the "nickname" field in the mutation.
  7300. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7301. v := m.nickname
  7302. if v == nil {
  7303. return
  7304. }
  7305. return *v, true
  7306. }
  7307. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7310. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7311. if !m.op.Is(OpUpdateOne) {
  7312. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7313. }
  7314. if m.id == nil || m.oldValue == nil {
  7315. return v, errors.New("OldNickname requires an ID field in the mutation")
  7316. }
  7317. oldValue, err := m.oldValue(ctx)
  7318. if err != nil {
  7319. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7320. }
  7321. return oldValue.Nickname, nil
  7322. }
  7323. // ResetNickname resets all changes to the "nickname" field.
  7324. func (m *ContactMutation) ResetNickname() {
  7325. m.nickname = nil
  7326. }
  7327. // SetMarkname sets the "markname" field.
  7328. func (m *ContactMutation) SetMarkname(s string) {
  7329. m.markname = &s
  7330. }
  7331. // Markname returns the value of the "markname" field in the mutation.
  7332. func (m *ContactMutation) Markname() (r string, exists bool) {
  7333. v := m.markname
  7334. if v == nil {
  7335. return
  7336. }
  7337. return *v, true
  7338. }
  7339. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7340. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7342. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7343. if !m.op.Is(OpUpdateOne) {
  7344. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7345. }
  7346. if m.id == nil || m.oldValue == nil {
  7347. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7348. }
  7349. oldValue, err := m.oldValue(ctx)
  7350. if err != nil {
  7351. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7352. }
  7353. return oldValue.Markname, nil
  7354. }
  7355. // ResetMarkname resets all changes to the "markname" field.
  7356. func (m *ContactMutation) ResetMarkname() {
  7357. m.markname = nil
  7358. }
  7359. // SetHeadimg sets the "headimg" field.
  7360. func (m *ContactMutation) SetHeadimg(s string) {
  7361. m.headimg = &s
  7362. }
  7363. // Headimg returns the value of the "headimg" field in the mutation.
  7364. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7365. v := m.headimg
  7366. if v == nil {
  7367. return
  7368. }
  7369. return *v, true
  7370. }
  7371. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7372. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7374. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7375. if !m.op.Is(OpUpdateOne) {
  7376. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7377. }
  7378. if m.id == nil || m.oldValue == nil {
  7379. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7380. }
  7381. oldValue, err := m.oldValue(ctx)
  7382. if err != nil {
  7383. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7384. }
  7385. return oldValue.Headimg, nil
  7386. }
  7387. // ResetHeadimg resets all changes to the "headimg" field.
  7388. func (m *ContactMutation) ResetHeadimg() {
  7389. m.headimg = nil
  7390. }
  7391. // SetSex sets the "sex" field.
  7392. func (m *ContactMutation) SetSex(i int) {
  7393. m.sex = &i
  7394. m.addsex = nil
  7395. }
  7396. // Sex returns the value of the "sex" field in the mutation.
  7397. func (m *ContactMutation) Sex() (r int, exists bool) {
  7398. v := m.sex
  7399. if v == nil {
  7400. return
  7401. }
  7402. return *v, true
  7403. }
  7404. // OldSex returns the old "sex" field's value of the Contact entity.
  7405. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7407. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7408. if !m.op.Is(OpUpdateOne) {
  7409. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7410. }
  7411. if m.id == nil || m.oldValue == nil {
  7412. return v, errors.New("OldSex requires an ID field in the mutation")
  7413. }
  7414. oldValue, err := m.oldValue(ctx)
  7415. if err != nil {
  7416. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7417. }
  7418. return oldValue.Sex, nil
  7419. }
  7420. // AddSex adds i to the "sex" field.
  7421. func (m *ContactMutation) AddSex(i int) {
  7422. if m.addsex != nil {
  7423. *m.addsex += i
  7424. } else {
  7425. m.addsex = &i
  7426. }
  7427. }
  7428. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7429. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7430. v := m.addsex
  7431. if v == nil {
  7432. return
  7433. }
  7434. return *v, true
  7435. }
  7436. // ResetSex resets all changes to the "sex" field.
  7437. func (m *ContactMutation) ResetSex() {
  7438. m.sex = nil
  7439. m.addsex = nil
  7440. }
  7441. // SetStarrole sets the "starrole" field.
  7442. func (m *ContactMutation) SetStarrole(s string) {
  7443. m.starrole = &s
  7444. }
  7445. // Starrole returns the value of the "starrole" field in the mutation.
  7446. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7447. v := m.starrole
  7448. if v == nil {
  7449. return
  7450. }
  7451. return *v, true
  7452. }
  7453. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7454. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7456. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7457. if !m.op.Is(OpUpdateOne) {
  7458. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7459. }
  7460. if m.id == nil || m.oldValue == nil {
  7461. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7462. }
  7463. oldValue, err := m.oldValue(ctx)
  7464. if err != nil {
  7465. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7466. }
  7467. return oldValue.Starrole, nil
  7468. }
  7469. // ResetStarrole resets all changes to the "starrole" field.
  7470. func (m *ContactMutation) ResetStarrole() {
  7471. m.starrole = nil
  7472. }
  7473. // SetDontseeit sets the "dontseeit" field.
  7474. func (m *ContactMutation) SetDontseeit(i int) {
  7475. m.dontseeit = &i
  7476. m.adddontseeit = nil
  7477. }
  7478. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7479. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7480. v := m.dontseeit
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7487. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7499. }
  7500. return oldValue.Dontseeit, nil
  7501. }
  7502. // AddDontseeit adds i to the "dontseeit" field.
  7503. func (m *ContactMutation) AddDontseeit(i int) {
  7504. if m.adddontseeit != nil {
  7505. *m.adddontseeit += i
  7506. } else {
  7507. m.adddontseeit = &i
  7508. }
  7509. }
  7510. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7511. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7512. v := m.adddontseeit
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // ResetDontseeit resets all changes to the "dontseeit" field.
  7519. func (m *ContactMutation) ResetDontseeit() {
  7520. m.dontseeit = nil
  7521. m.adddontseeit = nil
  7522. }
  7523. // SetDontseeme sets the "dontseeme" field.
  7524. func (m *ContactMutation) SetDontseeme(i int) {
  7525. m.dontseeme = &i
  7526. m.adddontseeme = nil
  7527. }
  7528. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7529. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7530. v := m.dontseeme
  7531. if v == nil {
  7532. return
  7533. }
  7534. return *v, true
  7535. }
  7536. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7539. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7540. if !m.op.Is(OpUpdateOne) {
  7541. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7542. }
  7543. if m.id == nil || m.oldValue == nil {
  7544. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7545. }
  7546. oldValue, err := m.oldValue(ctx)
  7547. if err != nil {
  7548. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7549. }
  7550. return oldValue.Dontseeme, nil
  7551. }
  7552. // AddDontseeme adds i to the "dontseeme" field.
  7553. func (m *ContactMutation) AddDontseeme(i int) {
  7554. if m.adddontseeme != nil {
  7555. *m.adddontseeme += i
  7556. } else {
  7557. m.adddontseeme = &i
  7558. }
  7559. }
  7560. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7561. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7562. v := m.adddontseeme
  7563. if v == nil {
  7564. return
  7565. }
  7566. return *v, true
  7567. }
  7568. // ResetDontseeme resets all changes to the "dontseeme" field.
  7569. func (m *ContactMutation) ResetDontseeme() {
  7570. m.dontseeme = nil
  7571. m.adddontseeme = nil
  7572. }
  7573. // SetLag sets the "lag" field.
  7574. func (m *ContactMutation) SetLag(s string) {
  7575. m.lag = &s
  7576. }
  7577. // Lag returns the value of the "lag" field in the mutation.
  7578. func (m *ContactMutation) Lag() (r string, exists bool) {
  7579. v := m.lag
  7580. if v == nil {
  7581. return
  7582. }
  7583. return *v, true
  7584. }
  7585. // OldLag returns the old "lag" field's value of the Contact entity.
  7586. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7588. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7589. if !m.op.Is(OpUpdateOne) {
  7590. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7591. }
  7592. if m.id == nil || m.oldValue == nil {
  7593. return v, errors.New("OldLag requires an ID field in the mutation")
  7594. }
  7595. oldValue, err := m.oldValue(ctx)
  7596. if err != nil {
  7597. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7598. }
  7599. return oldValue.Lag, nil
  7600. }
  7601. // ResetLag resets all changes to the "lag" field.
  7602. func (m *ContactMutation) ResetLag() {
  7603. m.lag = nil
  7604. }
  7605. // SetGid sets the "gid" field.
  7606. func (m *ContactMutation) SetGid(s string) {
  7607. m.gid = &s
  7608. }
  7609. // Gid returns the value of the "gid" field in the mutation.
  7610. func (m *ContactMutation) Gid() (r string, exists bool) {
  7611. v := m.gid
  7612. if v == nil {
  7613. return
  7614. }
  7615. return *v, true
  7616. }
  7617. // OldGid returns the old "gid" field's value of the Contact entity.
  7618. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7620. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7621. if !m.op.Is(OpUpdateOne) {
  7622. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7623. }
  7624. if m.id == nil || m.oldValue == nil {
  7625. return v, errors.New("OldGid requires an ID field in the mutation")
  7626. }
  7627. oldValue, err := m.oldValue(ctx)
  7628. if err != nil {
  7629. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7630. }
  7631. return oldValue.Gid, nil
  7632. }
  7633. // ResetGid resets all changes to the "gid" field.
  7634. func (m *ContactMutation) ResetGid() {
  7635. m.gid = nil
  7636. }
  7637. // SetGname sets the "gname" field.
  7638. func (m *ContactMutation) SetGname(s string) {
  7639. m.gname = &s
  7640. }
  7641. // Gname returns the value of the "gname" field in the mutation.
  7642. func (m *ContactMutation) Gname() (r string, exists bool) {
  7643. v := m.gname
  7644. if v == nil {
  7645. return
  7646. }
  7647. return *v, true
  7648. }
  7649. // OldGname returns the old "gname" field's value of the Contact entity.
  7650. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7652. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7653. if !m.op.Is(OpUpdateOne) {
  7654. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7655. }
  7656. if m.id == nil || m.oldValue == nil {
  7657. return v, errors.New("OldGname requires an ID field in the mutation")
  7658. }
  7659. oldValue, err := m.oldValue(ctx)
  7660. if err != nil {
  7661. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7662. }
  7663. return oldValue.Gname, nil
  7664. }
  7665. // ResetGname resets all changes to the "gname" field.
  7666. func (m *ContactMutation) ResetGname() {
  7667. m.gname = nil
  7668. }
  7669. // SetV3 sets the "v3" field.
  7670. func (m *ContactMutation) SetV3(s string) {
  7671. m.v3 = &s
  7672. }
  7673. // V3 returns the value of the "v3" field in the mutation.
  7674. func (m *ContactMutation) V3() (r string, exists bool) {
  7675. v := m.v3
  7676. if v == nil {
  7677. return
  7678. }
  7679. return *v, true
  7680. }
  7681. // OldV3 returns the old "v3" field's value of the Contact entity.
  7682. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7684. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7685. if !m.op.Is(OpUpdateOne) {
  7686. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7687. }
  7688. if m.id == nil || m.oldValue == nil {
  7689. return v, errors.New("OldV3 requires an ID field in the mutation")
  7690. }
  7691. oldValue, err := m.oldValue(ctx)
  7692. if err != nil {
  7693. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7694. }
  7695. return oldValue.V3, nil
  7696. }
  7697. // ResetV3 resets all changes to the "v3" field.
  7698. func (m *ContactMutation) ResetV3() {
  7699. m.v3 = nil
  7700. }
  7701. // SetOrganizationID sets the "organization_id" field.
  7702. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7703. m.organization_id = &u
  7704. m.addorganization_id = nil
  7705. }
  7706. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7707. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7708. v := m.organization_id
  7709. if v == nil {
  7710. return
  7711. }
  7712. return *v, true
  7713. }
  7714. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7715. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7717. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7718. if !m.op.Is(OpUpdateOne) {
  7719. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7720. }
  7721. if m.id == nil || m.oldValue == nil {
  7722. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7723. }
  7724. oldValue, err := m.oldValue(ctx)
  7725. if err != nil {
  7726. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7727. }
  7728. return oldValue.OrganizationID, nil
  7729. }
  7730. // AddOrganizationID adds u to the "organization_id" field.
  7731. func (m *ContactMutation) AddOrganizationID(u int64) {
  7732. if m.addorganization_id != nil {
  7733. *m.addorganization_id += u
  7734. } else {
  7735. m.addorganization_id = &u
  7736. }
  7737. }
  7738. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7739. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7740. v := m.addorganization_id
  7741. if v == nil {
  7742. return
  7743. }
  7744. return *v, true
  7745. }
  7746. // ClearOrganizationID clears the value of the "organization_id" field.
  7747. func (m *ContactMutation) ClearOrganizationID() {
  7748. m.organization_id = nil
  7749. m.addorganization_id = nil
  7750. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7751. }
  7752. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7753. func (m *ContactMutation) OrganizationIDCleared() bool {
  7754. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7755. return ok
  7756. }
  7757. // ResetOrganizationID resets all changes to the "organization_id" field.
  7758. func (m *ContactMutation) ResetOrganizationID() {
  7759. m.organization_id = nil
  7760. m.addorganization_id = nil
  7761. delete(m.clearedFields, contact.FieldOrganizationID)
  7762. }
  7763. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7764. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7765. if m.contact_relationships == nil {
  7766. m.contact_relationships = make(map[uint64]struct{})
  7767. }
  7768. for i := range ids {
  7769. m.contact_relationships[ids[i]] = struct{}{}
  7770. }
  7771. }
  7772. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7773. func (m *ContactMutation) ClearContactRelationships() {
  7774. m.clearedcontact_relationships = true
  7775. }
  7776. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7777. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7778. return m.clearedcontact_relationships
  7779. }
  7780. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7781. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7782. if m.removedcontact_relationships == nil {
  7783. m.removedcontact_relationships = make(map[uint64]struct{})
  7784. }
  7785. for i := range ids {
  7786. delete(m.contact_relationships, ids[i])
  7787. m.removedcontact_relationships[ids[i]] = struct{}{}
  7788. }
  7789. }
  7790. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7791. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7792. for id := range m.removedcontact_relationships {
  7793. ids = append(ids, id)
  7794. }
  7795. return
  7796. }
  7797. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7798. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7799. for id := range m.contact_relationships {
  7800. ids = append(ids, id)
  7801. }
  7802. return
  7803. }
  7804. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7805. func (m *ContactMutation) ResetContactRelationships() {
  7806. m.contact_relationships = nil
  7807. m.clearedcontact_relationships = false
  7808. m.removedcontact_relationships = nil
  7809. }
  7810. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7811. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7812. if m.contact_messages == nil {
  7813. m.contact_messages = make(map[uint64]struct{})
  7814. }
  7815. for i := range ids {
  7816. m.contact_messages[ids[i]] = struct{}{}
  7817. }
  7818. }
  7819. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7820. func (m *ContactMutation) ClearContactMessages() {
  7821. m.clearedcontact_messages = true
  7822. }
  7823. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7824. func (m *ContactMutation) ContactMessagesCleared() bool {
  7825. return m.clearedcontact_messages
  7826. }
  7827. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7828. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7829. if m.removedcontact_messages == nil {
  7830. m.removedcontact_messages = make(map[uint64]struct{})
  7831. }
  7832. for i := range ids {
  7833. delete(m.contact_messages, ids[i])
  7834. m.removedcontact_messages[ids[i]] = struct{}{}
  7835. }
  7836. }
  7837. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7838. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7839. for id := range m.removedcontact_messages {
  7840. ids = append(ids, id)
  7841. }
  7842. return
  7843. }
  7844. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7845. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7846. for id := range m.contact_messages {
  7847. ids = append(ids, id)
  7848. }
  7849. return
  7850. }
  7851. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7852. func (m *ContactMutation) ResetContactMessages() {
  7853. m.contact_messages = nil
  7854. m.clearedcontact_messages = false
  7855. m.removedcontact_messages = nil
  7856. }
  7857. // Where appends a list predicates to the ContactMutation builder.
  7858. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7859. m.predicates = append(m.predicates, ps...)
  7860. }
  7861. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7862. // users can use type-assertion to append predicates that do not depend on any generated package.
  7863. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7864. p := make([]predicate.Contact, len(ps))
  7865. for i := range ps {
  7866. p[i] = ps[i]
  7867. }
  7868. m.Where(p...)
  7869. }
  7870. // Op returns the operation name.
  7871. func (m *ContactMutation) Op() Op {
  7872. return m.op
  7873. }
  7874. // SetOp allows setting the mutation operation.
  7875. func (m *ContactMutation) SetOp(op Op) {
  7876. m.op = op
  7877. }
  7878. // Type returns the node type of this mutation (Contact).
  7879. func (m *ContactMutation) Type() string {
  7880. return m.typ
  7881. }
  7882. // Fields returns all fields that were changed during this mutation. Note that in
  7883. // order to get all numeric fields that were incremented/decremented, call
  7884. // AddedFields().
  7885. func (m *ContactMutation) Fields() []string {
  7886. fields := make([]string, 0, 20)
  7887. if m.created_at != nil {
  7888. fields = append(fields, contact.FieldCreatedAt)
  7889. }
  7890. if m.updated_at != nil {
  7891. fields = append(fields, contact.FieldUpdatedAt)
  7892. }
  7893. if m.status != nil {
  7894. fields = append(fields, contact.FieldStatus)
  7895. }
  7896. if m.deleted_at != nil {
  7897. fields = append(fields, contact.FieldDeletedAt)
  7898. }
  7899. if m.wx_wxid != nil {
  7900. fields = append(fields, contact.FieldWxWxid)
  7901. }
  7902. if m._type != nil {
  7903. fields = append(fields, contact.FieldType)
  7904. }
  7905. if m.wxid != nil {
  7906. fields = append(fields, contact.FieldWxid)
  7907. }
  7908. if m.account != nil {
  7909. fields = append(fields, contact.FieldAccount)
  7910. }
  7911. if m.nickname != nil {
  7912. fields = append(fields, contact.FieldNickname)
  7913. }
  7914. if m.markname != nil {
  7915. fields = append(fields, contact.FieldMarkname)
  7916. }
  7917. if m.headimg != nil {
  7918. fields = append(fields, contact.FieldHeadimg)
  7919. }
  7920. if m.sex != nil {
  7921. fields = append(fields, contact.FieldSex)
  7922. }
  7923. if m.starrole != nil {
  7924. fields = append(fields, contact.FieldStarrole)
  7925. }
  7926. if m.dontseeit != nil {
  7927. fields = append(fields, contact.FieldDontseeit)
  7928. }
  7929. if m.dontseeme != nil {
  7930. fields = append(fields, contact.FieldDontseeme)
  7931. }
  7932. if m.lag != nil {
  7933. fields = append(fields, contact.FieldLag)
  7934. }
  7935. if m.gid != nil {
  7936. fields = append(fields, contact.FieldGid)
  7937. }
  7938. if m.gname != nil {
  7939. fields = append(fields, contact.FieldGname)
  7940. }
  7941. if m.v3 != nil {
  7942. fields = append(fields, contact.FieldV3)
  7943. }
  7944. if m.organization_id != nil {
  7945. fields = append(fields, contact.FieldOrganizationID)
  7946. }
  7947. return fields
  7948. }
  7949. // Field returns the value of a field with the given name. The second boolean
  7950. // return value indicates that this field was not set, or was not defined in the
  7951. // schema.
  7952. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7953. switch name {
  7954. case contact.FieldCreatedAt:
  7955. return m.CreatedAt()
  7956. case contact.FieldUpdatedAt:
  7957. return m.UpdatedAt()
  7958. case contact.FieldStatus:
  7959. return m.Status()
  7960. case contact.FieldDeletedAt:
  7961. return m.DeletedAt()
  7962. case contact.FieldWxWxid:
  7963. return m.WxWxid()
  7964. case contact.FieldType:
  7965. return m.GetType()
  7966. case contact.FieldWxid:
  7967. return m.Wxid()
  7968. case contact.FieldAccount:
  7969. return m.Account()
  7970. case contact.FieldNickname:
  7971. return m.Nickname()
  7972. case contact.FieldMarkname:
  7973. return m.Markname()
  7974. case contact.FieldHeadimg:
  7975. return m.Headimg()
  7976. case contact.FieldSex:
  7977. return m.Sex()
  7978. case contact.FieldStarrole:
  7979. return m.Starrole()
  7980. case contact.FieldDontseeit:
  7981. return m.Dontseeit()
  7982. case contact.FieldDontseeme:
  7983. return m.Dontseeme()
  7984. case contact.FieldLag:
  7985. return m.Lag()
  7986. case contact.FieldGid:
  7987. return m.Gid()
  7988. case contact.FieldGname:
  7989. return m.Gname()
  7990. case contact.FieldV3:
  7991. return m.V3()
  7992. case contact.FieldOrganizationID:
  7993. return m.OrganizationID()
  7994. }
  7995. return nil, false
  7996. }
  7997. // OldField returns the old value of the field from the database. An error is
  7998. // returned if the mutation operation is not UpdateOne, or the query to the
  7999. // database failed.
  8000. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8001. switch name {
  8002. case contact.FieldCreatedAt:
  8003. return m.OldCreatedAt(ctx)
  8004. case contact.FieldUpdatedAt:
  8005. return m.OldUpdatedAt(ctx)
  8006. case contact.FieldStatus:
  8007. return m.OldStatus(ctx)
  8008. case contact.FieldDeletedAt:
  8009. return m.OldDeletedAt(ctx)
  8010. case contact.FieldWxWxid:
  8011. return m.OldWxWxid(ctx)
  8012. case contact.FieldType:
  8013. return m.OldType(ctx)
  8014. case contact.FieldWxid:
  8015. return m.OldWxid(ctx)
  8016. case contact.FieldAccount:
  8017. return m.OldAccount(ctx)
  8018. case contact.FieldNickname:
  8019. return m.OldNickname(ctx)
  8020. case contact.FieldMarkname:
  8021. return m.OldMarkname(ctx)
  8022. case contact.FieldHeadimg:
  8023. return m.OldHeadimg(ctx)
  8024. case contact.FieldSex:
  8025. return m.OldSex(ctx)
  8026. case contact.FieldStarrole:
  8027. return m.OldStarrole(ctx)
  8028. case contact.FieldDontseeit:
  8029. return m.OldDontseeit(ctx)
  8030. case contact.FieldDontseeme:
  8031. return m.OldDontseeme(ctx)
  8032. case contact.FieldLag:
  8033. return m.OldLag(ctx)
  8034. case contact.FieldGid:
  8035. return m.OldGid(ctx)
  8036. case contact.FieldGname:
  8037. return m.OldGname(ctx)
  8038. case contact.FieldV3:
  8039. return m.OldV3(ctx)
  8040. case contact.FieldOrganizationID:
  8041. return m.OldOrganizationID(ctx)
  8042. }
  8043. return nil, fmt.Errorf("unknown Contact field %s", name)
  8044. }
  8045. // SetField sets the value of a field with the given name. It returns an error if
  8046. // the field is not defined in the schema, or if the type mismatched the field
  8047. // type.
  8048. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8049. switch name {
  8050. case contact.FieldCreatedAt:
  8051. v, ok := value.(time.Time)
  8052. if !ok {
  8053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8054. }
  8055. m.SetCreatedAt(v)
  8056. return nil
  8057. case contact.FieldUpdatedAt:
  8058. v, ok := value.(time.Time)
  8059. if !ok {
  8060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8061. }
  8062. m.SetUpdatedAt(v)
  8063. return nil
  8064. case contact.FieldStatus:
  8065. v, ok := value.(uint8)
  8066. if !ok {
  8067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8068. }
  8069. m.SetStatus(v)
  8070. return nil
  8071. case contact.FieldDeletedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetDeletedAt(v)
  8077. return nil
  8078. case contact.FieldWxWxid:
  8079. v, ok := value.(string)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetWxWxid(v)
  8084. return nil
  8085. case contact.FieldType:
  8086. v, ok := value.(int)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetType(v)
  8091. return nil
  8092. case contact.FieldWxid:
  8093. v, ok := value.(string)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetWxid(v)
  8098. return nil
  8099. case contact.FieldAccount:
  8100. v, ok := value.(string)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetAccount(v)
  8105. return nil
  8106. case contact.FieldNickname:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetNickname(v)
  8112. return nil
  8113. case contact.FieldMarkname:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetMarkname(v)
  8119. return nil
  8120. case contact.FieldHeadimg:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetHeadimg(v)
  8126. return nil
  8127. case contact.FieldSex:
  8128. v, ok := value.(int)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetSex(v)
  8133. return nil
  8134. case contact.FieldStarrole:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetStarrole(v)
  8140. return nil
  8141. case contact.FieldDontseeit:
  8142. v, ok := value.(int)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetDontseeit(v)
  8147. return nil
  8148. case contact.FieldDontseeme:
  8149. v, ok := value.(int)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetDontseeme(v)
  8154. return nil
  8155. case contact.FieldLag:
  8156. v, ok := value.(string)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetLag(v)
  8161. return nil
  8162. case contact.FieldGid:
  8163. v, ok := value.(string)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetGid(v)
  8168. return nil
  8169. case contact.FieldGname:
  8170. v, ok := value.(string)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetGname(v)
  8175. return nil
  8176. case contact.FieldV3:
  8177. v, ok := value.(string)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetV3(v)
  8182. return nil
  8183. case contact.FieldOrganizationID:
  8184. v, ok := value.(uint64)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetOrganizationID(v)
  8189. return nil
  8190. }
  8191. return fmt.Errorf("unknown Contact field %s", name)
  8192. }
  8193. // AddedFields returns all numeric fields that were incremented/decremented during
  8194. // this mutation.
  8195. func (m *ContactMutation) AddedFields() []string {
  8196. var fields []string
  8197. if m.addstatus != nil {
  8198. fields = append(fields, contact.FieldStatus)
  8199. }
  8200. if m.add_type != nil {
  8201. fields = append(fields, contact.FieldType)
  8202. }
  8203. if m.addsex != nil {
  8204. fields = append(fields, contact.FieldSex)
  8205. }
  8206. if m.adddontseeit != nil {
  8207. fields = append(fields, contact.FieldDontseeit)
  8208. }
  8209. if m.adddontseeme != nil {
  8210. fields = append(fields, contact.FieldDontseeme)
  8211. }
  8212. if m.addorganization_id != nil {
  8213. fields = append(fields, contact.FieldOrganizationID)
  8214. }
  8215. return fields
  8216. }
  8217. // AddedField returns the numeric value that was incremented/decremented on a field
  8218. // with the given name. The second boolean return value indicates that this field
  8219. // was not set, or was not defined in the schema.
  8220. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8221. switch name {
  8222. case contact.FieldStatus:
  8223. return m.AddedStatus()
  8224. case contact.FieldType:
  8225. return m.AddedType()
  8226. case contact.FieldSex:
  8227. return m.AddedSex()
  8228. case contact.FieldDontseeit:
  8229. return m.AddedDontseeit()
  8230. case contact.FieldDontseeme:
  8231. return m.AddedDontseeme()
  8232. case contact.FieldOrganizationID:
  8233. return m.AddedOrganizationID()
  8234. }
  8235. return nil, false
  8236. }
  8237. // AddField adds the value to the field with the given name. It returns an error if
  8238. // the field is not defined in the schema, or if the type mismatched the field
  8239. // type.
  8240. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8241. switch name {
  8242. case contact.FieldStatus:
  8243. v, ok := value.(int8)
  8244. if !ok {
  8245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8246. }
  8247. m.AddStatus(v)
  8248. return nil
  8249. case contact.FieldType:
  8250. v, ok := value.(int)
  8251. if !ok {
  8252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8253. }
  8254. m.AddType(v)
  8255. return nil
  8256. case contact.FieldSex:
  8257. v, ok := value.(int)
  8258. if !ok {
  8259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8260. }
  8261. m.AddSex(v)
  8262. return nil
  8263. case contact.FieldDontseeit:
  8264. v, ok := value.(int)
  8265. if !ok {
  8266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8267. }
  8268. m.AddDontseeit(v)
  8269. return nil
  8270. case contact.FieldDontseeme:
  8271. v, ok := value.(int)
  8272. if !ok {
  8273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8274. }
  8275. m.AddDontseeme(v)
  8276. return nil
  8277. case contact.FieldOrganizationID:
  8278. v, ok := value.(int64)
  8279. if !ok {
  8280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8281. }
  8282. m.AddOrganizationID(v)
  8283. return nil
  8284. }
  8285. return fmt.Errorf("unknown Contact numeric field %s", name)
  8286. }
  8287. // ClearedFields returns all nullable fields that were cleared during this
  8288. // mutation.
  8289. func (m *ContactMutation) ClearedFields() []string {
  8290. var fields []string
  8291. if m.FieldCleared(contact.FieldStatus) {
  8292. fields = append(fields, contact.FieldStatus)
  8293. }
  8294. if m.FieldCleared(contact.FieldDeletedAt) {
  8295. fields = append(fields, contact.FieldDeletedAt)
  8296. }
  8297. if m.FieldCleared(contact.FieldType) {
  8298. fields = append(fields, contact.FieldType)
  8299. }
  8300. if m.FieldCleared(contact.FieldOrganizationID) {
  8301. fields = append(fields, contact.FieldOrganizationID)
  8302. }
  8303. return fields
  8304. }
  8305. // FieldCleared returns a boolean indicating if a field with the given name was
  8306. // cleared in this mutation.
  8307. func (m *ContactMutation) FieldCleared(name string) bool {
  8308. _, ok := m.clearedFields[name]
  8309. return ok
  8310. }
  8311. // ClearField clears the value of the field with the given name. It returns an
  8312. // error if the field is not defined in the schema.
  8313. func (m *ContactMutation) ClearField(name string) error {
  8314. switch name {
  8315. case contact.FieldStatus:
  8316. m.ClearStatus()
  8317. return nil
  8318. case contact.FieldDeletedAt:
  8319. m.ClearDeletedAt()
  8320. return nil
  8321. case contact.FieldType:
  8322. m.ClearType()
  8323. return nil
  8324. case contact.FieldOrganizationID:
  8325. m.ClearOrganizationID()
  8326. return nil
  8327. }
  8328. return fmt.Errorf("unknown Contact nullable field %s", name)
  8329. }
  8330. // ResetField resets all changes in the mutation for the field with the given name.
  8331. // It returns an error if the field is not defined in the schema.
  8332. func (m *ContactMutation) ResetField(name string) error {
  8333. switch name {
  8334. case contact.FieldCreatedAt:
  8335. m.ResetCreatedAt()
  8336. return nil
  8337. case contact.FieldUpdatedAt:
  8338. m.ResetUpdatedAt()
  8339. return nil
  8340. case contact.FieldStatus:
  8341. m.ResetStatus()
  8342. return nil
  8343. case contact.FieldDeletedAt:
  8344. m.ResetDeletedAt()
  8345. return nil
  8346. case contact.FieldWxWxid:
  8347. m.ResetWxWxid()
  8348. return nil
  8349. case contact.FieldType:
  8350. m.ResetType()
  8351. return nil
  8352. case contact.FieldWxid:
  8353. m.ResetWxid()
  8354. return nil
  8355. case contact.FieldAccount:
  8356. m.ResetAccount()
  8357. return nil
  8358. case contact.FieldNickname:
  8359. m.ResetNickname()
  8360. return nil
  8361. case contact.FieldMarkname:
  8362. m.ResetMarkname()
  8363. return nil
  8364. case contact.FieldHeadimg:
  8365. m.ResetHeadimg()
  8366. return nil
  8367. case contact.FieldSex:
  8368. m.ResetSex()
  8369. return nil
  8370. case contact.FieldStarrole:
  8371. m.ResetStarrole()
  8372. return nil
  8373. case contact.FieldDontseeit:
  8374. m.ResetDontseeit()
  8375. return nil
  8376. case contact.FieldDontseeme:
  8377. m.ResetDontseeme()
  8378. return nil
  8379. case contact.FieldLag:
  8380. m.ResetLag()
  8381. return nil
  8382. case contact.FieldGid:
  8383. m.ResetGid()
  8384. return nil
  8385. case contact.FieldGname:
  8386. m.ResetGname()
  8387. return nil
  8388. case contact.FieldV3:
  8389. m.ResetV3()
  8390. return nil
  8391. case contact.FieldOrganizationID:
  8392. m.ResetOrganizationID()
  8393. return nil
  8394. }
  8395. return fmt.Errorf("unknown Contact field %s", name)
  8396. }
  8397. // AddedEdges returns all edge names that were set/added in this mutation.
  8398. func (m *ContactMutation) AddedEdges() []string {
  8399. edges := make([]string, 0, 2)
  8400. if m.contact_relationships != nil {
  8401. edges = append(edges, contact.EdgeContactRelationships)
  8402. }
  8403. if m.contact_messages != nil {
  8404. edges = append(edges, contact.EdgeContactMessages)
  8405. }
  8406. return edges
  8407. }
  8408. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8409. // name in this mutation.
  8410. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8411. switch name {
  8412. case contact.EdgeContactRelationships:
  8413. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8414. for id := range m.contact_relationships {
  8415. ids = append(ids, id)
  8416. }
  8417. return ids
  8418. case contact.EdgeContactMessages:
  8419. ids := make([]ent.Value, 0, len(m.contact_messages))
  8420. for id := range m.contact_messages {
  8421. ids = append(ids, id)
  8422. }
  8423. return ids
  8424. }
  8425. return nil
  8426. }
  8427. // RemovedEdges returns all edge names that were removed in this mutation.
  8428. func (m *ContactMutation) RemovedEdges() []string {
  8429. edges := make([]string, 0, 2)
  8430. if m.removedcontact_relationships != nil {
  8431. edges = append(edges, contact.EdgeContactRelationships)
  8432. }
  8433. if m.removedcontact_messages != nil {
  8434. edges = append(edges, contact.EdgeContactMessages)
  8435. }
  8436. return edges
  8437. }
  8438. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8439. // the given name in this mutation.
  8440. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8441. switch name {
  8442. case contact.EdgeContactRelationships:
  8443. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8444. for id := range m.removedcontact_relationships {
  8445. ids = append(ids, id)
  8446. }
  8447. return ids
  8448. case contact.EdgeContactMessages:
  8449. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8450. for id := range m.removedcontact_messages {
  8451. ids = append(ids, id)
  8452. }
  8453. return ids
  8454. }
  8455. return nil
  8456. }
  8457. // ClearedEdges returns all edge names that were cleared in this mutation.
  8458. func (m *ContactMutation) ClearedEdges() []string {
  8459. edges := make([]string, 0, 2)
  8460. if m.clearedcontact_relationships {
  8461. edges = append(edges, contact.EdgeContactRelationships)
  8462. }
  8463. if m.clearedcontact_messages {
  8464. edges = append(edges, contact.EdgeContactMessages)
  8465. }
  8466. return edges
  8467. }
  8468. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8469. // was cleared in this mutation.
  8470. func (m *ContactMutation) EdgeCleared(name string) bool {
  8471. switch name {
  8472. case contact.EdgeContactRelationships:
  8473. return m.clearedcontact_relationships
  8474. case contact.EdgeContactMessages:
  8475. return m.clearedcontact_messages
  8476. }
  8477. return false
  8478. }
  8479. // ClearEdge clears the value of the edge with the given name. It returns an error
  8480. // if that edge is not defined in the schema.
  8481. func (m *ContactMutation) ClearEdge(name string) error {
  8482. switch name {
  8483. }
  8484. return fmt.Errorf("unknown Contact unique edge %s", name)
  8485. }
  8486. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8487. // It returns an error if the edge is not defined in the schema.
  8488. func (m *ContactMutation) ResetEdge(name string) error {
  8489. switch name {
  8490. case contact.EdgeContactRelationships:
  8491. m.ResetContactRelationships()
  8492. return nil
  8493. case contact.EdgeContactMessages:
  8494. m.ResetContactMessages()
  8495. return nil
  8496. }
  8497. return fmt.Errorf("unknown Contact edge %s", name)
  8498. }
  8499. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8500. type EmployeeMutation struct {
  8501. config
  8502. op Op
  8503. typ string
  8504. id *uint64
  8505. created_at *time.Time
  8506. updated_at *time.Time
  8507. deleted_at *time.Time
  8508. title *string
  8509. avatar *string
  8510. tags *string
  8511. hire_count *int
  8512. addhire_count *int
  8513. service_count *int
  8514. addservice_count *int
  8515. achievement_count *int
  8516. addachievement_count *int
  8517. intro *string
  8518. estimate *string
  8519. skill *string
  8520. ability_type *string
  8521. scene *string
  8522. switch_in *string
  8523. video_url *string
  8524. organization_id *uint64
  8525. addorganization_id *int64
  8526. category_id *uint64
  8527. addcategory_id *int64
  8528. api_base *string
  8529. api_key *string
  8530. ai_info *string
  8531. is_vip *int
  8532. addis_vip *int
  8533. clearedFields map[string]struct{}
  8534. em_work_experiences map[uint64]struct{}
  8535. removedem_work_experiences map[uint64]struct{}
  8536. clearedem_work_experiences bool
  8537. em_tutorial map[uint64]struct{}
  8538. removedem_tutorial map[uint64]struct{}
  8539. clearedem_tutorial bool
  8540. done bool
  8541. oldValue func(context.Context) (*Employee, error)
  8542. predicates []predicate.Employee
  8543. }
  8544. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8545. // employeeOption allows management of the mutation configuration using functional options.
  8546. type employeeOption func(*EmployeeMutation)
  8547. // newEmployeeMutation creates new mutation for the Employee entity.
  8548. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8549. m := &EmployeeMutation{
  8550. config: c,
  8551. op: op,
  8552. typ: TypeEmployee,
  8553. clearedFields: make(map[string]struct{}),
  8554. }
  8555. for _, opt := range opts {
  8556. opt(m)
  8557. }
  8558. return m
  8559. }
  8560. // withEmployeeID sets the ID field of the mutation.
  8561. func withEmployeeID(id uint64) employeeOption {
  8562. return func(m *EmployeeMutation) {
  8563. var (
  8564. err error
  8565. once sync.Once
  8566. value *Employee
  8567. )
  8568. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8569. once.Do(func() {
  8570. if m.done {
  8571. err = errors.New("querying old values post mutation is not allowed")
  8572. } else {
  8573. value, err = m.Client().Employee.Get(ctx, id)
  8574. }
  8575. })
  8576. return value, err
  8577. }
  8578. m.id = &id
  8579. }
  8580. }
  8581. // withEmployee sets the old Employee of the mutation.
  8582. func withEmployee(node *Employee) employeeOption {
  8583. return func(m *EmployeeMutation) {
  8584. m.oldValue = func(context.Context) (*Employee, error) {
  8585. return node, nil
  8586. }
  8587. m.id = &node.ID
  8588. }
  8589. }
  8590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8591. // executed in a transaction (ent.Tx), a transactional client is returned.
  8592. func (m EmployeeMutation) Client() *Client {
  8593. client := &Client{config: m.config}
  8594. client.init()
  8595. return client
  8596. }
  8597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8598. // it returns an error otherwise.
  8599. func (m EmployeeMutation) Tx() (*Tx, error) {
  8600. if _, ok := m.driver.(*txDriver); !ok {
  8601. return nil, errors.New("ent: mutation is not running in a transaction")
  8602. }
  8603. tx := &Tx{config: m.config}
  8604. tx.init()
  8605. return tx, nil
  8606. }
  8607. // SetID sets the value of the id field. Note that this
  8608. // operation is only accepted on creation of Employee entities.
  8609. func (m *EmployeeMutation) SetID(id uint64) {
  8610. m.id = &id
  8611. }
  8612. // ID returns the ID value in the mutation. Note that the ID is only available
  8613. // if it was provided to the builder or after it was returned from the database.
  8614. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8615. if m.id == nil {
  8616. return
  8617. }
  8618. return *m.id, true
  8619. }
  8620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8621. // That means, if the mutation is applied within a transaction with an isolation level such
  8622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8623. // or updated by the mutation.
  8624. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8625. switch {
  8626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8627. id, exists := m.ID()
  8628. if exists {
  8629. return []uint64{id}, nil
  8630. }
  8631. fallthrough
  8632. case m.op.Is(OpUpdate | OpDelete):
  8633. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8634. default:
  8635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8636. }
  8637. }
  8638. // SetCreatedAt sets the "created_at" field.
  8639. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8640. m.created_at = &t
  8641. }
  8642. // CreatedAt returns the value of the "created_at" field in the mutation.
  8643. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8644. v := m.created_at
  8645. if v == nil {
  8646. return
  8647. }
  8648. return *v, true
  8649. }
  8650. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8651. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8653. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8654. if !m.op.Is(OpUpdateOne) {
  8655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8656. }
  8657. if m.id == nil || m.oldValue == nil {
  8658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8659. }
  8660. oldValue, err := m.oldValue(ctx)
  8661. if err != nil {
  8662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8663. }
  8664. return oldValue.CreatedAt, nil
  8665. }
  8666. // ResetCreatedAt resets all changes to the "created_at" field.
  8667. func (m *EmployeeMutation) ResetCreatedAt() {
  8668. m.created_at = nil
  8669. }
  8670. // SetUpdatedAt sets the "updated_at" field.
  8671. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8672. m.updated_at = &t
  8673. }
  8674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8675. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8676. v := m.updated_at
  8677. if v == nil {
  8678. return
  8679. }
  8680. return *v, true
  8681. }
  8682. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8683. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8685. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8686. if !m.op.Is(OpUpdateOne) {
  8687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8688. }
  8689. if m.id == nil || m.oldValue == nil {
  8690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8691. }
  8692. oldValue, err := m.oldValue(ctx)
  8693. if err != nil {
  8694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8695. }
  8696. return oldValue.UpdatedAt, nil
  8697. }
  8698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8699. func (m *EmployeeMutation) ResetUpdatedAt() {
  8700. m.updated_at = nil
  8701. }
  8702. // SetDeletedAt sets the "deleted_at" field.
  8703. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8704. m.deleted_at = &t
  8705. }
  8706. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8707. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8708. v := m.deleted_at
  8709. if v == nil {
  8710. return
  8711. }
  8712. return *v, true
  8713. }
  8714. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8715. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8717. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8718. if !m.op.Is(OpUpdateOne) {
  8719. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8720. }
  8721. if m.id == nil || m.oldValue == nil {
  8722. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8723. }
  8724. oldValue, err := m.oldValue(ctx)
  8725. if err != nil {
  8726. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8727. }
  8728. return oldValue.DeletedAt, nil
  8729. }
  8730. // ClearDeletedAt clears the value of the "deleted_at" field.
  8731. func (m *EmployeeMutation) ClearDeletedAt() {
  8732. m.deleted_at = nil
  8733. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8734. }
  8735. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8736. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8737. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8738. return ok
  8739. }
  8740. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8741. func (m *EmployeeMutation) ResetDeletedAt() {
  8742. m.deleted_at = nil
  8743. delete(m.clearedFields, employee.FieldDeletedAt)
  8744. }
  8745. // SetTitle sets the "title" field.
  8746. func (m *EmployeeMutation) SetTitle(s string) {
  8747. m.title = &s
  8748. }
  8749. // Title returns the value of the "title" field in the mutation.
  8750. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8751. v := m.title
  8752. if v == nil {
  8753. return
  8754. }
  8755. return *v, true
  8756. }
  8757. // OldTitle returns the old "title" field's value of the Employee entity.
  8758. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8760. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8761. if !m.op.Is(OpUpdateOne) {
  8762. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8763. }
  8764. if m.id == nil || m.oldValue == nil {
  8765. return v, errors.New("OldTitle requires an ID field in the mutation")
  8766. }
  8767. oldValue, err := m.oldValue(ctx)
  8768. if err != nil {
  8769. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8770. }
  8771. return oldValue.Title, nil
  8772. }
  8773. // ResetTitle resets all changes to the "title" field.
  8774. func (m *EmployeeMutation) ResetTitle() {
  8775. m.title = nil
  8776. }
  8777. // SetAvatar sets the "avatar" field.
  8778. func (m *EmployeeMutation) SetAvatar(s string) {
  8779. m.avatar = &s
  8780. }
  8781. // Avatar returns the value of the "avatar" field in the mutation.
  8782. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8783. v := m.avatar
  8784. if v == nil {
  8785. return
  8786. }
  8787. return *v, true
  8788. }
  8789. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8790. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8792. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8793. if !m.op.Is(OpUpdateOne) {
  8794. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8795. }
  8796. if m.id == nil || m.oldValue == nil {
  8797. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8798. }
  8799. oldValue, err := m.oldValue(ctx)
  8800. if err != nil {
  8801. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8802. }
  8803. return oldValue.Avatar, nil
  8804. }
  8805. // ResetAvatar resets all changes to the "avatar" field.
  8806. func (m *EmployeeMutation) ResetAvatar() {
  8807. m.avatar = nil
  8808. }
  8809. // SetTags sets the "tags" field.
  8810. func (m *EmployeeMutation) SetTags(s string) {
  8811. m.tags = &s
  8812. }
  8813. // Tags returns the value of the "tags" field in the mutation.
  8814. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8815. v := m.tags
  8816. if v == nil {
  8817. return
  8818. }
  8819. return *v, true
  8820. }
  8821. // OldTags returns the old "tags" field's value of the Employee entity.
  8822. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8824. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8825. if !m.op.Is(OpUpdateOne) {
  8826. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8827. }
  8828. if m.id == nil || m.oldValue == nil {
  8829. return v, errors.New("OldTags requires an ID field in the mutation")
  8830. }
  8831. oldValue, err := m.oldValue(ctx)
  8832. if err != nil {
  8833. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8834. }
  8835. return oldValue.Tags, nil
  8836. }
  8837. // ResetTags resets all changes to the "tags" field.
  8838. func (m *EmployeeMutation) ResetTags() {
  8839. m.tags = nil
  8840. }
  8841. // SetHireCount sets the "hire_count" field.
  8842. func (m *EmployeeMutation) SetHireCount(i int) {
  8843. m.hire_count = &i
  8844. m.addhire_count = nil
  8845. }
  8846. // HireCount returns the value of the "hire_count" field in the mutation.
  8847. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8848. v := m.hire_count
  8849. if v == nil {
  8850. return
  8851. }
  8852. return *v, true
  8853. }
  8854. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8855. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8857. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8858. if !m.op.Is(OpUpdateOne) {
  8859. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8860. }
  8861. if m.id == nil || m.oldValue == nil {
  8862. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8863. }
  8864. oldValue, err := m.oldValue(ctx)
  8865. if err != nil {
  8866. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8867. }
  8868. return oldValue.HireCount, nil
  8869. }
  8870. // AddHireCount adds i to the "hire_count" field.
  8871. func (m *EmployeeMutation) AddHireCount(i int) {
  8872. if m.addhire_count != nil {
  8873. *m.addhire_count += i
  8874. } else {
  8875. m.addhire_count = &i
  8876. }
  8877. }
  8878. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8879. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8880. v := m.addhire_count
  8881. if v == nil {
  8882. return
  8883. }
  8884. return *v, true
  8885. }
  8886. // ResetHireCount resets all changes to the "hire_count" field.
  8887. func (m *EmployeeMutation) ResetHireCount() {
  8888. m.hire_count = nil
  8889. m.addhire_count = nil
  8890. }
  8891. // SetServiceCount sets the "service_count" field.
  8892. func (m *EmployeeMutation) SetServiceCount(i int) {
  8893. m.service_count = &i
  8894. m.addservice_count = nil
  8895. }
  8896. // ServiceCount returns the value of the "service_count" field in the mutation.
  8897. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8898. v := m.service_count
  8899. if v == nil {
  8900. return
  8901. }
  8902. return *v, true
  8903. }
  8904. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8905. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8907. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8908. if !m.op.Is(OpUpdateOne) {
  8909. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8910. }
  8911. if m.id == nil || m.oldValue == nil {
  8912. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8913. }
  8914. oldValue, err := m.oldValue(ctx)
  8915. if err != nil {
  8916. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8917. }
  8918. return oldValue.ServiceCount, nil
  8919. }
  8920. // AddServiceCount adds i to the "service_count" field.
  8921. func (m *EmployeeMutation) AddServiceCount(i int) {
  8922. if m.addservice_count != nil {
  8923. *m.addservice_count += i
  8924. } else {
  8925. m.addservice_count = &i
  8926. }
  8927. }
  8928. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8929. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8930. v := m.addservice_count
  8931. if v == nil {
  8932. return
  8933. }
  8934. return *v, true
  8935. }
  8936. // ResetServiceCount resets all changes to the "service_count" field.
  8937. func (m *EmployeeMutation) ResetServiceCount() {
  8938. m.service_count = nil
  8939. m.addservice_count = nil
  8940. }
  8941. // SetAchievementCount sets the "achievement_count" field.
  8942. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8943. m.achievement_count = &i
  8944. m.addachievement_count = nil
  8945. }
  8946. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8947. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8948. v := m.achievement_count
  8949. if v == nil {
  8950. return
  8951. }
  8952. return *v, true
  8953. }
  8954. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8955. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8957. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8958. if !m.op.Is(OpUpdateOne) {
  8959. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8960. }
  8961. if m.id == nil || m.oldValue == nil {
  8962. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8963. }
  8964. oldValue, err := m.oldValue(ctx)
  8965. if err != nil {
  8966. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8967. }
  8968. return oldValue.AchievementCount, nil
  8969. }
  8970. // AddAchievementCount adds i to the "achievement_count" field.
  8971. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8972. if m.addachievement_count != nil {
  8973. *m.addachievement_count += i
  8974. } else {
  8975. m.addachievement_count = &i
  8976. }
  8977. }
  8978. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8979. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8980. v := m.addachievement_count
  8981. if v == nil {
  8982. return
  8983. }
  8984. return *v, true
  8985. }
  8986. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8987. func (m *EmployeeMutation) ResetAchievementCount() {
  8988. m.achievement_count = nil
  8989. m.addachievement_count = nil
  8990. }
  8991. // SetIntro sets the "intro" field.
  8992. func (m *EmployeeMutation) SetIntro(s string) {
  8993. m.intro = &s
  8994. }
  8995. // Intro returns the value of the "intro" field in the mutation.
  8996. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  8997. v := m.intro
  8998. if v == nil {
  8999. return
  9000. }
  9001. return *v, true
  9002. }
  9003. // OldIntro returns the old "intro" field's value of the Employee entity.
  9004. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9006. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9007. if !m.op.Is(OpUpdateOne) {
  9008. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9009. }
  9010. if m.id == nil || m.oldValue == nil {
  9011. return v, errors.New("OldIntro requires an ID field in the mutation")
  9012. }
  9013. oldValue, err := m.oldValue(ctx)
  9014. if err != nil {
  9015. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9016. }
  9017. return oldValue.Intro, nil
  9018. }
  9019. // ResetIntro resets all changes to the "intro" field.
  9020. func (m *EmployeeMutation) ResetIntro() {
  9021. m.intro = nil
  9022. }
  9023. // SetEstimate sets the "estimate" field.
  9024. func (m *EmployeeMutation) SetEstimate(s string) {
  9025. m.estimate = &s
  9026. }
  9027. // Estimate returns the value of the "estimate" field in the mutation.
  9028. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9029. v := m.estimate
  9030. if v == nil {
  9031. return
  9032. }
  9033. return *v, true
  9034. }
  9035. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9036. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9038. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9039. if !m.op.Is(OpUpdateOne) {
  9040. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9041. }
  9042. if m.id == nil || m.oldValue == nil {
  9043. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9044. }
  9045. oldValue, err := m.oldValue(ctx)
  9046. if err != nil {
  9047. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9048. }
  9049. return oldValue.Estimate, nil
  9050. }
  9051. // ResetEstimate resets all changes to the "estimate" field.
  9052. func (m *EmployeeMutation) ResetEstimate() {
  9053. m.estimate = nil
  9054. }
  9055. // SetSkill sets the "skill" field.
  9056. func (m *EmployeeMutation) SetSkill(s string) {
  9057. m.skill = &s
  9058. }
  9059. // Skill returns the value of the "skill" field in the mutation.
  9060. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9061. v := m.skill
  9062. if v == nil {
  9063. return
  9064. }
  9065. return *v, true
  9066. }
  9067. // OldSkill returns the old "skill" field's value of the Employee entity.
  9068. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9070. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9071. if !m.op.Is(OpUpdateOne) {
  9072. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9073. }
  9074. if m.id == nil || m.oldValue == nil {
  9075. return v, errors.New("OldSkill requires an ID field in the mutation")
  9076. }
  9077. oldValue, err := m.oldValue(ctx)
  9078. if err != nil {
  9079. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9080. }
  9081. return oldValue.Skill, nil
  9082. }
  9083. // ResetSkill resets all changes to the "skill" field.
  9084. func (m *EmployeeMutation) ResetSkill() {
  9085. m.skill = nil
  9086. }
  9087. // SetAbilityType sets the "ability_type" field.
  9088. func (m *EmployeeMutation) SetAbilityType(s string) {
  9089. m.ability_type = &s
  9090. }
  9091. // AbilityType returns the value of the "ability_type" field in the mutation.
  9092. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9093. v := m.ability_type
  9094. if v == nil {
  9095. return
  9096. }
  9097. return *v, true
  9098. }
  9099. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9100. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9102. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9103. if !m.op.Is(OpUpdateOne) {
  9104. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9105. }
  9106. if m.id == nil || m.oldValue == nil {
  9107. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9108. }
  9109. oldValue, err := m.oldValue(ctx)
  9110. if err != nil {
  9111. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9112. }
  9113. return oldValue.AbilityType, nil
  9114. }
  9115. // ResetAbilityType resets all changes to the "ability_type" field.
  9116. func (m *EmployeeMutation) ResetAbilityType() {
  9117. m.ability_type = nil
  9118. }
  9119. // SetScene sets the "scene" field.
  9120. func (m *EmployeeMutation) SetScene(s string) {
  9121. m.scene = &s
  9122. }
  9123. // Scene returns the value of the "scene" field in the mutation.
  9124. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9125. v := m.scene
  9126. if v == nil {
  9127. return
  9128. }
  9129. return *v, true
  9130. }
  9131. // OldScene returns the old "scene" field's value of the Employee entity.
  9132. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9134. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9135. if !m.op.Is(OpUpdateOne) {
  9136. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9137. }
  9138. if m.id == nil || m.oldValue == nil {
  9139. return v, errors.New("OldScene requires an ID field in the mutation")
  9140. }
  9141. oldValue, err := m.oldValue(ctx)
  9142. if err != nil {
  9143. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9144. }
  9145. return oldValue.Scene, nil
  9146. }
  9147. // ResetScene resets all changes to the "scene" field.
  9148. func (m *EmployeeMutation) ResetScene() {
  9149. m.scene = nil
  9150. }
  9151. // SetSwitchIn sets the "switch_in" field.
  9152. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9153. m.switch_in = &s
  9154. }
  9155. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9156. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9157. v := m.switch_in
  9158. if v == nil {
  9159. return
  9160. }
  9161. return *v, true
  9162. }
  9163. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9164. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9166. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9167. if !m.op.Is(OpUpdateOne) {
  9168. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9169. }
  9170. if m.id == nil || m.oldValue == nil {
  9171. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9172. }
  9173. oldValue, err := m.oldValue(ctx)
  9174. if err != nil {
  9175. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9176. }
  9177. return oldValue.SwitchIn, nil
  9178. }
  9179. // ResetSwitchIn resets all changes to the "switch_in" field.
  9180. func (m *EmployeeMutation) ResetSwitchIn() {
  9181. m.switch_in = nil
  9182. }
  9183. // SetVideoURL sets the "video_url" field.
  9184. func (m *EmployeeMutation) SetVideoURL(s string) {
  9185. m.video_url = &s
  9186. }
  9187. // VideoURL returns the value of the "video_url" field in the mutation.
  9188. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9189. v := m.video_url
  9190. if v == nil {
  9191. return
  9192. }
  9193. return *v, true
  9194. }
  9195. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9196. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9198. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9199. if !m.op.Is(OpUpdateOne) {
  9200. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9201. }
  9202. if m.id == nil || m.oldValue == nil {
  9203. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9204. }
  9205. oldValue, err := m.oldValue(ctx)
  9206. if err != nil {
  9207. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9208. }
  9209. return oldValue.VideoURL, nil
  9210. }
  9211. // ResetVideoURL resets all changes to the "video_url" field.
  9212. func (m *EmployeeMutation) ResetVideoURL() {
  9213. m.video_url = nil
  9214. }
  9215. // SetOrganizationID sets the "organization_id" field.
  9216. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9217. m.organization_id = &u
  9218. m.addorganization_id = nil
  9219. }
  9220. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9221. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9222. v := m.organization_id
  9223. if v == nil {
  9224. return
  9225. }
  9226. return *v, true
  9227. }
  9228. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9229. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9231. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9232. if !m.op.Is(OpUpdateOne) {
  9233. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9234. }
  9235. if m.id == nil || m.oldValue == nil {
  9236. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9237. }
  9238. oldValue, err := m.oldValue(ctx)
  9239. if err != nil {
  9240. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9241. }
  9242. return oldValue.OrganizationID, nil
  9243. }
  9244. // AddOrganizationID adds u to the "organization_id" field.
  9245. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9246. if m.addorganization_id != nil {
  9247. *m.addorganization_id += u
  9248. } else {
  9249. m.addorganization_id = &u
  9250. }
  9251. }
  9252. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9253. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9254. v := m.addorganization_id
  9255. if v == nil {
  9256. return
  9257. }
  9258. return *v, true
  9259. }
  9260. // ResetOrganizationID resets all changes to the "organization_id" field.
  9261. func (m *EmployeeMutation) ResetOrganizationID() {
  9262. m.organization_id = nil
  9263. m.addorganization_id = nil
  9264. }
  9265. // SetCategoryID sets the "category_id" field.
  9266. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9267. m.category_id = &u
  9268. m.addcategory_id = nil
  9269. }
  9270. // CategoryID returns the value of the "category_id" field in the mutation.
  9271. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9272. v := m.category_id
  9273. if v == nil {
  9274. return
  9275. }
  9276. return *v, true
  9277. }
  9278. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9279. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9281. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9282. if !m.op.Is(OpUpdateOne) {
  9283. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9284. }
  9285. if m.id == nil || m.oldValue == nil {
  9286. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9287. }
  9288. oldValue, err := m.oldValue(ctx)
  9289. if err != nil {
  9290. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9291. }
  9292. return oldValue.CategoryID, nil
  9293. }
  9294. // AddCategoryID adds u to the "category_id" field.
  9295. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9296. if m.addcategory_id != nil {
  9297. *m.addcategory_id += u
  9298. } else {
  9299. m.addcategory_id = &u
  9300. }
  9301. }
  9302. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9303. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9304. v := m.addcategory_id
  9305. if v == nil {
  9306. return
  9307. }
  9308. return *v, true
  9309. }
  9310. // ResetCategoryID resets all changes to the "category_id" field.
  9311. func (m *EmployeeMutation) ResetCategoryID() {
  9312. m.category_id = nil
  9313. m.addcategory_id = nil
  9314. }
  9315. // SetAPIBase sets the "api_base" field.
  9316. func (m *EmployeeMutation) SetAPIBase(s string) {
  9317. m.api_base = &s
  9318. }
  9319. // APIBase returns the value of the "api_base" field in the mutation.
  9320. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9321. v := m.api_base
  9322. if v == nil {
  9323. return
  9324. }
  9325. return *v, true
  9326. }
  9327. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9328. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9330. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9331. if !m.op.Is(OpUpdateOne) {
  9332. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9333. }
  9334. if m.id == nil || m.oldValue == nil {
  9335. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9336. }
  9337. oldValue, err := m.oldValue(ctx)
  9338. if err != nil {
  9339. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9340. }
  9341. return oldValue.APIBase, nil
  9342. }
  9343. // ResetAPIBase resets all changes to the "api_base" field.
  9344. func (m *EmployeeMutation) ResetAPIBase() {
  9345. m.api_base = nil
  9346. }
  9347. // SetAPIKey sets the "api_key" field.
  9348. func (m *EmployeeMutation) SetAPIKey(s string) {
  9349. m.api_key = &s
  9350. }
  9351. // APIKey returns the value of the "api_key" field in the mutation.
  9352. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9353. v := m.api_key
  9354. if v == nil {
  9355. return
  9356. }
  9357. return *v, true
  9358. }
  9359. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9360. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9362. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9363. if !m.op.Is(OpUpdateOne) {
  9364. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9365. }
  9366. if m.id == nil || m.oldValue == nil {
  9367. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9368. }
  9369. oldValue, err := m.oldValue(ctx)
  9370. if err != nil {
  9371. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9372. }
  9373. return oldValue.APIKey, nil
  9374. }
  9375. // ResetAPIKey resets all changes to the "api_key" field.
  9376. func (m *EmployeeMutation) ResetAPIKey() {
  9377. m.api_key = nil
  9378. }
  9379. // SetAiInfo sets the "ai_info" field.
  9380. func (m *EmployeeMutation) SetAiInfo(s string) {
  9381. m.ai_info = &s
  9382. }
  9383. // AiInfo returns the value of the "ai_info" field in the mutation.
  9384. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9385. v := m.ai_info
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9392. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9394. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9395. if !m.op.Is(OpUpdateOne) {
  9396. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9397. }
  9398. if m.id == nil || m.oldValue == nil {
  9399. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9400. }
  9401. oldValue, err := m.oldValue(ctx)
  9402. if err != nil {
  9403. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9404. }
  9405. return oldValue.AiInfo, nil
  9406. }
  9407. // ClearAiInfo clears the value of the "ai_info" field.
  9408. func (m *EmployeeMutation) ClearAiInfo() {
  9409. m.ai_info = nil
  9410. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9411. }
  9412. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9413. func (m *EmployeeMutation) AiInfoCleared() bool {
  9414. _, ok := m.clearedFields[employee.FieldAiInfo]
  9415. return ok
  9416. }
  9417. // ResetAiInfo resets all changes to the "ai_info" field.
  9418. func (m *EmployeeMutation) ResetAiInfo() {
  9419. m.ai_info = nil
  9420. delete(m.clearedFields, employee.FieldAiInfo)
  9421. }
  9422. // SetIsVip sets the "is_vip" field.
  9423. func (m *EmployeeMutation) SetIsVip(i int) {
  9424. m.is_vip = &i
  9425. m.addis_vip = nil
  9426. }
  9427. // IsVip returns the value of the "is_vip" field in the mutation.
  9428. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9429. v := m.is_vip
  9430. if v == nil {
  9431. return
  9432. }
  9433. return *v, true
  9434. }
  9435. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9436. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9438. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9439. if !m.op.Is(OpUpdateOne) {
  9440. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9441. }
  9442. if m.id == nil || m.oldValue == nil {
  9443. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9444. }
  9445. oldValue, err := m.oldValue(ctx)
  9446. if err != nil {
  9447. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9448. }
  9449. return oldValue.IsVip, nil
  9450. }
  9451. // AddIsVip adds i to the "is_vip" field.
  9452. func (m *EmployeeMutation) AddIsVip(i int) {
  9453. if m.addis_vip != nil {
  9454. *m.addis_vip += i
  9455. } else {
  9456. m.addis_vip = &i
  9457. }
  9458. }
  9459. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9460. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9461. v := m.addis_vip
  9462. if v == nil {
  9463. return
  9464. }
  9465. return *v, true
  9466. }
  9467. // ResetIsVip resets all changes to the "is_vip" field.
  9468. func (m *EmployeeMutation) ResetIsVip() {
  9469. m.is_vip = nil
  9470. m.addis_vip = nil
  9471. }
  9472. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9473. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9474. if m.em_work_experiences == nil {
  9475. m.em_work_experiences = make(map[uint64]struct{})
  9476. }
  9477. for i := range ids {
  9478. m.em_work_experiences[ids[i]] = struct{}{}
  9479. }
  9480. }
  9481. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9482. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9483. m.clearedem_work_experiences = true
  9484. }
  9485. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9486. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9487. return m.clearedem_work_experiences
  9488. }
  9489. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9490. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9491. if m.removedem_work_experiences == nil {
  9492. m.removedem_work_experiences = make(map[uint64]struct{})
  9493. }
  9494. for i := range ids {
  9495. delete(m.em_work_experiences, ids[i])
  9496. m.removedem_work_experiences[ids[i]] = struct{}{}
  9497. }
  9498. }
  9499. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9500. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9501. for id := range m.removedem_work_experiences {
  9502. ids = append(ids, id)
  9503. }
  9504. return
  9505. }
  9506. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9507. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9508. for id := range m.em_work_experiences {
  9509. ids = append(ids, id)
  9510. }
  9511. return
  9512. }
  9513. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9514. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9515. m.em_work_experiences = nil
  9516. m.clearedem_work_experiences = false
  9517. m.removedem_work_experiences = nil
  9518. }
  9519. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9520. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9521. if m.em_tutorial == nil {
  9522. m.em_tutorial = make(map[uint64]struct{})
  9523. }
  9524. for i := range ids {
  9525. m.em_tutorial[ids[i]] = struct{}{}
  9526. }
  9527. }
  9528. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9529. func (m *EmployeeMutation) ClearEmTutorial() {
  9530. m.clearedem_tutorial = true
  9531. }
  9532. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9533. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9534. return m.clearedem_tutorial
  9535. }
  9536. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9537. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9538. if m.removedem_tutorial == nil {
  9539. m.removedem_tutorial = make(map[uint64]struct{})
  9540. }
  9541. for i := range ids {
  9542. delete(m.em_tutorial, ids[i])
  9543. m.removedem_tutorial[ids[i]] = struct{}{}
  9544. }
  9545. }
  9546. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9547. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9548. for id := range m.removedem_tutorial {
  9549. ids = append(ids, id)
  9550. }
  9551. return
  9552. }
  9553. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9554. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9555. for id := range m.em_tutorial {
  9556. ids = append(ids, id)
  9557. }
  9558. return
  9559. }
  9560. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9561. func (m *EmployeeMutation) ResetEmTutorial() {
  9562. m.em_tutorial = nil
  9563. m.clearedem_tutorial = false
  9564. m.removedem_tutorial = nil
  9565. }
  9566. // Where appends a list predicates to the EmployeeMutation builder.
  9567. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9568. m.predicates = append(m.predicates, ps...)
  9569. }
  9570. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9571. // users can use type-assertion to append predicates that do not depend on any generated package.
  9572. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9573. p := make([]predicate.Employee, len(ps))
  9574. for i := range ps {
  9575. p[i] = ps[i]
  9576. }
  9577. m.Where(p...)
  9578. }
  9579. // Op returns the operation name.
  9580. func (m *EmployeeMutation) Op() Op {
  9581. return m.op
  9582. }
  9583. // SetOp allows setting the mutation operation.
  9584. func (m *EmployeeMutation) SetOp(op Op) {
  9585. m.op = op
  9586. }
  9587. // Type returns the node type of this mutation (Employee).
  9588. func (m *EmployeeMutation) Type() string {
  9589. return m.typ
  9590. }
  9591. // Fields returns all fields that were changed during this mutation. Note that in
  9592. // order to get all numeric fields that were incremented/decremented, call
  9593. // AddedFields().
  9594. func (m *EmployeeMutation) Fields() []string {
  9595. fields := make([]string, 0, 22)
  9596. if m.created_at != nil {
  9597. fields = append(fields, employee.FieldCreatedAt)
  9598. }
  9599. if m.updated_at != nil {
  9600. fields = append(fields, employee.FieldUpdatedAt)
  9601. }
  9602. if m.deleted_at != nil {
  9603. fields = append(fields, employee.FieldDeletedAt)
  9604. }
  9605. if m.title != nil {
  9606. fields = append(fields, employee.FieldTitle)
  9607. }
  9608. if m.avatar != nil {
  9609. fields = append(fields, employee.FieldAvatar)
  9610. }
  9611. if m.tags != nil {
  9612. fields = append(fields, employee.FieldTags)
  9613. }
  9614. if m.hire_count != nil {
  9615. fields = append(fields, employee.FieldHireCount)
  9616. }
  9617. if m.service_count != nil {
  9618. fields = append(fields, employee.FieldServiceCount)
  9619. }
  9620. if m.achievement_count != nil {
  9621. fields = append(fields, employee.FieldAchievementCount)
  9622. }
  9623. if m.intro != nil {
  9624. fields = append(fields, employee.FieldIntro)
  9625. }
  9626. if m.estimate != nil {
  9627. fields = append(fields, employee.FieldEstimate)
  9628. }
  9629. if m.skill != nil {
  9630. fields = append(fields, employee.FieldSkill)
  9631. }
  9632. if m.ability_type != nil {
  9633. fields = append(fields, employee.FieldAbilityType)
  9634. }
  9635. if m.scene != nil {
  9636. fields = append(fields, employee.FieldScene)
  9637. }
  9638. if m.switch_in != nil {
  9639. fields = append(fields, employee.FieldSwitchIn)
  9640. }
  9641. if m.video_url != nil {
  9642. fields = append(fields, employee.FieldVideoURL)
  9643. }
  9644. if m.organization_id != nil {
  9645. fields = append(fields, employee.FieldOrganizationID)
  9646. }
  9647. if m.category_id != nil {
  9648. fields = append(fields, employee.FieldCategoryID)
  9649. }
  9650. if m.api_base != nil {
  9651. fields = append(fields, employee.FieldAPIBase)
  9652. }
  9653. if m.api_key != nil {
  9654. fields = append(fields, employee.FieldAPIKey)
  9655. }
  9656. if m.ai_info != nil {
  9657. fields = append(fields, employee.FieldAiInfo)
  9658. }
  9659. if m.is_vip != nil {
  9660. fields = append(fields, employee.FieldIsVip)
  9661. }
  9662. return fields
  9663. }
  9664. // Field returns the value of a field with the given name. The second boolean
  9665. // return value indicates that this field was not set, or was not defined in the
  9666. // schema.
  9667. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9668. switch name {
  9669. case employee.FieldCreatedAt:
  9670. return m.CreatedAt()
  9671. case employee.FieldUpdatedAt:
  9672. return m.UpdatedAt()
  9673. case employee.FieldDeletedAt:
  9674. return m.DeletedAt()
  9675. case employee.FieldTitle:
  9676. return m.Title()
  9677. case employee.FieldAvatar:
  9678. return m.Avatar()
  9679. case employee.FieldTags:
  9680. return m.Tags()
  9681. case employee.FieldHireCount:
  9682. return m.HireCount()
  9683. case employee.FieldServiceCount:
  9684. return m.ServiceCount()
  9685. case employee.FieldAchievementCount:
  9686. return m.AchievementCount()
  9687. case employee.FieldIntro:
  9688. return m.Intro()
  9689. case employee.FieldEstimate:
  9690. return m.Estimate()
  9691. case employee.FieldSkill:
  9692. return m.Skill()
  9693. case employee.FieldAbilityType:
  9694. return m.AbilityType()
  9695. case employee.FieldScene:
  9696. return m.Scene()
  9697. case employee.FieldSwitchIn:
  9698. return m.SwitchIn()
  9699. case employee.FieldVideoURL:
  9700. return m.VideoURL()
  9701. case employee.FieldOrganizationID:
  9702. return m.OrganizationID()
  9703. case employee.FieldCategoryID:
  9704. return m.CategoryID()
  9705. case employee.FieldAPIBase:
  9706. return m.APIBase()
  9707. case employee.FieldAPIKey:
  9708. return m.APIKey()
  9709. case employee.FieldAiInfo:
  9710. return m.AiInfo()
  9711. case employee.FieldIsVip:
  9712. return m.IsVip()
  9713. }
  9714. return nil, false
  9715. }
  9716. // OldField returns the old value of the field from the database. An error is
  9717. // returned if the mutation operation is not UpdateOne, or the query to the
  9718. // database failed.
  9719. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9720. switch name {
  9721. case employee.FieldCreatedAt:
  9722. return m.OldCreatedAt(ctx)
  9723. case employee.FieldUpdatedAt:
  9724. return m.OldUpdatedAt(ctx)
  9725. case employee.FieldDeletedAt:
  9726. return m.OldDeletedAt(ctx)
  9727. case employee.FieldTitle:
  9728. return m.OldTitle(ctx)
  9729. case employee.FieldAvatar:
  9730. return m.OldAvatar(ctx)
  9731. case employee.FieldTags:
  9732. return m.OldTags(ctx)
  9733. case employee.FieldHireCount:
  9734. return m.OldHireCount(ctx)
  9735. case employee.FieldServiceCount:
  9736. return m.OldServiceCount(ctx)
  9737. case employee.FieldAchievementCount:
  9738. return m.OldAchievementCount(ctx)
  9739. case employee.FieldIntro:
  9740. return m.OldIntro(ctx)
  9741. case employee.FieldEstimate:
  9742. return m.OldEstimate(ctx)
  9743. case employee.FieldSkill:
  9744. return m.OldSkill(ctx)
  9745. case employee.FieldAbilityType:
  9746. return m.OldAbilityType(ctx)
  9747. case employee.FieldScene:
  9748. return m.OldScene(ctx)
  9749. case employee.FieldSwitchIn:
  9750. return m.OldSwitchIn(ctx)
  9751. case employee.FieldVideoURL:
  9752. return m.OldVideoURL(ctx)
  9753. case employee.FieldOrganizationID:
  9754. return m.OldOrganizationID(ctx)
  9755. case employee.FieldCategoryID:
  9756. return m.OldCategoryID(ctx)
  9757. case employee.FieldAPIBase:
  9758. return m.OldAPIBase(ctx)
  9759. case employee.FieldAPIKey:
  9760. return m.OldAPIKey(ctx)
  9761. case employee.FieldAiInfo:
  9762. return m.OldAiInfo(ctx)
  9763. case employee.FieldIsVip:
  9764. return m.OldIsVip(ctx)
  9765. }
  9766. return nil, fmt.Errorf("unknown Employee field %s", name)
  9767. }
  9768. // SetField sets the value of a field with the given name. It returns an error if
  9769. // the field is not defined in the schema, or if the type mismatched the field
  9770. // type.
  9771. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9772. switch name {
  9773. case employee.FieldCreatedAt:
  9774. v, ok := value.(time.Time)
  9775. if !ok {
  9776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9777. }
  9778. m.SetCreatedAt(v)
  9779. return nil
  9780. case employee.FieldUpdatedAt:
  9781. v, ok := value.(time.Time)
  9782. if !ok {
  9783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9784. }
  9785. m.SetUpdatedAt(v)
  9786. return nil
  9787. case employee.FieldDeletedAt:
  9788. v, ok := value.(time.Time)
  9789. if !ok {
  9790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9791. }
  9792. m.SetDeletedAt(v)
  9793. return nil
  9794. case employee.FieldTitle:
  9795. v, ok := value.(string)
  9796. if !ok {
  9797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9798. }
  9799. m.SetTitle(v)
  9800. return nil
  9801. case employee.FieldAvatar:
  9802. v, ok := value.(string)
  9803. if !ok {
  9804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9805. }
  9806. m.SetAvatar(v)
  9807. return nil
  9808. case employee.FieldTags:
  9809. v, ok := value.(string)
  9810. if !ok {
  9811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9812. }
  9813. m.SetTags(v)
  9814. return nil
  9815. case employee.FieldHireCount:
  9816. v, ok := value.(int)
  9817. if !ok {
  9818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9819. }
  9820. m.SetHireCount(v)
  9821. return nil
  9822. case employee.FieldServiceCount:
  9823. v, ok := value.(int)
  9824. if !ok {
  9825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9826. }
  9827. m.SetServiceCount(v)
  9828. return nil
  9829. case employee.FieldAchievementCount:
  9830. v, ok := value.(int)
  9831. if !ok {
  9832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9833. }
  9834. m.SetAchievementCount(v)
  9835. return nil
  9836. case employee.FieldIntro:
  9837. v, ok := value.(string)
  9838. if !ok {
  9839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9840. }
  9841. m.SetIntro(v)
  9842. return nil
  9843. case employee.FieldEstimate:
  9844. v, ok := value.(string)
  9845. if !ok {
  9846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9847. }
  9848. m.SetEstimate(v)
  9849. return nil
  9850. case employee.FieldSkill:
  9851. v, ok := value.(string)
  9852. if !ok {
  9853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9854. }
  9855. m.SetSkill(v)
  9856. return nil
  9857. case employee.FieldAbilityType:
  9858. v, ok := value.(string)
  9859. if !ok {
  9860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9861. }
  9862. m.SetAbilityType(v)
  9863. return nil
  9864. case employee.FieldScene:
  9865. v, ok := value.(string)
  9866. if !ok {
  9867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9868. }
  9869. m.SetScene(v)
  9870. return nil
  9871. case employee.FieldSwitchIn:
  9872. v, ok := value.(string)
  9873. if !ok {
  9874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9875. }
  9876. m.SetSwitchIn(v)
  9877. return nil
  9878. case employee.FieldVideoURL:
  9879. v, ok := value.(string)
  9880. if !ok {
  9881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9882. }
  9883. m.SetVideoURL(v)
  9884. return nil
  9885. case employee.FieldOrganizationID:
  9886. v, ok := value.(uint64)
  9887. if !ok {
  9888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9889. }
  9890. m.SetOrganizationID(v)
  9891. return nil
  9892. case employee.FieldCategoryID:
  9893. v, ok := value.(uint64)
  9894. if !ok {
  9895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9896. }
  9897. m.SetCategoryID(v)
  9898. return nil
  9899. case employee.FieldAPIBase:
  9900. v, ok := value.(string)
  9901. if !ok {
  9902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9903. }
  9904. m.SetAPIBase(v)
  9905. return nil
  9906. case employee.FieldAPIKey:
  9907. v, ok := value.(string)
  9908. if !ok {
  9909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9910. }
  9911. m.SetAPIKey(v)
  9912. return nil
  9913. case employee.FieldAiInfo:
  9914. v, ok := value.(string)
  9915. if !ok {
  9916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9917. }
  9918. m.SetAiInfo(v)
  9919. return nil
  9920. case employee.FieldIsVip:
  9921. v, ok := value.(int)
  9922. if !ok {
  9923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9924. }
  9925. m.SetIsVip(v)
  9926. return nil
  9927. }
  9928. return fmt.Errorf("unknown Employee field %s", name)
  9929. }
  9930. // AddedFields returns all numeric fields that were incremented/decremented during
  9931. // this mutation.
  9932. func (m *EmployeeMutation) AddedFields() []string {
  9933. var fields []string
  9934. if m.addhire_count != nil {
  9935. fields = append(fields, employee.FieldHireCount)
  9936. }
  9937. if m.addservice_count != nil {
  9938. fields = append(fields, employee.FieldServiceCount)
  9939. }
  9940. if m.addachievement_count != nil {
  9941. fields = append(fields, employee.FieldAchievementCount)
  9942. }
  9943. if m.addorganization_id != nil {
  9944. fields = append(fields, employee.FieldOrganizationID)
  9945. }
  9946. if m.addcategory_id != nil {
  9947. fields = append(fields, employee.FieldCategoryID)
  9948. }
  9949. if m.addis_vip != nil {
  9950. fields = append(fields, employee.FieldIsVip)
  9951. }
  9952. return fields
  9953. }
  9954. // AddedField returns the numeric value that was incremented/decremented on a field
  9955. // with the given name. The second boolean return value indicates that this field
  9956. // was not set, or was not defined in the schema.
  9957. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  9958. switch name {
  9959. case employee.FieldHireCount:
  9960. return m.AddedHireCount()
  9961. case employee.FieldServiceCount:
  9962. return m.AddedServiceCount()
  9963. case employee.FieldAchievementCount:
  9964. return m.AddedAchievementCount()
  9965. case employee.FieldOrganizationID:
  9966. return m.AddedOrganizationID()
  9967. case employee.FieldCategoryID:
  9968. return m.AddedCategoryID()
  9969. case employee.FieldIsVip:
  9970. return m.AddedIsVip()
  9971. }
  9972. return nil, false
  9973. }
  9974. // AddField adds the value to the field with the given name. It returns an error if
  9975. // the field is not defined in the schema, or if the type mismatched the field
  9976. // type.
  9977. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  9978. switch name {
  9979. case employee.FieldHireCount:
  9980. v, ok := value.(int)
  9981. if !ok {
  9982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9983. }
  9984. m.AddHireCount(v)
  9985. return nil
  9986. case employee.FieldServiceCount:
  9987. v, ok := value.(int)
  9988. if !ok {
  9989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9990. }
  9991. m.AddServiceCount(v)
  9992. return nil
  9993. case employee.FieldAchievementCount:
  9994. v, ok := value.(int)
  9995. if !ok {
  9996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9997. }
  9998. m.AddAchievementCount(v)
  9999. return nil
  10000. case employee.FieldOrganizationID:
  10001. v, ok := value.(int64)
  10002. if !ok {
  10003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10004. }
  10005. m.AddOrganizationID(v)
  10006. return nil
  10007. case employee.FieldCategoryID:
  10008. v, ok := value.(int64)
  10009. if !ok {
  10010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10011. }
  10012. m.AddCategoryID(v)
  10013. return nil
  10014. case employee.FieldIsVip:
  10015. v, ok := value.(int)
  10016. if !ok {
  10017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10018. }
  10019. m.AddIsVip(v)
  10020. return nil
  10021. }
  10022. return fmt.Errorf("unknown Employee numeric field %s", name)
  10023. }
  10024. // ClearedFields returns all nullable fields that were cleared during this
  10025. // mutation.
  10026. func (m *EmployeeMutation) ClearedFields() []string {
  10027. var fields []string
  10028. if m.FieldCleared(employee.FieldDeletedAt) {
  10029. fields = append(fields, employee.FieldDeletedAt)
  10030. }
  10031. if m.FieldCleared(employee.FieldAiInfo) {
  10032. fields = append(fields, employee.FieldAiInfo)
  10033. }
  10034. return fields
  10035. }
  10036. // FieldCleared returns a boolean indicating if a field with the given name was
  10037. // cleared in this mutation.
  10038. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10039. _, ok := m.clearedFields[name]
  10040. return ok
  10041. }
  10042. // ClearField clears the value of the field with the given name. It returns an
  10043. // error if the field is not defined in the schema.
  10044. func (m *EmployeeMutation) ClearField(name string) error {
  10045. switch name {
  10046. case employee.FieldDeletedAt:
  10047. m.ClearDeletedAt()
  10048. return nil
  10049. case employee.FieldAiInfo:
  10050. m.ClearAiInfo()
  10051. return nil
  10052. }
  10053. return fmt.Errorf("unknown Employee nullable field %s", name)
  10054. }
  10055. // ResetField resets all changes in the mutation for the field with the given name.
  10056. // It returns an error if the field is not defined in the schema.
  10057. func (m *EmployeeMutation) ResetField(name string) error {
  10058. switch name {
  10059. case employee.FieldCreatedAt:
  10060. m.ResetCreatedAt()
  10061. return nil
  10062. case employee.FieldUpdatedAt:
  10063. m.ResetUpdatedAt()
  10064. return nil
  10065. case employee.FieldDeletedAt:
  10066. m.ResetDeletedAt()
  10067. return nil
  10068. case employee.FieldTitle:
  10069. m.ResetTitle()
  10070. return nil
  10071. case employee.FieldAvatar:
  10072. m.ResetAvatar()
  10073. return nil
  10074. case employee.FieldTags:
  10075. m.ResetTags()
  10076. return nil
  10077. case employee.FieldHireCount:
  10078. m.ResetHireCount()
  10079. return nil
  10080. case employee.FieldServiceCount:
  10081. m.ResetServiceCount()
  10082. return nil
  10083. case employee.FieldAchievementCount:
  10084. m.ResetAchievementCount()
  10085. return nil
  10086. case employee.FieldIntro:
  10087. m.ResetIntro()
  10088. return nil
  10089. case employee.FieldEstimate:
  10090. m.ResetEstimate()
  10091. return nil
  10092. case employee.FieldSkill:
  10093. m.ResetSkill()
  10094. return nil
  10095. case employee.FieldAbilityType:
  10096. m.ResetAbilityType()
  10097. return nil
  10098. case employee.FieldScene:
  10099. m.ResetScene()
  10100. return nil
  10101. case employee.FieldSwitchIn:
  10102. m.ResetSwitchIn()
  10103. return nil
  10104. case employee.FieldVideoURL:
  10105. m.ResetVideoURL()
  10106. return nil
  10107. case employee.FieldOrganizationID:
  10108. m.ResetOrganizationID()
  10109. return nil
  10110. case employee.FieldCategoryID:
  10111. m.ResetCategoryID()
  10112. return nil
  10113. case employee.FieldAPIBase:
  10114. m.ResetAPIBase()
  10115. return nil
  10116. case employee.FieldAPIKey:
  10117. m.ResetAPIKey()
  10118. return nil
  10119. case employee.FieldAiInfo:
  10120. m.ResetAiInfo()
  10121. return nil
  10122. case employee.FieldIsVip:
  10123. m.ResetIsVip()
  10124. return nil
  10125. }
  10126. return fmt.Errorf("unknown Employee field %s", name)
  10127. }
  10128. // AddedEdges returns all edge names that were set/added in this mutation.
  10129. func (m *EmployeeMutation) AddedEdges() []string {
  10130. edges := make([]string, 0, 2)
  10131. if m.em_work_experiences != nil {
  10132. edges = append(edges, employee.EdgeEmWorkExperiences)
  10133. }
  10134. if m.em_tutorial != nil {
  10135. edges = append(edges, employee.EdgeEmTutorial)
  10136. }
  10137. return edges
  10138. }
  10139. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10140. // name in this mutation.
  10141. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10142. switch name {
  10143. case employee.EdgeEmWorkExperiences:
  10144. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10145. for id := range m.em_work_experiences {
  10146. ids = append(ids, id)
  10147. }
  10148. return ids
  10149. case employee.EdgeEmTutorial:
  10150. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10151. for id := range m.em_tutorial {
  10152. ids = append(ids, id)
  10153. }
  10154. return ids
  10155. }
  10156. return nil
  10157. }
  10158. // RemovedEdges returns all edge names that were removed in this mutation.
  10159. func (m *EmployeeMutation) RemovedEdges() []string {
  10160. edges := make([]string, 0, 2)
  10161. if m.removedem_work_experiences != nil {
  10162. edges = append(edges, employee.EdgeEmWorkExperiences)
  10163. }
  10164. if m.removedem_tutorial != nil {
  10165. edges = append(edges, employee.EdgeEmTutorial)
  10166. }
  10167. return edges
  10168. }
  10169. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10170. // the given name in this mutation.
  10171. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10172. switch name {
  10173. case employee.EdgeEmWorkExperiences:
  10174. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10175. for id := range m.removedem_work_experiences {
  10176. ids = append(ids, id)
  10177. }
  10178. return ids
  10179. case employee.EdgeEmTutorial:
  10180. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10181. for id := range m.removedem_tutorial {
  10182. ids = append(ids, id)
  10183. }
  10184. return ids
  10185. }
  10186. return nil
  10187. }
  10188. // ClearedEdges returns all edge names that were cleared in this mutation.
  10189. func (m *EmployeeMutation) ClearedEdges() []string {
  10190. edges := make([]string, 0, 2)
  10191. if m.clearedem_work_experiences {
  10192. edges = append(edges, employee.EdgeEmWorkExperiences)
  10193. }
  10194. if m.clearedem_tutorial {
  10195. edges = append(edges, employee.EdgeEmTutorial)
  10196. }
  10197. return edges
  10198. }
  10199. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10200. // was cleared in this mutation.
  10201. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10202. switch name {
  10203. case employee.EdgeEmWorkExperiences:
  10204. return m.clearedem_work_experiences
  10205. case employee.EdgeEmTutorial:
  10206. return m.clearedem_tutorial
  10207. }
  10208. return false
  10209. }
  10210. // ClearEdge clears the value of the edge with the given name. It returns an error
  10211. // if that edge is not defined in the schema.
  10212. func (m *EmployeeMutation) ClearEdge(name string) error {
  10213. switch name {
  10214. }
  10215. return fmt.Errorf("unknown Employee unique edge %s", name)
  10216. }
  10217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10218. // It returns an error if the edge is not defined in the schema.
  10219. func (m *EmployeeMutation) ResetEdge(name string) error {
  10220. switch name {
  10221. case employee.EdgeEmWorkExperiences:
  10222. m.ResetEmWorkExperiences()
  10223. return nil
  10224. case employee.EdgeEmTutorial:
  10225. m.ResetEmTutorial()
  10226. return nil
  10227. }
  10228. return fmt.Errorf("unknown Employee edge %s", name)
  10229. }
  10230. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10231. type EmployeeConfigMutation struct {
  10232. config
  10233. op Op
  10234. typ string
  10235. id *uint64
  10236. created_at *time.Time
  10237. updated_at *time.Time
  10238. deleted_at *time.Time
  10239. stype *string
  10240. title *string
  10241. photo *string
  10242. organization_id *uint64
  10243. addorganization_id *int64
  10244. clearedFields map[string]struct{}
  10245. done bool
  10246. oldValue func(context.Context) (*EmployeeConfig, error)
  10247. predicates []predicate.EmployeeConfig
  10248. }
  10249. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10250. // employeeconfigOption allows management of the mutation configuration using functional options.
  10251. type employeeconfigOption func(*EmployeeConfigMutation)
  10252. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10253. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10254. m := &EmployeeConfigMutation{
  10255. config: c,
  10256. op: op,
  10257. typ: TypeEmployeeConfig,
  10258. clearedFields: make(map[string]struct{}),
  10259. }
  10260. for _, opt := range opts {
  10261. opt(m)
  10262. }
  10263. return m
  10264. }
  10265. // withEmployeeConfigID sets the ID field of the mutation.
  10266. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10267. return func(m *EmployeeConfigMutation) {
  10268. var (
  10269. err error
  10270. once sync.Once
  10271. value *EmployeeConfig
  10272. )
  10273. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10274. once.Do(func() {
  10275. if m.done {
  10276. err = errors.New("querying old values post mutation is not allowed")
  10277. } else {
  10278. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10279. }
  10280. })
  10281. return value, err
  10282. }
  10283. m.id = &id
  10284. }
  10285. }
  10286. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10287. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10288. return func(m *EmployeeConfigMutation) {
  10289. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10290. return node, nil
  10291. }
  10292. m.id = &node.ID
  10293. }
  10294. }
  10295. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10296. // executed in a transaction (ent.Tx), a transactional client is returned.
  10297. func (m EmployeeConfigMutation) Client() *Client {
  10298. client := &Client{config: m.config}
  10299. client.init()
  10300. return client
  10301. }
  10302. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10303. // it returns an error otherwise.
  10304. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10305. if _, ok := m.driver.(*txDriver); !ok {
  10306. return nil, errors.New("ent: mutation is not running in a transaction")
  10307. }
  10308. tx := &Tx{config: m.config}
  10309. tx.init()
  10310. return tx, nil
  10311. }
  10312. // SetID sets the value of the id field. Note that this
  10313. // operation is only accepted on creation of EmployeeConfig entities.
  10314. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10315. m.id = &id
  10316. }
  10317. // ID returns the ID value in the mutation. Note that the ID is only available
  10318. // if it was provided to the builder or after it was returned from the database.
  10319. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10320. if m.id == nil {
  10321. return
  10322. }
  10323. return *m.id, true
  10324. }
  10325. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10326. // That means, if the mutation is applied within a transaction with an isolation level such
  10327. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10328. // or updated by the mutation.
  10329. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10330. switch {
  10331. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10332. id, exists := m.ID()
  10333. if exists {
  10334. return []uint64{id}, nil
  10335. }
  10336. fallthrough
  10337. case m.op.Is(OpUpdate | OpDelete):
  10338. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10339. default:
  10340. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10341. }
  10342. }
  10343. // SetCreatedAt sets the "created_at" field.
  10344. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10345. m.created_at = &t
  10346. }
  10347. // CreatedAt returns the value of the "created_at" field in the mutation.
  10348. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10349. v := m.created_at
  10350. if v == nil {
  10351. return
  10352. }
  10353. return *v, true
  10354. }
  10355. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10356. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10358. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10359. if !m.op.Is(OpUpdateOne) {
  10360. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10361. }
  10362. if m.id == nil || m.oldValue == nil {
  10363. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10364. }
  10365. oldValue, err := m.oldValue(ctx)
  10366. if err != nil {
  10367. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10368. }
  10369. return oldValue.CreatedAt, nil
  10370. }
  10371. // ResetCreatedAt resets all changes to the "created_at" field.
  10372. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10373. m.created_at = nil
  10374. }
  10375. // SetUpdatedAt sets the "updated_at" field.
  10376. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10377. m.updated_at = &t
  10378. }
  10379. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10380. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10381. v := m.updated_at
  10382. if v == nil {
  10383. return
  10384. }
  10385. return *v, true
  10386. }
  10387. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10388. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10390. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10391. if !m.op.Is(OpUpdateOne) {
  10392. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10393. }
  10394. if m.id == nil || m.oldValue == nil {
  10395. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10396. }
  10397. oldValue, err := m.oldValue(ctx)
  10398. if err != nil {
  10399. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10400. }
  10401. return oldValue.UpdatedAt, nil
  10402. }
  10403. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10404. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10405. m.updated_at = nil
  10406. }
  10407. // SetDeletedAt sets the "deleted_at" field.
  10408. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10409. m.deleted_at = &t
  10410. }
  10411. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10412. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10413. v := m.deleted_at
  10414. if v == nil {
  10415. return
  10416. }
  10417. return *v, true
  10418. }
  10419. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10420. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10422. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10423. if !m.op.Is(OpUpdateOne) {
  10424. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10425. }
  10426. if m.id == nil || m.oldValue == nil {
  10427. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10428. }
  10429. oldValue, err := m.oldValue(ctx)
  10430. if err != nil {
  10431. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10432. }
  10433. return oldValue.DeletedAt, nil
  10434. }
  10435. // ClearDeletedAt clears the value of the "deleted_at" field.
  10436. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10437. m.deleted_at = nil
  10438. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10439. }
  10440. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10441. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10442. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10443. return ok
  10444. }
  10445. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10446. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10447. m.deleted_at = nil
  10448. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10449. }
  10450. // SetStype sets the "stype" field.
  10451. func (m *EmployeeConfigMutation) SetStype(s string) {
  10452. m.stype = &s
  10453. }
  10454. // Stype returns the value of the "stype" field in the mutation.
  10455. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10456. v := m.stype
  10457. if v == nil {
  10458. return
  10459. }
  10460. return *v, true
  10461. }
  10462. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10463. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10465. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10466. if !m.op.Is(OpUpdateOne) {
  10467. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10468. }
  10469. if m.id == nil || m.oldValue == nil {
  10470. return v, errors.New("OldStype requires an ID field in the mutation")
  10471. }
  10472. oldValue, err := m.oldValue(ctx)
  10473. if err != nil {
  10474. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10475. }
  10476. return oldValue.Stype, nil
  10477. }
  10478. // ResetStype resets all changes to the "stype" field.
  10479. func (m *EmployeeConfigMutation) ResetStype() {
  10480. m.stype = nil
  10481. }
  10482. // SetTitle sets the "title" field.
  10483. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10484. m.title = &s
  10485. }
  10486. // Title returns the value of the "title" field in the mutation.
  10487. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10488. v := m.title
  10489. if v == nil {
  10490. return
  10491. }
  10492. return *v, true
  10493. }
  10494. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10495. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10497. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10498. if !m.op.Is(OpUpdateOne) {
  10499. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10500. }
  10501. if m.id == nil || m.oldValue == nil {
  10502. return v, errors.New("OldTitle requires an ID field in the mutation")
  10503. }
  10504. oldValue, err := m.oldValue(ctx)
  10505. if err != nil {
  10506. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10507. }
  10508. return oldValue.Title, nil
  10509. }
  10510. // ResetTitle resets all changes to the "title" field.
  10511. func (m *EmployeeConfigMutation) ResetTitle() {
  10512. m.title = nil
  10513. }
  10514. // SetPhoto sets the "photo" field.
  10515. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10516. m.photo = &s
  10517. }
  10518. // Photo returns the value of the "photo" field in the mutation.
  10519. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10520. v := m.photo
  10521. if v == nil {
  10522. return
  10523. }
  10524. return *v, true
  10525. }
  10526. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10527. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10529. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10530. if !m.op.Is(OpUpdateOne) {
  10531. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10532. }
  10533. if m.id == nil || m.oldValue == nil {
  10534. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10535. }
  10536. oldValue, err := m.oldValue(ctx)
  10537. if err != nil {
  10538. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10539. }
  10540. return oldValue.Photo, nil
  10541. }
  10542. // ResetPhoto resets all changes to the "photo" field.
  10543. func (m *EmployeeConfigMutation) ResetPhoto() {
  10544. m.photo = nil
  10545. }
  10546. // SetOrganizationID sets the "organization_id" field.
  10547. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10548. m.organization_id = &u
  10549. m.addorganization_id = nil
  10550. }
  10551. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10552. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10553. v := m.organization_id
  10554. if v == nil {
  10555. return
  10556. }
  10557. return *v, true
  10558. }
  10559. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10560. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10562. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10563. if !m.op.Is(OpUpdateOne) {
  10564. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10565. }
  10566. if m.id == nil || m.oldValue == nil {
  10567. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10568. }
  10569. oldValue, err := m.oldValue(ctx)
  10570. if err != nil {
  10571. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10572. }
  10573. return oldValue.OrganizationID, nil
  10574. }
  10575. // AddOrganizationID adds u to the "organization_id" field.
  10576. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10577. if m.addorganization_id != nil {
  10578. *m.addorganization_id += u
  10579. } else {
  10580. m.addorganization_id = &u
  10581. }
  10582. }
  10583. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10584. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10585. v := m.addorganization_id
  10586. if v == nil {
  10587. return
  10588. }
  10589. return *v, true
  10590. }
  10591. // ClearOrganizationID clears the value of the "organization_id" field.
  10592. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10593. m.organization_id = nil
  10594. m.addorganization_id = nil
  10595. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10596. }
  10597. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10598. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10599. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10600. return ok
  10601. }
  10602. // ResetOrganizationID resets all changes to the "organization_id" field.
  10603. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10604. m.organization_id = nil
  10605. m.addorganization_id = nil
  10606. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10607. }
  10608. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10609. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10610. m.predicates = append(m.predicates, ps...)
  10611. }
  10612. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10613. // users can use type-assertion to append predicates that do not depend on any generated package.
  10614. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10615. p := make([]predicate.EmployeeConfig, len(ps))
  10616. for i := range ps {
  10617. p[i] = ps[i]
  10618. }
  10619. m.Where(p...)
  10620. }
  10621. // Op returns the operation name.
  10622. func (m *EmployeeConfigMutation) Op() Op {
  10623. return m.op
  10624. }
  10625. // SetOp allows setting the mutation operation.
  10626. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10627. m.op = op
  10628. }
  10629. // Type returns the node type of this mutation (EmployeeConfig).
  10630. func (m *EmployeeConfigMutation) Type() string {
  10631. return m.typ
  10632. }
  10633. // Fields returns all fields that were changed during this mutation. Note that in
  10634. // order to get all numeric fields that were incremented/decremented, call
  10635. // AddedFields().
  10636. func (m *EmployeeConfigMutation) Fields() []string {
  10637. fields := make([]string, 0, 7)
  10638. if m.created_at != nil {
  10639. fields = append(fields, employeeconfig.FieldCreatedAt)
  10640. }
  10641. if m.updated_at != nil {
  10642. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10643. }
  10644. if m.deleted_at != nil {
  10645. fields = append(fields, employeeconfig.FieldDeletedAt)
  10646. }
  10647. if m.stype != nil {
  10648. fields = append(fields, employeeconfig.FieldStype)
  10649. }
  10650. if m.title != nil {
  10651. fields = append(fields, employeeconfig.FieldTitle)
  10652. }
  10653. if m.photo != nil {
  10654. fields = append(fields, employeeconfig.FieldPhoto)
  10655. }
  10656. if m.organization_id != nil {
  10657. fields = append(fields, employeeconfig.FieldOrganizationID)
  10658. }
  10659. return fields
  10660. }
  10661. // Field returns the value of a field with the given name. The second boolean
  10662. // return value indicates that this field was not set, or was not defined in the
  10663. // schema.
  10664. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10665. switch name {
  10666. case employeeconfig.FieldCreatedAt:
  10667. return m.CreatedAt()
  10668. case employeeconfig.FieldUpdatedAt:
  10669. return m.UpdatedAt()
  10670. case employeeconfig.FieldDeletedAt:
  10671. return m.DeletedAt()
  10672. case employeeconfig.FieldStype:
  10673. return m.Stype()
  10674. case employeeconfig.FieldTitle:
  10675. return m.Title()
  10676. case employeeconfig.FieldPhoto:
  10677. return m.Photo()
  10678. case employeeconfig.FieldOrganizationID:
  10679. return m.OrganizationID()
  10680. }
  10681. return nil, false
  10682. }
  10683. // OldField returns the old value of the field from the database. An error is
  10684. // returned if the mutation operation is not UpdateOne, or the query to the
  10685. // database failed.
  10686. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10687. switch name {
  10688. case employeeconfig.FieldCreatedAt:
  10689. return m.OldCreatedAt(ctx)
  10690. case employeeconfig.FieldUpdatedAt:
  10691. return m.OldUpdatedAt(ctx)
  10692. case employeeconfig.FieldDeletedAt:
  10693. return m.OldDeletedAt(ctx)
  10694. case employeeconfig.FieldStype:
  10695. return m.OldStype(ctx)
  10696. case employeeconfig.FieldTitle:
  10697. return m.OldTitle(ctx)
  10698. case employeeconfig.FieldPhoto:
  10699. return m.OldPhoto(ctx)
  10700. case employeeconfig.FieldOrganizationID:
  10701. return m.OldOrganizationID(ctx)
  10702. }
  10703. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10704. }
  10705. // SetField sets the value of a field with the given name. It returns an error if
  10706. // the field is not defined in the schema, or if the type mismatched the field
  10707. // type.
  10708. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10709. switch name {
  10710. case employeeconfig.FieldCreatedAt:
  10711. v, ok := value.(time.Time)
  10712. if !ok {
  10713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10714. }
  10715. m.SetCreatedAt(v)
  10716. return nil
  10717. case employeeconfig.FieldUpdatedAt:
  10718. v, ok := value.(time.Time)
  10719. if !ok {
  10720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10721. }
  10722. m.SetUpdatedAt(v)
  10723. return nil
  10724. case employeeconfig.FieldDeletedAt:
  10725. v, ok := value.(time.Time)
  10726. if !ok {
  10727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10728. }
  10729. m.SetDeletedAt(v)
  10730. return nil
  10731. case employeeconfig.FieldStype:
  10732. v, ok := value.(string)
  10733. if !ok {
  10734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10735. }
  10736. m.SetStype(v)
  10737. return nil
  10738. case employeeconfig.FieldTitle:
  10739. v, ok := value.(string)
  10740. if !ok {
  10741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10742. }
  10743. m.SetTitle(v)
  10744. return nil
  10745. case employeeconfig.FieldPhoto:
  10746. v, ok := value.(string)
  10747. if !ok {
  10748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10749. }
  10750. m.SetPhoto(v)
  10751. return nil
  10752. case employeeconfig.FieldOrganizationID:
  10753. v, ok := value.(uint64)
  10754. if !ok {
  10755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10756. }
  10757. m.SetOrganizationID(v)
  10758. return nil
  10759. }
  10760. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10761. }
  10762. // AddedFields returns all numeric fields that were incremented/decremented during
  10763. // this mutation.
  10764. func (m *EmployeeConfigMutation) AddedFields() []string {
  10765. var fields []string
  10766. if m.addorganization_id != nil {
  10767. fields = append(fields, employeeconfig.FieldOrganizationID)
  10768. }
  10769. return fields
  10770. }
  10771. // AddedField returns the numeric value that was incremented/decremented on a field
  10772. // with the given name. The second boolean return value indicates that this field
  10773. // was not set, or was not defined in the schema.
  10774. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10775. switch name {
  10776. case employeeconfig.FieldOrganizationID:
  10777. return m.AddedOrganizationID()
  10778. }
  10779. return nil, false
  10780. }
  10781. // AddField adds the value to the field with the given name. It returns an error if
  10782. // the field is not defined in the schema, or if the type mismatched the field
  10783. // type.
  10784. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10785. switch name {
  10786. case employeeconfig.FieldOrganizationID:
  10787. v, ok := value.(int64)
  10788. if !ok {
  10789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10790. }
  10791. m.AddOrganizationID(v)
  10792. return nil
  10793. }
  10794. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10795. }
  10796. // ClearedFields returns all nullable fields that were cleared during this
  10797. // mutation.
  10798. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10799. var fields []string
  10800. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10801. fields = append(fields, employeeconfig.FieldDeletedAt)
  10802. }
  10803. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10804. fields = append(fields, employeeconfig.FieldOrganizationID)
  10805. }
  10806. return fields
  10807. }
  10808. // FieldCleared returns a boolean indicating if a field with the given name was
  10809. // cleared in this mutation.
  10810. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10811. _, ok := m.clearedFields[name]
  10812. return ok
  10813. }
  10814. // ClearField clears the value of the field with the given name. It returns an
  10815. // error if the field is not defined in the schema.
  10816. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10817. switch name {
  10818. case employeeconfig.FieldDeletedAt:
  10819. m.ClearDeletedAt()
  10820. return nil
  10821. case employeeconfig.FieldOrganizationID:
  10822. m.ClearOrganizationID()
  10823. return nil
  10824. }
  10825. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10826. }
  10827. // ResetField resets all changes in the mutation for the field with the given name.
  10828. // It returns an error if the field is not defined in the schema.
  10829. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10830. switch name {
  10831. case employeeconfig.FieldCreatedAt:
  10832. m.ResetCreatedAt()
  10833. return nil
  10834. case employeeconfig.FieldUpdatedAt:
  10835. m.ResetUpdatedAt()
  10836. return nil
  10837. case employeeconfig.FieldDeletedAt:
  10838. m.ResetDeletedAt()
  10839. return nil
  10840. case employeeconfig.FieldStype:
  10841. m.ResetStype()
  10842. return nil
  10843. case employeeconfig.FieldTitle:
  10844. m.ResetTitle()
  10845. return nil
  10846. case employeeconfig.FieldPhoto:
  10847. m.ResetPhoto()
  10848. return nil
  10849. case employeeconfig.FieldOrganizationID:
  10850. m.ResetOrganizationID()
  10851. return nil
  10852. }
  10853. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10854. }
  10855. // AddedEdges returns all edge names that were set/added in this mutation.
  10856. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10857. edges := make([]string, 0, 0)
  10858. return edges
  10859. }
  10860. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10861. // name in this mutation.
  10862. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10863. return nil
  10864. }
  10865. // RemovedEdges returns all edge names that were removed in this mutation.
  10866. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10867. edges := make([]string, 0, 0)
  10868. return edges
  10869. }
  10870. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10871. // the given name in this mutation.
  10872. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10873. return nil
  10874. }
  10875. // ClearedEdges returns all edge names that were cleared in this mutation.
  10876. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10877. edges := make([]string, 0, 0)
  10878. return edges
  10879. }
  10880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10881. // was cleared in this mutation.
  10882. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10883. return false
  10884. }
  10885. // ClearEdge clears the value of the edge with the given name. It returns an error
  10886. // if that edge is not defined in the schema.
  10887. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10888. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10889. }
  10890. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10891. // It returns an error if the edge is not defined in the schema.
  10892. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10893. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10894. }
  10895. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10896. type LabelMutation struct {
  10897. config
  10898. op Op
  10899. typ string
  10900. id *uint64
  10901. created_at *time.Time
  10902. updated_at *time.Time
  10903. status *uint8
  10904. addstatus *int8
  10905. _type *int
  10906. add_type *int
  10907. name *string
  10908. from *int
  10909. addfrom *int
  10910. mode *int
  10911. addmode *int
  10912. conditions *string
  10913. organization_id *uint64
  10914. addorganization_id *int64
  10915. clearedFields map[string]struct{}
  10916. label_relationships map[uint64]struct{}
  10917. removedlabel_relationships map[uint64]struct{}
  10918. clearedlabel_relationships bool
  10919. done bool
  10920. oldValue func(context.Context) (*Label, error)
  10921. predicates []predicate.Label
  10922. }
  10923. var _ ent.Mutation = (*LabelMutation)(nil)
  10924. // labelOption allows management of the mutation configuration using functional options.
  10925. type labelOption func(*LabelMutation)
  10926. // newLabelMutation creates new mutation for the Label entity.
  10927. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10928. m := &LabelMutation{
  10929. config: c,
  10930. op: op,
  10931. typ: TypeLabel,
  10932. clearedFields: make(map[string]struct{}),
  10933. }
  10934. for _, opt := range opts {
  10935. opt(m)
  10936. }
  10937. return m
  10938. }
  10939. // withLabelID sets the ID field of the mutation.
  10940. func withLabelID(id uint64) labelOption {
  10941. return func(m *LabelMutation) {
  10942. var (
  10943. err error
  10944. once sync.Once
  10945. value *Label
  10946. )
  10947. m.oldValue = func(ctx context.Context) (*Label, error) {
  10948. once.Do(func() {
  10949. if m.done {
  10950. err = errors.New("querying old values post mutation is not allowed")
  10951. } else {
  10952. value, err = m.Client().Label.Get(ctx, id)
  10953. }
  10954. })
  10955. return value, err
  10956. }
  10957. m.id = &id
  10958. }
  10959. }
  10960. // withLabel sets the old Label of the mutation.
  10961. func withLabel(node *Label) labelOption {
  10962. return func(m *LabelMutation) {
  10963. m.oldValue = func(context.Context) (*Label, error) {
  10964. return node, nil
  10965. }
  10966. m.id = &node.ID
  10967. }
  10968. }
  10969. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10970. // executed in a transaction (ent.Tx), a transactional client is returned.
  10971. func (m LabelMutation) Client() *Client {
  10972. client := &Client{config: m.config}
  10973. client.init()
  10974. return client
  10975. }
  10976. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10977. // it returns an error otherwise.
  10978. func (m LabelMutation) Tx() (*Tx, error) {
  10979. if _, ok := m.driver.(*txDriver); !ok {
  10980. return nil, errors.New("ent: mutation is not running in a transaction")
  10981. }
  10982. tx := &Tx{config: m.config}
  10983. tx.init()
  10984. return tx, nil
  10985. }
  10986. // SetID sets the value of the id field. Note that this
  10987. // operation is only accepted on creation of Label entities.
  10988. func (m *LabelMutation) SetID(id uint64) {
  10989. m.id = &id
  10990. }
  10991. // ID returns the ID value in the mutation. Note that the ID is only available
  10992. // if it was provided to the builder or after it was returned from the database.
  10993. func (m *LabelMutation) ID() (id uint64, exists bool) {
  10994. if m.id == nil {
  10995. return
  10996. }
  10997. return *m.id, true
  10998. }
  10999. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11000. // That means, if the mutation is applied within a transaction with an isolation level such
  11001. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11002. // or updated by the mutation.
  11003. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11004. switch {
  11005. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11006. id, exists := m.ID()
  11007. if exists {
  11008. return []uint64{id}, nil
  11009. }
  11010. fallthrough
  11011. case m.op.Is(OpUpdate | OpDelete):
  11012. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11013. default:
  11014. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11015. }
  11016. }
  11017. // SetCreatedAt sets the "created_at" field.
  11018. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11019. m.created_at = &t
  11020. }
  11021. // CreatedAt returns the value of the "created_at" field in the mutation.
  11022. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11023. v := m.created_at
  11024. if v == nil {
  11025. return
  11026. }
  11027. return *v, true
  11028. }
  11029. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11030. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11032. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11033. if !m.op.Is(OpUpdateOne) {
  11034. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11035. }
  11036. if m.id == nil || m.oldValue == nil {
  11037. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11038. }
  11039. oldValue, err := m.oldValue(ctx)
  11040. if err != nil {
  11041. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11042. }
  11043. return oldValue.CreatedAt, nil
  11044. }
  11045. // ResetCreatedAt resets all changes to the "created_at" field.
  11046. func (m *LabelMutation) ResetCreatedAt() {
  11047. m.created_at = nil
  11048. }
  11049. // SetUpdatedAt sets the "updated_at" field.
  11050. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11051. m.updated_at = &t
  11052. }
  11053. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11054. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11055. v := m.updated_at
  11056. if v == nil {
  11057. return
  11058. }
  11059. return *v, true
  11060. }
  11061. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11062. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11064. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11065. if !m.op.Is(OpUpdateOne) {
  11066. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11067. }
  11068. if m.id == nil || m.oldValue == nil {
  11069. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11070. }
  11071. oldValue, err := m.oldValue(ctx)
  11072. if err != nil {
  11073. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11074. }
  11075. return oldValue.UpdatedAt, nil
  11076. }
  11077. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11078. func (m *LabelMutation) ResetUpdatedAt() {
  11079. m.updated_at = nil
  11080. }
  11081. // SetStatus sets the "status" field.
  11082. func (m *LabelMutation) SetStatus(u uint8) {
  11083. m.status = &u
  11084. m.addstatus = nil
  11085. }
  11086. // Status returns the value of the "status" field in the mutation.
  11087. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11088. v := m.status
  11089. if v == nil {
  11090. return
  11091. }
  11092. return *v, true
  11093. }
  11094. // OldStatus returns the old "status" field's value of the Label entity.
  11095. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11097. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11098. if !m.op.Is(OpUpdateOne) {
  11099. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11100. }
  11101. if m.id == nil || m.oldValue == nil {
  11102. return v, errors.New("OldStatus requires an ID field in the mutation")
  11103. }
  11104. oldValue, err := m.oldValue(ctx)
  11105. if err != nil {
  11106. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11107. }
  11108. return oldValue.Status, nil
  11109. }
  11110. // AddStatus adds u to the "status" field.
  11111. func (m *LabelMutation) AddStatus(u int8) {
  11112. if m.addstatus != nil {
  11113. *m.addstatus += u
  11114. } else {
  11115. m.addstatus = &u
  11116. }
  11117. }
  11118. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11119. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11120. v := m.addstatus
  11121. if v == nil {
  11122. return
  11123. }
  11124. return *v, true
  11125. }
  11126. // ClearStatus clears the value of the "status" field.
  11127. func (m *LabelMutation) ClearStatus() {
  11128. m.status = nil
  11129. m.addstatus = nil
  11130. m.clearedFields[label.FieldStatus] = struct{}{}
  11131. }
  11132. // StatusCleared returns if the "status" field was cleared in this mutation.
  11133. func (m *LabelMutation) StatusCleared() bool {
  11134. _, ok := m.clearedFields[label.FieldStatus]
  11135. return ok
  11136. }
  11137. // ResetStatus resets all changes to the "status" field.
  11138. func (m *LabelMutation) ResetStatus() {
  11139. m.status = nil
  11140. m.addstatus = nil
  11141. delete(m.clearedFields, label.FieldStatus)
  11142. }
  11143. // SetType sets the "type" field.
  11144. func (m *LabelMutation) SetType(i int) {
  11145. m._type = &i
  11146. m.add_type = nil
  11147. }
  11148. // GetType returns the value of the "type" field in the mutation.
  11149. func (m *LabelMutation) GetType() (r int, exists bool) {
  11150. v := m._type
  11151. if v == nil {
  11152. return
  11153. }
  11154. return *v, true
  11155. }
  11156. // OldType returns the old "type" field's value of the Label entity.
  11157. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11159. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11160. if !m.op.Is(OpUpdateOne) {
  11161. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11162. }
  11163. if m.id == nil || m.oldValue == nil {
  11164. return v, errors.New("OldType requires an ID field in the mutation")
  11165. }
  11166. oldValue, err := m.oldValue(ctx)
  11167. if err != nil {
  11168. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11169. }
  11170. return oldValue.Type, nil
  11171. }
  11172. // AddType adds i to the "type" field.
  11173. func (m *LabelMutation) AddType(i int) {
  11174. if m.add_type != nil {
  11175. *m.add_type += i
  11176. } else {
  11177. m.add_type = &i
  11178. }
  11179. }
  11180. // AddedType returns the value that was added to the "type" field in this mutation.
  11181. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11182. v := m.add_type
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // ResetType resets all changes to the "type" field.
  11189. func (m *LabelMutation) ResetType() {
  11190. m._type = nil
  11191. m.add_type = nil
  11192. }
  11193. // SetName sets the "name" field.
  11194. func (m *LabelMutation) SetName(s string) {
  11195. m.name = &s
  11196. }
  11197. // Name returns the value of the "name" field in the mutation.
  11198. func (m *LabelMutation) Name() (r string, exists bool) {
  11199. v := m.name
  11200. if v == nil {
  11201. return
  11202. }
  11203. return *v, true
  11204. }
  11205. // OldName returns the old "name" field's value of the Label entity.
  11206. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11208. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11209. if !m.op.Is(OpUpdateOne) {
  11210. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11211. }
  11212. if m.id == nil || m.oldValue == nil {
  11213. return v, errors.New("OldName requires an ID field in the mutation")
  11214. }
  11215. oldValue, err := m.oldValue(ctx)
  11216. if err != nil {
  11217. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11218. }
  11219. return oldValue.Name, nil
  11220. }
  11221. // ResetName resets all changes to the "name" field.
  11222. func (m *LabelMutation) ResetName() {
  11223. m.name = nil
  11224. }
  11225. // SetFrom sets the "from" field.
  11226. func (m *LabelMutation) SetFrom(i int) {
  11227. m.from = &i
  11228. m.addfrom = nil
  11229. }
  11230. // From returns the value of the "from" field in the mutation.
  11231. func (m *LabelMutation) From() (r int, exists bool) {
  11232. v := m.from
  11233. if v == nil {
  11234. return
  11235. }
  11236. return *v, true
  11237. }
  11238. // OldFrom returns the old "from" field's value of the Label entity.
  11239. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11241. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11242. if !m.op.Is(OpUpdateOne) {
  11243. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11244. }
  11245. if m.id == nil || m.oldValue == nil {
  11246. return v, errors.New("OldFrom requires an ID field in the mutation")
  11247. }
  11248. oldValue, err := m.oldValue(ctx)
  11249. if err != nil {
  11250. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11251. }
  11252. return oldValue.From, nil
  11253. }
  11254. // AddFrom adds i to the "from" field.
  11255. func (m *LabelMutation) AddFrom(i int) {
  11256. if m.addfrom != nil {
  11257. *m.addfrom += i
  11258. } else {
  11259. m.addfrom = &i
  11260. }
  11261. }
  11262. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11263. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11264. v := m.addfrom
  11265. if v == nil {
  11266. return
  11267. }
  11268. return *v, true
  11269. }
  11270. // ResetFrom resets all changes to the "from" field.
  11271. func (m *LabelMutation) ResetFrom() {
  11272. m.from = nil
  11273. m.addfrom = nil
  11274. }
  11275. // SetMode sets the "mode" field.
  11276. func (m *LabelMutation) SetMode(i int) {
  11277. m.mode = &i
  11278. m.addmode = nil
  11279. }
  11280. // Mode returns the value of the "mode" field in the mutation.
  11281. func (m *LabelMutation) Mode() (r int, exists bool) {
  11282. v := m.mode
  11283. if v == nil {
  11284. return
  11285. }
  11286. return *v, true
  11287. }
  11288. // OldMode returns the old "mode" field's value of the Label entity.
  11289. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11291. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11292. if !m.op.Is(OpUpdateOne) {
  11293. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11294. }
  11295. if m.id == nil || m.oldValue == nil {
  11296. return v, errors.New("OldMode requires an ID field in the mutation")
  11297. }
  11298. oldValue, err := m.oldValue(ctx)
  11299. if err != nil {
  11300. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11301. }
  11302. return oldValue.Mode, nil
  11303. }
  11304. // AddMode adds i to the "mode" field.
  11305. func (m *LabelMutation) AddMode(i int) {
  11306. if m.addmode != nil {
  11307. *m.addmode += i
  11308. } else {
  11309. m.addmode = &i
  11310. }
  11311. }
  11312. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11313. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11314. v := m.addmode
  11315. if v == nil {
  11316. return
  11317. }
  11318. return *v, true
  11319. }
  11320. // ResetMode resets all changes to the "mode" field.
  11321. func (m *LabelMutation) ResetMode() {
  11322. m.mode = nil
  11323. m.addmode = nil
  11324. }
  11325. // SetConditions sets the "conditions" field.
  11326. func (m *LabelMutation) SetConditions(s string) {
  11327. m.conditions = &s
  11328. }
  11329. // Conditions returns the value of the "conditions" field in the mutation.
  11330. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11331. v := m.conditions
  11332. if v == nil {
  11333. return
  11334. }
  11335. return *v, true
  11336. }
  11337. // OldConditions returns the old "conditions" field's value of the Label entity.
  11338. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11340. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11341. if !m.op.Is(OpUpdateOne) {
  11342. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11343. }
  11344. if m.id == nil || m.oldValue == nil {
  11345. return v, errors.New("OldConditions requires an ID field in the mutation")
  11346. }
  11347. oldValue, err := m.oldValue(ctx)
  11348. if err != nil {
  11349. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11350. }
  11351. return oldValue.Conditions, nil
  11352. }
  11353. // ClearConditions clears the value of the "conditions" field.
  11354. func (m *LabelMutation) ClearConditions() {
  11355. m.conditions = nil
  11356. m.clearedFields[label.FieldConditions] = struct{}{}
  11357. }
  11358. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11359. func (m *LabelMutation) ConditionsCleared() bool {
  11360. _, ok := m.clearedFields[label.FieldConditions]
  11361. return ok
  11362. }
  11363. // ResetConditions resets all changes to the "conditions" field.
  11364. func (m *LabelMutation) ResetConditions() {
  11365. m.conditions = nil
  11366. delete(m.clearedFields, label.FieldConditions)
  11367. }
  11368. // SetOrganizationID sets the "organization_id" field.
  11369. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11370. m.organization_id = &u
  11371. m.addorganization_id = nil
  11372. }
  11373. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11374. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11375. v := m.organization_id
  11376. if v == nil {
  11377. return
  11378. }
  11379. return *v, true
  11380. }
  11381. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11382. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11384. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11385. if !m.op.Is(OpUpdateOne) {
  11386. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11387. }
  11388. if m.id == nil || m.oldValue == nil {
  11389. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11390. }
  11391. oldValue, err := m.oldValue(ctx)
  11392. if err != nil {
  11393. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11394. }
  11395. return oldValue.OrganizationID, nil
  11396. }
  11397. // AddOrganizationID adds u to the "organization_id" field.
  11398. func (m *LabelMutation) AddOrganizationID(u int64) {
  11399. if m.addorganization_id != nil {
  11400. *m.addorganization_id += u
  11401. } else {
  11402. m.addorganization_id = &u
  11403. }
  11404. }
  11405. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11406. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11407. v := m.addorganization_id
  11408. if v == nil {
  11409. return
  11410. }
  11411. return *v, true
  11412. }
  11413. // ClearOrganizationID clears the value of the "organization_id" field.
  11414. func (m *LabelMutation) ClearOrganizationID() {
  11415. m.organization_id = nil
  11416. m.addorganization_id = nil
  11417. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11418. }
  11419. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11420. func (m *LabelMutation) OrganizationIDCleared() bool {
  11421. _, ok := m.clearedFields[label.FieldOrganizationID]
  11422. return ok
  11423. }
  11424. // ResetOrganizationID resets all changes to the "organization_id" field.
  11425. func (m *LabelMutation) ResetOrganizationID() {
  11426. m.organization_id = nil
  11427. m.addorganization_id = nil
  11428. delete(m.clearedFields, label.FieldOrganizationID)
  11429. }
  11430. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11431. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11432. if m.label_relationships == nil {
  11433. m.label_relationships = make(map[uint64]struct{})
  11434. }
  11435. for i := range ids {
  11436. m.label_relationships[ids[i]] = struct{}{}
  11437. }
  11438. }
  11439. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11440. func (m *LabelMutation) ClearLabelRelationships() {
  11441. m.clearedlabel_relationships = true
  11442. }
  11443. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11444. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11445. return m.clearedlabel_relationships
  11446. }
  11447. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11448. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11449. if m.removedlabel_relationships == nil {
  11450. m.removedlabel_relationships = make(map[uint64]struct{})
  11451. }
  11452. for i := range ids {
  11453. delete(m.label_relationships, ids[i])
  11454. m.removedlabel_relationships[ids[i]] = struct{}{}
  11455. }
  11456. }
  11457. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11458. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11459. for id := range m.removedlabel_relationships {
  11460. ids = append(ids, id)
  11461. }
  11462. return
  11463. }
  11464. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11465. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11466. for id := range m.label_relationships {
  11467. ids = append(ids, id)
  11468. }
  11469. return
  11470. }
  11471. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11472. func (m *LabelMutation) ResetLabelRelationships() {
  11473. m.label_relationships = nil
  11474. m.clearedlabel_relationships = false
  11475. m.removedlabel_relationships = nil
  11476. }
  11477. // Where appends a list predicates to the LabelMutation builder.
  11478. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11479. m.predicates = append(m.predicates, ps...)
  11480. }
  11481. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11482. // users can use type-assertion to append predicates that do not depend on any generated package.
  11483. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11484. p := make([]predicate.Label, len(ps))
  11485. for i := range ps {
  11486. p[i] = ps[i]
  11487. }
  11488. m.Where(p...)
  11489. }
  11490. // Op returns the operation name.
  11491. func (m *LabelMutation) Op() Op {
  11492. return m.op
  11493. }
  11494. // SetOp allows setting the mutation operation.
  11495. func (m *LabelMutation) SetOp(op Op) {
  11496. m.op = op
  11497. }
  11498. // Type returns the node type of this mutation (Label).
  11499. func (m *LabelMutation) Type() string {
  11500. return m.typ
  11501. }
  11502. // Fields returns all fields that were changed during this mutation. Note that in
  11503. // order to get all numeric fields that were incremented/decremented, call
  11504. // AddedFields().
  11505. func (m *LabelMutation) Fields() []string {
  11506. fields := make([]string, 0, 9)
  11507. if m.created_at != nil {
  11508. fields = append(fields, label.FieldCreatedAt)
  11509. }
  11510. if m.updated_at != nil {
  11511. fields = append(fields, label.FieldUpdatedAt)
  11512. }
  11513. if m.status != nil {
  11514. fields = append(fields, label.FieldStatus)
  11515. }
  11516. if m._type != nil {
  11517. fields = append(fields, label.FieldType)
  11518. }
  11519. if m.name != nil {
  11520. fields = append(fields, label.FieldName)
  11521. }
  11522. if m.from != nil {
  11523. fields = append(fields, label.FieldFrom)
  11524. }
  11525. if m.mode != nil {
  11526. fields = append(fields, label.FieldMode)
  11527. }
  11528. if m.conditions != nil {
  11529. fields = append(fields, label.FieldConditions)
  11530. }
  11531. if m.organization_id != nil {
  11532. fields = append(fields, label.FieldOrganizationID)
  11533. }
  11534. return fields
  11535. }
  11536. // Field returns the value of a field with the given name. The second boolean
  11537. // return value indicates that this field was not set, or was not defined in the
  11538. // schema.
  11539. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11540. switch name {
  11541. case label.FieldCreatedAt:
  11542. return m.CreatedAt()
  11543. case label.FieldUpdatedAt:
  11544. return m.UpdatedAt()
  11545. case label.FieldStatus:
  11546. return m.Status()
  11547. case label.FieldType:
  11548. return m.GetType()
  11549. case label.FieldName:
  11550. return m.Name()
  11551. case label.FieldFrom:
  11552. return m.From()
  11553. case label.FieldMode:
  11554. return m.Mode()
  11555. case label.FieldConditions:
  11556. return m.Conditions()
  11557. case label.FieldOrganizationID:
  11558. return m.OrganizationID()
  11559. }
  11560. return nil, false
  11561. }
  11562. // OldField returns the old value of the field from the database. An error is
  11563. // returned if the mutation operation is not UpdateOne, or the query to the
  11564. // database failed.
  11565. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11566. switch name {
  11567. case label.FieldCreatedAt:
  11568. return m.OldCreatedAt(ctx)
  11569. case label.FieldUpdatedAt:
  11570. return m.OldUpdatedAt(ctx)
  11571. case label.FieldStatus:
  11572. return m.OldStatus(ctx)
  11573. case label.FieldType:
  11574. return m.OldType(ctx)
  11575. case label.FieldName:
  11576. return m.OldName(ctx)
  11577. case label.FieldFrom:
  11578. return m.OldFrom(ctx)
  11579. case label.FieldMode:
  11580. return m.OldMode(ctx)
  11581. case label.FieldConditions:
  11582. return m.OldConditions(ctx)
  11583. case label.FieldOrganizationID:
  11584. return m.OldOrganizationID(ctx)
  11585. }
  11586. return nil, fmt.Errorf("unknown Label field %s", name)
  11587. }
  11588. // SetField sets the value of a field with the given name. It returns an error if
  11589. // the field is not defined in the schema, or if the type mismatched the field
  11590. // type.
  11591. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11592. switch name {
  11593. case label.FieldCreatedAt:
  11594. v, ok := value.(time.Time)
  11595. if !ok {
  11596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11597. }
  11598. m.SetCreatedAt(v)
  11599. return nil
  11600. case label.FieldUpdatedAt:
  11601. v, ok := value.(time.Time)
  11602. if !ok {
  11603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11604. }
  11605. m.SetUpdatedAt(v)
  11606. return nil
  11607. case label.FieldStatus:
  11608. v, ok := value.(uint8)
  11609. if !ok {
  11610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11611. }
  11612. m.SetStatus(v)
  11613. return nil
  11614. case label.FieldType:
  11615. v, ok := value.(int)
  11616. if !ok {
  11617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11618. }
  11619. m.SetType(v)
  11620. return nil
  11621. case label.FieldName:
  11622. v, ok := value.(string)
  11623. if !ok {
  11624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11625. }
  11626. m.SetName(v)
  11627. return nil
  11628. case label.FieldFrom:
  11629. v, ok := value.(int)
  11630. if !ok {
  11631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11632. }
  11633. m.SetFrom(v)
  11634. return nil
  11635. case label.FieldMode:
  11636. v, ok := value.(int)
  11637. if !ok {
  11638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11639. }
  11640. m.SetMode(v)
  11641. return nil
  11642. case label.FieldConditions:
  11643. v, ok := value.(string)
  11644. if !ok {
  11645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11646. }
  11647. m.SetConditions(v)
  11648. return nil
  11649. case label.FieldOrganizationID:
  11650. v, ok := value.(uint64)
  11651. if !ok {
  11652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11653. }
  11654. m.SetOrganizationID(v)
  11655. return nil
  11656. }
  11657. return fmt.Errorf("unknown Label field %s", name)
  11658. }
  11659. // AddedFields returns all numeric fields that were incremented/decremented during
  11660. // this mutation.
  11661. func (m *LabelMutation) AddedFields() []string {
  11662. var fields []string
  11663. if m.addstatus != nil {
  11664. fields = append(fields, label.FieldStatus)
  11665. }
  11666. if m.add_type != nil {
  11667. fields = append(fields, label.FieldType)
  11668. }
  11669. if m.addfrom != nil {
  11670. fields = append(fields, label.FieldFrom)
  11671. }
  11672. if m.addmode != nil {
  11673. fields = append(fields, label.FieldMode)
  11674. }
  11675. if m.addorganization_id != nil {
  11676. fields = append(fields, label.FieldOrganizationID)
  11677. }
  11678. return fields
  11679. }
  11680. // AddedField returns the numeric value that was incremented/decremented on a field
  11681. // with the given name. The second boolean return value indicates that this field
  11682. // was not set, or was not defined in the schema.
  11683. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11684. switch name {
  11685. case label.FieldStatus:
  11686. return m.AddedStatus()
  11687. case label.FieldType:
  11688. return m.AddedType()
  11689. case label.FieldFrom:
  11690. return m.AddedFrom()
  11691. case label.FieldMode:
  11692. return m.AddedMode()
  11693. case label.FieldOrganizationID:
  11694. return m.AddedOrganizationID()
  11695. }
  11696. return nil, false
  11697. }
  11698. // AddField adds the value to the field with the given name. It returns an error if
  11699. // the field is not defined in the schema, or if the type mismatched the field
  11700. // type.
  11701. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11702. switch name {
  11703. case label.FieldStatus:
  11704. v, ok := value.(int8)
  11705. if !ok {
  11706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11707. }
  11708. m.AddStatus(v)
  11709. return nil
  11710. case label.FieldType:
  11711. v, ok := value.(int)
  11712. if !ok {
  11713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11714. }
  11715. m.AddType(v)
  11716. return nil
  11717. case label.FieldFrom:
  11718. v, ok := value.(int)
  11719. if !ok {
  11720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11721. }
  11722. m.AddFrom(v)
  11723. return nil
  11724. case label.FieldMode:
  11725. v, ok := value.(int)
  11726. if !ok {
  11727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11728. }
  11729. m.AddMode(v)
  11730. return nil
  11731. case label.FieldOrganizationID:
  11732. v, ok := value.(int64)
  11733. if !ok {
  11734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11735. }
  11736. m.AddOrganizationID(v)
  11737. return nil
  11738. }
  11739. return fmt.Errorf("unknown Label numeric field %s", name)
  11740. }
  11741. // ClearedFields returns all nullable fields that were cleared during this
  11742. // mutation.
  11743. func (m *LabelMutation) ClearedFields() []string {
  11744. var fields []string
  11745. if m.FieldCleared(label.FieldStatus) {
  11746. fields = append(fields, label.FieldStatus)
  11747. }
  11748. if m.FieldCleared(label.FieldConditions) {
  11749. fields = append(fields, label.FieldConditions)
  11750. }
  11751. if m.FieldCleared(label.FieldOrganizationID) {
  11752. fields = append(fields, label.FieldOrganizationID)
  11753. }
  11754. return fields
  11755. }
  11756. // FieldCleared returns a boolean indicating if a field with the given name was
  11757. // cleared in this mutation.
  11758. func (m *LabelMutation) FieldCleared(name string) bool {
  11759. _, ok := m.clearedFields[name]
  11760. return ok
  11761. }
  11762. // ClearField clears the value of the field with the given name. It returns an
  11763. // error if the field is not defined in the schema.
  11764. func (m *LabelMutation) ClearField(name string) error {
  11765. switch name {
  11766. case label.FieldStatus:
  11767. m.ClearStatus()
  11768. return nil
  11769. case label.FieldConditions:
  11770. m.ClearConditions()
  11771. return nil
  11772. case label.FieldOrganizationID:
  11773. m.ClearOrganizationID()
  11774. return nil
  11775. }
  11776. return fmt.Errorf("unknown Label nullable field %s", name)
  11777. }
  11778. // ResetField resets all changes in the mutation for the field with the given name.
  11779. // It returns an error if the field is not defined in the schema.
  11780. func (m *LabelMutation) ResetField(name string) error {
  11781. switch name {
  11782. case label.FieldCreatedAt:
  11783. m.ResetCreatedAt()
  11784. return nil
  11785. case label.FieldUpdatedAt:
  11786. m.ResetUpdatedAt()
  11787. return nil
  11788. case label.FieldStatus:
  11789. m.ResetStatus()
  11790. return nil
  11791. case label.FieldType:
  11792. m.ResetType()
  11793. return nil
  11794. case label.FieldName:
  11795. m.ResetName()
  11796. return nil
  11797. case label.FieldFrom:
  11798. m.ResetFrom()
  11799. return nil
  11800. case label.FieldMode:
  11801. m.ResetMode()
  11802. return nil
  11803. case label.FieldConditions:
  11804. m.ResetConditions()
  11805. return nil
  11806. case label.FieldOrganizationID:
  11807. m.ResetOrganizationID()
  11808. return nil
  11809. }
  11810. return fmt.Errorf("unknown Label field %s", name)
  11811. }
  11812. // AddedEdges returns all edge names that were set/added in this mutation.
  11813. func (m *LabelMutation) AddedEdges() []string {
  11814. edges := make([]string, 0, 1)
  11815. if m.label_relationships != nil {
  11816. edges = append(edges, label.EdgeLabelRelationships)
  11817. }
  11818. return edges
  11819. }
  11820. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11821. // name in this mutation.
  11822. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11823. switch name {
  11824. case label.EdgeLabelRelationships:
  11825. ids := make([]ent.Value, 0, len(m.label_relationships))
  11826. for id := range m.label_relationships {
  11827. ids = append(ids, id)
  11828. }
  11829. return ids
  11830. }
  11831. return nil
  11832. }
  11833. // RemovedEdges returns all edge names that were removed in this mutation.
  11834. func (m *LabelMutation) RemovedEdges() []string {
  11835. edges := make([]string, 0, 1)
  11836. if m.removedlabel_relationships != nil {
  11837. edges = append(edges, label.EdgeLabelRelationships)
  11838. }
  11839. return edges
  11840. }
  11841. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11842. // the given name in this mutation.
  11843. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11844. switch name {
  11845. case label.EdgeLabelRelationships:
  11846. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11847. for id := range m.removedlabel_relationships {
  11848. ids = append(ids, id)
  11849. }
  11850. return ids
  11851. }
  11852. return nil
  11853. }
  11854. // ClearedEdges returns all edge names that were cleared in this mutation.
  11855. func (m *LabelMutation) ClearedEdges() []string {
  11856. edges := make([]string, 0, 1)
  11857. if m.clearedlabel_relationships {
  11858. edges = append(edges, label.EdgeLabelRelationships)
  11859. }
  11860. return edges
  11861. }
  11862. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11863. // was cleared in this mutation.
  11864. func (m *LabelMutation) EdgeCleared(name string) bool {
  11865. switch name {
  11866. case label.EdgeLabelRelationships:
  11867. return m.clearedlabel_relationships
  11868. }
  11869. return false
  11870. }
  11871. // ClearEdge clears the value of the edge with the given name. It returns an error
  11872. // if that edge is not defined in the schema.
  11873. func (m *LabelMutation) ClearEdge(name string) error {
  11874. switch name {
  11875. }
  11876. return fmt.Errorf("unknown Label unique edge %s", name)
  11877. }
  11878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11879. // It returns an error if the edge is not defined in the schema.
  11880. func (m *LabelMutation) ResetEdge(name string) error {
  11881. switch name {
  11882. case label.EdgeLabelRelationships:
  11883. m.ResetLabelRelationships()
  11884. return nil
  11885. }
  11886. return fmt.Errorf("unknown Label edge %s", name)
  11887. }
  11888. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11889. type LabelRelationshipMutation struct {
  11890. config
  11891. op Op
  11892. typ string
  11893. id *uint64
  11894. created_at *time.Time
  11895. updated_at *time.Time
  11896. status *uint8
  11897. addstatus *int8
  11898. deleted_at *time.Time
  11899. organization_id *uint64
  11900. addorganization_id *int64
  11901. clearedFields map[string]struct{}
  11902. contacts *uint64
  11903. clearedcontacts bool
  11904. labels *uint64
  11905. clearedlabels bool
  11906. done bool
  11907. oldValue func(context.Context) (*LabelRelationship, error)
  11908. predicates []predicate.LabelRelationship
  11909. }
  11910. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11911. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11912. type labelrelationshipOption func(*LabelRelationshipMutation)
  11913. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11914. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11915. m := &LabelRelationshipMutation{
  11916. config: c,
  11917. op: op,
  11918. typ: TypeLabelRelationship,
  11919. clearedFields: make(map[string]struct{}),
  11920. }
  11921. for _, opt := range opts {
  11922. opt(m)
  11923. }
  11924. return m
  11925. }
  11926. // withLabelRelationshipID sets the ID field of the mutation.
  11927. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11928. return func(m *LabelRelationshipMutation) {
  11929. var (
  11930. err error
  11931. once sync.Once
  11932. value *LabelRelationship
  11933. )
  11934. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11935. once.Do(func() {
  11936. if m.done {
  11937. err = errors.New("querying old values post mutation is not allowed")
  11938. } else {
  11939. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11940. }
  11941. })
  11942. return value, err
  11943. }
  11944. m.id = &id
  11945. }
  11946. }
  11947. // withLabelRelationship sets the old LabelRelationship of the mutation.
  11948. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  11949. return func(m *LabelRelationshipMutation) {
  11950. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  11951. return node, nil
  11952. }
  11953. m.id = &node.ID
  11954. }
  11955. }
  11956. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11957. // executed in a transaction (ent.Tx), a transactional client is returned.
  11958. func (m LabelRelationshipMutation) Client() *Client {
  11959. client := &Client{config: m.config}
  11960. client.init()
  11961. return client
  11962. }
  11963. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11964. // it returns an error otherwise.
  11965. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  11966. if _, ok := m.driver.(*txDriver); !ok {
  11967. return nil, errors.New("ent: mutation is not running in a transaction")
  11968. }
  11969. tx := &Tx{config: m.config}
  11970. tx.init()
  11971. return tx, nil
  11972. }
  11973. // SetID sets the value of the id field. Note that this
  11974. // operation is only accepted on creation of LabelRelationship entities.
  11975. func (m *LabelRelationshipMutation) SetID(id uint64) {
  11976. m.id = &id
  11977. }
  11978. // ID returns the ID value in the mutation. Note that the ID is only available
  11979. // if it was provided to the builder or after it was returned from the database.
  11980. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  11981. if m.id == nil {
  11982. return
  11983. }
  11984. return *m.id, true
  11985. }
  11986. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11987. // That means, if the mutation is applied within a transaction with an isolation level such
  11988. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11989. // or updated by the mutation.
  11990. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  11991. switch {
  11992. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11993. id, exists := m.ID()
  11994. if exists {
  11995. return []uint64{id}, nil
  11996. }
  11997. fallthrough
  11998. case m.op.Is(OpUpdate | OpDelete):
  11999. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12000. default:
  12001. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12002. }
  12003. }
  12004. // SetCreatedAt sets the "created_at" field.
  12005. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12006. m.created_at = &t
  12007. }
  12008. // CreatedAt returns the value of the "created_at" field in the mutation.
  12009. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12010. v := m.created_at
  12011. if v == nil {
  12012. return
  12013. }
  12014. return *v, true
  12015. }
  12016. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12017. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12019. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12020. if !m.op.Is(OpUpdateOne) {
  12021. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12022. }
  12023. if m.id == nil || m.oldValue == nil {
  12024. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12025. }
  12026. oldValue, err := m.oldValue(ctx)
  12027. if err != nil {
  12028. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12029. }
  12030. return oldValue.CreatedAt, nil
  12031. }
  12032. // ResetCreatedAt resets all changes to the "created_at" field.
  12033. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12034. m.created_at = nil
  12035. }
  12036. // SetUpdatedAt sets the "updated_at" field.
  12037. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12038. m.updated_at = &t
  12039. }
  12040. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12041. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12042. v := m.updated_at
  12043. if v == nil {
  12044. return
  12045. }
  12046. return *v, true
  12047. }
  12048. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12049. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12051. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12052. if !m.op.Is(OpUpdateOne) {
  12053. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12054. }
  12055. if m.id == nil || m.oldValue == nil {
  12056. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12057. }
  12058. oldValue, err := m.oldValue(ctx)
  12059. if err != nil {
  12060. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12061. }
  12062. return oldValue.UpdatedAt, nil
  12063. }
  12064. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12065. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12066. m.updated_at = nil
  12067. }
  12068. // SetStatus sets the "status" field.
  12069. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12070. m.status = &u
  12071. m.addstatus = nil
  12072. }
  12073. // Status returns the value of the "status" field in the mutation.
  12074. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12075. v := m.status
  12076. if v == nil {
  12077. return
  12078. }
  12079. return *v, true
  12080. }
  12081. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12082. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12084. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12085. if !m.op.Is(OpUpdateOne) {
  12086. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12087. }
  12088. if m.id == nil || m.oldValue == nil {
  12089. return v, errors.New("OldStatus requires an ID field in the mutation")
  12090. }
  12091. oldValue, err := m.oldValue(ctx)
  12092. if err != nil {
  12093. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12094. }
  12095. return oldValue.Status, nil
  12096. }
  12097. // AddStatus adds u to the "status" field.
  12098. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12099. if m.addstatus != nil {
  12100. *m.addstatus += u
  12101. } else {
  12102. m.addstatus = &u
  12103. }
  12104. }
  12105. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12106. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12107. v := m.addstatus
  12108. if v == nil {
  12109. return
  12110. }
  12111. return *v, true
  12112. }
  12113. // ClearStatus clears the value of the "status" field.
  12114. func (m *LabelRelationshipMutation) ClearStatus() {
  12115. m.status = nil
  12116. m.addstatus = nil
  12117. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12118. }
  12119. // StatusCleared returns if the "status" field was cleared in this mutation.
  12120. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12121. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12122. return ok
  12123. }
  12124. // ResetStatus resets all changes to the "status" field.
  12125. func (m *LabelRelationshipMutation) ResetStatus() {
  12126. m.status = nil
  12127. m.addstatus = nil
  12128. delete(m.clearedFields, labelrelationship.FieldStatus)
  12129. }
  12130. // SetDeletedAt sets the "deleted_at" field.
  12131. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12132. m.deleted_at = &t
  12133. }
  12134. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12135. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12136. v := m.deleted_at
  12137. if v == nil {
  12138. return
  12139. }
  12140. return *v, true
  12141. }
  12142. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12143. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12145. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12146. if !m.op.Is(OpUpdateOne) {
  12147. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12148. }
  12149. if m.id == nil || m.oldValue == nil {
  12150. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12151. }
  12152. oldValue, err := m.oldValue(ctx)
  12153. if err != nil {
  12154. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12155. }
  12156. return oldValue.DeletedAt, nil
  12157. }
  12158. // ClearDeletedAt clears the value of the "deleted_at" field.
  12159. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12160. m.deleted_at = nil
  12161. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12162. }
  12163. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12164. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12165. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12166. return ok
  12167. }
  12168. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12169. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12170. m.deleted_at = nil
  12171. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12172. }
  12173. // SetLabelID sets the "label_id" field.
  12174. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12175. m.labels = &u
  12176. }
  12177. // LabelID returns the value of the "label_id" field in the mutation.
  12178. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12179. v := m.labels
  12180. if v == nil {
  12181. return
  12182. }
  12183. return *v, true
  12184. }
  12185. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12186. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12188. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12189. if !m.op.Is(OpUpdateOne) {
  12190. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12191. }
  12192. if m.id == nil || m.oldValue == nil {
  12193. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12194. }
  12195. oldValue, err := m.oldValue(ctx)
  12196. if err != nil {
  12197. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12198. }
  12199. return oldValue.LabelID, nil
  12200. }
  12201. // ResetLabelID resets all changes to the "label_id" field.
  12202. func (m *LabelRelationshipMutation) ResetLabelID() {
  12203. m.labels = nil
  12204. }
  12205. // SetContactID sets the "contact_id" field.
  12206. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12207. m.contacts = &u
  12208. }
  12209. // ContactID returns the value of the "contact_id" field in the mutation.
  12210. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12211. v := m.contacts
  12212. if v == nil {
  12213. return
  12214. }
  12215. return *v, true
  12216. }
  12217. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12218. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12220. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12221. if !m.op.Is(OpUpdateOne) {
  12222. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12223. }
  12224. if m.id == nil || m.oldValue == nil {
  12225. return v, errors.New("OldContactID requires an ID field in the mutation")
  12226. }
  12227. oldValue, err := m.oldValue(ctx)
  12228. if err != nil {
  12229. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12230. }
  12231. return oldValue.ContactID, nil
  12232. }
  12233. // ResetContactID resets all changes to the "contact_id" field.
  12234. func (m *LabelRelationshipMutation) ResetContactID() {
  12235. m.contacts = nil
  12236. }
  12237. // SetOrganizationID sets the "organization_id" field.
  12238. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12239. m.organization_id = &u
  12240. m.addorganization_id = nil
  12241. }
  12242. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12243. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12244. v := m.organization_id
  12245. if v == nil {
  12246. return
  12247. }
  12248. return *v, true
  12249. }
  12250. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12251. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12253. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12254. if !m.op.Is(OpUpdateOne) {
  12255. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12256. }
  12257. if m.id == nil || m.oldValue == nil {
  12258. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12259. }
  12260. oldValue, err := m.oldValue(ctx)
  12261. if err != nil {
  12262. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12263. }
  12264. return oldValue.OrganizationID, nil
  12265. }
  12266. // AddOrganizationID adds u to the "organization_id" field.
  12267. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12268. if m.addorganization_id != nil {
  12269. *m.addorganization_id += u
  12270. } else {
  12271. m.addorganization_id = &u
  12272. }
  12273. }
  12274. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12275. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12276. v := m.addorganization_id
  12277. if v == nil {
  12278. return
  12279. }
  12280. return *v, true
  12281. }
  12282. // ClearOrganizationID clears the value of the "organization_id" field.
  12283. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12284. m.organization_id = nil
  12285. m.addorganization_id = nil
  12286. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12287. }
  12288. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12289. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12290. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12291. return ok
  12292. }
  12293. // ResetOrganizationID resets all changes to the "organization_id" field.
  12294. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12295. m.organization_id = nil
  12296. m.addorganization_id = nil
  12297. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12298. }
  12299. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12300. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12301. m.contacts = &id
  12302. }
  12303. // ClearContacts clears the "contacts" edge to the Contact entity.
  12304. func (m *LabelRelationshipMutation) ClearContacts() {
  12305. m.clearedcontacts = true
  12306. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12307. }
  12308. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12309. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12310. return m.clearedcontacts
  12311. }
  12312. // ContactsID returns the "contacts" edge ID in the mutation.
  12313. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12314. if m.contacts != nil {
  12315. return *m.contacts, true
  12316. }
  12317. return
  12318. }
  12319. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12320. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12321. // ContactsID instead. It exists only for internal usage by the builders.
  12322. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12323. if id := m.contacts; id != nil {
  12324. ids = append(ids, *id)
  12325. }
  12326. return
  12327. }
  12328. // ResetContacts resets all changes to the "contacts" edge.
  12329. func (m *LabelRelationshipMutation) ResetContacts() {
  12330. m.contacts = nil
  12331. m.clearedcontacts = false
  12332. }
  12333. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12334. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12335. m.labels = &id
  12336. }
  12337. // ClearLabels clears the "labels" edge to the Label entity.
  12338. func (m *LabelRelationshipMutation) ClearLabels() {
  12339. m.clearedlabels = true
  12340. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12341. }
  12342. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12343. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12344. return m.clearedlabels
  12345. }
  12346. // LabelsID returns the "labels" edge ID in the mutation.
  12347. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12348. if m.labels != nil {
  12349. return *m.labels, true
  12350. }
  12351. return
  12352. }
  12353. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12354. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12355. // LabelsID instead. It exists only for internal usage by the builders.
  12356. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12357. if id := m.labels; id != nil {
  12358. ids = append(ids, *id)
  12359. }
  12360. return
  12361. }
  12362. // ResetLabels resets all changes to the "labels" edge.
  12363. func (m *LabelRelationshipMutation) ResetLabels() {
  12364. m.labels = nil
  12365. m.clearedlabels = false
  12366. }
  12367. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12368. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12369. m.predicates = append(m.predicates, ps...)
  12370. }
  12371. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12372. // users can use type-assertion to append predicates that do not depend on any generated package.
  12373. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12374. p := make([]predicate.LabelRelationship, len(ps))
  12375. for i := range ps {
  12376. p[i] = ps[i]
  12377. }
  12378. m.Where(p...)
  12379. }
  12380. // Op returns the operation name.
  12381. func (m *LabelRelationshipMutation) Op() Op {
  12382. return m.op
  12383. }
  12384. // SetOp allows setting the mutation operation.
  12385. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12386. m.op = op
  12387. }
  12388. // Type returns the node type of this mutation (LabelRelationship).
  12389. func (m *LabelRelationshipMutation) Type() string {
  12390. return m.typ
  12391. }
  12392. // Fields returns all fields that were changed during this mutation. Note that in
  12393. // order to get all numeric fields that were incremented/decremented, call
  12394. // AddedFields().
  12395. func (m *LabelRelationshipMutation) Fields() []string {
  12396. fields := make([]string, 0, 7)
  12397. if m.created_at != nil {
  12398. fields = append(fields, labelrelationship.FieldCreatedAt)
  12399. }
  12400. if m.updated_at != nil {
  12401. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12402. }
  12403. if m.status != nil {
  12404. fields = append(fields, labelrelationship.FieldStatus)
  12405. }
  12406. if m.deleted_at != nil {
  12407. fields = append(fields, labelrelationship.FieldDeletedAt)
  12408. }
  12409. if m.labels != nil {
  12410. fields = append(fields, labelrelationship.FieldLabelID)
  12411. }
  12412. if m.contacts != nil {
  12413. fields = append(fields, labelrelationship.FieldContactID)
  12414. }
  12415. if m.organization_id != nil {
  12416. fields = append(fields, labelrelationship.FieldOrganizationID)
  12417. }
  12418. return fields
  12419. }
  12420. // Field returns the value of a field with the given name. The second boolean
  12421. // return value indicates that this field was not set, or was not defined in the
  12422. // schema.
  12423. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12424. switch name {
  12425. case labelrelationship.FieldCreatedAt:
  12426. return m.CreatedAt()
  12427. case labelrelationship.FieldUpdatedAt:
  12428. return m.UpdatedAt()
  12429. case labelrelationship.FieldStatus:
  12430. return m.Status()
  12431. case labelrelationship.FieldDeletedAt:
  12432. return m.DeletedAt()
  12433. case labelrelationship.FieldLabelID:
  12434. return m.LabelID()
  12435. case labelrelationship.FieldContactID:
  12436. return m.ContactID()
  12437. case labelrelationship.FieldOrganizationID:
  12438. return m.OrganizationID()
  12439. }
  12440. return nil, false
  12441. }
  12442. // OldField returns the old value of the field from the database. An error is
  12443. // returned if the mutation operation is not UpdateOne, or the query to the
  12444. // database failed.
  12445. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12446. switch name {
  12447. case labelrelationship.FieldCreatedAt:
  12448. return m.OldCreatedAt(ctx)
  12449. case labelrelationship.FieldUpdatedAt:
  12450. return m.OldUpdatedAt(ctx)
  12451. case labelrelationship.FieldStatus:
  12452. return m.OldStatus(ctx)
  12453. case labelrelationship.FieldDeletedAt:
  12454. return m.OldDeletedAt(ctx)
  12455. case labelrelationship.FieldLabelID:
  12456. return m.OldLabelID(ctx)
  12457. case labelrelationship.FieldContactID:
  12458. return m.OldContactID(ctx)
  12459. case labelrelationship.FieldOrganizationID:
  12460. return m.OldOrganizationID(ctx)
  12461. }
  12462. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12463. }
  12464. // SetField sets the value of a field with the given name. It returns an error if
  12465. // the field is not defined in the schema, or if the type mismatched the field
  12466. // type.
  12467. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12468. switch name {
  12469. case labelrelationship.FieldCreatedAt:
  12470. v, ok := value.(time.Time)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetCreatedAt(v)
  12475. return nil
  12476. case labelrelationship.FieldUpdatedAt:
  12477. v, ok := value.(time.Time)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetUpdatedAt(v)
  12482. return nil
  12483. case labelrelationship.FieldStatus:
  12484. v, ok := value.(uint8)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetStatus(v)
  12489. return nil
  12490. case labelrelationship.FieldDeletedAt:
  12491. v, ok := value.(time.Time)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetDeletedAt(v)
  12496. return nil
  12497. case labelrelationship.FieldLabelID:
  12498. v, ok := value.(uint64)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetLabelID(v)
  12503. return nil
  12504. case labelrelationship.FieldContactID:
  12505. v, ok := value.(uint64)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetContactID(v)
  12510. return nil
  12511. case labelrelationship.FieldOrganizationID:
  12512. v, ok := value.(uint64)
  12513. if !ok {
  12514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12515. }
  12516. m.SetOrganizationID(v)
  12517. return nil
  12518. }
  12519. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12520. }
  12521. // AddedFields returns all numeric fields that were incremented/decremented during
  12522. // this mutation.
  12523. func (m *LabelRelationshipMutation) AddedFields() []string {
  12524. var fields []string
  12525. if m.addstatus != nil {
  12526. fields = append(fields, labelrelationship.FieldStatus)
  12527. }
  12528. if m.addorganization_id != nil {
  12529. fields = append(fields, labelrelationship.FieldOrganizationID)
  12530. }
  12531. return fields
  12532. }
  12533. // AddedField returns the numeric value that was incremented/decremented on a field
  12534. // with the given name. The second boolean return value indicates that this field
  12535. // was not set, or was not defined in the schema.
  12536. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12537. switch name {
  12538. case labelrelationship.FieldStatus:
  12539. return m.AddedStatus()
  12540. case labelrelationship.FieldOrganizationID:
  12541. return m.AddedOrganizationID()
  12542. }
  12543. return nil, false
  12544. }
  12545. // AddField adds the value to the field with the given name. It returns an error if
  12546. // the field is not defined in the schema, or if the type mismatched the field
  12547. // type.
  12548. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12549. switch name {
  12550. case labelrelationship.FieldStatus:
  12551. v, ok := value.(int8)
  12552. if !ok {
  12553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12554. }
  12555. m.AddStatus(v)
  12556. return nil
  12557. case labelrelationship.FieldOrganizationID:
  12558. v, ok := value.(int64)
  12559. if !ok {
  12560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12561. }
  12562. m.AddOrganizationID(v)
  12563. return nil
  12564. }
  12565. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12566. }
  12567. // ClearedFields returns all nullable fields that were cleared during this
  12568. // mutation.
  12569. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12570. var fields []string
  12571. if m.FieldCleared(labelrelationship.FieldStatus) {
  12572. fields = append(fields, labelrelationship.FieldStatus)
  12573. }
  12574. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12575. fields = append(fields, labelrelationship.FieldDeletedAt)
  12576. }
  12577. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12578. fields = append(fields, labelrelationship.FieldOrganizationID)
  12579. }
  12580. return fields
  12581. }
  12582. // FieldCleared returns a boolean indicating if a field with the given name was
  12583. // cleared in this mutation.
  12584. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12585. _, ok := m.clearedFields[name]
  12586. return ok
  12587. }
  12588. // ClearField clears the value of the field with the given name. It returns an
  12589. // error if the field is not defined in the schema.
  12590. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12591. switch name {
  12592. case labelrelationship.FieldStatus:
  12593. m.ClearStatus()
  12594. return nil
  12595. case labelrelationship.FieldDeletedAt:
  12596. m.ClearDeletedAt()
  12597. return nil
  12598. case labelrelationship.FieldOrganizationID:
  12599. m.ClearOrganizationID()
  12600. return nil
  12601. }
  12602. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12603. }
  12604. // ResetField resets all changes in the mutation for the field with the given name.
  12605. // It returns an error if the field is not defined in the schema.
  12606. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12607. switch name {
  12608. case labelrelationship.FieldCreatedAt:
  12609. m.ResetCreatedAt()
  12610. return nil
  12611. case labelrelationship.FieldUpdatedAt:
  12612. m.ResetUpdatedAt()
  12613. return nil
  12614. case labelrelationship.FieldStatus:
  12615. m.ResetStatus()
  12616. return nil
  12617. case labelrelationship.FieldDeletedAt:
  12618. m.ResetDeletedAt()
  12619. return nil
  12620. case labelrelationship.FieldLabelID:
  12621. m.ResetLabelID()
  12622. return nil
  12623. case labelrelationship.FieldContactID:
  12624. m.ResetContactID()
  12625. return nil
  12626. case labelrelationship.FieldOrganizationID:
  12627. m.ResetOrganizationID()
  12628. return nil
  12629. }
  12630. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12631. }
  12632. // AddedEdges returns all edge names that were set/added in this mutation.
  12633. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12634. edges := make([]string, 0, 2)
  12635. if m.contacts != nil {
  12636. edges = append(edges, labelrelationship.EdgeContacts)
  12637. }
  12638. if m.labels != nil {
  12639. edges = append(edges, labelrelationship.EdgeLabels)
  12640. }
  12641. return edges
  12642. }
  12643. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12644. // name in this mutation.
  12645. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12646. switch name {
  12647. case labelrelationship.EdgeContacts:
  12648. if id := m.contacts; id != nil {
  12649. return []ent.Value{*id}
  12650. }
  12651. case labelrelationship.EdgeLabels:
  12652. if id := m.labels; id != nil {
  12653. return []ent.Value{*id}
  12654. }
  12655. }
  12656. return nil
  12657. }
  12658. // RemovedEdges returns all edge names that were removed in this mutation.
  12659. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12660. edges := make([]string, 0, 2)
  12661. return edges
  12662. }
  12663. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12664. // the given name in this mutation.
  12665. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12666. return nil
  12667. }
  12668. // ClearedEdges returns all edge names that were cleared in this mutation.
  12669. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12670. edges := make([]string, 0, 2)
  12671. if m.clearedcontacts {
  12672. edges = append(edges, labelrelationship.EdgeContacts)
  12673. }
  12674. if m.clearedlabels {
  12675. edges = append(edges, labelrelationship.EdgeLabels)
  12676. }
  12677. return edges
  12678. }
  12679. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12680. // was cleared in this mutation.
  12681. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12682. switch name {
  12683. case labelrelationship.EdgeContacts:
  12684. return m.clearedcontacts
  12685. case labelrelationship.EdgeLabels:
  12686. return m.clearedlabels
  12687. }
  12688. return false
  12689. }
  12690. // ClearEdge clears the value of the edge with the given name. It returns an error
  12691. // if that edge is not defined in the schema.
  12692. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12693. switch name {
  12694. case labelrelationship.EdgeContacts:
  12695. m.ClearContacts()
  12696. return nil
  12697. case labelrelationship.EdgeLabels:
  12698. m.ClearLabels()
  12699. return nil
  12700. }
  12701. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12702. }
  12703. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12704. // It returns an error if the edge is not defined in the schema.
  12705. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12706. switch name {
  12707. case labelrelationship.EdgeContacts:
  12708. m.ResetContacts()
  12709. return nil
  12710. case labelrelationship.EdgeLabels:
  12711. m.ResetLabels()
  12712. return nil
  12713. }
  12714. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12715. }
  12716. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12717. type MessageMutation struct {
  12718. config
  12719. op Op
  12720. typ string
  12721. id *int
  12722. wx_wxid *string
  12723. wxid *string
  12724. content *string
  12725. clearedFields map[string]struct{}
  12726. done bool
  12727. oldValue func(context.Context) (*Message, error)
  12728. predicates []predicate.Message
  12729. }
  12730. var _ ent.Mutation = (*MessageMutation)(nil)
  12731. // messageOption allows management of the mutation configuration using functional options.
  12732. type messageOption func(*MessageMutation)
  12733. // newMessageMutation creates new mutation for the Message entity.
  12734. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12735. m := &MessageMutation{
  12736. config: c,
  12737. op: op,
  12738. typ: TypeMessage,
  12739. clearedFields: make(map[string]struct{}),
  12740. }
  12741. for _, opt := range opts {
  12742. opt(m)
  12743. }
  12744. return m
  12745. }
  12746. // withMessageID sets the ID field of the mutation.
  12747. func withMessageID(id int) messageOption {
  12748. return func(m *MessageMutation) {
  12749. var (
  12750. err error
  12751. once sync.Once
  12752. value *Message
  12753. )
  12754. m.oldValue = func(ctx context.Context) (*Message, error) {
  12755. once.Do(func() {
  12756. if m.done {
  12757. err = errors.New("querying old values post mutation is not allowed")
  12758. } else {
  12759. value, err = m.Client().Message.Get(ctx, id)
  12760. }
  12761. })
  12762. return value, err
  12763. }
  12764. m.id = &id
  12765. }
  12766. }
  12767. // withMessage sets the old Message of the mutation.
  12768. func withMessage(node *Message) messageOption {
  12769. return func(m *MessageMutation) {
  12770. m.oldValue = func(context.Context) (*Message, error) {
  12771. return node, nil
  12772. }
  12773. m.id = &node.ID
  12774. }
  12775. }
  12776. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12777. // executed in a transaction (ent.Tx), a transactional client is returned.
  12778. func (m MessageMutation) Client() *Client {
  12779. client := &Client{config: m.config}
  12780. client.init()
  12781. return client
  12782. }
  12783. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12784. // it returns an error otherwise.
  12785. func (m MessageMutation) Tx() (*Tx, error) {
  12786. if _, ok := m.driver.(*txDriver); !ok {
  12787. return nil, errors.New("ent: mutation is not running in a transaction")
  12788. }
  12789. tx := &Tx{config: m.config}
  12790. tx.init()
  12791. return tx, nil
  12792. }
  12793. // ID returns the ID value in the mutation. Note that the ID is only available
  12794. // if it was provided to the builder or after it was returned from the database.
  12795. func (m *MessageMutation) ID() (id int, exists bool) {
  12796. if m.id == nil {
  12797. return
  12798. }
  12799. return *m.id, true
  12800. }
  12801. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12802. // That means, if the mutation is applied within a transaction with an isolation level such
  12803. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12804. // or updated by the mutation.
  12805. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12806. switch {
  12807. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12808. id, exists := m.ID()
  12809. if exists {
  12810. return []int{id}, nil
  12811. }
  12812. fallthrough
  12813. case m.op.Is(OpUpdate | OpDelete):
  12814. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12815. default:
  12816. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12817. }
  12818. }
  12819. // SetWxWxid sets the "wx_wxid" field.
  12820. func (m *MessageMutation) SetWxWxid(s string) {
  12821. m.wx_wxid = &s
  12822. }
  12823. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12824. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12825. v := m.wx_wxid
  12826. if v == nil {
  12827. return
  12828. }
  12829. return *v, true
  12830. }
  12831. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12832. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12834. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12835. if !m.op.Is(OpUpdateOne) {
  12836. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12837. }
  12838. if m.id == nil || m.oldValue == nil {
  12839. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12840. }
  12841. oldValue, err := m.oldValue(ctx)
  12842. if err != nil {
  12843. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12844. }
  12845. return oldValue.WxWxid, nil
  12846. }
  12847. // ClearWxWxid clears the value of the "wx_wxid" field.
  12848. func (m *MessageMutation) ClearWxWxid() {
  12849. m.wx_wxid = nil
  12850. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12851. }
  12852. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12853. func (m *MessageMutation) WxWxidCleared() bool {
  12854. _, ok := m.clearedFields[message.FieldWxWxid]
  12855. return ok
  12856. }
  12857. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12858. func (m *MessageMutation) ResetWxWxid() {
  12859. m.wx_wxid = nil
  12860. delete(m.clearedFields, message.FieldWxWxid)
  12861. }
  12862. // SetWxid sets the "wxid" field.
  12863. func (m *MessageMutation) SetWxid(s string) {
  12864. m.wxid = &s
  12865. }
  12866. // Wxid returns the value of the "wxid" field in the mutation.
  12867. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12868. v := m.wxid
  12869. if v == nil {
  12870. return
  12871. }
  12872. return *v, true
  12873. }
  12874. // OldWxid returns the old "wxid" field's value of the Message entity.
  12875. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12877. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12878. if !m.op.Is(OpUpdateOne) {
  12879. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12880. }
  12881. if m.id == nil || m.oldValue == nil {
  12882. return v, errors.New("OldWxid requires an ID field in the mutation")
  12883. }
  12884. oldValue, err := m.oldValue(ctx)
  12885. if err != nil {
  12886. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12887. }
  12888. return oldValue.Wxid, nil
  12889. }
  12890. // ResetWxid resets all changes to the "wxid" field.
  12891. func (m *MessageMutation) ResetWxid() {
  12892. m.wxid = nil
  12893. }
  12894. // SetContent sets the "content" field.
  12895. func (m *MessageMutation) SetContent(s string) {
  12896. m.content = &s
  12897. }
  12898. // Content returns the value of the "content" field in the mutation.
  12899. func (m *MessageMutation) Content() (r string, exists bool) {
  12900. v := m.content
  12901. if v == nil {
  12902. return
  12903. }
  12904. return *v, true
  12905. }
  12906. // OldContent returns the old "content" field's value of the Message entity.
  12907. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12909. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12910. if !m.op.Is(OpUpdateOne) {
  12911. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12912. }
  12913. if m.id == nil || m.oldValue == nil {
  12914. return v, errors.New("OldContent requires an ID field in the mutation")
  12915. }
  12916. oldValue, err := m.oldValue(ctx)
  12917. if err != nil {
  12918. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12919. }
  12920. return oldValue.Content, nil
  12921. }
  12922. // ResetContent resets all changes to the "content" field.
  12923. func (m *MessageMutation) ResetContent() {
  12924. m.content = nil
  12925. }
  12926. // Where appends a list predicates to the MessageMutation builder.
  12927. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12928. m.predicates = append(m.predicates, ps...)
  12929. }
  12930. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12931. // users can use type-assertion to append predicates that do not depend on any generated package.
  12932. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12933. p := make([]predicate.Message, len(ps))
  12934. for i := range ps {
  12935. p[i] = ps[i]
  12936. }
  12937. m.Where(p...)
  12938. }
  12939. // Op returns the operation name.
  12940. func (m *MessageMutation) Op() Op {
  12941. return m.op
  12942. }
  12943. // SetOp allows setting the mutation operation.
  12944. func (m *MessageMutation) SetOp(op Op) {
  12945. m.op = op
  12946. }
  12947. // Type returns the node type of this mutation (Message).
  12948. func (m *MessageMutation) Type() string {
  12949. return m.typ
  12950. }
  12951. // Fields returns all fields that were changed during this mutation. Note that in
  12952. // order to get all numeric fields that were incremented/decremented, call
  12953. // AddedFields().
  12954. func (m *MessageMutation) Fields() []string {
  12955. fields := make([]string, 0, 3)
  12956. if m.wx_wxid != nil {
  12957. fields = append(fields, message.FieldWxWxid)
  12958. }
  12959. if m.wxid != nil {
  12960. fields = append(fields, message.FieldWxid)
  12961. }
  12962. if m.content != nil {
  12963. fields = append(fields, message.FieldContent)
  12964. }
  12965. return fields
  12966. }
  12967. // Field returns the value of a field with the given name. The second boolean
  12968. // return value indicates that this field was not set, or was not defined in the
  12969. // schema.
  12970. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  12971. switch name {
  12972. case message.FieldWxWxid:
  12973. return m.WxWxid()
  12974. case message.FieldWxid:
  12975. return m.Wxid()
  12976. case message.FieldContent:
  12977. return m.Content()
  12978. }
  12979. return nil, false
  12980. }
  12981. // OldField returns the old value of the field from the database. An error is
  12982. // returned if the mutation operation is not UpdateOne, or the query to the
  12983. // database failed.
  12984. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12985. switch name {
  12986. case message.FieldWxWxid:
  12987. return m.OldWxWxid(ctx)
  12988. case message.FieldWxid:
  12989. return m.OldWxid(ctx)
  12990. case message.FieldContent:
  12991. return m.OldContent(ctx)
  12992. }
  12993. return nil, fmt.Errorf("unknown Message field %s", name)
  12994. }
  12995. // SetField sets the value of a field with the given name. It returns an error if
  12996. // the field is not defined in the schema, or if the type mismatched the field
  12997. // type.
  12998. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  12999. switch name {
  13000. case message.FieldWxWxid:
  13001. v, ok := value.(string)
  13002. if !ok {
  13003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13004. }
  13005. m.SetWxWxid(v)
  13006. return nil
  13007. case message.FieldWxid:
  13008. v, ok := value.(string)
  13009. if !ok {
  13010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13011. }
  13012. m.SetWxid(v)
  13013. return nil
  13014. case message.FieldContent:
  13015. v, ok := value.(string)
  13016. if !ok {
  13017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13018. }
  13019. m.SetContent(v)
  13020. return nil
  13021. }
  13022. return fmt.Errorf("unknown Message field %s", name)
  13023. }
  13024. // AddedFields returns all numeric fields that were incremented/decremented during
  13025. // this mutation.
  13026. func (m *MessageMutation) AddedFields() []string {
  13027. return nil
  13028. }
  13029. // AddedField returns the numeric value that was incremented/decremented on a field
  13030. // with the given name. The second boolean return value indicates that this field
  13031. // was not set, or was not defined in the schema.
  13032. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13033. return nil, false
  13034. }
  13035. // AddField adds the value to the field with the given name. It returns an error if
  13036. // the field is not defined in the schema, or if the type mismatched the field
  13037. // type.
  13038. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13039. switch name {
  13040. }
  13041. return fmt.Errorf("unknown Message numeric field %s", name)
  13042. }
  13043. // ClearedFields returns all nullable fields that were cleared during this
  13044. // mutation.
  13045. func (m *MessageMutation) ClearedFields() []string {
  13046. var fields []string
  13047. if m.FieldCleared(message.FieldWxWxid) {
  13048. fields = append(fields, message.FieldWxWxid)
  13049. }
  13050. return fields
  13051. }
  13052. // FieldCleared returns a boolean indicating if a field with the given name was
  13053. // cleared in this mutation.
  13054. func (m *MessageMutation) FieldCleared(name string) bool {
  13055. _, ok := m.clearedFields[name]
  13056. return ok
  13057. }
  13058. // ClearField clears the value of the field with the given name. It returns an
  13059. // error if the field is not defined in the schema.
  13060. func (m *MessageMutation) ClearField(name string) error {
  13061. switch name {
  13062. case message.FieldWxWxid:
  13063. m.ClearWxWxid()
  13064. return nil
  13065. }
  13066. return fmt.Errorf("unknown Message nullable field %s", name)
  13067. }
  13068. // ResetField resets all changes in the mutation for the field with the given name.
  13069. // It returns an error if the field is not defined in the schema.
  13070. func (m *MessageMutation) ResetField(name string) error {
  13071. switch name {
  13072. case message.FieldWxWxid:
  13073. m.ResetWxWxid()
  13074. return nil
  13075. case message.FieldWxid:
  13076. m.ResetWxid()
  13077. return nil
  13078. case message.FieldContent:
  13079. m.ResetContent()
  13080. return nil
  13081. }
  13082. return fmt.Errorf("unknown Message field %s", name)
  13083. }
  13084. // AddedEdges returns all edge names that were set/added in this mutation.
  13085. func (m *MessageMutation) AddedEdges() []string {
  13086. edges := make([]string, 0, 0)
  13087. return edges
  13088. }
  13089. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13090. // name in this mutation.
  13091. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13092. return nil
  13093. }
  13094. // RemovedEdges returns all edge names that were removed in this mutation.
  13095. func (m *MessageMutation) RemovedEdges() []string {
  13096. edges := make([]string, 0, 0)
  13097. return edges
  13098. }
  13099. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13100. // the given name in this mutation.
  13101. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13102. return nil
  13103. }
  13104. // ClearedEdges returns all edge names that were cleared in this mutation.
  13105. func (m *MessageMutation) ClearedEdges() []string {
  13106. edges := make([]string, 0, 0)
  13107. return edges
  13108. }
  13109. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13110. // was cleared in this mutation.
  13111. func (m *MessageMutation) EdgeCleared(name string) bool {
  13112. return false
  13113. }
  13114. // ClearEdge clears the value of the edge with the given name. It returns an error
  13115. // if that edge is not defined in the schema.
  13116. func (m *MessageMutation) ClearEdge(name string) error {
  13117. return fmt.Errorf("unknown Message unique edge %s", name)
  13118. }
  13119. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13120. // It returns an error if the edge is not defined in the schema.
  13121. func (m *MessageMutation) ResetEdge(name string) error {
  13122. return fmt.Errorf("unknown Message edge %s", name)
  13123. }
  13124. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13125. type MessageRecordsMutation struct {
  13126. config
  13127. op Op
  13128. typ string
  13129. id *uint64
  13130. created_at *time.Time
  13131. updated_at *time.Time
  13132. status *uint8
  13133. addstatus *int8
  13134. bot_wxid *string
  13135. contact_type *int
  13136. addcontact_type *int
  13137. contact_wxid *string
  13138. content_type *int
  13139. addcontent_type *int
  13140. content *string
  13141. meta *custom_types.Meta
  13142. error_detail *string
  13143. send_time *time.Time
  13144. source_type *int
  13145. addsource_type *int
  13146. organization_id *uint64
  13147. addorganization_id *int64
  13148. clearedFields map[string]struct{}
  13149. sop_stage *uint64
  13150. clearedsop_stage bool
  13151. sop_node *uint64
  13152. clearedsop_node bool
  13153. message_contact *uint64
  13154. clearedmessage_contact bool
  13155. done bool
  13156. oldValue func(context.Context) (*MessageRecords, error)
  13157. predicates []predicate.MessageRecords
  13158. }
  13159. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13160. // messagerecordsOption allows management of the mutation configuration using functional options.
  13161. type messagerecordsOption func(*MessageRecordsMutation)
  13162. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13163. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13164. m := &MessageRecordsMutation{
  13165. config: c,
  13166. op: op,
  13167. typ: TypeMessageRecords,
  13168. clearedFields: make(map[string]struct{}),
  13169. }
  13170. for _, opt := range opts {
  13171. opt(m)
  13172. }
  13173. return m
  13174. }
  13175. // withMessageRecordsID sets the ID field of the mutation.
  13176. func withMessageRecordsID(id uint64) messagerecordsOption {
  13177. return func(m *MessageRecordsMutation) {
  13178. var (
  13179. err error
  13180. once sync.Once
  13181. value *MessageRecords
  13182. )
  13183. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13184. once.Do(func() {
  13185. if m.done {
  13186. err = errors.New("querying old values post mutation is not allowed")
  13187. } else {
  13188. value, err = m.Client().MessageRecords.Get(ctx, id)
  13189. }
  13190. })
  13191. return value, err
  13192. }
  13193. m.id = &id
  13194. }
  13195. }
  13196. // withMessageRecords sets the old MessageRecords of the mutation.
  13197. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13198. return func(m *MessageRecordsMutation) {
  13199. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13200. return node, nil
  13201. }
  13202. m.id = &node.ID
  13203. }
  13204. }
  13205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13206. // executed in a transaction (ent.Tx), a transactional client is returned.
  13207. func (m MessageRecordsMutation) Client() *Client {
  13208. client := &Client{config: m.config}
  13209. client.init()
  13210. return client
  13211. }
  13212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13213. // it returns an error otherwise.
  13214. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13215. if _, ok := m.driver.(*txDriver); !ok {
  13216. return nil, errors.New("ent: mutation is not running in a transaction")
  13217. }
  13218. tx := &Tx{config: m.config}
  13219. tx.init()
  13220. return tx, nil
  13221. }
  13222. // SetID sets the value of the id field. Note that this
  13223. // operation is only accepted on creation of MessageRecords entities.
  13224. func (m *MessageRecordsMutation) SetID(id uint64) {
  13225. m.id = &id
  13226. }
  13227. // ID returns the ID value in the mutation. Note that the ID is only available
  13228. // if it was provided to the builder or after it was returned from the database.
  13229. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13230. if m.id == nil {
  13231. return
  13232. }
  13233. return *m.id, true
  13234. }
  13235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13236. // That means, if the mutation is applied within a transaction with an isolation level such
  13237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13238. // or updated by the mutation.
  13239. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13240. switch {
  13241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13242. id, exists := m.ID()
  13243. if exists {
  13244. return []uint64{id}, nil
  13245. }
  13246. fallthrough
  13247. case m.op.Is(OpUpdate | OpDelete):
  13248. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13249. default:
  13250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13251. }
  13252. }
  13253. // SetCreatedAt sets the "created_at" field.
  13254. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13255. m.created_at = &t
  13256. }
  13257. // CreatedAt returns the value of the "created_at" field in the mutation.
  13258. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13259. v := m.created_at
  13260. if v == nil {
  13261. return
  13262. }
  13263. return *v, true
  13264. }
  13265. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13266. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13268. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13269. if !m.op.Is(OpUpdateOne) {
  13270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13271. }
  13272. if m.id == nil || m.oldValue == nil {
  13273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13274. }
  13275. oldValue, err := m.oldValue(ctx)
  13276. if err != nil {
  13277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13278. }
  13279. return oldValue.CreatedAt, nil
  13280. }
  13281. // ResetCreatedAt resets all changes to the "created_at" field.
  13282. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13283. m.created_at = nil
  13284. }
  13285. // SetUpdatedAt sets the "updated_at" field.
  13286. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13287. m.updated_at = &t
  13288. }
  13289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13290. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13291. v := m.updated_at
  13292. if v == nil {
  13293. return
  13294. }
  13295. return *v, true
  13296. }
  13297. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13298. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13300. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13301. if !m.op.Is(OpUpdateOne) {
  13302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13303. }
  13304. if m.id == nil || m.oldValue == nil {
  13305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13306. }
  13307. oldValue, err := m.oldValue(ctx)
  13308. if err != nil {
  13309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13310. }
  13311. return oldValue.UpdatedAt, nil
  13312. }
  13313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13314. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13315. m.updated_at = nil
  13316. }
  13317. // SetStatus sets the "status" field.
  13318. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13319. m.status = &u
  13320. m.addstatus = nil
  13321. }
  13322. // Status returns the value of the "status" field in the mutation.
  13323. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13324. v := m.status
  13325. if v == nil {
  13326. return
  13327. }
  13328. return *v, true
  13329. }
  13330. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13331. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13333. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13334. if !m.op.Is(OpUpdateOne) {
  13335. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13336. }
  13337. if m.id == nil || m.oldValue == nil {
  13338. return v, errors.New("OldStatus requires an ID field in the mutation")
  13339. }
  13340. oldValue, err := m.oldValue(ctx)
  13341. if err != nil {
  13342. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13343. }
  13344. return oldValue.Status, nil
  13345. }
  13346. // AddStatus adds u to the "status" field.
  13347. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13348. if m.addstatus != nil {
  13349. *m.addstatus += u
  13350. } else {
  13351. m.addstatus = &u
  13352. }
  13353. }
  13354. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13355. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13356. v := m.addstatus
  13357. if v == nil {
  13358. return
  13359. }
  13360. return *v, true
  13361. }
  13362. // ClearStatus clears the value of the "status" field.
  13363. func (m *MessageRecordsMutation) ClearStatus() {
  13364. m.status = nil
  13365. m.addstatus = nil
  13366. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13367. }
  13368. // StatusCleared returns if the "status" field was cleared in this mutation.
  13369. func (m *MessageRecordsMutation) StatusCleared() bool {
  13370. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13371. return ok
  13372. }
  13373. // ResetStatus resets all changes to the "status" field.
  13374. func (m *MessageRecordsMutation) ResetStatus() {
  13375. m.status = nil
  13376. m.addstatus = nil
  13377. delete(m.clearedFields, messagerecords.FieldStatus)
  13378. }
  13379. // SetBotWxid sets the "bot_wxid" field.
  13380. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13381. m.bot_wxid = &s
  13382. }
  13383. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13384. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13385. v := m.bot_wxid
  13386. if v == nil {
  13387. return
  13388. }
  13389. return *v, true
  13390. }
  13391. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13392. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13394. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13395. if !m.op.Is(OpUpdateOne) {
  13396. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13397. }
  13398. if m.id == nil || m.oldValue == nil {
  13399. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13400. }
  13401. oldValue, err := m.oldValue(ctx)
  13402. if err != nil {
  13403. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13404. }
  13405. return oldValue.BotWxid, nil
  13406. }
  13407. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13408. func (m *MessageRecordsMutation) ResetBotWxid() {
  13409. m.bot_wxid = nil
  13410. }
  13411. // SetContactID sets the "contact_id" field.
  13412. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13413. m.message_contact = &u
  13414. }
  13415. // ContactID returns the value of the "contact_id" field in the mutation.
  13416. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13417. v := m.message_contact
  13418. if v == nil {
  13419. return
  13420. }
  13421. return *v, true
  13422. }
  13423. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13424. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13426. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13427. if !m.op.Is(OpUpdateOne) {
  13428. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13429. }
  13430. if m.id == nil || m.oldValue == nil {
  13431. return v, errors.New("OldContactID requires an ID field in the mutation")
  13432. }
  13433. oldValue, err := m.oldValue(ctx)
  13434. if err != nil {
  13435. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13436. }
  13437. return oldValue.ContactID, nil
  13438. }
  13439. // ClearContactID clears the value of the "contact_id" field.
  13440. func (m *MessageRecordsMutation) ClearContactID() {
  13441. m.message_contact = nil
  13442. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13443. }
  13444. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13445. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13446. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13447. return ok
  13448. }
  13449. // ResetContactID resets all changes to the "contact_id" field.
  13450. func (m *MessageRecordsMutation) ResetContactID() {
  13451. m.message_contact = nil
  13452. delete(m.clearedFields, messagerecords.FieldContactID)
  13453. }
  13454. // SetContactType sets the "contact_type" field.
  13455. func (m *MessageRecordsMutation) SetContactType(i int) {
  13456. m.contact_type = &i
  13457. m.addcontact_type = nil
  13458. }
  13459. // ContactType returns the value of the "contact_type" field in the mutation.
  13460. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13461. v := m.contact_type
  13462. if v == nil {
  13463. return
  13464. }
  13465. return *v, true
  13466. }
  13467. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13468. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13470. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13471. if !m.op.Is(OpUpdateOne) {
  13472. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13473. }
  13474. if m.id == nil || m.oldValue == nil {
  13475. return v, errors.New("OldContactType requires an ID field in the mutation")
  13476. }
  13477. oldValue, err := m.oldValue(ctx)
  13478. if err != nil {
  13479. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13480. }
  13481. return oldValue.ContactType, nil
  13482. }
  13483. // AddContactType adds i to the "contact_type" field.
  13484. func (m *MessageRecordsMutation) AddContactType(i int) {
  13485. if m.addcontact_type != nil {
  13486. *m.addcontact_type += i
  13487. } else {
  13488. m.addcontact_type = &i
  13489. }
  13490. }
  13491. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13492. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13493. v := m.addcontact_type
  13494. if v == nil {
  13495. return
  13496. }
  13497. return *v, true
  13498. }
  13499. // ResetContactType resets all changes to the "contact_type" field.
  13500. func (m *MessageRecordsMutation) ResetContactType() {
  13501. m.contact_type = nil
  13502. m.addcontact_type = nil
  13503. }
  13504. // SetContactWxid sets the "contact_wxid" field.
  13505. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13506. m.contact_wxid = &s
  13507. }
  13508. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13509. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13510. v := m.contact_wxid
  13511. if v == nil {
  13512. return
  13513. }
  13514. return *v, true
  13515. }
  13516. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13517. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13519. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13520. if !m.op.Is(OpUpdateOne) {
  13521. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13522. }
  13523. if m.id == nil || m.oldValue == nil {
  13524. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13525. }
  13526. oldValue, err := m.oldValue(ctx)
  13527. if err != nil {
  13528. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13529. }
  13530. return oldValue.ContactWxid, nil
  13531. }
  13532. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13533. func (m *MessageRecordsMutation) ResetContactWxid() {
  13534. m.contact_wxid = nil
  13535. }
  13536. // SetContentType sets the "content_type" field.
  13537. func (m *MessageRecordsMutation) SetContentType(i int) {
  13538. m.content_type = &i
  13539. m.addcontent_type = nil
  13540. }
  13541. // ContentType returns the value of the "content_type" field in the mutation.
  13542. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13543. v := m.content_type
  13544. if v == nil {
  13545. return
  13546. }
  13547. return *v, true
  13548. }
  13549. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13550. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13552. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13553. if !m.op.Is(OpUpdateOne) {
  13554. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13555. }
  13556. if m.id == nil || m.oldValue == nil {
  13557. return v, errors.New("OldContentType requires an ID field in the mutation")
  13558. }
  13559. oldValue, err := m.oldValue(ctx)
  13560. if err != nil {
  13561. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13562. }
  13563. return oldValue.ContentType, nil
  13564. }
  13565. // AddContentType adds i to the "content_type" field.
  13566. func (m *MessageRecordsMutation) AddContentType(i int) {
  13567. if m.addcontent_type != nil {
  13568. *m.addcontent_type += i
  13569. } else {
  13570. m.addcontent_type = &i
  13571. }
  13572. }
  13573. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13574. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13575. v := m.addcontent_type
  13576. if v == nil {
  13577. return
  13578. }
  13579. return *v, true
  13580. }
  13581. // ResetContentType resets all changes to the "content_type" field.
  13582. func (m *MessageRecordsMutation) ResetContentType() {
  13583. m.content_type = nil
  13584. m.addcontent_type = nil
  13585. }
  13586. // SetContent sets the "content" field.
  13587. func (m *MessageRecordsMutation) SetContent(s string) {
  13588. m.content = &s
  13589. }
  13590. // Content returns the value of the "content" field in the mutation.
  13591. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13592. v := m.content
  13593. if v == nil {
  13594. return
  13595. }
  13596. return *v, true
  13597. }
  13598. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13599. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13601. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13602. if !m.op.Is(OpUpdateOne) {
  13603. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13604. }
  13605. if m.id == nil || m.oldValue == nil {
  13606. return v, errors.New("OldContent requires an ID field in the mutation")
  13607. }
  13608. oldValue, err := m.oldValue(ctx)
  13609. if err != nil {
  13610. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13611. }
  13612. return oldValue.Content, nil
  13613. }
  13614. // ResetContent resets all changes to the "content" field.
  13615. func (m *MessageRecordsMutation) ResetContent() {
  13616. m.content = nil
  13617. }
  13618. // SetMeta sets the "meta" field.
  13619. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13620. m.meta = &ct
  13621. }
  13622. // Meta returns the value of the "meta" field in the mutation.
  13623. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13624. v := m.meta
  13625. if v == nil {
  13626. return
  13627. }
  13628. return *v, true
  13629. }
  13630. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13631. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13633. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13634. if !m.op.Is(OpUpdateOne) {
  13635. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13636. }
  13637. if m.id == nil || m.oldValue == nil {
  13638. return v, errors.New("OldMeta requires an ID field in the mutation")
  13639. }
  13640. oldValue, err := m.oldValue(ctx)
  13641. if err != nil {
  13642. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13643. }
  13644. return oldValue.Meta, nil
  13645. }
  13646. // ClearMeta clears the value of the "meta" field.
  13647. func (m *MessageRecordsMutation) ClearMeta() {
  13648. m.meta = nil
  13649. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13650. }
  13651. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13652. func (m *MessageRecordsMutation) MetaCleared() bool {
  13653. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13654. return ok
  13655. }
  13656. // ResetMeta resets all changes to the "meta" field.
  13657. func (m *MessageRecordsMutation) ResetMeta() {
  13658. m.meta = nil
  13659. delete(m.clearedFields, messagerecords.FieldMeta)
  13660. }
  13661. // SetErrorDetail sets the "error_detail" field.
  13662. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13663. m.error_detail = &s
  13664. }
  13665. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13666. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13667. v := m.error_detail
  13668. if v == nil {
  13669. return
  13670. }
  13671. return *v, true
  13672. }
  13673. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13674. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13676. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13677. if !m.op.Is(OpUpdateOne) {
  13678. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13679. }
  13680. if m.id == nil || m.oldValue == nil {
  13681. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13682. }
  13683. oldValue, err := m.oldValue(ctx)
  13684. if err != nil {
  13685. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13686. }
  13687. return oldValue.ErrorDetail, nil
  13688. }
  13689. // ResetErrorDetail resets all changes to the "error_detail" field.
  13690. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13691. m.error_detail = nil
  13692. }
  13693. // SetSendTime sets the "send_time" field.
  13694. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13695. m.send_time = &t
  13696. }
  13697. // SendTime returns the value of the "send_time" field in the mutation.
  13698. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13699. v := m.send_time
  13700. if v == nil {
  13701. return
  13702. }
  13703. return *v, true
  13704. }
  13705. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13706. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13708. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13709. if !m.op.Is(OpUpdateOne) {
  13710. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13711. }
  13712. if m.id == nil || m.oldValue == nil {
  13713. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13714. }
  13715. oldValue, err := m.oldValue(ctx)
  13716. if err != nil {
  13717. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13718. }
  13719. return oldValue.SendTime, nil
  13720. }
  13721. // ClearSendTime clears the value of the "send_time" field.
  13722. func (m *MessageRecordsMutation) ClearSendTime() {
  13723. m.send_time = nil
  13724. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13725. }
  13726. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13727. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13728. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13729. return ok
  13730. }
  13731. // ResetSendTime resets all changes to the "send_time" field.
  13732. func (m *MessageRecordsMutation) ResetSendTime() {
  13733. m.send_time = nil
  13734. delete(m.clearedFields, messagerecords.FieldSendTime)
  13735. }
  13736. // SetSourceType sets the "source_type" field.
  13737. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13738. m.source_type = &i
  13739. m.addsource_type = nil
  13740. }
  13741. // SourceType returns the value of the "source_type" field in the mutation.
  13742. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13743. v := m.source_type
  13744. if v == nil {
  13745. return
  13746. }
  13747. return *v, true
  13748. }
  13749. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13750. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13752. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13753. if !m.op.Is(OpUpdateOne) {
  13754. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13755. }
  13756. if m.id == nil || m.oldValue == nil {
  13757. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13758. }
  13759. oldValue, err := m.oldValue(ctx)
  13760. if err != nil {
  13761. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13762. }
  13763. return oldValue.SourceType, nil
  13764. }
  13765. // AddSourceType adds i to the "source_type" field.
  13766. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13767. if m.addsource_type != nil {
  13768. *m.addsource_type += i
  13769. } else {
  13770. m.addsource_type = &i
  13771. }
  13772. }
  13773. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13774. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13775. v := m.addsource_type
  13776. if v == nil {
  13777. return
  13778. }
  13779. return *v, true
  13780. }
  13781. // ResetSourceType resets all changes to the "source_type" field.
  13782. func (m *MessageRecordsMutation) ResetSourceType() {
  13783. m.source_type = nil
  13784. m.addsource_type = nil
  13785. }
  13786. // SetSourceID sets the "source_id" field.
  13787. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13788. m.sop_stage = &u
  13789. }
  13790. // SourceID returns the value of the "source_id" field in the mutation.
  13791. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13792. v := m.sop_stage
  13793. if v == nil {
  13794. return
  13795. }
  13796. return *v, true
  13797. }
  13798. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13799. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13801. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13802. if !m.op.Is(OpUpdateOne) {
  13803. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13804. }
  13805. if m.id == nil || m.oldValue == nil {
  13806. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13807. }
  13808. oldValue, err := m.oldValue(ctx)
  13809. if err != nil {
  13810. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13811. }
  13812. return oldValue.SourceID, nil
  13813. }
  13814. // ClearSourceID clears the value of the "source_id" field.
  13815. func (m *MessageRecordsMutation) ClearSourceID() {
  13816. m.sop_stage = nil
  13817. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13818. }
  13819. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13820. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13821. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13822. return ok
  13823. }
  13824. // ResetSourceID resets all changes to the "source_id" field.
  13825. func (m *MessageRecordsMutation) ResetSourceID() {
  13826. m.sop_stage = nil
  13827. delete(m.clearedFields, messagerecords.FieldSourceID)
  13828. }
  13829. // SetSubSourceID sets the "sub_source_id" field.
  13830. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13831. m.sop_node = &u
  13832. }
  13833. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13834. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13835. v := m.sop_node
  13836. if v == nil {
  13837. return
  13838. }
  13839. return *v, true
  13840. }
  13841. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13842. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13844. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13845. if !m.op.Is(OpUpdateOne) {
  13846. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13847. }
  13848. if m.id == nil || m.oldValue == nil {
  13849. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13850. }
  13851. oldValue, err := m.oldValue(ctx)
  13852. if err != nil {
  13853. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13854. }
  13855. return oldValue.SubSourceID, nil
  13856. }
  13857. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13858. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13859. m.sop_node = nil
  13860. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13861. }
  13862. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13863. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13864. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13865. return ok
  13866. }
  13867. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13868. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13869. m.sop_node = nil
  13870. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13871. }
  13872. // SetOrganizationID sets the "organization_id" field.
  13873. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13874. m.organization_id = &u
  13875. m.addorganization_id = nil
  13876. }
  13877. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13878. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13879. v := m.organization_id
  13880. if v == nil {
  13881. return
  13882. }
  13883. return *v, true
  13884. }
  13885. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13886. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13888. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13889. if !m.op.Is(OpUpdateOne) {
  13890. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13891. }
  13892. if m.id == nil || m.oldValue == nil {
  13893. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13894. }
  13895. oldValue, err := m.oldValue(ctx)
  13896. if err != nil {
  13897. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13898. }
  13899. return oldValue.OrganizationID, nil
  13900. }
  13901. // AddOrganizationID adds u to the "organization_id" field.
  13902. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13903. if m.addorganization_id != nil {
  13904. *m.addorganization_id += u
  13905. } else {
  13906. m.addorganization_id = &u
  13907. }
  13908. }
  13909. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13910. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13911. v := m.addorganization_id
  13912. if v == nil {
  13913. return
  13914. }
  13915. return *v, true
  13916. }
  13917. // ClearOrganizationID clears the value of the "organization_id" field.
  13918. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13919. m.organization_id = nil
  13920. m.addorganization_id = nil
  13921. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13922. }
  13923. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13924. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13925. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13926. return ok
  13927. }
  13928. // ResetOrganizationID resets all changes to the "organization_id" field.
  13929. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13930. m.organization_id = nil
  13931. m.addorganization_id = nil
  13932. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13933. }
  13934. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13935. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13936. m.sop_stage = &id
  13937. }
  13938. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13939. func (m *MessageRecordsMutation) ClearSopStage() {
  13940. m.clearedsop_stage = true
  13941. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13942. }
  13943. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13944. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13945. return m.SourceIDCleared() || m.clearedsop_stage
  13946. }
  13947. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13948. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  13949. if m.sop_stage != nil {
  13950. return *m.sop_stage, true
  13951. }
  13952. return
  13953. }
  13954. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13955. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13956. // SopStageID instead. It exists only for internal usage by the builders.
  13957. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  13958. if id := m.sop_stage; id != nil {
  13959. ids = append(ids, *id)
  13960. }
  13961. return
  13962. }
  13963. // ResetSopStage resets all changes to the "sop_stage" edge.
  13964. func (m *MessageRecordsMutation) ResetSopStage() {
  13965. m.sop_stage = nil
  13966. m.clearedsop_stage = false
  13967. }
  13968. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  13969. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  13970. m.sop_node = &id
  13971. }
  13972. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  13973. func (m *MessageRecordsMutation) ClearSopNode() {
  13974. m.clearedsop_node = true
  13975. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13976. }
  13977. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  13978. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  13979. return m.SubSourceIDCleared() || m.clearedsop_node
  13980. }
  13981. // SopNodeID returns the "sop_node" edge ID in the mutation.
  13982. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  13983. if m.sop_node != nil {
  13984. return *m.sop_node, true
  13985. }
  13986. return
  13987. }
  13988. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  13989. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13990. // SopNodeID instead. It exists only for internal usage by the builders.
  13991. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  13992. if id := m.sop_node; id != nil {
  13993. ids = append(ids, *id)
  13994. }
  13995. return
  13996. }
  13997. // ResetSopNode resets all changes to the "sop_node" edge.
  13998. func (m *MessageRecordsMutation) ResetSopNode() {
  13999. m.sop_node = nil
  14000. m.clearedsop_node = false
  14001. }
  14002. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14003. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14004. m.message_contact = &id
  14005. }
  14006. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14007. func (m *MessageRecordsMutation) ClearMessageContact() {
  14008. m.clearedmessage_contact = true
  14009. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14010. }
  14011. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14012. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14013. return m.ContactIDCleared() || m.clearedmessage_contact
  14014. }
  14015. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14016. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14017. if m.message_contact != nil {
  14018. return *m.message_contact, true
  14019. }
  14020. return
  14021. }
  14022. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14023. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14024. // MessageContactID instead. It exists only for internal usage by the builders.
  14025. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14026. if id := m.message_contact; id != nil {
  14027. ids = append(ids, *id)
  14028. }
  14029. return
  14030. }
  14031. // ResetMessageContact resets all changes to the "message_contact" edge.
  14032. func (m *MessageRecordsMutation) ResetMessageContact() {
  14033. m.message_contact = nil
  14034. m.clearedmessage_contact = false
  14035. }
  14036. // Where appends a list predicates to the MessageRecordsMutation builder.
  14037. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14038. m.predicates = append(m.predicates, ps...)
  14039. }
  14040. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14041. // users can use type-assertion to append predicates that do not depend on any generated package.
  14042. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14043. p := make([]predicate.MessageRecords, len(ps))
  14044. for i := range ps {
  14045. p[i] = ps[i]
  14046. }
  14047. m.Where(p...)
  14048. }
  14049. // Op returns the operation name.
  14050. func (m *MessageRecordsMutation) Op() Op {
  14051. return m.op
  14052. }
  14053. // SetOp allows setting the mutation operation.
  14054. func (m *MessageRecordsMutation) SetOp(op Op) {
  14055. m.op = op
  14056. }
  14057. // Type returns the node type of this mutation (MessageRecords).
  14058. func (m *MessageRecordsMutation) Type() string {
  14059. return m.typ
  14060. }
  14061. // Fields returns all fields that were changed during this mutation. Note that in
  14062. // order to get all numeric fields that were incremented/decremented, call
  14063. // AddedFields().
  14064. func (m *MessageRecordsMutation) Fields() []string {
  14065. fields := make([]string, 0, 16)
  14066. if m.created_at != nil {
  14067. fields = append(fields, messagerecords.FieldCreatedAt)
  14068. }
  14069. if m.updated_at != nil {
  14070. fields = append(fields, messagerecords.FieldUpdatedAt)
  14071. }
  14072. if m.status != nil {
  14073. fields = append(fields, messagerecords.FieldStatus)
  14074. }
  14075. if m.bot_wxid != nil {
  14076. fields = append(fields, messagerecords.FieldBotWxid)
  14077. }
  14078. if m.message_contact != nil {
  14079. fields = append(fields, messagerecords.FieldContactID)
  14080. }
  14081. if m.contact_type != nil {
  14082. fields = append(fields, messagerecords.FieldContactType)
  14083. }
  14084. if m.contact_wxid != nil {
  14085. fields = append(fields, messagerecords.FieldContactWxid)
  14086. }
  14087. if m.content_type != nil {
  14088. fields = append(fields, messagerecords.FieldContentType)
  14089. }
  14090. if m.content != nil {
  14091. fields = append(fields, messagerecords.FieldContent)
  14092. }
  14093. if m.meta != nil {
  14094. fields = append(fields, messagerecords.FieldMeta)
  14095. }
  14096. if m.error_detail != nil {
  14097. fields = append(fields, messagerecords.FieldErrorDetail)
  14098. }
  14099. if m.send_time != nil {
  14100. fields = append(fields, messagerecords.FieldSendTime)
  14101. }
  14102. if m.source_type != nil {
  14103. fields = append(fields, messagerecords.FieldSourceType)
  14104. }
  14105. if m.sop_stage != nil {
  14106. fields = append(fields, messagerecords.FieldSourceID)
  14107. }
  14108. if m.sop_node != nil {
  14109. fields = append(fields, messagerecords.FieldSubSourceID)
  14110. }
  14111. if m.organization_id != nil {
  14112. fields = append(fields, messagerecords.FieldOrganizationID)
  14113. }
  14114. return fields
  14115. }
  14116. // Field returns the value of a field with the given name. The second boolean
  14117. // return value indicates that this field was not set, or was not defined in the
  14118. // schema.
  14119. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14120. switch name {
  14121. case messagerecords.FieldCreatedAt:
  14122. return m.CreatedAt()
  14123. case messagerecords.FieldUpdatedAt:
  14124. return m.UpdatedAt()
  14125. case messagerecords.FieldStatus:
  14126. return m.Status()
  14127. case messagerecords.FieldBotWxid:
  14128. return m.BotWxid()
  14129. case messagerecords.FieldContactID:
  14130. return m.ContactID()
  14131. case messagerecords.FieldContactType:
  14132. return m.ContactType()
  14133. case messagerecords.FieldContactWxid:
  14134. return m.ContactWxid()
  14135. case messagerecords.FieldContentType:
  14136. return m.ContentType()
  14137. case messagerecords.FieldContent:
  14138. return m.Content()
  14139. case messagerecords.FieldMeta:
  14140. return m.Meta()
  14141. case messagerecords.FieldErrorDetail:
  14142. return m.ErrorDetail()
  14143. case messagerecords.FieldSendTime:
  14144. return m.SendTime()
  14145. case messagerecords.FieldSourceType:
  14146. return m.SourceType()
  14147. case messagerecords.FieldSourceID:
  14148. return m.SourceID()
  14149. case messagerecords.FieldSubSourceID:
  14150. return m.SubSourceID()
  14151. case messagerecords.FieldOrganizationID:
  14152. return m.OrganizationID()
  14153. }
  14154. return nil, false
  14155. }
  14156. // OldField returns the old value of the field from the database. An error is
  14157. // returned if the mutation operation is not UpdateOne, or the query to the
  14158. // database failed.
  14159. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14160. switch name {
  14161. case messagerecords.FieldCreatedAt:
  14162. return m.OldCreatedAt(ctx)
  14163. case messagerecords.FieldUpdatedAt:
  14164. return m.OldUpdatedAt(ctx)
  14165. case messagerecords.FieldStatus:
  14166. return m.OldStatus(ctx)
  14167. case messagerecords.FieldBotWxid:
  14168. return m.OldBotWxid(ctx)
  14169. case messagerecords.FieldContactID:
  14170. return m.OldContactID(ctx)
  14171. case messagerecords.FieldContactType:
  14172. return m.OldContactType(ctx)
  14173. case messagerecords.FieldContactWxid:
  14174. return m.OldContactWxid(ctx)
  14175. case messagerecords.FieldContentType:
  14176. return m.OldContentType(ctx)
  14177. case messagerecords.FieldContent:
  14178. return m.OldContent(ctx)
  14179. case messagerecords.FieldMeta:
  14180. return m.OldMeta(ctx)
  14181. case messagerecords.FieldErrorDetail:
  14182. return m.OldErrorDetail(ctx)
  14183. case messagerecords.FieldSendTime:
  14184. return m.OldSendTime(ctx)
  14185. case messagerecords.FieldSourceType:
  14186. return m.OldSourceType(ctx)
  14187. case messagerecords.FieldSourceID:
  14188. return m.OldSourceID(ctx)
  14189. case messagerecords.FieldSubSourceID:
  14190. return m.OldSubSourceID(ctx)
  14191. case messagerecords.FieldOrganizationID:
  14192. return m.OldOrganizationID(ctx)
  14193. }
  14194. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14195. }
  14196. // SetField sets the value of a field with the given name. It returns an error if
  14197. // the field is not defined in the schema, or if the type mismatched the field
  14198. // type.
  14199. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14200. switch name {
  14201. case messagerecords.FieldCreatedAt:
  14202. v, ok := value.(time.Time)
  14203. if !ok {
  14204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14205. }
  14206. m.SetCreatedAt(v)
  14207. return nil
  14208. case messagerecords.FieldUpdatedAt:
  14209. v, ok := value.(time.Time)
  14210. if !ok {
  14211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14212. }
  14213. m.SetUpdatedAt(v)
  14214. return nil
  14215. case messagerecords.FieldStatus:
  14216. v, ok := value.(uint8)
  14217. if !ok {
  14218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14219. }
  14220. m.SetStatus(v)
  14221. return nil
  14222. case messagerecords.FieldBotWxid:
  14223. v, ok := value.(string)
  14224. if !ok {
  14225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14226. }
  14227. m.SetBotWxid(v)
  14228. return nil
  14229. case messagerecords.FieldContactID:
  14230. v, ok := value.(uint64)
  14231. if !ok {
  14232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14233. }
  14234. m.SetContactID(v)
  14235. return nil
  14236. case messagerecords.FieldContactType:
  14237. v, ok := value.(int)
  14238. if !ok {
  14239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14240. }
  14241. m.SetContactType(v)
  14242. return nil
  14243. case messagerecords.FieldContactWxid:
  14244. v, ok := value.(string)
  14245. if !ok {
  14246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14247. }
  14248. m.SetContactWxid(v)
  14249. return nil
  14250. case messagerecords.FieldContentType:
  14251. v, ok := value.(int)
  14252. if !ok {
  14253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14254. }
  14255. m.SetContentType(v)
  14256. return nil
  14257. case messagerecords.FieldContent:
  14258. v, ok := value.(string)
  14259. if !ok {
  14260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14261. }
  14262. m.SetContent(v)
  14263. return nil
  14264. case messagerecords.FieldMeta:
  14265. v, ok := value.(custom_types.Meta)
  14266. if !ok {
  14267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14268. }
  14269. m.SetMeta(v)
  14270. return nil
  14271. case messagerecords.FieldErrorDetail:
  14272. v, ok := value.(string)
  14273. if !ok {
  14274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14275. }
  14276. m.SetErrorDetail(v)
  14277. return nil
  14278. case messagerecords.FieldSendTime:
  14279. v, ok := value.(time.Time)
  14280. if !ok {
  14281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14282. }
  14283. m.SetSendTime(v)
  14284. return nil
  14285. case messagerecords.FieldSourceType:
  14286. v, ok := value.(int)
  14287. if !ok {
  14288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14289. }
  14290. m.SetSourceType(v)
  14291. return nil
  14292. case messagerecords.FieldSourceID:
  14293. v, ok := value.(uint64)
  14294. if !ok {
  14295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14296. }
  14297. m.SetSourceID(v)
  14298. return nil
  14299. case messagerecords.FieldSubSourceID:
  14300. v, ok := value.(uint64)
  14301. if !ok {
  14302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14303. }
  14304. m.SetSubSourceID(v)
  14305. return nil
  14306. case messagerecords.FieldOrganizationID:
  14307. v, ok := value.(uint64)
  14308. if !ok {
  14309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14310. }
  14311. m.SetOrganizationID(v)
  14312. return nil
  14313. }
  14314. return fmt.Errorf("unknown MessageRecords field %s", name)
  14315. }
  14316. // AddedFields returns all numeric fields that were incremented/decremented during
  14317. // this mutation.
  14318. func (m *MessageRecordsMutation) AddedFields() []string {
  14319. var fields []string
  14320. if m.addstatus != nil {
  14321. fields = append(fields, messagerecords.FieldStatus)
  14322. }
  14323. if m.addcontact_type != nil {
  14324. fields = append(fields, messagerecords.FieldContactType)
  14325. }
  14326. if m.addcontent_type != nil {
  14327. fields = append(fields, messagerecords.FieldContentType)
  14328. }
  14329. if m.addsource_type != nil {
  14330. fields = append(fields, messagerecords.FieldSourceType)
  14331. }
  14332. if m.addorganization_id != nil {
  14333. fields = append(fields, messagerecords.FieldOrganizationID)
  14334. }
  14335. return fields
  14336. }
  14337. // AddedField returns the numeric value that was incremented/decremented on a field
  14338. // with the given name. The second boolean return value indicates that this field
  14339. // was not set, or was not defined in the schema.
  14340. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14341. switch name {
  14342. case messagerecords.FieldStatus:
  14343. return m.AddedStatus()
  14344. case messagerecords.FieldContactType:
  14345. return m.AddedContactType()
  14346. case messagerecords.FieldContentType:
  14347. return m.AddedContentType()
  14348. case messagerecords.FieldSourceType:
  14349. return m.AddedSourceType()
  14350. case messagerecords.FieldOrganizationID:
  14351. return m.AddedOrganizationID()
  14352. }
  14353. return nil, false
  14354. }
  14355. // AddField adds the value to the field with the given name. It returns an error if
  14356. // the field is not defined in the schema, or if the type mismatched the field
  14357. // type.
  14358. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14359. switch name {
  14360. case messagerecords.FieldStatus:
  14361. v, ok := value.(int8)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.AddStatus(v)
  14366. return nil
  14367. case messagerecords.FieldContactType:
  14368. v, ok := value.(int)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.AddContactType(v)
  14373. return nil
  14374. case messagerecords.FieldContentType:
  14375. v, ok := value.(int)
  14376. if !ok {
  14377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14378. }
  14379. m.AddContentType(v)
  14380. return nil
  14381. case messagerecords.FieldSourceType:
  14382. v, ok := value.(int)
  14383. if !ok {
  14384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14385. }
  14386. m.AddSourceType(v)
  14387. return nil
  14388. case messagerecords.FieldOrganizationID:
  14389. v, ok := value.(int64)
  14390. if !ok {
  14391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14392. }
  14393. m.AddOrganizationID(v)
  14394. return nil
  14395. }
  14396. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14397. }
  14398. // ClearedFields returns all nullable fields that were cleared during this
  14399. // mutation.
  14400. func (m *MessageRecordsMutation) ClearedFields() []string {
  14401. var fields []string
  14402. if m.FieldCleared(messagerecords.FieldStatus) {
  14403. fields = append(fields, messagerecords.FieldStatus)
  14404. }
  14405. if m.FieldCleared(messagerecords.FieldContactID) {
  14406. fields = append(fields, messagerecords.FieldContactID)
  14407. }
  14408. if m.FieldCleared(messagerecords.FieldMeta) {
  14409. fields = append(fields, messagerecords.FieldMeta)
  14410. }
  14411. if m.FieldCleared(messagerecords.FieldSendTime) {
  14412. fields = append(fields, messagerecords.FieldSendTime)
  14413. }
  14414. if m.FieldCleared(messagerecords.FieldSourceID) {
  14415. fields = append(fields, messagerecords.FieldSourceID)
  14416. }
  14417. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14418. fields = append(fields, messagerecords.FieldSubSourceID)
  14419. }
  14420. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14421. fields = append(fields, messagerecords.FieldOrganizationID)
  14422. }
  14423. return fields
  14424. }
  14425. // FieldCleared returns a boolean indicating if a field with the given name was
  14426. // cleared in this mutation.
  14427. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14428. _, ok := m.clearedFields[name]
  14429. return ok
  14430. }
  14431. // ClearField clears the value of the field with the given name. It returns an
  14432. // error if the field is not defined in the schema.
  14433. func (m *MessageRecordsMutation) ClearField(name string) error {
  14434. switch name {
  14435. case messagerecords.FieldStatus:
  14436. m.ClearStatus()
  14437. return nil
  14438. case messagerecords.FieldContactID:
  14439. m.ClearContactID()
  14440. return nil
  14441. case messagerecords.FieldMeta:
  14442. m.ClearMeta()
  14443. return nil
  14444. case messagerecords.FieldSendTime:
  14445. m.ClearSendTime()
  14446. return nil
  14447. case messagerecords.FieldSourceID:
  14448. m.ClearSourceID()
  14449. return nil
  14450. case messagerecords.FieldSubSourceID:
  14451. m.ClearSubSourceID()
  14452. return nil
  14453. case messagerecords.FieldOrganizationID:
  14454. m.ClearOrganizationID()
  14455. return nil
  14456. }
  14457. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14458. }
  14459. // ResetField resets all changes in the mutation for the field with the given name.
  14460. // It returns an error if the field is not defined in the schema.
  14461. func (m *MessageRecordsMutation) ResetField(name string) error {
  14462. switch name {
  14463. case messagerecords.FieldCreatedAt:
  14464. m.ResetCreatedAt()
  14465. return nil
  14466. case messagerecords.FieldUpdatedAt:
  14467. m.ResetUpdatedAt()
  14468. return nil
  14469. case messagerecords.FieldStatus:
  14470. m.ResetStatus()
  14471. return nil
  14472. case messagerecords.FieldBotWxid:
  14473. m.ResetBotWxid()
  14474. return nil
  14475. case messagerecords.FieldContactID:
  14476. m.ResetContactID()
  14477. return nil
  14478. case messagerecords.FieldContactType:
  14479. m.ResetContactType()
  14480. return nil
  14481. case messagerecords.FieldContactWxid:
  14482. m.ResetContactWxid()
  14483. return nil
  14484. case messagerecords.FieldContentType:
  14485. m.ResetContentType()
  14486. return nil
  14487. case messagerecords.FieldContent:
  14488. m.ResetContent()
  14489. return nil
  14490. case messagerecords.FieldMeta:
  14491. m.ResetMeta()
  14492. return nil
  14493. case messagerecords.FieldErrorDetail:
  14494. m.ResetErrorDetail()
  14495. return nil
  14496. case messagerecords.FieldSendTime:
  14497. m.ResetSendTime()
  14498. return nil
  14499. case messagerecords.FieldSourceType:
  14500. m.ResetSourceType()
  14501. return nil
  14502. case messagerecords.FieldSourceID:
  14503. m.ResetSourceID()
  14504. return nil
  14505. case messagerecords.FieldSubSourceID:
  14506. m.ResetSubSourceID()
  14507. return nil
  14508. case messagerecords.FieldOrganizationID:
  14509. m.ResetOrganizationID()
  14510. return nil
  14511. }
  14512. return fmt.Errorf("unknown MessageRecords field %s", name)
  14513. }
  14514. // AddedEdges returns all edge names that were set/added in this mutation.
  14515. func (m *MessageRecordsMutation) AddedEdges() []string {
  14516. edges := make([]string, 0, 3)
  14517. if m.sop_stage != nil {
  14518. edges = append(edges, messagerecords.EdgeSopStage)
  14519. }
  14520. if m.sop_node != nil {
  14521. edges = append(edges, messagerecords.EdgeSopNode)
  14522. }
  14523. if m.message_contact != nil {
  14524. edges = append(edges, messagerecords.EdgeMessageContact)
  14525. }
  14526. return edges
  14527. }
  14528. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14529. // name in this mutation.
  14530. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14531. switch name {
  14532. case messagerecords.EdgeSopStage:
  14533. if id := m.sop_stage; id != nil {
  14534. return []ent.Value{*id}
  14535. }
  14536. case messagerecords.EdgeSopNode:
  14537. if id := m.sop_node; id != nil {
  14538. return []ent.Value{*id}
  14539. }
  14540. case messagerecords.EdgeMessageContact:
  14541. if id := m.message_contact; id != nil {
  14542. return []ent.Value{*id}
  14543. }
  14544. }
  14545. return nil
  14546. }
  14547. // RemovedEdges returns all edge names that were removed in this mutation.
  14548. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14549. edges := make([]string, 0, 3)
  14550. return edges
  14551. }
  14552. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14553. // the given name in this mutation.
  14554. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14555. return nil
  14556. }
  14557. // ClearedEdges returns all edge names that were cleared in this mutation.
  14558. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14559. edges := make([]string, 0, 3)
  14560. if m.clearedsop_stage {
  14561. edges = append(edges, messagerecords.EdgeSopStage)
  14562. }
  14563. if m.clearedsop_node {
  14564. edges = append(edges, messagerecords.EdgeSopNode)
  14565. }
  14566. if m.clearedmessage_contact {
  14567. edges = append(edges, messagerecords.EdgeMessageContact)
  14568. }
  14569. return edges
  14570. }
  14571. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14572. // was cleared in this mutation.
  14573. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14574. switch name {
  14575. case messagerecords.EdgeSopStage:
  14576. return m.clearedsop_stage
  14577. case messagerecords.EdgeSopNode:
  14578. return m.clearedsop_node
  14579. case messagerecords.EdgeMessageContact:
  14580. return m.clearedmessage_contact
  14581. }
  14582. return false
  14583. }
  14584. // ClearEdge clears the value of the edge with the given name. It returns an error
  14585. // if that edge is not defined in the schema.
  14586. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14587. switch name {
  14588. case messagerecords.EdgeSopStage:
  14589. m.ClearSopStage()
  14590. return nil
  14591. case messagerecords.EdgeSopNode:
  14592. m.ClearSopNode()
  14593. return nil
  14594. case messagerecords.EdgeMessageContact:
  14595. m.ClearMessageContact()
  14596. return nil
  14597. }
  14598. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14599. }
  14600. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14601. // It returns an error if the edge is not defined in the schema.
  14602. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14603. switch name {
  14604. case messagerecords.EdgeSopStage:
  14605. m.ResetSopStage()
  14606. return nil
  14607. case messagerecords.EdgeSopNode:
  14608. m.ResetSopNode()
  14609. return nil
  14610. case messagerecords.EdgeMessageContact:
  14611. m.ResetMessageContact()
  14612. return nil
  14613. }
  14614. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14615. }
  14616. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14617. type MsgMutation struct {
  14618. config
  14619. op Op
  14620. typ string
  14621. id *uint64
  14622. created_at *time.Time
  14623. updated_at *time.Time
  14624. deleted_at *time.Time
  14625. status *uint8
  14626. addstatus *int8
  14627. fromwxid *string
  14628. toid *string
  14629. msgtype *int32
  14630. addmsgtype *int32
  14631. msg *string
  14632. batch_no *string
  14633. clearedFields map[string]struct{}
  14634. done bool
  14635. oldValue func(context.Context) (*Msg, error)
  14636. predicates []predicate.Msg
  14637. }
  14638. var _ ent.Mutation = (*MsgMutation)(nil)
  14639. // msgOption allows management of the mutation configuration using functional options.
  14640. type msgOption func(*MsgMutation)
  14641. // newMsgMutation creates new mutation for the Msg entity.
  14642. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14643. m := &MsgMutation{
  14644. config: c,
  14645. op: op,
  14646. typ: TypeMsg,
  14647. clearedFields: make(map[string]struct{}),
  14648. }
  14649. for _, opt := range opts {
  14650. opt(m)
  14651. }
  14652. return m
  14653. }
  14654. // withMsgID sets the ID field of the mutation.
  14655. func withMsgID(id uint64) msgOption {
  14656. return func(m *MsgMutation) {
  14657. var (
  14658. err error
  14659. once sync.Once
  14660. value *Msg
  14661. )
  14662. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14663. once.Do(func() {
  14664. if m.done {
  14665. err = errors.New("querying old values post mutation is not allowed")
  14666. } else {
  14667. value, err = m.Client().Msg.Get(ctx, id)
  14668. }
  14669. })
  14670. return value, err
  14671. }
  14672. m.id = &id
  14673. }
  14674. }
  14675. // withMsg sets the old Msg of the mutation.
  14676. func withMsg(node *Msg) msgOption {
  14677. return func(m *MsgMutation) {
  14678. m.oldValue = func(context.Context) (*Msg, error) {
  14679. return node, nil
  14680. }
  14681. m.id = &node.ID
  14682. }
  14683. }
  14684. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14685. // executed in a transaction (ent.Tx), a transactional client is returned.
  14686. func (m MsgMutation) Client() *Client {
  14687. client := &Client{config: m.config}
  14688. client.init()
  14689. return client
  14690. }
  14691. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14692. // it returns an error otherwise.
  14693. func (m MsgMutation) Tx() (*Tx, error) {
  14694. if _, ok := m.driver.(*txDriver); !ok {
  14695. return nil, errors.New("ent: mutation is not running in a transaction")
  14696. }
  14697. tx := &Tx{config: m.config}
  14698. tx.init()
  14699. return tx, nil
  14700. }
  14701. // SetID sets the value of the id field. Note that this
  14702. // operation is only accepted on creation of Msg entities.
  14703. func (m *MsgMutation) SetID(id uint64) {
  14704. m.id = &id
  14705. }
  14706. // ID returns the ID value in the mutation. Note that the ID is only available
  14707. // if it was provided to the builder or after it was returned from the database.
  14708. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14709. if m.id == nil {
  14710. return
  14711. }
  14712. return *m.id, true
  14713. }
  14714. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14715. // That means, if the mutation is applied within a transaction with an isolation level such
  14716. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14717. // or updated by the mutation.
  14718. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14719. switch {
  14720. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14721. id, exists := m.ID()
  14722. if exists {
  14723. return []uint64{id}, nil
  14724. }
  14725. fallthrough
  14726. case m.op.Is(OpUpdate | OpDelete):
  14727. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14728. default:
  14729. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14730. }
  14731. }
  14732. // SetCreatedAt sets the "created_at" field.
  14733. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14734. m.created_at = &t
  14735. }
  14736. // CreatedAt returns the value of the "created_at" field in the mutation.
  14737. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14738. v := m.created_at
  14739. if v == nil {
  14740. return
  14741. }
  14742. return *v, true
  14743. }
  14744. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14745. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14747. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14748. if !m.op.Is(OpUpdateOne) {
  14749. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14750. }
  14751. if m.id == nil || m.oldValue == nil {
  14752. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14753. }
  14754. oldValue, err := m.oldValue(ctx)
  14755. if err != nil {
  14756. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14757. }
  14758. return oldValue.CreatedAt, nil
  14759. }
  14760. // ResetCreatedAt resets all changes to the "created_at" field.
  14761. func (m *MsgMutation) ResetCreatedAt() {
  14762. m.created_at = nil
  14763. }
  14764. // SetUpdatedAt sets the "updated_at" field.
  14765. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14766. m.updated_at = &t
  14767. }
  14768. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14769. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14770. v := m.updated_at
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14777. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14779. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14780. if !m.op.Is(OpUpdateOne) {
  14781. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14782. }
  14783. if m.id == nil || m.oldValue == nil {
  14784. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14785. }
  14786. oldValue, err := m.oldValue(ctx)
  14787. if err != nil {
  14788. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14789. }
  14790. return oldValue.UpdatedAt, nil
  14791. }
  14792. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14793. func (m *MsgMutation) ResetUpdatedAt() {
  14794. m.updated_at = nil
  14795. }
  14796. // SetDeletedAt sets the "deleted_at" field.
  14797. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14798. m.deleted_at = &t
  14799. }
  14800. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14801. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14802. v := m.deleted_at
  14803. if v == nil {
  14804. return
  14805. }
  14806. return *v, true
  14807. }
  14808. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14809. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14811. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14812. if !m.op.Is(OpUpdateOne) {
  14813. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14814. }
  14815. if m.id == nil || m.oldValue == nil {
  14816. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14817. }
  14818. oldValue, err := m.oldValue(ctx)
  14819. if err != nil {
  14820. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14821. }
  14822. return oldValue.DeletedAt, nil
  14823. }
  14824. // ClearDeletedAt clears the value of the "deleted_at" field.
  14825. func (m *MsgMutation) ClearDeletedAt() {
  14826. m.deleted_at = nil
  14827. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14828. }
  14829. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14830. func (m *MsgMutation) DeletedAtCleared() bool {
  14831. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14832. return ok
  14833. }
  14834. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14835. func (m *MsgMutation) ResetDeletedAt() {
  14836. m.deleted_at = nil
  14837. delete(m.clearedFields, msg.FieldDeletedAt)
  14838. }
  14839. // SetStatus sets the "status" field.
  14840. func (m *MsgMutation) SetStatus(u uint8) {
  14841. m.status = &u
  14842. m.addstatus = nil
  14843. }
  14844. // Status returns the value of the "status" field in the mutation.
  14845. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14846. v := m.status
  14847. if v == nil {
  14848. return
  14849. }
  14850. return *v, true
  14851. }
  14852. // OldStatus returns the old "status" field's value of the Msg entity.
  14853. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14855. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14856. if !m.op.Is(OpUpdateOne) {
  14857. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14858. }
  14859. if m.id == nil || m.oldValue == nil {
  14860. return v, errors.New("OldStatus requires an ID field in the mutation")
  14861. }
  14862. oldValue, err := m.oldValue(ctx)
  14863. if err != nil {
  14864. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14865. }
  14866. return oldValue.Status, nil
  14867. }
  14868. // AddStatus adds u to the "status" field.
  14869. func (m *MsgMutation) AddStatus(u int8) {
  14870. if m.addstatus != nil {
  14871. *m.addstatus += u
  14872. } else {
  14873. m.addstatus = &u
  14874. }
  14875. }
  14876. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14877. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14878. v := m.addstatus
  14879. if v == nil {
  14880. return
  14881. }
  14882. return *v, true
  14883. }
  14884. // ClearStatus clears the value of the "status" field.
  14885. func (m *MsgMutation) ClearStatus() {
  14886. m.status = nil
  14887. m.addstatus = nil
  14888. m.clearedFields[msg.FieldStatus] = struct{}{}
  14889. }
  14890. // StatusCleared returns if the "status" field was cleared in this mutation.
  14891. func (m *MsgMutation) StatusCleared() bool {
  14892. _, ok := m.clearedFields[msg.FieldStatus]
  14893. return ok
  14894. }
  14895. // ResetStatus resets all changes to the "status" field.
  14896. func (m *MsgMutation) ResetStatus() {
  14897. m.status = nil
  14898. m.addstatus = nil
  14899. delete(m.clearedFields, msg.FieldStatus)
  14900. }
  14901. // SetFromwxid sets the "fromwxid" field.
  14902. func (m *MsgMutation) SetFromwxid(s string) {
  14903. m.fromwxid = &s
  14904. }
  14905. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14906. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14907. v := m.fromwxid
  14908. if v == nil {
  14909. return
  14910. }
  14911. return *v, true
  14912. }
  14913. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14914. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14916. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14917. if !m.op.Is(OpUpdateOne) {
  14918. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14919. }
  14920. if m.id == nil || m.oldValue == nil {
  14921. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14922. }
  14923. oldValue, err := m.oldValue(ctx)
  14924. if err != nil {
  14925. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14926. }
  14927. return oldValue.Fromwxid, nil
  14928. }
  14929. // ClearFromwxid clears the value of the "fromwxid" field.
  14930. func (m *MsgMutation) ClearFromwxid() {
  14931. m.fromwxid = nil
  14932. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14933. }
  14934. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14935. func (m *MsgMutation) FromwxidCleared() bool {
  14936. _, ok := m.clearedFields[msg.FieldFromwxid]
  14937. return ok
  14938. }
  14939. // ResetFromwxid resets all changes to the "fromwxid" field.
  14940. func (m *MsgMutation) ResetFromwxid() {
  14941. m.fromwxid = nil
  14942. delete(m.clearedFields, msg.FieldFromwxid)
  14943. }
  14944. // SetToid sets the "toid" field.
  14945. func (m *MsgMutation) SetToid(s string) {
  14946. m.toid = &s
  14947. }
  14948. // Toid returns the value of the "toid" field in the mutation.
  14949. func (m *MsgMutation) Toid() (r string, exists bool) {
  14950. v := m.toid
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // OldToid returns the old "toid" field's value of the Msg entity.
  14957. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14959. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  14960. if !m.op.Is(OpUpdateOne) {
  14961. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  14962. }
  14963. if m.id == nil || m.oldValue == nil {
  14964. return v, errors.New("OldToid requires an ID field in the mutation")
  14965. }
  14966. oldValue, err := m.oldValue(ctx)
  14967. if err != nil {
  14968. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  14969. }
  14970. return oldValue.Toid, nil
  14971. }
  14972. // ClearToid clears the value of the "toid" field.
  14973. func (m *MsgMutation) ClearToid() {
  14974. m.toid = nil
  14975. m.clearedFields[msg.FieldToid] = struct{}{}
  14976. }
  14977. // ToidCleared returns if the "toid" field was cleared in this mutation.
  14978. func (m *MsgMutation) ToidCleared() bool {
  14979. _, ok := m.clearedFields[msg.FieldToid]
  14980. return ok
  14981. }
  14982. // ResetToid resets all changes to the "toid" field.
  14983. func (m *MsgMutation) ResetToid() {
  14984. m.toid = nil
  14985. delete(m.clearedFields, msg.FieldToid)
  14986. }
  14987. // SetMsgtype sets the "msgtype" field.
  14988. func (m *MsgMutation) SetMsgtype(i int32) {
  14989. m.msgtype = &i
  14990. m.addmsgtype = nil
  14991. }
  14992. // Msgtype returns the value of the "msgtype" field in the mutation.
  14993. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  14994. v := m.msgtype
  14995. if v == nil {
  14996. return
  14997. }
  14998. return *v, true
  14999. }
  15000. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15001. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15003. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15004. if !m.op.Is(OpUpdateOne) {
  15005. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15006. }
  15007. if m.id == nil || m.oldValue == nil {
  15008. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15009. }
  15010. oldValue, err := m.oldValue(ctx)
  15011. if err != nil {
  15012. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15013. }
  15014. return oldValue.Msgtype, nil
  15015. }
  15016. // AddMsgtype adds i to the "msgtype" field.
  15017. func (m *MsgMutation) AddMsgtype(i int32) {
  15018. if m.addmsgtype != nil {
  15019. *m.addmsgtype += i
  15020. } else {
  15021. m.addmsgtype = &i
  15022. }
  15023. }
  15024. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15025. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15026. v := m.addmsgtype
  15027. if v == nil {
  15028. return
  15029. }
  15030. return *v, true
  15031. }
  15032. // ClearMsgtype clears the value of the "msgtype" field.
  15033. func (m *MsgMutation) ClearMsgtype() {
  15034. m.msgtype = nil
  15035. m.addmsgtype = nil
  15036. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15037. }
  15038. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15039. func (m *MsgMutation) MsgtypeCleared() bool {
  15040. _, ok := m.clearedFields[msg.FieldMsgtype]
  15041. return ok
  15042. }
  15043. // ResetMsgtype resets all changes to the "msgtype" field.
  15044. func (m *MsgMutation) ResetMsgtype() {
  15045. m.msgtype = nil
  15046. m.addmsgtype = nil
  15047. delete(m.clearedFields, msg.FieldMsgtype)
  15048. }
  15049. // SetMsg sets the "msg" field.
  15050. func (m *MsgMutation) SetMsg(s string) {
  15051. m.msg = &s
  15052. }
  15053. // Msg returns the value of the "msg" field in the mutation.
  15054. func (m *MsgMutation) Msg() (r string, exists bool) {
  15055. v := m.msg
  15056. if v == nil {
  15057. return
  15058. }
  15059. return *v, true
  15060. }
  15061. // OldMsg returns the old "msg" field's value of the Msg entity.
  15062. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15064. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15065. if !m.op.Is(OpUpdateOne) {
  15066. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15067. }
  15068. if m.id == nil || m.oldValue == nil {
  15069. return v, errors.New("OldMsg requires an ID field in the mutation")
  15070. }
  15071. oldValue, err := m.oldValue(ctx)
  15072. if err != nil {
  15073. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15074. }
  15075. return oldValue.Msg, nil
  15076. }
  15077. // ClearMsg clears the value of the "msg" field.
  15078. func (m *MsgMutation) ClearMsg() {
  15079. m.msg = nil
  15080. m.clearedFields[msg.FieldMsg] = struct{}{}
  15081. }
  15082. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15083. func (m *MsgMutation) MsgCleared() bool {
  15084. _, ok := m.clearedFields[msg.FieldMsg]
  15085. return ok
  15086. }
  15087. // ResetMsg resets all changes to the "msg" field.
  15088. func (m *MsgMutation) ResetMsg() {
  15089. m.msg = nil
  15090. delete(m.clearedFields, msg.FieldMsg)
  15091. }
  15092. // SetBatchNo sets the "batch_no" field.
  15093. func (m *MsgMutation) SetBatchNo(s string) {
  15094. m.batch_no = &s
  15095. }
  15096. // BatchNo returns the value of the "batch_no" field in the mutation.
  15097. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15098. v := m.batch_no
  15099. if v == nil {
  15100. return
  15101. }
  15102. return *v, true
  15103. }
  15104. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15105. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15107. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15108. if !m.op.Is(OpUpdateOne) {
  15109. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15110. }
  15111. if m.id == nil || m.oldValue == nil {
  15112. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15113. }
  15114. oldValue, err := m.oldValue(ctx)
  15115. if err != nil {
  15116. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15117. }
  15118. return oldValue.BatchNo, nil
  15119. }
  15120. // ClearBatchNo clears the value of the "batch_no" field.
  15121. func (m *MsgMutation) ClearBatchNo() {
  15122. m.batch_no = nil
  15123. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15124. }
  15125. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15126. func (m *MsgMutation) BatchNoCleared() bool {
  15127. _, ok := m.clearedFields[msg.FieldBatchNo]
  15128. return ok
  15129. }
  15130. // ResetBatchNo resets all changes to the "batch_no" field.
  15131. func (m *MsgMutation) ResetBatchNo() {
  15132. m.batch_no = nil
  15133. delete(m.clearedFields, msg.FieldBatchNo)
  15134. }
  15135. // Where appends a list predicates to the MsgMutation builder.
  15136. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15137. m.predicates = append(m.predicates, ps...)
  15138. }
  15139. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15140. // users can use type-assertion to append predicates that do not depend on any generated package.
  15141. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15142. p := make([]predicate.Msg, len(ps))
  15143. for i := range ps {
  15144. p[i] = ps[i]
  15145. }
  15146. m.Where(p...)
  15147. }
  15148. // Op returns the operation name.
  15149. func (m *MsgMutation) Op() Op {
  15150. return m.op
  15151. }
  15152. // SetOp allows setting the mutation operation.
  15153. func (m *MsgMutation) SetOp(op Op) {
  15154. m.op = op
  15155. }
  15156. // Type returns the node type of this mutation (Msg).
  15157. func (m *MsgMutation) Type() string {
  15158. return m.typ
  15159. }
  15160. // Fields returns all fields that were changed during this mutation. Note that in
  15161. // order to get all numeric fields that were incremented/decremented, call
  15162. // AddedFields().
  15163. func (m *MsgMutation) Fields() []string {
  15164. fields := make([]string, 0, 9)
  15165. if m.created_at != nil {
  15166. fields = append(fields, msg.FieldCreatedAt)
  15167. }
  15168. if m.updated_at != nil {
  15169. fields = append(fields, msg.FieldUpdatedAt)
  15170. }
  15171. if m.deleted_at != nil {
  15172. fields = append(fields, msg.FieldDeletedAt)
  15173. }
  15174. if m.status != nil {
  15175. fields = append(fields, msg.FieldStatus)
  15176. }
  15177. if m.fromwxid != nil {
  15178. fields = append(fields, msg.FieldFromwxid)
  15179. }
  15180. if m.toid != nil {
  15181. fields = append(fields, msg.FieldToid)
  15182. }
  15183. if m.msgtype != nil {
  15184. fields = append(fields, msg.FieldMsgtype)
  15185. }
  15186. if m.msg != nil {
  15187. fields = append(fields, msg.FieldMsg)
  15188. }
  15189. if m.batch_no != nil {
  15190. fields = append(fields, msg.FieldBatchNo)
  15191. }
  15192. return fields
  15193. }
  15194. // Field returns the value of a field with the given name. The second boolean
  15195. // return value indicates that this field was not set, or was not defined in the
  15196. // schema.
  15197. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15198. switch name {
  15199. case msg.FieldCreatedAt:
  15200. return m.CreatedAt()
  15201. case msg.FieldUpdatedAt:
  15202. return m.UpdatedAt()
  15203. case msg.FieldDeletedAt:
  15204. return m.DeletedAt()
  15205. case msg.FieldStatus:
  15206. return m.Status()
  15207. case msg.FieldFromwxid:
  15208. return m.Fromwxid()
  15209. case msg.FieldToid:
  15210. return m.Toid()
  15211. case msg.FieldMsgtype:
  15212. return m.Msgtype()
  15213. case msg.FieldMsg:
  15214. return m.Msg()
  15215. case msg.FieldBatchNo:
  15216. return m.BatchNo()
  15217. }
  15218. return nil, false
  15219. }
  15220. // OldField returns the old value of the field from the database. An error is
  15221. // returned if the mutation operation is not UpdateOne, or the query to the
  15222. // database failed.
  15223. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15224. switch name {
  15225. case msg.FieldCreatedAt:
  15226. return m.OldCreatedAt(ctx)
  15227. case msg.FieldUpdatedAt:
  15228. return m.OldUpdatedAt(ctx)
  15229. case msg.FieldDeletedAt:
  15230. return m.OldDeletedAt(ctx)
  15231. case msg.FieldStatus:
  15232. return m.OldStatus(ctx)
  15233. case msg.FieldFromwxid:
  15234. return m.OldFromwxid(ctx)
  15235. case msg.FieldToid:
  15236. return m.OldToid(ctx)
  15237. case msg.FieldMsgtype:
  15238. return m.OldMsgtype(ctx)
  15239. case msg.FieldMsg:
  15240. return m.OldMsg(ctx)
  15241. case msg.FieldBatchNo:
  15242. return m.OldBatchNo(ctx)
  15243. }
  15244. return nil, fmt.Errorf("unknown Msg field %s", name)
  15245. }
  15246. // SetField sets the value of a field with the given name. It returns an error if
  15247. // the field is not defined in the schema, or if the type mismatched the field
  15248. // type.
  15249. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15250. switch name {
  15251. case msg.FieldCreatedAt:
  15252. v, ok := value.(time.Time)
  15253. if !ok {
  15254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15255. }
  15256. m.SetCreatedAt(v)
  15257. return nil
  15258. case msg.FieldUpdatedAt:
  15259. v, ok := value.(time.Time)
  15260. if !ok {
  15261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15262. }
  15263. m.SetUpdatedAt(v)
  15264. return nil
  15265. case msg.FieldDeletedAt:
  15266. v, ok := value.(time.Time)
  15267. if !ok {
  15268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15269. }
  15270. m.SetDeletedAt(v)
  15271. return nil
  15272. case msg.FieldStatus:
  15273. v, ok := value.(uint8)
  15274. if !ok {
  15275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15276. }
  15277. m.SetStatus(v)
  15278. return nil
  15279. case msg.FieldFromwxid:
  15280. v, ok := value.(string)
  15281. if !ok {
  15282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15283. }
  15284. m.SetFromwxid(v)
  15285. return nil
  15286. case msg.FieldToid:
  15287. v, ok := value.(string)
  15288. if !ok {
  15289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15290. }
  15291. m.SetToid(v)
  15292. return nil
  15293. case msg.FieldMsgtype:
  15294. v, ok := value.(int32)
  15295. if !ok {
  15296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15297. }
  15298. m.SetMsgtype(v)
  15299. return nil
  15300. case msg.FieldMsg:
  15301. v, ok := value.(string)
  15302. if !ok {
  15303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15304. }
  15305. m.SetMsg(v)
  15306. return nil
  15307. case msg.FieldBatchNo:
  15308. v, ok := value.(string)
  15309. if !ok {
  15310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15311. }
  15312. m.SetBatchNo(v)
  15313. return nil
  15314. }
  15315. return fmt.Errorf("unknown Msg field %s", name)
  15316. }
  15317. // AddedFields returns all numeric fields that were incremented/decremented during
  15318. // this mutation.
  15319. func (m *MsgMutation) AddedFields() []string {
  15320. var fields []string
  15321. if m.addstatus != nil {
  15322. fields = append(fields, msg.FieldStatus)
  15323. }
  15324. if m.addmsgtype != nil {
  15325. fields = append(fields, msg.FieldMsgtype)
  15326. }
  15327. return fields
  15328. }
  15329. // AddedField returns the numeric value that was incremented/decremented on a field
  15330. // with the given name. The second boolean return value indicates that this field
  15331. // was not set, or was not defined in the schema.
  15332. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15333. switch name {
  15334. case msg.FieldStatus:
  15335. return m.AddedStatus()
  15336. case msg.FieldMsgtype:
  15337. return m.AddedMsgtype()
  15338. }
  15339. return nil, false
  15340. }
  15341. // AddField adds the value to the field with the given name. It returns an error if
  15342. // the field is not defined in the schema, or if the type mismatched the field
  15343. // type.
  15344. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15345. switch name {
  15346. case msg.FieldStatus:
  15347. v, ok := value.(int8)
  15348. if !ok {
  15349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15350. }
  15351. m.AddStatus(v)
  15352. return nil
  15353. case msg.FieldMsgtype:
  15354. v, ok := value.(int32)
  15355. if !ok {
  15356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15357. }
  15358. m.AddMsgtype(v)
  15359. return nil
  15360. }
  15361. return fmt.Errorf("unknown Msg numeric field %s", name)
  15362. }
  15363. // ClearedFields returns all nullable fields that were cleared during this
  15364. // mutation.
  15365. func (m *MsgMutation) ClearedFields() []string {
  15366. var fields []string
  15367. if m.FieldCleared(msg.FieldDeletedAt) {
  15368. fields = append(fields, msg.FieldDeletedAt)
  15369. }
  15370. if m.FieldCleared(msg.FieldStatus) {
  15371. fields = append(fields, msg.FieldStatus)
  15372. }
  15373. if m.FieldCleared(msg.FieldFromwxid) {
  15374. fields = append(fields, msg.FieldFromwxid)
  15375. }
  15376. if m.FieldCleared(msg.FieldToid) {
  15377. fields = append(fields, msg.FieldToid)
  15378. }
  15379. if m.FieldCleared(msg.FieldMsgtype) {
  15380. fields = append(fields, msg.FieldMsgtype)
  15381. }
  15382. if m.FieldCleared(msg.FieldMsg) {
  15383. fields = append(fields, msg.FieldMsg)
  15384. }
  15385. if m.FieldCleared(msg.FieldBatchNo) {
  15386. fields = append(fields, msg.FieldBatchNo)
  15387. }
  15388. return fields
  15389. }
  15390. // FieldCleared returns a boolean indicating if a field with the given name was
  15391. // cleared in this mutation.
  15392. func (m *MsgMutation) FieldCleared(name string) bool {
  15393. _, ok := m.clearedFields[name]
  15394. return ok
  15395. }
  15396. // ClearField clears the value of the field with the given name. It returns an
  15397. // error if the field is not defined in the schema.
  15398. func (m *MsgMutation) ClearField(name string) error {
  15399. switch name {
  15400. case msg.FieldDeletedAt:
  15401. m.ClearDeletedAt()
  15402. return nil
  15403. case msg.FieldStatus:
  15404. m.ClearStatus()
  15405. return nil
  15406. case msg.FieldFromwxid:
  15407. m.ClearFromwxid()
  15408. return nil
  15409. case msg.FieldToid:
  15410. m.ClearToid()
  15411. return nil
  15412. case msg.FieldMsgtype:
  15413. m.ClearMsgtype()
  15414. return nil
  15415. case msg.FieldMsg:
  15416. m.ClearMsg()
  15417. return nil
  15418. case msg.FieldBatchNo:
  15419. m.ClearBatchNo()
  15420. return nil
  15421. }
  15422. return fmt.Errorf("unknown Msg nullable field %s", name)
  15423. }
  15424. // ResetField resets all changes in the mutation for the field with the given name.
  15425. // It returns an error if the field is not defined in the schema.
  15426. func (m *MsgMutation) ResetField(name string) error {
  15427. switch name {
  15428. case msg.FieldCreatedAt:
  15429. m.ResetCreatedAt()
  15430. return nil
  15431. case msg.FieldUpdatedAt:
  15432. m.ResetUpdatedAt()
  15433. return nil
  15434. case msg.FieldDeletedAt:
  15435. m.ResetDeletedAt()
  15436. return nil
  15437. case msg.FieldStatus:
  15438. m.ResetStatus()
  15439. return nil
  15440. case msg.FieldFromwxid:
  15441. m.ResetFromwxid()
  15442. return nil
  15443. case msg.FieldToid:
  15444. m.ResetToid()
  15445. return nil
  15446. case msg.FieldMsgtype:
  15447. m.ResetMsgtype()
  15448. return nil
  15449. case msg.FieldMsg:
  15450. m.ResetMsg()
  15451. return nil
  15452. case msg.FieldBatchNo:
  15453. m.ResetBatchNo()
  15454. return nil
  15455. }
  15456. return fmt.Errorf("unknown Msg field %s", name)
  15457. }
  15458. // AddedEdges returns all edge names that were set/added in this mutation.
  15459. func (m *MsgMutation) AddedEdges() []string {
  15460. edges := make([]string, 0, 0)
  15461. return edges
  15462. }
  15463. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15464. // name in this mutation.
  15465. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15466. return nil
  15467. }
  15468. // RemovedEdges returns all edge names that were removed in this mutation.
  15469. func (m *MsgMutation) RemovedEdges() []string {
  15470. edges := make([]string, 0, 0)
  15471. return edges
  15472. }
  15473. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15474. // the given name in this mutation.
  15475. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15476. return nil
  15477. }
  15478. // ClearedEdges returns all edge names that were cleared in this mutation.
  15479. func (m *MsgMutation) ClearedEdges() []string {
  15480. edges := make([]string, 0, 0)
  15481. return edges
  15482. }
  15483. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15484. // was cleared in this mutation.
  15485. func (m *MsgMutation) EdgeCleared(name string) bool {
  15486. return false
  15487. }
  15488. // ClearEdge clears the value of the edge with the given name. It returns an error
  15489. // if that edge is not defined in the schema.
  15490. func (m *MsgMutation) ClearEdge(name string) error {
  15491. return fmt.Errorf("unknown Msg unique edge %s", name)
  15492. }
  15493. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15494. // It returns an error if the edge is not defined in the schema.
  15495. func (m *MsgMutation) ResetEdge(name string) error {
  15496. return fmt.Errorf("unknown Msg edge %s", name)
  15497. }
  15498. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15499. type ServerMutation struct {
  15500. config
  15501. op Op
  15502. typ string
  15503. id *uint64
  15504. created_at *time.Time
  15505. updated_at *time.Time
  15506. status *uint8
  15507. addstatus *int8
  15508. deleted_at *time.Time
  15509. name *string
  15510. public_ip *string
  15511. private_ip *string
  15512. admin_port *string
  15513. clearedFields map[string]struct{}
  15514. wxs map[uint64]struct{}
  15515. removedwxs map[uint64]struct{}
  15516. clearedwxs bool
  15517. done bool
  15518. oldValue func(context.Context) (*Server, error)
  15519. predicates []predicate.Server
  15520. }
  15521. var _ ent.Mutation = (*ServerMutation)(nil)
  15522. // serverOption allows management of the mutation configuration using functional options.
  15523. type serverOption func(*ServerMutation)
  15524. // newServerMutation creates new mutation for the Server entity.
  15525. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15526. m := &ServerMutation{
  15527. config: c,
  15528. op: op,
  15529. typ: TypeServer,
  15530. clearedFields: make(map[string]struct{}),
  15531. }
  15532. for _, opt := range opts {
  15533. opt(m)
  15534. }
  15535. return m
  15536. }
  15537. // withServerID sets the ID field of the mutation.
  15538. func withServerID(id uint64) serverOption {
  15539. return func(m *ServerMutation) {
  15540. var (
  15541. err error
  15542. once sync.Once
  15543. value *Server
  15544. )
  15545. m.oldValue = func(ctx context.Context) (*Server, error) {
  15546. once.Do(func() {
  15547. if m.done {
  15548. err = errors.New("querying old values post mutation is not allowed")
  15549. } else {
  15550. value, err = m.Client().Server.Get(ctx, id)
  15551. }
  15552. })
  15553. return value, err
  15554. }
  15555. m.id = &id
  15556. }
  15557. }
  15558. // withServer sets the old Server of the mutation.
  15559. func withServer(node *Server) serverOption {
  15560. return func(m *ServerMutation) {
  15561. m.oldValue = func(context.Context) (*Server, error) {
  15562. return node, nil
  15563. }
  15564. m.id = &node.ID
  15565. }
  15566. }
  15567. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15568. // executed in a transaction (ent.Tx), a transactional client is returned.
  15569. func (m ServerMutation) Client() *Client {
  15570. client := &Client{config: m.config}
  15571. client.init()
  15572. return client
  15573. }
  15574. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15575. // it returns an error otherwise.
  15576. func (m ServerMutation) Tx() (*Tx, error) {
  15577. if _, ok := m.driver.(*txDriver); !ok {
  15578. return nil, errors.New("ent: mutation is not running in a transaction")
  15579. }
  15580. tx := &Tx{config: m.config}
  15581. tx.init()
  15582. return tx, nil
  15583. }
  15584. // SetID sets the value of the id field. Note that this
  15585. // operation is only accepted on creation of Server entities.
  15586. func (m *ServerMutation) SetID(id uint64) {
  15587. m.id = &id
  15588. }
  15589. // ID returns the ID value in the mutation. Note that the ID is only available
  15590. // if it was provided to the builder or after it was returned from the database.
  15591. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15592. if m.id == nil {
  15593. return
  15594. }
  15595. return *m.id, true
  15596. }
  15597. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15598. // That means, if the mutation is applied within a transaction with an isolation level such
  15599. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15600. // or updated by the mutation.
  15601. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15602. switch {
  15603. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15604. id, exists := m.ID()
  15605. if exists {
  15606. return []uint64{id}, nil
  15607. }
  15608. fallthrough
  15609. case m.op.Is(OpUpdate | OpDelete):
  15610. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15611. default:
  15612. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15613. }
  15614. }
  15615. // SetCreatedAt sets the "created_at" field.
  15616. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15617. m.created_at = &t
  15618. }
  15619. // CreatedAt returns the value of the "created_at" field in the mutation.
  15620. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15621. v := m.created_at
  15622. if v == nil {
  15623. return
  15624. }
  15625. return *v, true
  15626. }
  15627. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15628. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15630. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15631. if !m.op.Is(OpUpdateOne) {
  15632. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15633. }
  15634. if m.id == nil || m.oldValue == nil {
  15635. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15636. }
  15637. oldValue, err := m.oldValue(ctx)
  15638. if err != nil {
  15639. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15640. }
  15641. return oldValue.CreatedAt, nil
  15642. }
  15643. // ResetCreatedAt resets all changes to the "created_at" field.
  15644. func (m *ServerMutation) ResetCreatedAt() {
  15645. m.created_at = nil
  15646. }
  15647. // SetUpdatedAt sets the "updated_at" field.
  15648. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15649. m.updated_at = &t
  15650. }
  15651. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15652. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15653. v := m.updated_at
  15654. if v == nil {
  15655. return
  15656. }
  15657. return *v, true
  15658. }
  15659. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15660. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15662. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15663. if !m.op.Is(OpUpdateOne) {
  15664. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15665. }
  15666. if m.id == nil || m.oldValue == nil {
  15667. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15668. }
  15669. oldValue, err := m.oldValue(ctx)
  15670. if err != nil {
  15671. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15672. }
  15673. return oldValue.UpdatedAt, nil
  15674. }
  15675. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15676. func (m *ServerMutation) ResetUpdatedAt() {
  15677. m.updated_at = nil
  15678. }
  15679. // SetStatus sets the "status" field.
  15680. func (m *ServerMutation) SetStatus(u uint8) {
  15681. m.status = &u
  15682. m.addstatus = nil
  15683. }
  15684. // Status returns the value of the "status" field in the mutation.
  15685. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15686. v := m.status
  15687. if v == nil {
  15688. return
  15689. }
  15690. return *v, true
  15691. }
  15692. // OldStatus returns the old "status" field's value of the Server entity.
  15693. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15695. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15696. if !m.op.Is(OpUpdateOne) {
  15697. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15698. }
  15699. if m.id == nil || m.oldValue == nil {
  15700. return v, errors.New("OldStatus requires an ID field in the mutation")
  15701. }
  15702. oldValue, err := m.oldValue(ctx)
  15703. if err != nil {
  15704. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15705. }
  15706. return oldValue.Status, nil
  15707. }
  15708. // AddStatus adds u to the "status" field.
  15709. func (m *ServerMutation) AddStatus(u int8) {
  15710. if m.addstatus != nil {
  15711. *m.addstatus += u
  15712. } else {
  15713. m.addstatus = &u
  15714. }
  15715. }
  15716. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15717. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15718. v := m.addstatus
  15719. if v == nil {
  15720. return
  15721. }
  15722. return *v, true
  15723. }
  15724. // ClearStatus clears the value of the "status" field.
  15725. func (m *ServerMutation) ClearStatus() {
  15726. m.status = nil
  15727. m.addstatus = nil
  15728. m.clearedFields[server.FieldStatus] = struct{}{}
  15729. }
  15730. // StatusCleared returns if the "status" field was cleared in this mutation.
  15731. func (m *ServerMutation) StatusCleared() bool {
  15732. _, ok := m.clearedFields[server.FieldStatus]
  15733. return ok
  15734. }
  15735. // ResetStatus resets all changes to the "status" field.
  15736. func (m *ServerMutation) ResetStatus() {
  15737. m.status = nil
  15738. m.addstatus = nil
  15739. delete(m.clearedFields, server.FieldStatus)
  15740. }
  15741. // SetDeletedAt sets the "deleted_at" field.
  15742. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15743. m.deleted_at = &t
  15744. }
  15745. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15746. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15747. v := m.deleted_at
  15748. if v == nil {
  15749. return
  15750. }
  15751. return *v, true
  15752. }
  15753. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15754. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15756. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15757. if !m.op.Is(OpUpdateOne) {
  15758. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15759. }
  15760. if m.id == nil || m.oldValue == nil {
  15761. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15762. }
  15763. oldValue, err := m.oldValue(ctx)
  15764. if err != nil {
  15765. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15766. }
  15767. return oldValue.DeletedAt, nil
  15768. }
  15769. // ClearDeletedAt clears the value of the "deleted_at" field.
  15770. func (m *ServerMutation) ClearDeletedAt() {
  15771. m.deleted_at = nil
  15772. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15773. }
  15774. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15775. func (m *ServerMutation) DeletedAtCleared() bool {
  15776. _, ok := m.clearedFields[server.FieldDeletedAt]
  15777. return ok
  15778. }
  15779. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15780. func (m *ServerMutation) ResetDeletedAt() {
  15781. m.deleted_at = nil
  15782. delete(m.clearedFields, server.FieldDeletedAt)
  15783. }
  15784. // SetName sets the "name" field.
  15785. func (m *ServerMutation) SetName(s string) {
  15786. m.name = &s
  15787. }
  15788. // Name returns the value of the "name" field in the mutation.
  15789. func (m *ServerMutation) Name() (r string, exists bool) {
  15790. v := m.name
  15791. if v == nil {
  15792. return
  15793. }
  15794. return *v, true
  15795. }
  15796. // OldName returns the old "name" field's value of the Server entity.
  15797. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15799. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15800. if !m.op.Is(OpUpdateOne) {
  15801. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15802. }
  15803. if m.id == nil || m.oldValue == nil {
  15804. return v, errors.New("OldName requires an ID field in the mutation")
  15805. }
  15806. oldValue, err := m.oldValue(ctx)
  15807. if err != nil {
  15808. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15809. }
  15810. return oldValue.Name, nil
  15811. }
  15812. // ResetName resets all changes to the "name" field.
  15813. func (m *ServerMutation) ResetName() {
  15814. m.name = nil
  15815. }
  15816. // SetPublicIP sets the "public_ip" field.
  15817. func (m *ServerMutation) SetPublicIP(s string) {
  15818. m.public_ip = &s
  15819. }
  15820. // PublicIP returns the value of the "public_ip" field in the mutation.
  15821. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15822. v := m.public_ip
  15823. if v == nil {
  15824. return
  15825. }
  15826. return *v, true
  15827. }
  15828. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15829. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15831. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15832. if !m.op.Is(OpUpdateOne) {
  15833. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15834. }
  15835. if m.id == nil || m.oldValue == nil {
  15836. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15837. }
  15838. oldValue, err := m.oldValue(ctx)
  15839. if err != nil {
  15840. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15841. }
  15842. return oldValue.PublicIP, nil
  15843. }
  15844. // ResetPublicIP resets all changes to the "public_ip" field.
  15845. func (m *ServerMutation) ResetPublicIP() {
  15846. m.public_ip = nil
  15847. }
  15848. // SetPrivateIP sets the "private_ip" field.
  15849. func (m *ServerMutation) SetPrivateIP(s string) {
  15850. m.private_ip = &s
  15851. }
  15852. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15853. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15854. v := m.private_ip
  15855. if v == nil {
  15856. return
  15857. }
  15858. return *v, true
  15859. }
  15860. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15861. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15863. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15864. if !m.op.Is(OpUpdateOne) {
  15865. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15866. }
  15867. if m.id == nil || m.oldValue == nil {
  15868. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15869. }
  15870. oldValue, err := m.oldValue(ctx)
  15871. if err != nil {
  15872. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15873. }
  15874. return oldValue.PrivateIP, nil
  15875. }
  15876. // ResetPrivateIP resets all changes to the "private_ip" field.
  15877. func (m *ServerMutation) ResetPrivateIP() {
  15878. m.private_ip = nil
  15879. }
  15880. // SetAdminPort sets the "admin_port" field.
  15881. func (m *ServerMutation) SetAdminPort(s string) {
  15882. m.admin_port = &s
  15883. }
  15884. // AdminPort returns the value of the "admin_port" field in the mutation.
  15885. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15886. v := m.admin_port
  15887. if v == nil {
  15888. return
  15889. }
  15890. return *v, true
  15891. }
  15892. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15893. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15895. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15896. if !m.op.Is(OpUpdateOne) {
  15897. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15898. }
  15899. if m.id == nil || m.oldValue == nil {
  15900. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15901. }
  15902. oldValue, err := m.oldValue(ctx)
  15903. if err != nil {
  15904. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15905. }
  15906. return oldValue.AdminPort, nil
  15907. }
  15908. // ResetAdminPort resets all changes to the "admin_port" field.
  15909. func (m *ServerMutation) ResetAdminPort() {
  15910. m.admin_port = nil
  15911. }
  15912. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15913. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15914. if m.wxs == nil {
  15915. m.wxs = make(map[uint64]struct{})
  15916. }
  15917. for i := range ids {
  15918. m.wxs[ids[i]] = struct{}{}
  15919. }
  15920. }
  15921. // ClearWxs clears the "wxs" edge to the Wx entity.
  15922. func (m *ServerMutation) ClearWxs() {
  15923. m.clearedwxs = true
  15924. }
  15925. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15926. func (m *ServerMutation) WxsCleared() bool {
  15927. return m.clearedwxs
  15928. }
  15929. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15930. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15931. if m.removedwxs == nil {
  15932. m.removedwxs = make(map[uint64]struct{})
  15933. }
  15934. for i := range ids {
  15935. delete(m.wxs, ids[i])
  15936. m.removedwxs[ids[i]] = struct{}{}
  15937. }
  15938. }
  15939. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15940. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15941. for id := range m.removedwxs {
  15942. ids = append(ids, id)
  15943. }
  15944. return
  15945. }
  15946. // WxsIDs returns the "wxs" edge IDs in the mutation.
  15947. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  15948. for id := range m.wxs {
  15949. ids = append(ids, id)
  15950. }
  15951. return
  15952. }
  15953. // ResetWxs resets all changes to the "wxs" edge.
  15954. func (m *ServerMutation) ResetWxs() {
  15955. m.wxs = nil
  15956. m.clearedwxs = false
  15957. m.removedwxs = nil
  15958. }
  15959. // Where appends a list predicates to the ServerMutation builder.
  15960. func (m *ServerMutation) Where(ps ...predicate.Server) {
  15961. m.predicates = append(m.predicates, ps...)
  15962. }
  15963. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  15964. // users can use type-assertion to append predicates that do not depend on any generated package.
  15965. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  15966. p := make([]predicate.Server, len(ps))
  15967. for i := range ps {
  15968. p[i] = ps[i]
  15969. }
  15970. m.Where(p...)
  15971. }
  15972. // Op returns the operation name.
  15973. func (m *ServerMutation) Op() Op {
  15974. return m.op
  15975. }
  15976. // SetOp allows setting the mutation operation.
  15977. func (m *ServerMutation) SetOp(op Op) {
  15978. m.op = op
  15979. }
  15980. // Type returns the node type of this mutation (Server).
  15981. func (m *ServerMutation) Type() string {
  15982. return m.typ
  15983. }
  15984. // Fields returns all fields that were changed during this mutation. Note that in
  15985. // order to get all numeric fields that were incremented/decremented, call
  15986. // AddedFields().
  15987. func (m *ServerMutation) Fields() []string {
  15988. fields := make([]string, 0, 8)
  15989. if m.created_at != nil {
  15990. fields = append(fields, server.FieldCreatedAt)
  15991. }
  15992. if m.updated_at != nil {
  15993. fields = append(fields, server.FieldUpdatedAt)
  15994. }
  15995. if m.status != nil {
  15996. fields = append(fields, server.FieldStatus)
  15997. }
  15998. if m.deleted_at != nil {
  15999. fields = append(fields, server.FieldDeletedAt)
  16000. }
  16001. if m.name != nil {
  16002. fields = append(fields, server.FieldName)
  16003. }
  16004. if m.public_ip != nil {
  16005. fields = append(fields, server.FieldPublicIP)
  16006. }
  16007. if m.private_ip != nil {
  16008. fields = append(fields, server.FieldPrivateIP)
  16009. }
  16010. if m.admin_port != nil {
  16011. fields = append(fields, server.FieldAdminPort)
  16012. }
  16013. return fields
  16014. }
  16015. // Field returns the value of a field with the given name. The second boolean
  16016. // return value indicates that this field was not set, or was not defined in the
  16017. // schema.
  16018. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16019. switch name {
  16020. case server.FieldCreatedAt:
  16021. return m.CreatedAt()
  16022. case server.FieldUpdatedAt:
  16023. return m.UpdatedAt()
  16024. case server.FieldStatus:
  16025. return m.Status()
  16026. case server.FieldDeletedAt:
  16027. return m.DeletedAt()
  16028. case server.FieldName:
  16029. return m.Name()
  16030. case server.FieldPublicIP:
  16031. return m.PublicIP()
  16032. case server.FieldPrivateIP:
  16033. return m.PrivateIP()
  16034. case server.FieldAdminPort:
  16035. return m.AdminPort()
  16036. }
  16037. return nil, false
  16038. }
  16039. // OldField returns the old value of the field from the database. An error is
  16040. // returned if the mutation operation is not UpdateOne, or the query to the
  16041. // database failed.
  16042. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16043. switch name {
  16044. case server.FieldCreatedAt:
  16045. return m.OldCreatedAt(ctx)
  16046. case server.FieldUpdatedAt:
  16047. return m.OldUpdatedAt(ctx)
  16048. case server.FieldStatus:
  16049. return m.OldStatus(ctx)
  16050. case server.FieldDeletedAt:
  16051. return m.OldDeletedAt(ctx)
  16052. case server.FieldName:
  16053. return m.OldName(ctx)
  16054. case server.FieldPublicIP:
  16055. return m.OldPublicIP(ctx)
  16056. case server.FieldPrivateIP:
  16057. return m.OldPrivateIP(ctx)
  16058. case server.FieldAdminPort:
  16059. return m.OldAdminPort(ctx)
  16060. }
  16061. return nil, fmt.Errorf("unknown Server field %s", name)
  16062. }
  16063. // SetField sets the value of a field with the given name. It returns an error if
  16064. // the field is not defined in the schema, or if the type mismatched the field
  16065. // type.
  16066. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16067. switch name {
  16068. case server.FieldCreatedAt:
  16069. v, ok := value.(time.Time)
  16070. if !ok {
  16071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16072. }
  16073. m.SetCreatedAt(v)
  16074. return nil
  16075. case server.FieldUpdatedAt:
  16076. v, ok := value.(time.Time)
  16077. if !ok {
  16078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16079. }
  16080. m.SetUpdatedAt(v)
  16081. return nil
  16082. case server.FieldStatus:
  16083. v, ok := value.(uint8)
  16084. if !ok {
  16085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16086. }
  16087. m.SetStatus(v)
  16088. return nil
  16089. case server.FieldDeletedAt:
  16090. v, ok := value.(time.Time)
  16091. if !ok {
  16092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16093. }
  16094. m.SetDeletedAt(v)
  16095. return nil
  16096. case server.FieldName:
  16097. v, ok := value.(string)
  16098. if !ok {
  16099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16100. }
  16101. m.SetName(v)
  16102. return nil
  16103. case server.FieldPublicIP:
  16104. v, ok := value.(string)
  16105. if !ok {
  16106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16107. }
  16108. m.SetPublicIP(v)
  16109. return nil
  16110. case server.FieldPrivateIP:
  16111. v, ok := value.(string)
  16112. if !ok {
  16113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16114. }
  16115. m.SetPrivateIP(v)
  16116. return nil
  16117. case server.FieldAdminPort:
  16118. v, ok := value.(string)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.SetAdminPort(v)
  16123. return nil
  16124. }
  16125. return fmt.Errorf("unknown Server field %s", name)
  16126. }
  16127. // AddedFields returns all numeric fields that were incremented/decremented during
  16128. // this mutation.
  16129. func (m *ServerMutation) AddedFields() []string {
  16130. var fields []string
  16131. if m.addstatus != nil {
  16132. fields = append(fields, server.FieldStatus)
  16133. }
  16134. return fields
  16135. }
  16136. // AddedField returns the numeric value that was incremented/decremented on a field
  16137. // with the given name. The second boolean return value indicates that this field
  16138. // was not set, or was not defined in the schema.
  16139. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16140. switch name {
  16141. case server.FieldStatus:
  16142. return m.AddedStatus()
  16143. }
  16144. return nil, false
  16145. }
  16146. // AddField adds the value to the field with the given name. It returns an error if
  16147. // the field is not defined in the schema, or if the type mismatched the field
  16148. // type.
  16149. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16150. switch name {
  16151. case server.FieldStatus:
  16152. v, ok := value.(int8)
  16153. if !ok {
  16154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16155. }
  16156. m.AddStatus(v)
  16157. return nil
  16158. }
  16159. return fmt.Errorf("unknown Server numeric field %s", name)
  16160. }
  16161. // ClearedFields returns all nullable fields that were cleared during this
  16162. // mutation.
  16163. func (m *ServerMutation) ClearedFields() []string {
  16164. var fields []string
  16165. if m.FieldCleared(server.FieldStatus) {
  16166. fields = append(fields, server.FieldStatus)
  16167. }
  16168. if m.FieldCleared(server.FieldDeletedAt) {
  16169. fields = append(fields, server.FieldDeletedAt)
  16170. }
  16171. return fields
  16172. }
  16173. // FieldCleared returns a boolean indicating if a field with the given name was
  16174. // cleared in this mutation.
  16175. func (m *ServerMutation) FieldCleared(name string) bool {
  16176. _, ok := m.clearedFields[name]
  16177. return ok
  16178. }
  16179. // ClearField clears the value of the field with the given name. It returns an
  16180. // error if the field is not defined in the schema.
  16181. func (m *ServerMutation) ClearField(name string) error {
  16182. switch name {
  16183. case server.FieldStatus:
  16184. m.ClearStatus()
  16185. return nil
  16186. case server.FieldDeletedAt:
  16187. m.ClearDeletedAt()
  16188. return nil
  16189. }
  16190. return fmt.Errorf("unknown Server nullable field %s", name)
  16191. }
  16192. // ResetField resets all changes in the mutation for the field with the given name.
  16193. // It returns an error if the field is not defined in the schema.
  16194. func (m *ServerMutation) ResetField(name string) error {
  16195. switch name {
  16196. case server.FieldCreatedAt:
  16197. m.ResetCreatedAt()
  16198. return nil
  16199. case server.FieldUpdatedAt:
  16200. m.ResetUpdatedAt()
  16201. return nil
  16202. case server.FieldStatus:
  16203. m.ResetStatus()
  16204. return nil
  16205. case server.FieldDeletedAt:
  16206. m.ResetDeletedAt()
  16207. return nil
  16208. case server.FieldName:
  16209. m.ResetName()
  16210. return nil
  16211. case server.FieldPublicIP:
  16212. m.ResetPublicIP()
  16213. return nil
  16214. case server.FieldPrivateIP:
  16215. m.ResetPrivateIP()
  16216. return nil
  16217. case server.FieldAdminPort:
  16218. m.ResetAdminPort()
  16219. return nil
  16220. }
  16221. return fmt.Errorf("unknown Server field %s", name)
  16222. }
  16223. // AddedEdges returns all edge names that were set/added in this mutation.
  16224. func (m *ServerMutation) AddedEdges() []string {
  16225. edges := make([]string, 0, 1)
  16226. if m.wxs != nil {
  16227. edges = append(edges, server.EdgeWxs)
  16228. }
  16229. return edges
  16230. }
  16231. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16232. // name in this mutation.
  16233. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16234. switch name {
  16235. case server.EdgeWxs:
  16236. ids := make([]ent.Value, 0, len(m.wxs))
  16237. for id := range m.wxs {
  16238. ids = append(ids, id)
  16239. }
  16240. return ids
  16241. }
  16242. return nil
  16243. }
  16244. // RemovedEdges returns all edge names that were removed in this mutation.
  16245. func (m *ServerMutation) RemovedEdges() []string {
  16246. edges := make([]string, 0, 1)
  16247. if m.removedwxs != nil {
  16248. edges = append(edges, server.EdgeWxs)
  16249. }
  16250. return edges
  16251. }
  16252. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16253. // the given name in this mutation.
  16254. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16255. switch name {
  16256. case server.EdgeWxs:
  16257. ids := make([]ent.Value, 0, len(m.removedwxs))
  16258. for id := range m.removedwxs {
  16259. ids = append(ids, id)
  16260. }
  16261. return ids
  16262. }
  16263. return nil
  16264. }
  16265. // ClearedEdges returns all edge names that were cleared in this mutation.
  16266. func (m *ServerMutation) ClearedEdges() []string {
  16267. edges := make([]string, 0, 1)
  16268. if m.clearedwxs {
  16269. edges = append(edges, server.EdgeWxs)
  16270. }
  16271. return edges
  16272. }
  16273. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16274. // was cleared in this mutation.
  16275. func (m *ServerMutation) EdgeCleared(name string) bool {
  16276. switch name {
  16277. case server.EdgeWxs:
  16278. return m.clearedwxs
  16279. }
  16280. return false
  16281. }
  16282. // ClearEdge clears the value of the edge with the given name. It returns an error
  16283. // if that edge is not defined in the schema.
  16284. func (m *ServerMutation) ClearEdge(name string) error {
  16285. switch name {
  16286. }
  16287. return fmt.Errorf("unknown Server unique edge %s", name)
  16288. }
  16289. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16290. // It returns an error if the edge is not defined in the schema.
  16291. func (m *ServerMutation) ResetEdge(name string) error {
  16292. switch name {
  16293. case server.EdgeWxs:
  16294. m.ResetWxs()
  16295. return nil
  16296. }
  16297. return fmt.Errorf("unknown Server edge %s", name)
  16298. }
  16299. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16300. type SopNodeMutation struct {
  16301. config
  16302. op Op
  16303. typ string
  16304. id *uint64
  16305. created_at *time.Time
  16306. updated_at *time.Time
  16307. status *uint8
  16308. addstatus *int8
  16309. deleted_at *time.Time
  16310. parent_id *uint64
  16311. addparent_id *int64
  16312. name *string
  16313. condition_type *int
  16314. addcondition_type *int
  16315. condition_list *[]string
  16316. appendcondition_list []string
  16317. no_reply_condition *uint64
  16318. addno_reply_condition *int64
  16319. no_reply_unit *string
  16320. action_message *[]custom_types.Action
  16321. appendaction_message []custom_types.Action
  16322. action_label_add *[]uint64
  16323. appendaction_label_add []uint64
  16324. action_label_del *[]uint64
  16325. appendaction_label_del []uint64
  16326. action_forward **custom_types.ActionForward
  16327. clearedFields map[string]struct{}
  16328. sop_stage *uint64
  16329. clearedsop_stage bool
  16330. node_messages map[uint64]struct{}
  16331. removednode_messages map[uint64]struct{}
  16332. clearednode_messages bool
  16333. done bool
  16334. oldValue func(context.Context) (*SopNode, error)
  16335. predicates []predicate.SopNode
  16336. }
  16337. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16338. // sopnodeOption allows management of the mutation configuration using functional options.
  16339. type sopnodeOption func(*SopNodeMutation)
  16340. // newSopNodeMutation creates new mutation for the SopNode entity.
  16341. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16342. m := &SopNodeMutation{
  16343. config: c,
  16344. op: op,
  16345. typ: TypeSopNode,
  16346. clearedFields: make(map[string]struct{}),
  16347. }
  16348. for _, opt := range opts {
  16349. opt(m)
  16350. }
  16351. return m
  16352. }
  16353. // withSopNodeID sets the ID field of the mutation.
  16354. func withSopNodeID(id uint64) sopnodeOption {
  16355. return func(m *SopNodeMutation) {
  16356. var (
  16357. err error
  16358. once sync.Once
  16359. value *SopNode
  16360. )
  16361. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16362. once.Do(func() {
  16363. if m.done {
  16364. err = errors.New("querying old values post mutation is not allowed")
  16365. } else {
  16366. value, err = m.Client().SopNode.Get(ctx, id)
  16367. }
  16368. })
  16369. return value, err
  16370. }
  16371. m.id = &id
  16372. }
  16373. }
  16374. // withSopNode sets the old SopNode of the mutation.
  16375. func withSopNode(node *SopNode) sopnodeOption {
  16376. return func(m *SopNodeMutation) {
  16377. m.oldValue = func(context.Context) (*SopNode, error) {
  16378. return node, nil
  16379. }
  16380. m.id = &node.ID
  16381. }
  16382. }
  16383. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16384. // executed in a transaction (ent.Tx), a transactional client is returned.
  16385. func (m SopNodeMutation) Client() *Client {
  16386. client := &Client{config: m.config}
  16387. client.init()
  16388. return client
  16389. }
  16390. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16391. // it returns an error otherwise.
  16392. func (m SopNodeMutation) Tx() (*Tx, error) {
  16393. if _, ok := m.driver.(*txDriver); !ok {
  16394. return nil, errors.New("ent: mutation is not running in a transaction")
  16395. }
  16396. tx := &Tx{config: m.config}
  16397. tx.init()
  16398. return tx, nil
  16399. }
  16400. // SetID sets the value of the id field. Note that this
  16401. // operation is only accepted on creation of SopNode entities.
  16402. func (m *SopNodeMutation) SetID(id uint64) {
  16403. m.id = &id
  16404. }
  16405. // ID returns the ID value in the mutation. Note that the ID is only available
  16406. // if it was provided to the builder or after it was returned from the database.
  16407. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16408. if m.id == nil {
  16409. return
  16410. }
  16411. return *m.id, true
  16412. }
  16413. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16414. // That means, if the mutation is applied within a transaction with an isolation level such
  16415. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16416. // or updated by the mutation.
  16417. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16418. switch {
  16419. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16420. id, exists := m.ID()
  16421. if exists {
  16422. return []uint64{id}, nil
  16423. }
  16424. fallthrough
  16425. case m.op.Is(OpUpdate | OpDelete):
  16426. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16427. default:
  16428. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16429. }
  16430. }
  16431. // SetCreatedAt sets the "created_at" field.
  16432. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16433. m.created_at = &t
  16434. }
  16435. // CreatedAt returns the value of the "created_at" field in the mutation.
  16436. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16437. v := m.created_at
  16438. if v == nil {
  16439. return
  16440. }
  16441. return *v, true
  16442. }
  16443. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16444. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16446. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16447. if !m.op.Is(OpUpdateOne) {
  16448. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16449. }
  16450. if m.id == nil || m.oldValue == nil {
  16451. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16452. }
  16453. oldValue, err := m.oldValue(ctx)
  16454. if err != nil {
  16455. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16456. }
  16457. return oldValue.CreatedAt, nil
  16458. }
  16459. // ResetCreatedAt resets all changes to the "created_at" field.
  16460. func (m *SopNodeMutation) ResetCreatedAt() {
  16461. m.created_at = nil
  16462. }
  16463. // SetUpdatedAt sets the "updated_at" field.
  16464. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16465. m.updated_at = &t
  16466. }
  16467. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16468. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16469. v := m.updated_at
  16470. if v == nil {
  16471. return
  16472. }
  16473. return *v, true
  16474. }
  16475. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16476. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16478. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16479. if !m.op.Is(OpUpdateOne) {
  16480. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16481. }
  16482. if m.id == nil || m.oldValue == nil {
  16483. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16484. }
  16485. oldValue, err := m.oldValue(ctx)
  16486. if err != nil {
  16487. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16488. }
  16489. return oldValue.UpdatedAt, nil
  16490. }
  16491. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16492. func (m *SopNodeMutation) ResetUpdatedAt() {
  16493. m.updated_at = nil
  16494. }
  16495. // SetStatus sets the "status" field.
  16496. func (m *SopNodeMutation) SetStatus(u uint8) {
  16497. m.status = &u
  16498. m.addstatus = nil
  16499. }
  16500. // Status returns the value of the "status" field in the mutation.
  16501. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16502. v := m.status
  16503. if v == nil {
  16504. return
  16505. }
  16506. return *v, true
  16507. }
  16508. // OldStatus returns the old "status" field's value of the SopNode entity.
  16509. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16511. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16512. if !m.op.Is(OpUpdateOne) {
  16513. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16514. }
  16515. if m.id == nil || m.oldValue == nil {
  16516. return v, errors.New("OldStatus requires an ID field in the mutation")
  16517. }
  16518. oldValue, err := m.oldValue(ctx)
  16519. if err != nil {
  16520. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16521. }
  16522. return oldValue.Status, nil
  16523. }
  16524. // AddStatus adds u to the "status" field.
  16525. func (m *SopNodeMutation) AddStatus(u int8) {
  16526. if m.addstatus != nil {
  16527. *m.addstatus += u
  16528. } else {
  16529. m.addstatus = &u
  16530. }
  16531. }
  16532. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16533. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16534. v := m.addstatus
  16535. if v == nil {
  16536. return
  16537. }
  16538. return *v, true
  16539. }
  16540. // ClearStatus clears the value of the "status" field.
  16541. func (m *SopNodeMutation) ClearStatus() {
  16542. m.status = nil
  16543. m.addstatus = nil
  16544. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16545. }
  16546. // StatusCleared returns if the "status" field was cleared in this mutation.
  16547. func (m *SopNodeMutation) StatusCleared() bool {
  16548. _, ok := m.clearedFields[sopnode.FieldStatus]
  16549. return ok
  16550. }
  16551. // ResetStatus resets all changes to the "status" field.
  16552. func (m *SopNodeMutation) ResetStatus() {
  16553. m.status = nil
  16554. m.addstatus = nil
  16555. delete(m.clearedFields, sopnode.FieldStatus)
  16556. }
  16557. // SetDeletedAt sets the "deleted_at" field.
  16558. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16559. m.deleted_at = &t
  16560. }
  16561. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16562. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16563. v := m.deleted_at
  16564. if v == nil {
  16565. return
  16566. }
  16567. return *v, true
  16568. }
  16569. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16570. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16572. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16573. if !m.op.Is(OpUpdateOne) {
  16574. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16575. }
  16576. if m.id == nil || m.oldValue == nil {
  16577. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16578. }
  16579. oldValue, err := m.oldValue(ctx)
  16580. if err != nil {
  16581. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16582. }
  16583. return oldValue.DeletedAt, nil
  16584. }
  16585. // ClearDeletedAt clears the value of the "deleted_at" field.
  16586. func (m *SopNodeMutation) ClearDeletedAt() {
  16587. m.deleted_at = nil
  16588. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16589. }
  16590. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16591. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16592. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16593. return ok
  16594. }
  16595. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16596. func (m *SopNodeMutation) ResetDeletedAt() {
  16597. m.deleted_at = nil
  16598. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16599. }
  16600. // SetStageID sets the "stage_id" field.
  16601. func (m *SopNodeMutation) SetStageID(u uint64) {
  16602. m.sop_stage = &u
  16603. }
  16604. // StageID returns the value of the "stage_id" field in the mutation.
  16605. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16606. v := m.sop_stage
  16607. if v == nil {
  16608. return
  16609. }
  16610. return *v, true
  16611. }
  16612. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16613. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16615. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16616. if !m.op.Is(OpUpdateOne) {
  16617. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16618. }
  16619. if m.id == nil || m.oldValue == nil {
  16620. return v, errors.New("OldStageID requires an ID field in the mutation")
  16621. }
  16622. oldValue, err := m.oldValue(ctx)
  16623. if err != nil {
  16624. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16625. }
  16626. return oldValue.StageID, nil
  16627. }
  16628. // ResetStageID resets all changes to the "stage_id" field.
  16629. func (m *SopNodeMutation) ResetStageID() {
  16630. m.sop_stage = nil
  16631. }
  16632. // SetParentID sets the "parent_id" field.
  16633. func (m *SopNodeMutation) SetParentID(u uint64) {
  16634. m.parent_id = &u
  16635. m.addparent_id = nil
  16636. }
  16637. // ParentID returns the value of the "parent_id" field in the mutation.
  16638. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16639. v := m.parent_id
  16640. if v == nil {
  16641. return
  16642. }
  16643. return *v, true
  16644. }
  16645. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16646. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16648. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16649. if !m.op.Is(OpUpdateOne) {
  16650. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16651. }
  16652. if m.id == nil || m.oldValue == nil {
  16653. return v, errors.New("OldParentID requires an ID field in the mutation")
  16654. }
  16655. oldValue, err := m.oldValue(ctx)
  16656. if err != nil {
  16657. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16658. }
  16659. return oldValue.ParentID, nil
  16660. }
  16661. // AddParentID adds u to the "parent_id" field.
  16662. func (m *SopNodeMutation) AddParentID(u int64) {
  16663. if m.addparent_id != nil {
  16664. *m.addparent_id += u
  16665. } else {
  16666. m.addparent_id = &u
  16667. }
  16668. }
  16669. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16670. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16671. v := m.addparent_id
  16672. if v == nil {
  16673. return
  16674. }
  16675. return *v, true
  16676. }
  16677. // ResetParentID resets all changes to the "parent_id" field.
  16678. func (m *SopNodeMutation) ResetParentID() {
  16679. m.parent_id = nil
  16680. m.addparent_id = nil
  16681. }
  16682. // SetName sets the "name" field.
  16683. func (m *SopNodeMutation) SetName(s string) {
  16684. m.name = &s
  16685. }
  16686. // Name returns the value of the "name" field in the mutation.
  16687. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16688. v := m.name
  16689. if v == nil {
  16690. return
  16691. }
  16692. return *v, true
  16693. }
  16694. // OldName returns the old "name" field's value of the SopNode entity.
  16695. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16697. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16698. if !m.op.Is(OpUpdateOne) {
  16699. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16700. }
  16701. if m.id == nil || m.oldValue == nil {
  16702. return v, errors.New("OldName requires an ID field in the mutation")
  16703. }
  16704. oldValue, err := m.oldValue(ctx)
  16705. if err != nil {
  16706. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16707. }
  16708. return oldValue.Name, nil
  16709. }
  16710. // ResetName resets all changes to the "name" field.
  16711. func (m *SopNodeMutation) ResetName() {
  16712. m.name = nil
  16713. }
  16714. // SetConditionType sets the "condition_type" field.
  16715. func (m *SopNodeMutation) SetConditionType(i int) {
  16716. m.condition_type = &i
  16717. m.addcondition_type = nil
  16718. }
  16719. // ConditionType returns the value of the "condition_type" field in the mutation.
  16720. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16721. v := m.condition_type
  16722. if v == nil {
  16723. return
  16724. }
  16725. return *v, true
  16726. }
  16727. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16728. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16730. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16731. if !m.op.Is(OpUpdateOne) {
  16732. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16733. }
  16734. if m.id == nil || m.oldValue == nil {
  16735. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16736. }
  16737. oldValue, err := m.oldValue(ctx)
  16738. if err != nil {
  16739. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16740. }
  16741. return oldValue.ConditionType, nil
  16742. }
  16743. // AddConditionType adds i to the "condition_type" field.
  16744. func (m *SopNodeMutation) AddConditionType(i int) {
  16745. if m.addcondition_type != nil {
  16746. *m.addcondition_type += i
  16747. } else {
  16748. m.addcondition_type = &i
  16749. }
  16750. }
  16751. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16752. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16753. v := m.addcondition_type
  16754. if v == nil {
  16755. return
  16756. }
  16757. return *v, true
  16758. }
  16759. // ResetConditionType resets all changes to the "condition_type" field.
  16760. func (m *SopNodeMutation) ResetConditionType() {
  16761. m.condition_type = nil
  16762. m.addcondition_type = nil
  16763. }
  16764. // SetConditionList sets the "condition_list" field.
  16765. func (m *SopNodeMutation) SetConditionList(s []string) {
  16766. m.condition_list = &s
  16767. m.appendcondition_list = nil
  16768. }
  16769. // ConditionList returns the value of the "condition_list" field in the mutation.
  16770. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16771. v := m.condition_list
  16772. if v == nil {
  16773. return
  16774. }
  16775. return *v, true
  16776. }
  16777. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16778. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16780. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16781. if !m.op.Is(OpUpdateOne) {
  16782. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16783. }
  16784. if m.id == nil || m.oldValue == nil {
  16785. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16786. }
  16787. oldValue, err := m.oldValue(ctx)
  16788. if err != nil {
  16789. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16790. }
  16791. return oldValue.ConditionList, nil
  16792. }
  16793. // AppendConditionList adds s to the "condition_list" field.
  16794. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16795. m.appendcondition_list = append(m.appendcondition_list, s...)
  16796. }
  16797. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16798. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16799. if len(m.appendcondition_list) == 0 {
  16800. return nil, false
  16801. }
  16802. return m.appendcondition_list, true
  16803. }
  16804. // ClearConditionList clears the value of the "condition_list" field.
  16805. func (m *SopNodeMutation) ClearConditionList() {
  16806. m.condition_list = nil
  16807. m.appendcondition_list = nil
  16808. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16809. }
  16810. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16811. func (m *SopNodeMutation) ConditionListCleared() bool {
  16812. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16813. return ok
  16814. }
  16815. // ResetConditionList resets all changes to the "condition_list" field.
  16816. func (m *SopNodeMutation) ResetConditionList() {
  16817. m.condition_list = nil
  16818. m.appendcondition_list = nil
  16819. delete(m.clearedFields, sopnode.FieldConditionList)
  16820. }
  16821. // SetNoReplyCondition sets the "no_reply_condition" field.
  16822. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16823. m.no_reply_condition = &u
  16824. m.addno_reply_condition = nil
  16825. }
  16826. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16827. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16828. v := m.no_reply_condition
  16829. if v == nil {
  16830. return
  16831. }
  16832. return *v, true
  16833. }
  16834. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16835. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16837. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16838. if !m.op.Is(OpUpdateOne) {
  16839. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16840. }
  16841. if m.id == nil || m.oldValue == nil {
  16842. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16843. }
  16844. oldValue, err := m.oldValue(ctx)
  16845. if err != nil {
  16846. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16847. }
  16848. return oldValue.NoReplyCondition, nil
  16849. }
  16850. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16851. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16852. if m.addno_reply_condition != nil {
  16853. *m.addno_reply_condition += u
  16854. } else {
  16855. m.addno_reply_condition = &u
  16856. }
  16857. }
  16858. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16859. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16860. v := m.addno_reply_condition
  16861. if v == nil {
  16862. return
  16863. }
  16864. return *v, true
  16865. }
  16866. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16867. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16868. m.no_reply_condition = nil
  16869. m.addno_reply_condition = nil
  16870. }
  16871. // SetNoReplyUnit sets the "no_reply_unit" field.
  16872. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16873. m.no_reply_unit = &s
  16874. }
  16875. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16876. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16877. v := m.no_reply_unit
  16878. if v == nil {
  16879. return
  16880. }
  16881. return *v, true
  16882. }
  16883. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16884. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16886. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16887. if !m.op.Is(OpUpdateOne) {
  16888. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16889. }
  16890. if m.id == nil || m.oldValue == nil {
  16891. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16892. }
  16893. oldValue, err := m.oldValue(ctx)
  16894. if err != nil {
  16895. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16896. }
  16897. return oldValue.NoReplyUnit, nil
  16898. }
  16899. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16900. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16901. m.no_reply_unit = nil
  16902. }
  16903. // SetActionMessage sets the "action_message" field.
  16904. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16905. m.action_message = &ct
  16906. m.appendaction_message = nil
  16907. }
  16908. // ActionMessage returns the value of the "action_message" field in the mutation.
  16909. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16910. v := m.action_message
  16911. if v == nil {
  16912. return
  16913. }
  16914. return *v, true
  16915. }
  16916. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16917. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16919. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16920. if !m.op.Is(OpUpdateOne) {
  16921. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16922. }
  16923. if m.id == nil || m.oldValue == nil {
  16924. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16925. }
  16926. oldValue, err := m.oldValue(ctx)
  16927. if err != nil {
  16928. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16929. }
  16930. return oldValue.ActionMessage, nil
  16931. }
  16932. // AppendActionMessage adds ct to the "action_message" field.
  16933. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16934. m.appendaction_message = append(m.appendaction_message, ct...)
  16935. }
  16936. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16937. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16938. if len(m.appendaction_message) == 0 {
  16939. return nil, false
  16940. }
  16941. return m.appendaction_message, true
  16942. }
  16943. // ClearActionMessage clears the value of the "action_message" field.
  16944. func (m *SopNodeMutation) ClearActionMessage() {
  16945. m.action_message = nil
  16946. m.appendaction_message = nil
  16947. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  16948. }
  16949. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  16950. func (m *SopNodeMutation) ActionMessageCleared() bool {
  16951. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  16952. return ok
  16953. }
  16954. // ResetActionMessage resets all changes to the "action_message" field.
  16955. func (m *SopNodeMutation) ResetActionMessage() {
  16956. m.action_message = nil
  16957. m.appendaction_message = nil
  16958. delete(m.clearedFields, sopnode.FieldActionMessage)
  16959. }
  16960. // SetActionLabelAdd sets the "action_label_add" field.
  16961. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  16962. m.action_label_add = &u
  16963. m.appendaction_label_add = nil
  16964. }
  16965. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16966. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16967. v := m.action_label_add
  16968. if v == nil {
  16969. return
  16970. }
  16971. return *v, true
  16972. }
  16973. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  16974. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16976. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16977. if !m.op.Is(OpUpdateOne) {
  16978. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16979. }
  16980. if m.id == nil || m.oldValue == nil {
  16981. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16982. }
  16983. oldValue, err := m.oldValue(ctx)
  16984. if err != nil {
  16985. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16986. }
  16987. return oldValue.ActionLabelAdd, nil
  16988. }
  16989. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16990. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  16991. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16992. }
  16993. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16994. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16995. if len(m.appendaction_label_add) == 0 {
  16996. return nil, false
  16997. }
  16998. return m.appendaction_label_add, true
  16999. }
  17000. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17001. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17002. m.action_label_add = nil
  17003. m.appendaction_label_add = nil
  17004. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17005. }
  17006. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17007. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17008. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17009. return ok
  17010. }
  17011. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17012. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17013. m.action_label_add = nil
  17014. m.appendaction_label_add = nil
  17015. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17016. }
  17017. // SetActionLabelDel sets the "action_label_del" field.
  17018. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17019. m.action_label_del = &u
  17020. m.appendaction_label_del = nil
  17021. }
  17022. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17023. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17024. v := m.action_label_del
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17031. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17033. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17034. if !m.op.Is(OpUpdateOne) {
  17035. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17036. }
  17037. if m.id == nil || m.oldValue == nil {
  17038. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17039. }
  17040. oldValue, err := m.oldValue(ctx)
  17041. if err != nil {
  17042. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17043. }
  17044. return oldValue.ActionLabelDel, nil
  17045. }
  17046. // AppendActionLabelDel adds u to the "action_label_del" field.
  17047. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17048. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17049. }
  17050. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17051. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17052. if len(m.appendaction_label_del) == 0 {
  17053. return nil, false
  17054. }
  17055. return m.appendaction_label_del, true
  17056. }
  17057. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17058. func (m *SopNodeMutation) ClearActionLabelDel() {
  17059. m.action_label_del = nil
  17060. m.appendaction_label_del = nil
  17061. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17062. }
  17063. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17064. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17065. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17066. return ok
  17067. }
  17068. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17069. func (m *SopNodeMutation) ResetActionLabelDel() {
  17070. m.action_label_del = nil
  17071. m.appendaction_label_del = nil
  17072. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17073. }
  17074. // SetActionForward sets the "action_forward" field.
  17075. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17076. m.action_forward = &ctf
  17077. }
  17078. // ActionForward returns the value of the "action_forward" field in the mutation.
  17079. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17080. v := m.action_forward
  17081. if v == nil {
  17082. return
  17083. }
  17084. return *v, true
  17085. }
  17086. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17087. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17089. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17090. if !m.op.Is(OpUpdateOne) {
  17091. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17092. }
  17093. if m.id == nil || m.oldValue == nil {
  17094. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17095. }
  17096. oldValue, err := m.oldValue(ctx)
  17097. if err != nil {
  17098. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17099. }
  17100. return oldValue.ActionForward, nil
  17101. }
  17102. // ClearActionForward clears the value of the "action_forward" field.
  17103. func (m *SopNodeMutation) ClearActionForward() {
  17104. m.action_forward = nil
  17105. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17106. }
  17107. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17108. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17109. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17110. return ok
  17111. }
  17112. // ResetActionForward resets all changes to the "action_forward" field.
  17113. func (m *SopNodeMutation) ResetActionForward() {
  17114. m.action_forward = nil
  17115. delete(m.clearedFields, sopnode.FieldActionForward)
  17116. }
  17117. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17118. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17119. m.sop_stage = &id
  17120. }
  17121. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17122. func (m *SopNodeMutation) ClearSopStage() {
  17123. m.clearedsop_stage = true
  17124. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17125. }
  17126. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17127. func (m *SopNodeMutation) SopStageCleared() bool {
  17128. return m.clearedsop_stage
  17129. }
  17130. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17131. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17132. if m.sop_stage != nil {
  17133. return *m.sop_stage, true
  17134. }
  17135. return
  17136. }
  17137. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17138. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17139. // SopStageID instead. It exists only for internal usage by the builders.
  17140. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17141. if id := m.sop_stage; id != nil {
  17142. ids = append(ids, *id)
  17143. }
  17144. return
  17145. }
  17146. // ResetSopStage resets all changes to the "sop_stage" edge.
  17147. func (m *SopNodeMutation) ResetSopStage() {
  17148. m.sop_stage = nil
  17149. m.clearedsop_stage = false
  17150. }
  17151. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17152. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17153. if m.node_messages == nil {
  17154. m.node_messages = make(map[uint64]struct{})
  17155. }
  17156. for i := range ids {
  17157. m.node_messages[ids[i]] = struct{}{}
  17158. }
  17159. }
  17160. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17161. func (m *SopNodeMutation) ClearNodeMessages() {
  17162. m.clearednode_messages = true
  17163. }
  17164. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17165. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17166. return m.clearednode_messages
  17167. }
  17168. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17169. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17170. if m.removednode_messages == nil {
  17171. m.removednode_messages = make(map[uint64]struct{})
  17172. }
  17173. for i := range ids {
  17174. delete(m.node_messages, ids[i])
  17175. m.removednode_messages[ids[i]] = struct{}{}
  17176. }
  17177. }
  17178. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17179. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17180. for id := range m.removednode_messages {
  17181. ids = append(ids, id)
  17182. }
  17183. return
  17184. }
  17185. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17186. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17187. for id := range m.node_messages {
  17188. ids = append(ids, id)
  17189. }
  17190. return
  17191. }
  17192. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17193. func (m *SopNodeMutation) ResetNodeMessages() {
  17194. m.node_messages = nil
  17195. m.clearednode_messages = false
  17196. m.removednode_messages = nil
  17197. }
  17198. // Where appends a list predicates to the SopNodeMutation builder.
  17199. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17200. m.predicates = append(m.predicates, ps...)
  17201. }
  17202. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17203. // users can use type-assertion to append predicates that do not depend on any generated package.
  17204. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17205. p := make([]predicate.SopNode, len(ps))
  17206. for i := range ps {
  17207. p[i] = ps[i]
  17208. }
  17209. m.Where(p...)
  17210. }
  17211. // Op returns the operation name.
  17212. func (m *SopNodeMutation) Op() Op {
  17213. return m.op
  17214. }
  17215. // SetOp allows setting the mutation operation.
  17216. func (m *SopNodeMutation) SetOp(op Op) {
  17217. m.op = op
  17218. }
  17219. // Type returns the node type of this mutation (SopNode).
  17220. func (m *SopNodeMutation) Type() string {
  17221. return m.typ
  17222. }
  17223. // Fields returns all fields that were changed during this mutation. Note that in
  17224. // order to get all numeric fields that were incremented/decremented, call
  17225. // AddedFields().
  17226. func (m *SopNodeMutation) Fields() []string {
  17227. fields := make([]string, 0, 15)
  17228. if m.created_at != nil {
  17229. fields = append(fields, sopnode.FieldCreatedAt)
  17230. }
  17231. if m.updated_at != nil {
  17232. fields = append(fields, sopnode.FieldUpdatedAt)
  17233. }
  17234. if m.status != nil {
  17235. fields = append(fields, sopnode.FieldStatus)
  17236. }
  17237. if m.deleted_at != nil {
  17238. fields = append(fields, sopnode.FieldDeletedAt)
  17239. }
  17240. if m.sop_stage != nil {
  17241. fields = append(fields, sopnode.FieldStageID)
  17242. }
  17243. if m.parent_id != nil {
  17244. fields = append(fields, sopnode.FieldParentID)
  17245. }
  17246. if m.name != nil {
  17247. fields = append(fields, sopnode.FieldName)
  17248. }
  17249. if m.condition_type != nil {
  17250. fields = append(fields, sopnode.FieldConditionType)
  17251. }
  17252. if m.condition_list != nil {
  17253. fields = append(fields, sopnode.FieldConditionList)
  17254. }
  17255. if m.no_reply_condition != nil {
  17256. fields = append(fields, sopnode.FieldNoReplyCondition)
  17257. }
  17258. if m.no_reply_unit != nil {
  17259. fields = append(fields, sopnode.FieldNoReplyUnit)
  17260. }
  17261. if m.action_message != nil {
  17262. fields = append(fields, sopnode.FieldActionMessage)
  17263. }
  17264. if m.action_label_add != nil {
  17265. fields = append(fields, sopnode.FieldActionLabelAdd)
  17266. }
  17267. if m.action_label_del != nil {
  17268. fields = append(fields, sopnode.FieldActionLabelDel)
  17269. }
  17270. if m.action_forward != nil {
  17271. fields = append(fields, sopnode.FieldActionForward)
  17272. }
  17273. return fields
  17274. }
  17275. // Field returns the value of a field with the given name. The second boolean
  17276. // return value indicates that this field was not set, or was not defined in the
  17277. // schema.
  17278. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17279. switch name {
  17280. case sopnode.FieldCreatedAt:
  17281. return m.CreatedAt()
  17282. case sopnode.FieldUpdatedAt:
  17283. return m.UpdatedAt()
  17284. case sopnode.FieldStatus:
  17285. return m.Status()
  17286. case sopnode.FieldDeletedAt:
  17287. return m.DeletedAt()
  17288. case sopnode.FieldStageID:
  17289. return m.StageID()
  17290. case sopnode.FieldParentID:
  17291. return m.ParentID()
  17292. case sopnode.FieldName:
  17293. return m.Name()
  17294. case sopnode.FieldConditionType:
  17295. return m.ConditionType()
  17296. case sopnode.FieldConditionList:
  17297. return m.ConditionList()
  17298. case sopnode.FieldNoReplyCondition:
  17299. return m.NoReplyCondition()
  17300. case sopnode.FieldNoReplyUnit:
  17301. return m.NoReplyUnit()
  17302. case sopnode.FieldActionMessage:
  17303. return m.ActionMessage()
  17304. case sopnode.FieldActionLabelAdd:
  17305. return m.ActionLabelAdd()
  17306. case sopnode.FieldActionLabelDel:
  17307. return m.ActionLabelDel()
  17308. case sopnode.FieldActionForward:
  17309. return m.ActionForward()
  17310. }
  17311. return nil, false
  17312. }
  17313. // OldField returns the old value of the field from the database. An error is
  17314. // returned if the mutation operation is not UpdateOne, or the query to the
  17315. // database failed.
  17316. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17317. switch name {
  17318. case sopnode.FieldCreatedAt:
  17319. return m.OldCreatedAt(ctx)
  17320. case sopnode.FieldUpdatedAt:
  17321. return m.OldUpdatedAt(ctx)
  17322. case sopnode.FieldStatus:
  17323. return m.OldStatus(ctx)
  17324. case sopnode.FieldDeletedAt:
  17325. return m.OldDeletedAt(ctx)
  17326. case sopnode.FieldStageID:
  17327. return m.OldStageID(ctx)
  17328. case sopnode.FieldParentID:
  17329. return m.OldParentID(ctx)
  17330. case sopnode.FieldName:
  17331. return m.OldName(ctx)
  17332. case sopnode.FieldConditionType:
  17333. return m.OldConditionType(ctx)
  17334. case sopnode.FieldConditionList:
  17335. return m.OldConditionList(ctx)
  17336. case sopnode.FieldNoReplyCondition:
  17337. return m.OldNoReplyCondition(ctx)
  17338. case sopnode.FieldNoReplyUnit:
  17339. return m.OldNoReplyUnit(ctx)
  17340. case sopnode.FieldActionMessage:
  17341. return m.OldActionMessage(ctx)
  17342. case sopnode.FieldActionLabelAdd:
  17343. return m.OldActionLabelAdd(ctx)
  17344. case sopnode.FieldActionLabelDel:
  17345. return m.OldActionLabelDel(ctx)
  17346. case sopnode.FieldActionForward:
  17347. return m.OldActionForward(ctx)
  17348. }
  17349. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17350. }
  17351. // SetField sets the value of a field with the given name. It returns an error if
  17352. // the field is not defined in the schema, or if the type mismatched the field
  17353. // type.
  17354. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17355. switch name {
  17356. case sopnode.FieldCreatedAt:
  17357. v, ok := value.(time.Time)
  17358. if !ok {
  17359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17360. }
  17361. m.SetCreatedAt(v)
  17362. return nil
  17363. case sopnode.FieldUpdatedAt:
  17364. v, ok := value.(time.Time)
  17365. if !ok {
  17366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17367. }
  17368. m.SetUpdatedAt(v)
  17369. return nil
  17370. case sopnode.FieldStatus:
  17371. v, ok := value.(uint8)
  17372. if !ok {
  17373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17374. }
  17375. m.SetStatus(v)
  17376. return nil
  17377. case sopnode.FieldDeletedAt:
  17378. v, ok := value.(time.Time)
  17379. if !ok {
  17380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17381. }
  17382. m.SetDeletedAt(v)
  17383. return nil
  17384. case sopnode.FieldStageID:
  17385. v, ok := value.(uint64)
  17386. if !ok {
  17387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17388. }
  17389. m.SetStageID(v)
  17390. return nil
  17391. case sopnode.FieldParentID:
  17392. v, ok := value.(uint64)
  17393. if !ok {
  17394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17395. }
  17396. m.SetParentID(v)
  17397. return nil
  17398. case sopnode.FieldName:
  17399. v, ok := value.(string)
  17400. if !ok {
  17401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17402. }
  17403. m.SetName(v)
  17404. return nil
  17405. case sopnode.FieldConditionType:
  17406. v, ok := value.(int)
  17407. if !ok {
  17408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17409. }
  17410. m.SetConditionType(v)
  17411. return nil
  17412. case sopnode.FieldConditionList:
  17413. v, ok := value.([]string)
  17414. if !ok {
  17415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17416. }
  17417. m.SetConditionList(v)
  17418. return nil
  17419. case sopnode.FieldNoReplyCondition:
  17420. v, ok := value.(uint64)
  17421. if !ok {
  17422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17423. }
  17424. m.SetNoReplyCondition(v)
  17425. return nil
  17426. case sopnode.FieldNoReplyUnit:
  17427. v, ok := value.(string)
  17428. if !ok {
  17429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17430. }
  17431. m.SetNoReplyUnit(v)
  17432. return nil
  17433. case sopnode.FieldActionMessage:
  17434. v, ok := value.([]custom_types.Action)
  17435. if !ok {
  17436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17437. }
  17438. m.SetActionMessage(v)
  17439. return nil
  17440. case sopnode.FieldActionLabelAdd:
  17441. v, ok := value.([]uint64)
  17442. if !ok {
  17443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17444. }
  17445. m.SetActionLabelAdd(v)
  17446. return nil
  17447. case sopnode.FieldActionLabelDel:
  17448. v, ok := value.([]uint64)
  17449. if !ok {
  17450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17451. }
  17452. m.SetActionLabelDel(v)
  17453. return nil
  17454. case sopnode.FieldActionForward:
  17455. v, ok := value.(*custom_types.ActionForward)
  17456. if !ok {
  17457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17458. }
  17459. m.SetActionForward(v)
  17460. return nil
  17461. }
  17462. return fmt.Errorf("unknown SopNode field %s", name)
  17463. }
  17464. // AddedFields returns all numeric fields that were incremented/decremented during
  17465. // this mutation.
  17466. func (m *SopNodeMutation) AddedFields() []string {
  17467. var fields []string
  17468. if m.addstatus != nil {
  17469. fields = append(fields, sopnode.FieldStatus)
  17470. }
  17471. if m.addparent_id != nil {
  17472. fields = append(fields, sopnode.FieldParentID)
  17473. }
  17474. if m.addcondition_type != nil {
  17475. fields = append(fields, sopnode.FieldConditionType)
  17476. }
  17477. if m.addno_reply_condition != nil {
  17478. fields = append(fields, sopnode.FieldNoReplyCondition)
  17479. }
  17480. return fields
  17481. }
  17482. // AddedField returns the numeric value that was incremented/decremented on a field
  17483. // with the given name. The second boolean return value indicates that this field
  17484. // was not set, or was not defined in the schema.
  17485. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17486. switch name {
  17487. case sopnode.FieldStatus:
  17488. return m.AddedStatus()
  17489. case sopnode.FieldParentID:
  17490. return m.AddedParentID()
  17491. case sopnode.FieldConditionType:
  17492. return m.AddedConditionType()
  17493. case sopnode.FieldNoReplyCondition:
  17494. return m.AddedNoReplyCondition()
  17495. }
  17496. return nil, false
  17497. }
  17498. // AddField adds the value to the field with the given name. It returns an error if
  17499. // the field is not defined in the schema, or if the type mismatched the field
  17500. // type.
  17501. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17502. switch name {
  17503. case sopnode.FieldStatus:
  17504. v, ok := value.(int8)
  17505. if !ok {
  17506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17507. }
  17508. m.AddStatus(v)
  17509. return nil
  17510. case sopnode.FieldParentID:
  17511. v, ok := value.(int64)
  17512. if !ok {
  17513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17514. }
  17515. m.AddParentID(v)
  17516. return nil
  17517. case sopnode.FieldConditionType:
  17518. v, ok := value.(int)
  17519. if !ok {
  17520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17521. }
  17522. m.AddConditionType(v)
  17523. return nil
  17524. case sopnode.FieldNoReplyCondition:
  17525. v, ok := value.(int64)
  17526. if !ok {
  17527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17528. }
  17529. m.AddNoReplyCondition(v)
  17530. return nil
  17531. }
  17532. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17533. }
  17534. // ClearedFields returns all nullable fields that were cleared during this
  17535. // mutation.
  17536. func (m *SopNodeMutation) ClearedFields() []string {
  17537. var fields []string
  17538. if m.FieldCleared(sopnode.FieldStatus) {
  17539. fields = append(fields, sopnode.FieldStatus)
  17540. }
  17541. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17542. fields = append(fields, sopnode.FieldDeletedAt)
  17543. }
  17544. if m.FieldCleared(sopnode.FieldConditionList) {
  17545. fields = append(fields, sopnode.FieldConditionList)
  17546. }
  17547. if m.FieldCleared(sopnode.FieldActionMessage) {
  17548. fields = append(fields, sopnode.FieldActionMessage)
  17549. }
  17550. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17551. fields = append(fields, sopnode.FieldActionLabelAdd)
  17552. }
  17553. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17554. fields = append(fields, sopnode.FieldActionLabelDel)
  17555. }
  17556. if m.FieldCleared(sopnode.FieldActionForward) {
  17557. fields = append(fields, sopnode.FieldActionForward)
  17558. }
  17559. return fields
  17560. }
  17561. // FieldCleared returns a boolean indicating if a field with the given name was
  17562. // cleared in this mutation.
  17563. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17564. _, ok := m.clearedFields[name]
  17565. return ok
  17566. }
  17567. // ClearField clears the value of the field with the given name. It returns an
  17568. // error if the field is not defined in the schema.
  17569. func (m *SopNodeMutation) ClearField(name string) error {
  17570. switch name {
  17571. case sopnode.FieldStatus:
  17572. m.ClearStatus()
  17573. return nil
  17574. case sopnode.FieldDeletedAt:
  17575. m.ClearDeletedAt()
  17576. return nil
  17577. case sopnode.FieldConditionList:
  17578. m.ClearConditionList()
  17579. return nil
  17580. case sopnode.FieldActionMessage:
  17581. m.ClearActionMessage()
  17582. return nil
  17583. case sopnode.FieldActionLabelAdd:
  17584. m.ClearActionLabelAdd()
  17585. return nil
  17586. case sopnode.FieldActionLabelDel:
  17587. m.ClearActionLabelDel()
  17588. return nil
  17589. case sopnode.FieldActionForward:
  17590. m.ClearActionForward()
  17591. return nil
  17592. }
  17593. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17594. }
  17595. // ResetField resets all changes in the mutation for the field with the given name.
  17596. // It returns an error if the field is not defined in the schema.
  17597. func (m *SopNodeMutation) ResetField(name string) error {
  17598. switch name {
  17599. case sopnode.FieldCreatedAt:
  17600. m.ResetCreatedAt()
  17601. return nil
  17602. case sopnode.FieldUpdatedAt:
  17603. m.ResetUpdatedAt()
  17604. return nil
  17605. case sopnode.FieldStatus:
  17606. m.ResetStatus()
  17607. return nil
  17608. case sopnode.FieldDeletedAt:
  17609. m.ResetDeletedAt()
  17610. return nil
  17611. case sopnode.FieldStageID:
  17612. m.ResetStageID()
  17613. return nil
  17614. case sopnode.FieldParentID:
  17615. m.ResetParentID()
  17616. return nil
  17617. case sopnode.FieldName:
  17618. m.ResetName()
  17619. return nil
  17620. case sopnode.FieldConditionType:
  17621. m.ResetConditionType()
  17622. return nil
  17623. case sopnode.FieldConditionList:
  17624. m.ResetConditionList()
  17625. return nil
  17626. case sopnode.FieldNoReplyCondition:
  17627. m.ResetNoReplyCondition()
  17628. return nil
  17629. case sopnode.FieldNoReplyUnit:
  17630. m.ResetNoReplyUnit()
  17631. return nil
  17632. case sopnode.FieldActionMessage:
  17633. m.ResetActionMessage()
  17634. return nil
  17635. case sopnode.FieldActionLabelAdd:
  17636. m.ResetActionLabelAdd()
  17637. return nil
  17638. case sopnode.FieldActionLabelDel:
  17639. m.ResetActionLabelDel()
  17640. return nil
  17641. case sopnode.FieldActionForward:
  17642. m.ResetActionForward()
  17643. return nil
  17644. }
  17645. return fmt.Errorf("unknown SopNode field %s", name)
  17646. }
  17647. // AddedEdges returns all edge names that were set/added in this mutation.
  17648. func (m *SopNodeMutation) AddedEdges() []string {
  17649. edges := make([]string, 0, 2)
  17650. if m.sop_stage != nil {
  17651. edges = append(edges, sopnode.EdgeSopStage)
  17652. }
  17653. if m.node_messages != nil {
  17654. edges = append(edges, sopnode.EdgeNodeMessages)
  17655. }
  17656. return edges
  17657. }
  17658. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17659. // name in this mutation.
  17660. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17661. switch name {
  17662. case sopnode.EdgeSopStage:
  17663. if id := m.sop_stage; id != nil {
  17664. return []ent.Value{*id}
  17665. }
  17666. case sopnode.EdgeNodeMessages:
  17667. ids := make([]ent.Value, 0, len(m.node_messages))
  17668. for id := range m.node_messages {
  17669. ids = append(ids, id)
  17670. }
  17671. return ids
  17672. }
  17673. return nil
  17674. }
  17675. // RemovedEdges returns all edge names that were removed in this mutation.
  17676. func (m *SopNodeMutation) RemovedEdges() []string {
  17677. edges := make([]string, 0, 2)
  17678. if m.removednode_messages != nil {
  17679. edges = append(edges, sopnode.EdgeNodeMessages)
  17680. }
  17681. return edges
  17682. }
  17683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17684. // the given name in this mutation.
  17685. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17686. switch name {
  17687. case sopnode.EdgeNodeMessages:
  17688. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17689. for id := range m.removednode_messages {
  17690. ids = append(ids, id)
  17691. }
  17692. return ids
  17693. }
  17694. return nil
  17695. }
  17696. // ClearedEdges returns all edge names that were cleared in this mutation.
  17697. func (m *SopNodeMutation) ClearedEdges() []string {
  17698. edges := make([]string, 0, 2)
  17699. if m.clearedsop_stage {
  17700. edges = append(edges, sopnode.EdgeSopStage)
  17701. }
  17702. if m.clearednode_messages {
  17703. edges = append(edges, sopnode.EdgeNodeMessages)
  17704. }
  17705. return edges
  17706. }
  17707. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17708. // was cleared in this mutation.
  17709. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17710. switch name {
  17711. case sopnode.EdgeSopStage:
  17712. return m.clearedsop_stage
  17713. case sopnode.EdgeNodeMessages:
  17714. return m.clearednode_messages
  17715. }
  17716. return false
  17717. }
  17718. // ClearEdge clears the value of the edge with the given name. It returns an error
  17719. // if that edge is not defined in the schema.
  17720. func (m *SopNodeMutation) ClearEdge(name string) error {
  17721. switch name {
  17722. case sopnode.EdgeSopStage:
  17723. m.ClearSopStage()
  17724. return nil
  17725. }
  17726. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17727. }
  17728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17729. // It returns an error if the edge is not defined in the schema.
  17730. func (m *SopNodeMutation) ResetEdge(name string) error {
  17731. switch name {
  17732. case sopnode.EdgeSopStage:
  17733. m.ResetSopStage()
  17734. return nil
  17735. case sopnode.EdgeNodeMessages:
  17736. m.ResetNodeMessages()
  17737. return nil
  17738. }
  17739. return fmt.Errorf("unknown SopNode edge %s", name)
  17740. }
  17741. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17742. type SopStageMutation struct {
  17743. config
  17744. op Op
  17745. typ string
  17746. id *uint64
  17747. created_at *time.Time
  17748. updated_at *time.Time
  17749. status *uint8
  17750. addstatus *int8
  17751. deleted_at *time.Time
  17752. name *string
  17753. condition_type *int
  17754. addcondition_type *int
  17755. condition_operator *int
  17756. addcondition_operator *int
  17757. condition_list *[]custom_types.Condition
  17758. appendcondition_list []custom_types.Condition
  17759. action_message *[]custom_types.Action
  17760. appendaction_message []custom_types.Action
  17761. action_label_add *[]uint64
  17762. appendaction_label_add []uint64
  17763. action_label_del *[]uint64
  17764. appendaction_label_del []uint64
  17765. action_forward **custom_types.ActionForward
  17766. index_sort *int
  17767. addindex_sort *int
  17768. clearedFields map[string]struct{}
  17769. sop_task *uint64
  17770. clearedsop_task bool
  17771. stage_nodes map[uint64]struct{}
  17772. removedstage_nodes map[uint64]struct{}
  17773. clearedstage_nodes bool
  17774. stage_messages map[uint64]struct{}
  17775. removedstage_messages map[uint64]struct{}
  17776. clearedstage_messages bool
  17777. done bool
  17778. oldValue func(context.Context) (*SopStage, error)
  17779. predicates []predicate.SopStage
  17780. }
  17781. var _ ent.Mutation = (*SopStageMutation)(nil)
  17782. // sopstageOption allows management of the mutation configuration using functional options.
  17783. type sopstageOption func(*SopStageMutation)
  17784. // newSopStageMutation creates new mutation for the SopStage entity.
  17785. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17786. m := &SopStageMutation{
  17787. config: c,
  17788. op: op,
  17789. typ: TypeSopStage,
  17790. clearedFields: make(map[string]struct{}),
  17791. }
  17792. for _, opt := range opts {
  17793. opt(m)
  17794. }
  17795. return m
  17796. }
  17797. // withSopStageID sets the ID field of the mutation.
  17798. func withSopStageID(id uint64) sopstageOption {
  17799. return func(m *SopStageMutation) {
  17800. var (
  17801. err error
  17802. once sync.Once
  17803. value *SopStage
  17804. )
  17805. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17806. once.Do(func() {
  17807. if m.done {
  17808. err = errors.New("querying old values post mutation is not allowed")
  17809. } else {
  17810. value, err = m.Client().SopStage.Get(ctx, id)
  17811. }
  17812. })
  17813. return value, err
  17814. }
  17815. m.id = &id
  17816. }
  17817. }
  17818. // withSopStage sets the old SopStage of the mutation.
  17819. func withSopStage(node *SopStage) sopstageOption {
  17820. return func(m *SopStageMutation) {
  17821. m.oldValue = func(context.Context) (*SopStage, error) {
  17822. return node, nil
  17823. }
  17824. m.id = &node.ID
  17825. }
  17826. }
  17827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17828. // executed in a transaction (ent.Tx), a transactional client is returned.
  17829. func (m SopStageMutation) Client() *Client {
  17830. client := &Client{config: m.config}
  17831. client.init()
  17832. return client
  17833. }
  17834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17835. // it returns an error otherwise.
  17836. func (m SopStageMutation) Tx() (*Tx, error) {
  17837. if _, ok := m.driver.(*txDriver); !ok {
  17838. return nil, errors.New("ent: mutation is not running in a transaction")
  17839. }
  17840. tx := &Tx{config: m.config}
  17841. tx.init()
  17842. return tx, nil
  17843. }
  17844. // SetID sets the value of the id field. Note that this
  17845. // operation is only accepted on creation of SopStage entities.
  17846. func (m *SopStageMutation) SetID(id uint64) {
  17847. m.id = &id
  17848. }
  17849. // ID returns the ID value in the mutation. Note that the ID is only available
  17850. // if it was provided to the builder or after it was returned from the database.
  17851. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17852. if m.id == nil {
  17853. return
  17854. }
  17855. return *m.id, true
  17856. }
  17857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17858. // That means, if the mutation is applied within a transaction with an isolation level such
  17859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17860. // or updated by the mutation.
  17861. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17862. switch {
  17863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17864. id, exists := m.ID()
  17865. if exists {
  17866. return []uint64{id}, nil
  17867. }
  17868. fallthrough
  17869. case m.op.Is(OpUpdate | OpDelete):
  17870. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17871. default:
  17872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17873. }
  17874. }
  17875. // SetCreatedAt sets the "created_at" field.
  17876. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17877. m.created_at = &t
  17878. }
  17879. // CreatedAt returns the value of the "created_at" field in the mutation.
  17880. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17881. v := m.created_at
  17882. if v == nil {
  17883. return
  17884. }
  17885. return *v, true
  17886. }
  17887. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17888. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17890. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17891. if !m.op.Is(OpUpdateOne) {
  17892. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17893. }
  17894. if m.id == nil || m.oldValue == nil {
  17895. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17896. }
  17897. oldValue, err := m.oldValue(ctx)
  17898. if err != nil {
  17899. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17900. }
  17901. return oldValue.CreatedAt, nil
  17902. }
  17903. // ResetCreatedAt resets all changes to the "created_at" field.
  17904. func (m *SopStageMutation) ResetCreatedAt() {
  17905. m.created_at = nil
  17906. }
  17907. // SetUpdatedAt sets the "updated_at" field.
  17908. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17909. m.updated_at = &t
  17910. }
  17911. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17912. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17913. v := m.updated_at
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17920. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17932. }
  17933. return oldValue.UpdatedAt, nil
  17934. }
  17935. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17936. func (m *SopStageMutation) ResetUpdatedAt() {
  17937. m.updated_at = nil
  17938. }
  17939. // SetStatus sets the "status" field.
  17940. func (m *SopStageMutation) SetStatus(u uint8) {
  17941. m.status = &u
  17942. m.addstatus = nil
  17943. }
  17944. // Status returns the value of the "status" field in the mutation.
  17945. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  17946. v := m.status
  17947. if v == nil {
  17948. return
  17949. }
  17950. return *v, true
  17951. }
  17952. // OldStatus returns the old "status" field's value of the SopStage entity.
  17953. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17955. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17956. if !m.op.Is(OpUpdateOne) {
  17957. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17958. }
  17959. if m.id == nil || m.oldValue == nil {
  17960. return v, errors.New("OldStatus requires an ID field in the mutation")
  17961. }
  17962. oldValue, err := m.oldValue(ctx)
  17963. if err != nil {
  17964. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17965. }
  17966. return oldValue.Status, nil
  17967. }
  17968. // AddStatus adds u to the "status" field.
  17969. func (m *SopStageMutation) AddStatus(u int8) {
  17970. if m.addstatus != nil {
  17971. *m.addstatus += u
  17972. } else {
  17973. m.addstatus = &u
  17974. }
  17975. }
  17976. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17977. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  17978. v := m.addstatus
  17979. if v == nil {
  17980. return
  17981. }
  17982. return *v, true
  17983. }
  17984. // ClearStatus clears the value of the "status" field.
  17985. func (m *SopStageMutation) ClearStatus() {
  17986. m.status = nil
  17987. m.addstatus = nil
  17988. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  17989. }
  17990. // StatusCleared returns if the "status" field was cleared in this mutation.
  17991. func (m *SopStageMutation) StatusCleared() bool {
  17992. _, ok := m.clearedFields[sopstage.FieldStatus]
  17993. return ok
  17994. }
  17995. // ResetStatus resets all changes to the "status" field.
  17996. func (m *SopStageMutation) ResetStatus() {
  17997. m.status = nil
  17998. m.addstatus = nil
  17999. delete(m.clearedFields, sopstage.FieldStatus)
  18000. }
  18001. // SetDeletedAt sets the "deleted_at" field.
  18002. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18003. m.deleted_at = &t
  18004. }
  18005. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18006. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18007. v := m.deleted_at
  18008. if v == nil {
  18009. return
  18010. }
  18011. return *v, true
  18012. }
  18013. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18014. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18016. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18017. if !m.op.Is(OpUpdateOne) {
  18018. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18019. }
  18020. if m.id == nil || m.oldValue == nil {
  18021. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18022. }
  18023. oldValue, err := m.oldValue(ctx)
  18024. if err != nil {
  18025. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18026. }
  18027. return oldValue.DeletedAt, nil
  18028. }
  18029. // ClearDeletedAt clears the value of the "deleted_at" field.
  18030. func (m *SopStageMutation) ClearDeletedAt() {
  18031. m.deleted_at = nil
  18032. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18033. }
  18034. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18035. func (m *SopStageMutation) DeletedAtCleared() bool {
  18036. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18037. return ok
  18038. }
  18039. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18040. func (m *SopStageMutation) ResetDeletedAt() {
  18041. m.deleted_at = nil
  18042. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18043. }
  18044. // SetTaskID sets the "task_id" field.
  18045. func (m *SopStageMutation) SetTaskID(u uint64) {
  18046. m.sop_task = &u
  18047. }
  18048. // TaskID returns the value of the "task_id" field in the mutation.
  18049. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18050. v := m.sop_task
  18051. if v == nil {
  18052. return
  18053. }
  18054. return *v, true
  18055. }
  18056. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18057. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18059. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18060. if !m.op.Is(OpUpdateOne) {
  18061. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18062. }
  18063. if m.id == nil || m.oldValue == nil {
  18064. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18065. }
  18066. oldValue, err := m.oldValue(ctx)
  18067. if err != nil {
  18068. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18069. }
  18070. return oldValue.TaskID, nil
  18071. }
  18072. // ResetTaskID resets all changes to the "task_id" field.
  18073. func (m *SopStageMutation) ResetTaskID() {
  18074. m.sop_task = nil
  18075. }
  18076. // SetName sets the "name" field.
  18077. func (m *SopStageMutation) SetName(s string) {
  18078. m.name = &s
  18079. }
  18080. // Name returns the value of the "name" field in the mutation.
  18081. func (m *SopStageMutation) Name() (r string, exists bool) {
  18082. v := m.name
  18083. if v == nil {
  18084. return
  18085. }
  18086. return *v, true
  18087. }
  18088. // OldName returns the old "name" field's value of the SopStage entity.
  18089. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18091. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18092. if !m.op.Is(OpUpdateOne) {
  18093. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18094. }
  18095. if m.id == nil || m.oldValue == nil {
  18096. return v, errors.New("OldName requires an ID field in the mutation")
  18097. }
  18098. oldValue, err := m.oldValue(ctx)
  18099. if err != nil {
  18100. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18101. }
  18102. return oldValue.Name, nil
  18103. }
  18104. // ResetName resets all changes to the "name" field.
  18105. func (m *SopStageMutation) ResetName() {
  18106. m.name = nil
  18107. }
  18108. // SetConditionType sets the "condition_type" field.
  18109. func (m *SopStageMutation) SetConditionType(i int) {
  18110. m.condition_type = &i
  18111. m.addcondition_type = nil
  18112. }
  18113. // ConditionType returns the value of the "condition_type" field in the mutation.
  18114. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18115. v := m.condition_type
  18116. if v == nil {
  18117. return
  18118. }
  18119. return *v, true
  18120. }
  18121. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18122. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18124. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18125. if !m.op.Is(OpUpdateOne) {
  18126. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18127. }
  18128. if m.id == nil || m.oldValue == nil {
  18129. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18130. }
  18131. oldValue, err := m.oldValue(ctx)
  18132. if err != nil {
  18133. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18134. }
  18135. return oldValue.ConditionType, nil
  18136. }
  18137. // AddConditionType adds i to the "condition_type" field.
  18138. func (m *SopStageMutation) AddConditionType(i int) {
  18139. if m.addcondition_type != nil {
  18140. *m.addcondition_type += i
  18141. } else {
  18142. m.addcondition_type = &i
  18143. }
  18144. }
  18145. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18146. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18147. v := m.addcondition_type
  18148. if v == nil {
  18149. return
  18150. }
  18151. return *v, true
  18152. }
  18153. // ResetConditionType resets all changes to the "condition_type" field.
  18154. func (m *SopStageMutation) ResetConditionType() {
  18155. m.condition_type = nil
  18156. m.addcondition_type = nil
  18157. }
  18158. // SetConditionOperator sets the "condition_operator" field.
  18159. func (m *SopStageMutation) SetConditionOperator(i int) {
  18160. m.condition_operator = &i
  18161. m.addcondition_operator = nil
  18162. }
  18163. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18164. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18165. v := m.condition_operator
  18166. if v == nil {
  18167. return
  18168. }
  18169. return *v, true
  18170. }
  18171. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18172. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18174. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18175. if !m.op.Is(OpUpdateOne) {
  18176. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18177. }
  18178. if m.id == nil || m.oldValue == nil {
  18179. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18180. }
  18181. oldValue, err := m.oldValue(ctx)
  18182. if err != nil {
  18183. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18184. }
  18185. return oldValue.ConditionOperator, nil
  18186. }
  18187. // AddConditionOperator adds i to the "condition_operator" field.
  18188. func (m *SopStageMutation) AddConditionOperator(i int) {
  18189. if m.addcondition_operator != nil {
  18190. *m.addcondition_operator += i
  18191. } else {
  18192. m.addcondition_operator = &i
  18193. }
  18194. }
  18195. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18196. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18197. v := m.addcondition_operator
  18198. if v == nil {
  18199. return
  18200. }
  18201. return *v, true
  18202. }
  18203. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18204. func (m *SopStageMutation) ResetConditionOperator() {
  18205. m.condition_operator = nil
  18206. m.addcondition_operator = nil
  18207. }
  18208. // SetConditionList sets the "condition_list" field.
  18209. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18210. m.condition_list = &ct
  18211. m.appendcondition_list = nil
  18212. }
  18213. // ConditionList returns the value of the "condition_list" field in the mutation.
  18214. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18215. v := m.condition_list
  18216. if v == nil {
  18217. return
  18218. }
  18219. return *v, true
  18220. }
  18221. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18222. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18224. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18225. if !m.op.Is(OpUpdateOne) {
  18226. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18227. }
  18228. if m.id == nil || m.oldValue == nil {
  18229. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18230. }
  18231. oldValue, err := m.oldValue(ctx)
  18232. if err != nil {
  18233. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18234. }
  18235. return oldValue.ConditionList, nil
  18236. }
  18237. // AppendConditionList adds ct to the "condition_list" field.
  18238. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18239. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18240. }
  18241. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18242. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18243. if len(m.appendcondition_list) == 0 {
  18244. return nil, false
  18245. }
  18246. return m.appendcondition_list, true
  18247. }
  18248. // ResetConditionList resets all changes to the "condition_list" field.
  18249. func (m *SopStageMutation) ResetConditionList() {
  18250. m.condition_list = nil
  18251. m.appendcondition_list = nil
  18252. }
  18253. // SetActionMessage sets the "action_message" field.
  18254. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18255. m.action_message = &ct
  18256. m.appendaction_message = nil
  18257. }
  18258. // ActionMessage returns the value of the "action_message" field in the mutation.
  18259. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18260. v := m.action_message
  18261. if v == nil {
  18262. return
  18263. }
  18264. return *v, true
  18265. }
  18266. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18267. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18269. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18270. if !m.op.Is(OpUpdateOne) {
  18271. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18272. }
  18273. if m.id == nil || m.oldValue == nil {
  18274. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18275. }
  18276. oldValue, err := m.oldValue(ctx)
  18277. if err != nil {
  18278. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18279. }
  18280. return oldValue.ActionMessage, nil
  18281. }
  18282. // AppendActionMessage adds ct to the "action_message" field.
  18283. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18284. m.appendaction_message = append(m.appendaction_message, ct...)
  18285. }
  18286. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18287. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18288. if len(m.appendaction_message) == 0 {
  18289. return nil, false
  18290. }
  18291. return m.appendaction_message, true
  18292. }
  18293. // ClearActionMessage clears the value of the "action_message" field.
  18294. func (m *SopStageMutation) ClearActionMessage() {
  18295. m.action_message = nil
  18296. m.appendaction_message = nil
  18297. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18298. }
  18299. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18300. func (m *SopStageMutation) ActionMessageCleared() bool {
  18301. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18302. return ok
  18303. }
  18304. // ResetActionMessage resets all changes to the "action_message" field.
  18305. func (m *SopStageMutation) ResetActionMessage() {
  18306. m.action_message = nil
  18307. m.appendaction_message = nil
  18308. delete(m.clearedFields, sopstage.FieldActionMessage)
  18309. }
  18310. // SetActionLabelAdd sets the "action_label_add" field.
  18311. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18312. m.action_label_add = &u
  18313. m.appendaction_label_add = nil
  18314. }
  18315. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18316. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18317. v := m.action_label_add
  18318. if v == nil {
  18319. return
  18320. }
  18321. return *v, true
  18322. }
  18323. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18324. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18326. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18327. if !m.op.Is(OpUpdateOne) {
  18328. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18329. }
  18330. if m.id == nil || m.oldValue == nil {
  18331. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18332. }
  18333. oldValue, err := m.oldValue(ctx)
  18334. if err != nil {
  18335. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18336. }
  18337. return oldValue.ActionLabelAdd, nil
  18338. }
  18339. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18340. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18341. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18342. }
  18343. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18344. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18345. if len(m.appendaction_label_add) == 0 {
  18346. return nil, false
  18347. }
  18348. return m.appendaction_label_add, true
  18349. }
  18350. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18351. func (m *SopStageMutation) ClearActionLabelAdd() {
  18352. m.action_label_add = nil
  18353. m.appendaction_label_add = nil
  18354. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18355. }
  18356. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18357. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18358. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18359. return ok
  18360. }
  18361. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18362. func (m *SopStageMutation) ResetActionLabelAdd() {
  18363. m.action_label_add = nil
  18364. m.appendaction_label_add = nil
  18365. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18366. }
  18367. // SetActionLabelDel sets the "action_label_del" field.
  18368. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18369. m.action_label_del = &u
  18370. m.appendaction_label_del = nil
  18371. }
  18372. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18373. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18374. v := m.action_label_del
  18375. if v == nil {
  18376. return
  18377. }
  18378. return *v, true
  18379. }
  18380. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18381. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18383. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18384. if !m.op.Is(OpUpdateOne) {
  18385. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18386. }
  18387. if m.id == nil || m.oldValue == nil {
  18388. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18389. }
  18390. oldValue, err := m.oldValue(ctx)
  18391. if err != nil {
  18392. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18393. }
  18394. return oldValue.ActionLabelDel, nil
  18395. }
  18396. // AppendActionLabelDel adds u to the "action_label_del" field.
  18397. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18398. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18399. }
  18400. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18401. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18402. if len(m.appendaction_label_del) == 0 {
  18403. return nil, false
  18404. }
  18405. return m.appendaction_label_del, true
  18406. }
  18407. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18408. func (m *SopStageMutation) ClearActionLabelDel() {
  18409. m.action_label_del = nil
  18410. m.appendaction_label_del = nil
  18411. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18412. }
  18413. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18414. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18415. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18416. return ok
  18417. }
  18418. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18419. func (m *SopStageMutation) ResetActionLabelDel() {
  18420. m.action_label_del = nil
  18421. m.appendaction_label_del = nil
  18422. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18423. }
  18424. // SetActionForward sets the "action_forward" field.
  18425. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18426. m.action_forward = &ctf
  18427. }
  18428. // ActionForward returns the value of the "action_forward" field in the mutation.
  18429. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18430. v := m.action_forward
  18431. if v == nil {
  18432. return
  18433. }
  18434. return *v, true
  18435. }
  18436. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18437. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18439. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18440. if !m.op.Is(OpUpdateOne) {
  18441. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18442. }
  18443. if m.id == nil || m.oldValue == nil {
  18444. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18445. }
  18446. oldValue, err := m.oldValue(ctx)
  18447. if err != nil {
  18448. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18449. }
  18450. return oldValue.ActionForward, nil
  18451. }
  18452. // ClearActionForward clears the value of the "action_forward" field.
  18453. func (m *SopStageMutation) ClearActionForward() {
  18454. m.action_forward = nil
  18455. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18456. }
  18457. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18458. func (m *SopStageMutation) ActionForwardCleared() bool {
  18459. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18460. return ok
  18461. }
  18462. // ResetActionForward resets all changes to the "action_forward" field.
  18463. func (m *SopStageMutation) ResetActionForward() {
  18464. m.action_forward = nil
  18465. delete(m.clearedFields, sopstage.FieldActionForward)
  18466. }
  18467. // SetIndexSort sets the "index_sort" field.
  18468. func (m *SopStageMutation) SetIndexSort(i int) {
  18469. m.index_sort = &i
  18470. m.addindex_sort = nil
  18471. }
  18472. // IndexSort returns the value of the "index_sort" field in the mutation.
  18473. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18474. v := m.index_sort
  18475. if v == nil {
  18476. return
  18477. }
  18478. return *v, true
  18479. }
  18480. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18481. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18483. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18484. if !m.op.Is(OpUpdateOne) {
  18485. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18486. }
  18487. if m.id == nil || m.oldValue == nil {
  18488. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18489. }
  18490. oldValue, err := m.oldValue(ctx)
  18491. if err != nil {
  18492. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18493. }
  18494. return oldValue.IndexSort, nil
  18495. }
  18496. // AddIndexSort adds i to the "index_sort" field.
  18497. func (m *SopStageMutation) AddIndexSort(i int) {
  18498. if m.addindex_sort != nil {
  18499. *m.addindex_sort += i
  18500. } else {
  18501. m.addindex_sort = &i
  18502. }
  18503. }
  18504. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18505. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18506. v := m.addindex_sort
  18507. if v == nil {
  18508. return
  18509. }
  18510. return *v, true
  18511. }
  18512. // ClearIndexSort clears the value of the "index_sort" field.
  18513. func (m *SopStageMutation) ClearIndexSort() {
  18514. m.index_sort = nil
  18515. m.addindex_sort = nil
  18516. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18517. }
  18518. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18519. func (m *SopStageMutation) IndexSortCleared() bool {
  18520. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18521. return ok
  18522. }
  18523. // ResetIndexSort resets all changes to the "index_sort" field.
  18524. func (m *SopStageMutation) ResetIndexSort() {
  18525. m.index_sort = nil
  18526. m.addindex_sort = nil
  18527. delete(m.clearedFields, sopstage.FieldIndexSort)
  18528. }
  18529. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18530. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18531. m.sop_task = &id
  18532. }
  18533. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18534. func (m *SopStageMutation) ClearSopTask() {
  18535. m.clearedsop_task = true
  18536. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18537. }
  18538. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18539. func (m *SopStageMutation) SopTaskCleared() bool {
  18540. return m.clearedsop_task
  18541. }
  18542. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18543. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18544. if m.sop_task != nil {
  18545. return *m.sop_task, true
  18546. }
  18547. return
  18548. }
  18549. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18550. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18551. // SopTaskID instead. It exists only for internal usage by the builders.
  18552. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18553. if id := m.sop_task; id != nil {
  18554. ids = append(ids, *id)
  18555. }
  18556. return
  18557. }
  18558. // ResetSopTask resets all changes to the "sop_task" edge.
  18559. func (m *SopStageMutation) ResetSopTask() {
  18560. m.sop_task = nil
  18561. m.clearedsop_task = false
  18562. }
  18563. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18564. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18565. if m.stage_nodes == nil {
  18566. m.stage_nodes = make(map[uint64]struct{})
  18567. }
  18568. for i := range ids {
  18569. m.stage_nodes[ids[i]] = struct{}{}
  18570. }
  18571. }
  18572. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18573. func (m *SopStageMutation) ClearStageNodes() {
  18574. m.clearedstage_nodes = true
  18575. }
  18576. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18577. func (m *SopStageMutation) StageNodesCleared() bool {
  18578. return m.clearedstage_nodes
  18579. }
  18580. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18581. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18582. if m.removedstage_nodes == nil {
  18583. m.removedstage_nodes = make(map[uint64]struct{})
  18584. }
  18585. for i := range ids {
  18586. delete(m.stage_nodes, ids[i])
  18587. m.removedstage_nodes[ids[i]] = struct{}{}
  18588. }
  18589. }
  18590. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18591. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18592. for id := range m.removedstage_nodes {
  18593. ids = append(ids, id)
  18594. }
  18595. return
  18596. }
  18597. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18598. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18599. for id := range m.stage_nodes {
  18600. ids = append(ids, id)
  18601. }
  18602. return
  18603. }
  18604. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18605. func (m *SopStageMutation) ResetStageNodes() {
  18606. m.stage_nodes = nil
  18607. m.clearedstage_nodes = false
  18608. m.removedstage_nodes = nil
  18609. }
  18610. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18611. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18612. if m.stage_messages == nil {
  18613. m.stage_messages = make(map[uint64]struct{})
  18614. }
  18615. for i := range ids {
  18616. m.stage_messages[ids[i]] = struct{}{}
  18617. }
  18618. }
  18619. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18620. func (m *SopStageMutation) ClearStageMessages() {
  18621. m.clearedstage_messages = true
  18622. }
  18623. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18624. func (m *SopStageMutation) StageMessagesCleared() bool {
  18625. return m.clearedstage_messages
  18626. }
  18627. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18628. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18629. if m.removedstage_messages == nil {
  18630. m.removedstage_messages = make(map[uint64]struct{})
  18631. }
  18632. for i := range ids {
  18633. delete(m.stage_messages, ids[i])
  18634. m.removedstage_messages[ids[i]] = struct{}{}
  18635. }
  18636. }
  18637. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18638. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18639. for id := range m.removedstage_messages {
  18640. ids = append(ids, id)
  18641. }
  18642. return
  18643. }
  18644. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18645. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18646. for id := range m.stage_messages {
  18647. ids = append(ids, id)
  18648. }
  18649. return
  18650. }
  18651. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18652. func (m *SopStageMutation) ResetStageMessages() {
  18653. m.stage_messages = nil
  18654. m.clearedstage_messages = false
  18655. m.removedstage_messages = nil
  18656. }
  18657. // Where appends a list predicates to the SopStageMutation builder.
  18658. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18659. m.predicates = append(m.predicates, ps...)
  18660. }
  18661. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18662. // users can use type-assertion to append predicates that do not depend on any generated package.
  18663. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18664. p := make([]predicate.SopStage, len(ps))
  18665. for i := range ps {
  18666. p[i] = ps[i]
  18667. }
  18668. m.Where(p...)
  18669. }
  18670. // Op returns the operation name.
  18671. func (m *SopStageMutation) Op() Op {
  18672. return m.op
  18673. }
  18674. // SetOp allows setting the mutation operation.
  18675. func (m *SopStageMutation) SetOp(op Op) {
  18676. m.op = op
  18677. }
  18678. // Type returns the node type of this mutation (SopStage).
  18679. func (m *SopStageMutation) Type() string {
  18680. return m.typ
  18681. }
  18682. // Fields returns all fields that were changed during this mutation. Note that in
  18683. // order to get all numeric fields that were incremented/decremented, call
  18684. // AddedFields().
  18685. func (m *SopStageMutation) Fields() []string {
  18686. fields := make([]string, 0, 14)
  18687. if m.created_at != nil {
  18688. fields = append(fields, sopstage.FieldCreatedAt)
  18689. }
  18690. if m.updated_at != nil {
  18691. fields = append(fields, sopstage.FieldUpdatedAt)
  18692. }
  18693. if m.status != nil {
  18694. fields = append(fields, sopstage.FieldStatus)
  18695. }
  18696. if m.deleted_at != nil {
  18697. fields = append(fields, sopstage.FieldDeletedAt)
  18698. }
  18699. if m.sop_task != nil {
  18700. fields = append(fields, sopstage.FieldTaskID)
  18701. }
  18702. if m.name != nil {
  18703. fields = append(fields, sopstage.FieldName)
  18704. }
  18705. if m.condition_type != nil {
  18706. fields = append(fields, sopstage.FieldConditionType)
  18707. }
  18708. if m.condition_operator != nil {
  18709. fields = append(fields, sopstage.FieldConditionOperator)
  18710. }
  18711. if m.condition_list != nil {
  18712. fields = append(fields, sopstage.FieldConditionList)
  18713. }
  18714. if m.action_message != nil {
  18715. fields = append(fields, sopstage.FieldActionMessage)
  18716. }
  18717. if m.action_label_add != nil {
  18718. fields = append(fields, sopstage.FieldActionLabelAdd)
  18719. }
  18720. if m.action_label_del != nil {
  18721. fields = append(fields, sopstage.FieldActionLabelDel)
  18722. }
  18723. if m.action_forward != nil {
  18724. fields = append(fields, sopstage.FieldActionForward)
  18725. }
  18726. if m.index_sort != nil {
  18727. fields = append(fields, sopstage.FieldIndexSort)
  18728. }
  18729. return fields
  18730. }
  18731. // Field returns the value of a field with the given name. The second boolean
  18732. // return value indicates that this field was not set, or was not defined in the
  18733. // schema.
  18734. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18735. switch name {
  18736. case sopstage.FieldCreatedAt:
  18737. return m.CreatedAt()
  18738. case sopstage.FieldUpdatedAt:
  18739. return m.UpdatedAt()
  18740. case sopstage.FieldStatus:
  18741. return m.Status()
  18742. case sopstage.FieldDeletedAt:
  18743. return m.DeletedAt()
  18744. case sopstage.FieldTaskID:
  18745. return m.TaskID()
  18746. case sopstage.FieldName:
  18747. return m.Name()
  18748. case sopstage.FieldConditionType:
  18749. return m.ConditionType()
  18750. case sopstage.FieldConditionOperator:
  18751. return m.ConditionOperator()
  18752. case sopstage.FieldConditionList:
  18753. return m.ConditionList()
  18754. case sopstage.FieldActionMessage:
  18755. return m.ActionMessage()
  18756. case sopstage.FieldActionLabelAdd:
  18757. return m.ActionLabelAdd()
  18758. case sopstage.FieldActionLabelDel:
  18759. return m.ActionLabelDel()
  18760. case sopstage.FieldActionForward:
  18761. return m.ActionForward()
  18762. case sopstage.FieldIndexSort:
  18763. return m.IndexSort()
  18764. }
  18765. return nil, false
  18766. }
  18767. // OldField returns the old value of the field from the database. An error is
  18768. // returned if the mutation operation is not UpdateOne, or the query to the
  18769. // database failed.
  18770. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18771. switch name {
  18772. case sopstage.FieldCreatedAt:
  18773. return m.OldCreatedAt(ctx)
  18774. case sopstage.FieldUpdatedAt:
  18775. return m.OldUpdatedAt(ctx)
  18776. case sopstage.FieldStatus:
  18777. return m.OldStatus(ctx)
  18778. case sopstage.FieldDeletedAt:
  18779. return m.OldDeletedAt(ctx)
  18780. case sopstage.FieldTaskID:
  18781. return m.OldTaskID(ctx)
  18782. case sopstage.FieldName:
  18783. return m.OldName(ctx)
  18784. case sopstage.FieldConditionType:
  18785. return m.OldConditionType(ctx)
  18786. case sopstage.FieldConditionOperator:
  18787. return m.OldConditionOperator(ctx)
  18788. case sopstage.FieldConditionList:
  18789. return m.OldConditionList(ctx)
  18790. case sopstage.FieldActionMessage:
  18791. return m.OldActionMessage(ctx)
  18792. case sopstage.FieldActionLabelAdd:
  18793. return m.OldActionLabelAdd(ctx)
  18794. case sopstage.FieldActionLabelDel:
  18795. return m.OldActionLabelDel(ctx)
  18796. case sopstage.FieldActionForward:
  18797. return m.OldActionForward(ctx)
  18798. case sopstage.FieldIndexSort:
  18799. return m.OldIndexSort(ctx)
  18800. }
  18801. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18802. }
  18803. // SetField sets the value of a field with the given name. It returns an error if
  18804. // the field is not defined in the schema, or if the type mismatched the field
  18805. // type.
  18806. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18807. switch name {
  18808. case sopstage.FieldCreatedAt:
  18809. v, ok := value.(time.Time)
  18810. if !ok {
  18811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18812. }
  18813. m.SetCreatedAt(v)
  18814. return nil
  18815. case sopstage.FieldUpdatedAt:
  18816. v, ok := value.(time.Time)
  18817. if !ok {
  18818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18819. }
  18820. m.SetUpdatedAt(v)
  18821. return nil
  18822. case sopstage.FieldStatus:
  18823. v, ok := value.(uint8)
  18824. if !ok {
  18825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18826. }
  18827. m.SetStatus(v)
  18828. return nil
  18829. case sopstage.FieldDeletedAt:
  18830. v, ok := value.(time.Time)
  18831. if !ok {
  18832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18833. }
  18834. m.SetDeletedAt(v)
  18835. return nil
  18836. case sopstage.FieldTaskID:
  18837. v, ok := value.(uint64)
  18838. if !ok {
  18839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18840. }
  18841. m.SetTaskID(v)
  18842. return nil
  18843. case sopstage.FieldName:
  18844. v, ok := value.(string)
  18845. if !ok {
  18846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18847. }
  18848. m.SetName(v)
  18849. return nil
  18850. case sopstage.FieldConditionType:
  18851. v, ok := value.(int)
  18852. if !ok {
  18853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18854. }
  18855. m.SetConditionType(v)
  18856. return nil
  18857. case sopstage.FieldConditionOperator:
  18858. v, ok := value.(int)
  18859. if !ok {
  18860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18861. }
  18862. m.SetConditionOperator(v)
  18863. return nil
  18864. case sopstage.FieldConditionList:
  18865. v, ok := value.([]custom_types.Condition)
  18866. if !ok {
  18867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18868. }
  18869. m.SetConditionList(v)
  18870. return nil
  18871. case sopstage.FieldActionMessage:
  18872. v, ok := value.([]custom_types.Action)
  18873. if !ok {
  18874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18875. }
  18876. m.SetActionMessage(v)
  18877. return nil
  18878. case sopstage.FieldActionLabelAdd:
  18879. v, ok := value.([]uint64)
  18880. if !ok {
  18881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18882. }
  18883. m.SetActionLabelAdd(v)
  18884. return nil
  18885. case sopstage.FieldActionLabelDel:
  18886. v, ok := value.([]uint64)
  18887. if !ok {
  18888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18889. }
  18890. m.SetActionLabelDel(v)
  18891. return nil
  18892. case sopstage.FieldActionForward:
  18893. v, ok := value.(*custom_types.ActionForward)
  18894. if !ok {
  18895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18896. }
  18897. m.SetActionForward(v)
  18898. return nil
  18899. case sopstage.FieldIndexSort:
  18900. v, ok := value.(int)
  18901. if !ok {
  18902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18903. }
  18904. m.SetIndexSort(v)
  18905. return nil
  18906. }
  18907. return fmt.Errorf("unknown SopStage field %s", name)
  18908. }
  18909. // AddedFields returns all numeric fields that were incremented/decremented during
  18910. // this mutation.
  18911. func (m *SopStageMutation) AddedFields() []string {
  18912. var fields []string
  18913. if m.addstatus != nil {
  18914. fields = append(fields, sopstage.FieldStatus)
  18915. }
  18916. if m.addcondition_type != nil {
  18917. fields = append(fields, sopstage.FieldConditionType)
  18918. }
  18919. if m.addcondition_operator != nil {
  18920. fields = append(fields, sopstage.FieldConditionOperator)
  18921. }
  18922. if m.addindex_sort != nil {
  18923. fields = append(fields, sopstage.FieldIndexSort)
  18924. }
  18925. return fields
  18926. }
  18927. // AddedField returns the numeric value that was incremented/decremented on a field
  18928. // with the given name. The second boolean return value indicates that this field
  18929. // was not set, or was not defined in the schema.
  18930. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18931. switch name {
  18932. case sopstage.FieldStatus:
  18933. return m.AddedStatus()
  18934. case sopstage.FieldConditionType:
  18935. return m.AddedConditionType()
  18936. case sopstage.FieldConditionOperator:
  18937. return m.AddedConditionOperator()
  18938. case sopstage.FieldIndexSort:
  18939. return m.AddedIndexSort()
  18940. }
  18941. return nil, false
  18942. }
  18943. // AddField adds the value to the field with the given name. It returns an error if
  18944. // the field is not defined in the schema, or if the type mismatched the field
  18945. // type.
  18946. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  18947. switch name {
  18948. case sopstage.FieldStatus:
  18949. v, ok := value.(int8)
  18950. if !ok {
  18951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18952. }
  18953. m.AddStatus(v)
  18954. return nil
  18955. case sopstage.FieldConditionType:
  18956. v, ok := value.(int)
  18957. if !ok {
  18958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18959. }
  18960. m.AddConditionType(v)
  18961. return nil
  18962. case sopstage.FieldConditionOperator:
  18963. v, ok := value.(int)
  18964. if !ok {
  18965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18966. }
  18967. m.AddConditionOperator(v)
  18968. return nil
  18969. case sopstage.FieldIndexSort:
  18970. v, ok := value.(int)
  18971. if !ok {
  18972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18973. }
  18974. m.AddIndexSort(v)
  18975. return nil
  18976. }
  18977. return fmt.Errorf("unknown SopStage numeric field %s", name)
  18978. }
  18979. // ClearedFields returns all nullable fields that were cleared during this
  18980. // mutation.
  18981. func (m *SopStageMutation) ClearedFields() []string {
  18982. var fields []string
  18983. if m.FieldCleared(sopstage.FieldStatus) {
  18984. fields = append(fields, sopstage.FieldStatus)
  18985. }
  18986. if m.FieldCleared(sopstage.FieldDeletedAt) {
  18987. fields = append(fields, sopstage.FieldDeletedAt)
  18988. }
  18989. if m.FieldCleared(sopstage.FieldActionMessage) {
  18990. fields = append(fields, sopstage.FieldActionMessage)
  18991. }
  18992. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  18993. fields = append(fields, sopstage.FieldActionLabelAdd)
  18994. }
  18995. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  18996. fields = append(fields, sopstage.FieldActionLabelDel)
  18997. }
  18998. if m.FieldCleared(sopstage.FieldActionForward) {
  18999. fields = append(fields, sopstage.FieldActionForward)
  19000. }
  19001. if m.FieldCleared(sopstage.FieldIndexSort) {
  19002. fields = append(fields, sopstage.FieldIndexSort)
  19003. }
  19004. return fields
  19005. }
  19006. // FieldCleared returns a boolean indicating if a field with the given name was
  19007. // cleared in this mutation.
  19008. func (m *SopStageMutation) FieldCleared(name string) bool {
  19009. _, ok := m.clearedFields[name]
  19010. return ok
  19011. }
  19012. // ClearField clears the value of the field with the given name. It returns an
  19013. // error if the field is not defined in the schema.
  19014. func (m *SopStageMutation) ClearField(name string) error {
  19015. switch name {
  19016. case sopstage.FieldStatus:
  19017. m.ClearStatus()
  19018. return nil
  19019. case sopstage.FieldDeletedAt:
  19020. m.ClearDeletedAt()
  19021. return nil
  19022. case sopstage.FieldActionMessage:
  19023. m.ClearActionMessage()
  19024. return nil
  19025. case sopstage.FieldActionLabelAdd:
  19026. m.ClearActionLabelAdd()
  19027. return nil
  19028. case sopstage.FieldActionLabelDel:
  19029. m.ClearActionLabelDel()
  19030. return nil
  19031. case sopstage.FieldActionForward:
  19032. m.ClearActionForward()
  19033. return nil
  19034. case sopstage.FieldIndexSort:
  19035. m.ClearIndexSort()
  19036. return nil
  19037. }
  19038. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19039. }
  19040. // ResetField resets all changes in the mutation for the field with the given name.
  19041. // It returns an error if the field is not defined in the schema.
  19042. func (m *SopStageMutation) ResetField(name string) error {
  19043. switch name {
  19044. case sopstage.FieldCreatedAt:
  19045. m.ResetCreatedAt()
  19046. return nil
  19047. case sopstage.FieldUpdatedAt:
  19048. m.ResetUpdatedAt()
  19049. return nil
  19050. case sopstage.FieldStatus:
  19051. m.ResetStatus()
  19052. return nil
  19053. case sopstage.FieldDeletedAt:
  19054. m.ResetDeletedAt()
  19055. return nil
  19056. case sopstage.FieldTaskID:
  19057. m.ResetTaskID()
  19058. return nil
  19059. case sopstage.FieldName:
  19060. m.ResetName()
  19061. return nil
  19062. case sopstage.FieldConditionType:
  19063. m.ResetConditionType()
  19064. return nil
  19065. case sopstage.FieldConditionOperator:
  19066. m.ResetConditionOperator()
  19067. return nil
  19068. case sopstage.FieldConditionList:
  19069. m.ResetConditionList()
  19070. return nil
  19071. case sopstage.FieldActionMessage:
  19072. m.ResetActionMessage()
  19073. return nil
  19074. case sopstage.FieldActionLabelAdd:
  19075. m.ResetActionLabelAdd()
  19076. return nil
  19077. case sopstage.FieldActionLabelDel:
  19078. m.ResetActionLabelDel()
  19079. return nil
  19080. case sopstage.FieldActionForward:
  19081. m.ResetActionForward()
  19082. return nil
  19083. case sopstage.FieldIndexSort:
  19084. m.ResetIndexSort()
  19085. return nil
  19086. }
  19087. return fmt.Errorf("unknown SopStage field %s", name)
  19088. }
  19089. // AddedEdges returns all edge names that were set/added in this mutation.
  19090. func (m *SopStageMutation) AddedEdges() []string {
  19091. edges := make([]string, 0, 3)
  19092. if m.sop_task != nil {
  19093. edges = append(edges, sopstage.EdgeSopTask)
  19094. }
  19095. if m.stage_nodes != nil {
  19096. edges = append(edges, sopstage.EdgeStageNodes)
  19097. }
  19098. if m.stage_messages != nil {
  19099. edges = append(edges, sopstage.EdgeStageMessages)
  19100. }
  19101. return edges
  19102. }
  19103. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19104. // name in this mutation.
  19105. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19106. switch name {
  19107. case sopstage.EdgeSopTask:
  19108. if id := m.sop_task; id != nil {
  19109. return []ent.Value{*id}
  19110. }
  19111. case sopstage.EdgeStageNodes:
  19112. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19113. for id := range m.stage_nodes {
  19114. ids = append(ids, id)
  19115. }
  19116. return ids
  19117. case sopstage.EdgeStageMessages:
  19118. ids := make([]ent.Value, 0, len(m.stage_messages))
  19119. for id := range m.stage_messages {
  19120. ids = append(ids, id)
  19121. }
  19122. return ids
  19123. }
  19124. return nil
  19125. }
  19126. // RemovedEdges returns all edge names that were removed in this mutation.
  19127. func (m *SopStageMutation) RemovedEdges() []string {
  19128. edges := make([]string, 0, 3)
  19129. if m.removedstage_nodes != nil {
  19130. edges = append(edges, sopstage.EdgeStageNodes)
  19131. }
  19132. if m.removedstage_messages != nil {
  19133. edges = append(edges, sopstage.EdgeStageMessages)
  19134. }
  19135. return edges
  19136. }
  19137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19138. // the given name in this mutation.
  19139. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19140. switch name {
  19141. case sopstage.EdgeStageNodes:
  19142. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19143. for id := range m.removedstage_nodes {
  19144. ids = append(ids, id)
  19145. }
  19146. return ids
  19147. case sopstage.EdgeStageMessages:
  19148. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19149. for id := range m.removedstage_messages {
  19150. ids = append(ids, id)
  19151. }
  19152. return ids
  19153. }
  19154. return nil
  19155. }
  19156. // ClearedEdges returns all edge names that were cleared in this mutation.
  19157. func (m *SopStageMutation) ClearedEdges() []string {
  19158. edges := make([]string, 0, 3)
  19159. if m.clearedsop_task {
  19160. edges = append(edges, sopstage.EdgeSopTask)
  19161. }
  19162. if m.clearedstage_nodes {
  19163. edges = append(edges, sopstage.EdgeStageNodes)
  19164. }
  19165. if m.clearedstage_messages {
  19166. edges = append(edges, sopstage.EdgeStageMessages)
  19167. }
  19168. return edges
  19169. }
  19170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19171. // was cleared in this mutation.
  19172. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19173. switch name {
  19174. case sopstage.EdgeSopTask:
  19175. return m.clearedsop_task
  19176. case sopstage.EdgeStageNodes:
  19177. return m.clearedstage_nodes
  19178. case sopstage.EdgeStageMessages:
  19179. return m.clearedstage_messages
  19180. }
  19181. return false
  19182. }
  19183. // ClearEdge clears the value of the edge with the given name. It returns an error
  19184. // if that edge is not defined in the schema.
  19185. func (m *SopStageMutation) ClearEdge(name string) error {
  19186. switch name {
  19187. case sopstage.EdgeSopTask:
  19188. m.ClearSopTask()
  19189. return nil
  19190. }
  19191. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19192. }
  19193. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19194. // It returns an error if the edge is not defined in the schema.
  19195. func (m *SopStageMutation) ResetEdge(name string) error {
  19196. switch name {
  19197. case sopstage.EdgeSopTask:
  19198. m.ResetSopTask()
  19199. return nil
  19200. case sopstage.EdgeStageNodes:
  19201. m.ResetStageNodes()
  19202. return nil
  19203. case sopstage.EdgeStageMessages:
  19204. m.ResetStageMessages()
  19205. return nil
  19206. }
  19207. return fmt.Errorf("unknown SopStage edge %s", name)
  19208. }
  19209. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19210. type SopTaskMutation struct {
  19211. config
  19212. op Op
  19213. typ string
  19214. id *uint64
  19215. created_at *time.Time
  19216. updated_at *time.Time
  19217. status *uint8
  19218. addstatus *int8
  19219. deleted_at *time.Time
  19220. name *string
  19221. bot_wxid_list *[]string
  19222. appendbot_wxid_list []string
  19223. _type *int
  19224. add_type *int
  19225. plan_start_time *time.Time
  19226. plan_end_time *time.Time
  19227. creator_id *string
  19228. organization_id *uint64
  19229. addorganization_id *int64
  19230. clearedFields map[string]struct{}
  19231. task_stages map[uint64]struct{}
  19232. removedtask_stages map[uint64]struct{}
  19233. clearedtask_stages bool
  19234. done bool
  19235. oldValue func(context.Context) (*SopTask, error)
  19236. predicates []predicate.SopTask
  19237. }
  19238. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19239. // soptaskOption allows management of the mutation configuration using functional options.
  19240. type soptaskOption func(*SopTaskMutation)
  19241. // newSopTaskMutation creates new mutation for the SopTask entity.
  19242. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19243. m := &SopTaskMutation{
  19244. config: c,
  19245. op: op,
  19246. typ: TypeSopTask,
  19247. clearedFields: make(map[string]struct{}),
  19248. }
  19249. for _, opt := range opts {
  19250. opt(m)
  19251. }
  19252. return m
  19253. }
  19254. // withSopTaskID sets the ID field of the mutation.
  19255. func withSopTaskID(id uint64) soptaskOption {
  19256. return func(m *SopTaskMutation) {
  19257. var (
  19258. err error
  19259. once sync.Once
  19260. value *SopTask
  19261. )
  19262. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19263. once.Do(func() {
  19264. if m.done {
  19265. err = errors.New("querying old values post mutation is not allowed")
  19266. } else {
  19267. value, err = m.Client().SopTask.Get(ctx, id)
  19268. }
  19269. })
  19270. return value, err
  19271. }
  19272. m.id = &id
  19273. }
  19274. }
  19275. // withSopTask sets the old SopTask of the mutation.
  19276. func withSopTask(node *SopTask) soptaskOption {
  19277. return func(m *SopTaskMutation) {
  19278. m.oldValue = func(context.Context) (*SopTask, error) {
  19279. return node, nil
  19280. }
  19281. m.id = &node.ID
  19282. }
  19283. }
  19284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19285. // executed in a transaction (ent.Tx), a transactional client is returned.
  19286. func (m SopTaskMutation) Client() *Client {
  19287. client := &Client{config: m.config}
  19288. client.init()
  19289. return client
  19290. }
  19291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19292. // it returns an error otherwise.
  19293. func (m SopTaskMutation) Tx() (*Tx, error) {
  19294. if _, ok := m.driver.(*txDriver); !ok {
  19295. return nil, errors.New("ent: mutation is not running in a transaction")
  19296. }
  19297. tx := &Tx{config: m.config}
  19298. tx.init()
  19299. return tx, nil
  19300. }
  19301. // SetID sets the value of the id field. Note that this
  19302. // operation is only accepted on creation of SopTask entities.
  19303. func (m *SopTaskMutation) SetID(id uint64) {
  19304. m.id = &id
  19305. }
  19306. // ID returns the ID value in the mutation. Note that the ID is only available
  19307. // if it was provided to the builder or after it was returned from the database.
  19308. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19309. if m.id == nil {
  19310. return
  19311. }
  19312. return *m.id, true
  19313. }
  19314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19315. // That means, if the mutation is applied within a transaction with an isolation level such
  19316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19317. // or updated by the mutation.
  19318. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19319. switch {
  19320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19321. id, exists := m.ID()
  19322. if exists {
  19323. return []uint64{id}, nil
  19324. }
  19325. fallthrough
  19326. case m.op.Is(OpUpdate | OpDelete):
  19327. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19328. default:
  19329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19330. }
  19331. }
  19332. // SetCreatedAt sets the "created_at" field.
  19333. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19334. m.created_at = &t
  19335. }
  19336. // CreatedAt returns the value of the "created_at" field in the mutation.
  19337. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19338. v := m.created_at
  19339. if v == nil {
  19340. return
  19341. }
  19342. return *v, true
  19343. }
  19344. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19345. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19347. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19348. if !m.op.Is(OpUpdateOne) {
  19349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19350. }
  19351. if m.id == nil || m.oldValue == nil {
  19352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19353. }
  19354. oldValue, err := m.oldValue(ctx)
  19355. if err != nil {
  19356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19357. }
  19358. return oldValue.CreatedAt, nil
  19359. }
  19360. // ResetCreatedAt resets all changes to the "created_at" field.
  19361. func (m *SopTaskMutation) ResetCreatedAt() {
  19362. m.created_at = nil
  19363. }
  19364. // SetUpdatedAt sets the "updated_at" field.
  19365. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19366. m.updated_at = &t
  19367. }
  19368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19369. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19370. v := m.updated_at
  19371. if v == nil {
  19372. return
  19373. }
  19374. return *v, true
  19375. }
  19376. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19377. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19379. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19380. if !m.op.Is(OpUpdateOne) {
  19381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19382. }
  19383. if m.id == nil || m.oldValue == nil {
  19384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19385. }
  19386. oldValue, err := m.oldValue(ctx)
  19387. if err != nil {
  19388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19389. }
  19390. return oldValue.UpdatedAt, nil
  19391. }
  19392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19393. func (m *SopTaskMutation) ResetUpdatedAt() {
  19394. m.updated_at = nil
  19395. }
  19396. // SetStatus sets the "status" field.
  19397. func (m *SopTaskMutation) SetStatus(u uint8) {
  19398. m.status = &u
  19399. m.addstatus = nil
  19400. }
  19401. // Status returns the value of the "status" field in the mutation.
  19402. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19403. v := m.status
  19404. if v == nil {
  19405. return
  19406. }
  19407. return *v, true
  19408. }
  19409. // OldStatus returns the old "status" field's value of the SopTask entity.
  19410. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19412. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19413. if !m.op.Is(OpUpdateOne) {
  19414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19415. }
  19416. if m.id == nil || m.oldValue == nil {
  19417. return v, errors.New("OldStatus requires an ID field in the mutation")
  19418. }
  19419. oldValue, err := m.oldValue(ctx)
  19420. if err != nil {
  19421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19422. }
  19423. return oldValue.Status, nil
  19424. }
  19425. // AddStatus adds u to the "status" field.
  19426. func (m *SopTaskMutation) AddStatus(u int8) {
  19427. if m.addstatus != nil {
  19428. *m.addstatus += u
  19429. } else {
  19430. m.addstatus = &u
  19431. }
  19432. }
  19433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19434. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19435. v := m.addstatus
  19436. if v == nil {
  19437. return
  19438. }
  19439. return *v, true
  19440. }
  19441. // ClearStatus clears the value of the "status" field.
  19442. func (m *SopTaskMutation) ClearStatus() {
  19443. m.status = nil
  19444. m.addstatus = nil
  19445. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19446. }
  19447. // StatusCleared returns if the "status" field was cleared in this mutation.
  19448. func (m *SopTaskMutation) StatusCleared() bool {
  19449. _, ok := m.clearedFields[soptask.FieldStatus]
  19450. return ok
  19451. }
  19452. // ResetStatus resets all changes to the "status" field.
  19453. func (m *SopTaskMutation) ResetStatus() {
  19454. m.status = nil
  19455. m.addstatus = nil
  19456. delete(m.clearedFields, soptask.FieldStatus)
  19457. }
  19458. // SetDeletedAt sets the "deleted_at" field.
  19459. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19460. m.deleted_at = &t
  19461. }
  19462. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19463. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19464. v := m.deleted_at
  19465. if v == nil {
  19466. return
  19467. }
  19468. return *v, true
  19469. }
  19470. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19471. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19473. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19474. if !m.op.Is(OpUpdateOne) {
  19475. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19476. }
  19477. if m.id == nil || m.oldValue == nil {
  19478. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19479. }
  19480. oldValue, err := m.oldValue(ctx)
  19481. if err != nil {
  19482. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19483. }
  19484. return oldValue.DeletedAt, nil
  19485. }
  19486. // ClearDeletedAt clears the value of the "deleted_at" field.
  19487. func (m *SopTaskMutation) ClearDeletedAt() {
  19488. m.deleted_at = nil
  19489. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19490. }
  19491. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19492. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19493. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19494. return ok
  19495. }
  19496. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19497. func (m *SopTaskMutation) ResetDeletedAt() {
  19498. m.deleted_at = nil
  19499. delete(m.clearedFields, soptask.FieldDeletedAt)
  19500. }
  19501. // SetName sets the "name" field.
  19502. func (m *SopTaskMutation) SetName(s string) {
  19503. m.name = &s
  19504. }
  19505. // Name returns the value of the "name" field in the mutation.
  19506. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19507. v := m.name
  19508. if v == nil {
  19509. return
  19510. }
  19511. return *v, true
  19512. }
  19513. // OldName returns the old "name" field's value of the SopTask entity.
  19514. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19516. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19517. if !m.op.Is(OpUpdateOne) {
  19518. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19519. }
  19520. if m.id == nil || m.oldValue == nil {
  19521. return v, errors.New("OldName requires an ID field in the mutation")
  19522. }
  19523. oldValue, err := m.oldValue(ctx)
  19524. if err != nil {
  19525. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19526. }
  19527. return oldValue.Name, nil
  19528. }
  19529. // ResetName resets all changes to the "name" field.
  19530. func (m *SopTaskMutation) ResetName() {
  19531. m.name = nil
  19532. }
  19533. // SetBotWxidList sets the "bot_wxid_list" field.
  19534. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19535. m.bot_wxid_list = &s
  19536. m.appendbot_wxid_list = nil
  19537. }
  19538. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19539. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19540. v := m.bot_wxid_list
  19541. if v == nil {
  19542. return
  19543. }
  19544. return *v, true
  19545. }
  19546. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19547. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19549. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19550. if !m.op.Is(OpUpdateOne) {
  19551. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19552. }
  19553. if m.id == nil || m.oldValue == nil {
  19554. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19555. }
  19556. oldValue, err := m.oldValue(ctx)
  19557. if err != nil {
  19558. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19559. }
  19560. return oldValue.BotWxidList, nil
  19561. }
  19562. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19563. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19564. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19565. }
  19566. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19567. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19568. if len(m.appendbot_wxid_list) == 0 {
  19569. return nil, false
  19570. }
  19571. return m.appendbot_wxid_list, true
  19572. }
  19573. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19574. func (m *SopTaskMutation) ClearBotWxidList() {
  19575. m.bot_wxid_list = nil
  19576. m.appendbot_wxid_list = nil
  19577. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19578. }
  19579. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19580. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19581. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19582. return ok
  19583. }
  19584. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19585. func (m *SopTaskMutation) ResetBotWxidList() {
  19586. m.bot_wxid_list = nil
  19587. m.appendbot_wxid_list = nil
  19588. delete(m.clearedFields, soptask.FieldBotWxidList)
  19589. }
  19590. // SetType sets the "type" field.
  19591. func (m *SopTaskMutation) SetType(i int) {
  19592. m._type = &i
  19593. m.add_type = nil
  19594. }
  19595. // GetType returns the value of the "type" field in the mutation.
  19596. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19597. v := m._type
  19598. if v == nil {
  19599. return
  19600. }
  19601. return *v, true
  19602. }
  19603. // OldType returns the old "type" field's value of the SopTask entity.
  19604. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19606. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19607. if !m.op.Is(OpUpdateOne) {
  19608. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19609. }
  19610. if m.id == nil || m.oldValue == nil {
  19611. return v, errors.New("OldType requires an ID field in the mutation")
  19612. }
  19613. oldValue, err := m.oldValue(ctx)
  19614. if err != nil {
  19615. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19616. }
  19617. return oldValue.Type, nil
  19618. }
  19619. // AddType adds i to the "type" field.
  19620. func (m *SopTaskMutation) AddType(i int) {
  19621. if m.add_type != nil {
  19622. *m.add_type += i
  19623. } else {
  19624. m.add_type = &i
  19625. }
  19626. }
  19627. // AddedType returns the value that was added to the "type" field in this mutation.
  19628. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19629. v := m.add_type
  19630. if v == nil {
  19631. return
  19632. }
  19633. return *v, true
  19634. }
  19635. // ResetType resets all changes to the "type" field.
  19636. func (m *SopTaskMutation) ResetType() {
  19637. m._type = nil
  19638. m.add_type = nil
  19639. }
  19640. // SetPlanStartTime sets the "plan_start_time" field.
  19641. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19642. m.plan_start_time = &t
  19643. }
  19644. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19645. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19646. v := m.plan_start_time
  19647. if v == nil {
  19648. return
  19649. }
  19650. return *v, true
  19651. }
  19652. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19653. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19655. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19656. if !m.op.Is(OpUpdateOne) {
  19657. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19658. }
  19659. if m.id == nil || m.oldValue == nil {
  19660. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19661. }
  19662. oldValue, err := m.oldValue(ctx)
  19663. if err != nil {
  19664. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19665. }
  19666. return oldValue.PlanStartTime, nil
  19667. }
  19668. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19669. func (m *SopTaskMutation) ClearPlanStartTime() {
  19670. m.plan_start_time = nil
  19671. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19672. }
  19673. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19674. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19675. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19676. return ok
  19677. }
  19678. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19679. func (m *SopTaskMutation) ResetPlanStartTime() {
  19680. m.plan_start_time = nil
  19681. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19682. }
  19683. // SetPlanEndTime sets the "plan_end_time" field.
  19684. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19685. m.plan_end_time = &t
  19686. }
  19687. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19688. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19689. v := m.plan_end_time
  19690. if v == nil {
  19691. return
  19692. }
  19693. return *v, true
  19694. }
  19695. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19696. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19698. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19699. if !m.op.Is(OpUpdateOne) {
  19700. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19701. }
  19702. if m.id == nil || m.oldValue == nil {
  19703. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19704. }
  19705. oldValue, err := m.oldValue(ctx)
  19706. if err != nil {
  19707. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19708. }
  19709. return oldValue.PlanEndTime, nil
  19710. }
  19711. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19712. func (m *SopTaskMutation) ClearPlanEndTime() {
  19713. m.plan_end_time = nil
  19714. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19715. }
  19716. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19717. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19718. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19719. return ok
  19720. }
  19721. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19722. func (m *SopTaskMutation) ResetPlanEndTime() {
  19723. m.plan_end_time = nil
  19724. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19725. }
  19726. // SetCreatorID sets the "creator_id" field.
  19727. func (m *SopTaskMutation) SetCreatorID(s string) {
  19728. m.creator_id = &s
  19729. }
  19730. // CreatorID returns the value of the "creator_id" field in the mutation.
  19731. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19732. v := m.creator_id
  19733. if v == nil {
  19734. return
  19735. }
  19736. return *v, true
  19737. }
  19738. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19739. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19741. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19742. if !m.op.Is(OpUpdateOne) {
  19743. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19744. }
  19745. if m.id == nil || m.oldValue == nil {
  19746. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19747. }
  19748. oldValue, err := m.oldValue(ctx)
  19749. if err != nil {
  19750. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19751. }
  19752. return oldValue.CreatorID, nil
  19753. }
  19754. // ClearCreatorID clears the value of the "creator_id" field.
  19755. func (m *SopTaskMutation) ClearCreatorID() {
  19756. m.creator_id = nil
  19757. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19758. }
  19759. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19760. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19761. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19762. return ok
  19763. }
  19764. // ResetCreatorID resets all changes to the "creator_id" field.
  19765. func (m *SopTaskMutation) ResetCreatorID() {
  19766. m.creator_id = nil
  19767. delete(m.clearedFields, soptask.FieldCreatorID)
  19768. }
  19769. // SetOrganizationID sets the "organization_id" field.
  19770. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19771. m.organization_id = &u
  19772. m.addorganization_id = nil
  19773. }
  19774. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19775. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19776. v := m.organization_id
  19777. if v == nil {
  19778. return
  19779. }
  19780. return *v, true
  19781. }
  19782. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19783. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19785. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19786. if !m.op.Is(OpUpdateOne) {
  19787. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19788. }
  19789. if m.id == nil || m.oldValue == nil {
  19790. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19791. }
  19792. oldValue, err := m.oldValue(ctx)
  19793. if err != nil {
  19794. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19795. }
  19796. return oldValue.OrganizationID, nil
  19797. }
  19798. // AddOrganizationID adds u to the "organization_id" field.
  19799. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19800. if m.addorganization_id != nil {
  19801. *m.addorganization_id += u
  19802. } else {
  19803. m.addorganization_id = &u
  19804. }
  19805. }
  19806. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19807. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19808. v := m.addorganization_id
  19809. if v == nil {
  19810. return
  19811. }
  19812. return *v, true
  19813. }
  19814. // ClearOrganizationID clears the value of the "organization_id" field.
  19815. func (m *SopTaskMutation) ClearOrganizationID() {
  19816. m.organization_id = nil
  19817. m.addorganization_id = nil
  19818. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19819. }
  19820. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19821. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19822. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19823. return ok
  19824. }
  19825. // ResetOrganizationID resets all changes to the "organization_id" field.
  19826. func (m *SopTaskMutation) ResetOrganizationID() {
  19827. m.organization_id = nil
  19828. m.addorganization_id = nil
  19829. delete(m.clearedFields, soptask.FieldOrganizationID)
  19830. }
  19831. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19832. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19833. if m.task_stages == nil {
  19834. m.task_stages = make(map[uint64]struct{})
  19835. }
  19836. for i := range ids {
  19837. m.task_stages[ids[i]] = struct{}{}
  19838. }
  19839. }
  19840. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19841. func (m *SopTaskMutation) ClearTaskStages() {
  19842. m.clearedtask_stages = true
  19843. }
  19844. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19845. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19846. return m.clearedtask_stages
  19847. }
  19848. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19849. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19850. if m.removedtask_stages == nil {
  19851. m.removedtask_stages = make(map[uint64]struct{})
  19852. }
  19853. for i := range ids {
  19854. delete(m.task_stages, ids[i])
  19855. m.removedtask_stages[ids[i]] = struct{}{}
  19856. }
  19857. }
  19858. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19859. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19860. for id := range m.removedtask_stages {
  19861. ids = append(ids, id)
  19862. }
  19863. return
  19864. }
  19865. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19866. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19867. for id := range m.task_stages {
  19868. ids = append(ids, id)
  19869. }
  19870. return
  19871. }
  19872. // ResetTaskStages resets all changes to the "task_stages" edge.
  19873. func (m *SopTaskMutation) ResetTaskStages() {
  19874. m.task_stages = nil
  19875. m.clearedtask_stages = false
  19876. m.removedtask_stages = nil
  19877. }
  19878. // Where appends a list predicates to the SopTaskMutation builder.
  19879. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19880. m.predicates = append(m.predicates, ps...)
  19881. }
  19882. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19883. // users can use type-assertion to append predicates that do not depend on any generated package.
  19884. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19885. p := make([]predicate.SopTask, len(ps))
  19886. for i := range ps {
  19887. p[i] = ps[i]
  19888. }
  19889. m.Where(p...)
  19890. }
  19891. // Op returns the operation name.
  19892. func (m *SopTaskMutation) Op() Op {
  19893. return m.op
  19894. }
  19895. // SetOp allows setting the mutation operation.
  19896. func (m *SopTaskMutation) SetOp(op Op) {
  19897. m.op = op
  19898. }
  19899. // Type returns the node type of this mutation (SopTask).
  19900. func (m *SopTaskMutation) Type() string {
  19901. return m.typ
  19902. }
  19903. // Fields returns all fields that were changed during this mutation. Note that in
  19904. // order to get all numeric fields that were incremented/decremented, call
  19905. // AddedFields().
  19906. func (m *SopTaskMutation) Fields() []string {
  19907. fields := make([]string, 0, 11)
  19908. if m.created_at != nil {
  19909. fields = append(fields, soptask.FieldCreatedAt)
  19910. }
  19911. if m.updated_at != nil {
  19912. fields = append(fields, soptask.FieldUpdatedAt)
  19913. }
  19914. if m.status != nil {
  19915. fields = append(fields, soptask.FieldStatus)
  19916. }
  19917. if m.deleted_at != nil {
  19918. fields = append(fields, soptask.FieldDeletedAt)
  19919. }
  19920. if m.name != nil {
  19921. fields = append(fields, soptask.FieldName)
  19922. }
  19923. if m.bot_wxid_list != nil {
  19924. fields = append(fields, soptask.FieldBotWxidList)
  19925. }
  19926. if m._type != nil {
  19927. fields = append(fields, soptask.FieldType)
  19928. }
  19929. if m.plan_start_time != nil {
  19930. fields = append(fields, soptask.FieldPlanStartTime)
  19931. }
  19932. if m.plan_end_time != nil {
  19933. fields = append(fields, soptask.FieldPlanEndTime)
  19934. }
  19935. if m.creator_id != nil {
  19936. fields = append(fields, soptask.FieldCreatorID)
  19937. }
  19938. if m.organization_id != nil {
  19939. fields = append(fields, soptask.FieldOrganizationID)
  19940. }
  19941. return fields
  19942. }
  19943. // Field returns the value of a field with the given name. The second boolean
  19944. // return value indicates that this field was not set, or was not defined in the
  19945. // schema.
  19946. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  19947. switch name {
  19948. case soptask.FieldCreatedAt:
  19949. return m.CreatedAt()
  19950. case soptask.FieldUpdatedAt:
  19951. return m.UpdatedAt()
  19952. case soptask.FieldStatus:
  19953. return m.Status()
  19954. case soptask.FieldDeletedAt:
  19955. return m.DeletedAt()
  19956. case soptask.FieldName:
  19957. return m.Name()
  19958. case soptask.FieldBotWxidList:
  19959. return m.BotWxidList()
  19960. case soptask.FieldType:
  19961. return m.GetType()
  19962. case soptask.FieldPlanStartTime:
  19963. return m.PlanStartTime()
  19964. case soptask.FieldPlanEndTime:
  19965. return m.PlanEndTime()
  19966. case soptask.FieldCreatorID:
  19967. return m.CreatorID()
  19968. case soptask.FieldOrganizationID:
  19969. return m.OrganizationID()
  19970. }
  19971. return nil, false
  19972. }
  19973. // OldField returns the old value of the field from the database. An error is
  19974. // returned if the mutation operation is not UpdateOne, or the query to the
  19975. // database failed.
  19976. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19977. switch name {
  19978. case soptask.FieldCreatedAt:
  19979. return m.OldCreatedAt(ctx)
  19980. case soptask.FieldUpdatedAt:
  19981. return m.OldUpdatedAt(ctx)
  19982. case soptask.FieldStatus:
  19983. return m.OldStatus(ctx)
  19984. case soptask.FieldDeletedAt:
  19985. return m.OldDeletedAt(ctx)
  19986. case soptask.FieldName:
  19987. return m.OldName(ctx)
  19988. case soptask.FieldBotWxidList:
  19989. return m.OldBotWxidList(ctx)
  19990. case soptask.FieldType:
  19991. return m.OldType(ctx)
  19992. case soptask.FieldPlanStartTime:
  19993. return m.OldPlanStartTime(ctx)
  19994. case soptask.FieldPlanEndTime:
  19995. return m.OldPlanEndTime(ctx)
  19996. case soptask.FieldCreatorID:
  19997. return m.OldCreatorID(ctx)
  19998. case soptask.FieldOrganizationID:
  19999. return m.OldOrganizationID(ctx)
  20000. }
  20001. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20002. }
  20003. // SetField sets the value of a field with the given name. It returns an error if
  20004. // the field is not defined in the schema, or if the type mismatched the field
  20005. // type.
  20006. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20007. switch name {
  20008. case soptask.FieldCreatedAt:
  20009. v, ok := value.(time.Time)
  20010. if !ok {
  20011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20012. }
  20013. m.SetCreatedAt(v)
  20014. return nil
  20015. case soptask.FieldUpdatedAt:
  20016. v, ok := value.(time.Time)
  20017. if !ok {
  20018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20019. }
  20020. m.SetUpdatedAt(v)
  20021. return nil
  20022. case soptask.FieldStatus:
  20023. v, ok := value.(uint8)
  20024. if !ok {
  20025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20026. }
  20027. m.SetStatus(v)
  20028. return nil
  20029. case soptask.FieldDeletedAt:
  20030. v, ok := value.(time.Time)
  20031. if !ok {
  20032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20033. }
  20034. m.SetDeletedAt(v)
  20035. return nil
  20036. case soptask.FieldName:
  20037. v, ok := value.(string)
  20038. if !ok {
  20039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20040. }
  20041. m.SetName(v)
  20042. return nil
  20043. case soptask.FieldBotWxidList:
  20044. v, ok := value.([]string)
  20045. if !ok {
  20046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20047. }
  20048. m.SetBotWxidList(v)
  20049. return nil
  20050. case soptask.FieldType:
  20051. v, ok := value.(int)
  20052. if !ok {
  20053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20054. }
  20055. m.SetType(v)
  20056. return nil
  20057. case soptask.FieldPlanStartTime:
  20058. v, ok := value.(time.Time)
  20059. if !ok {
  20060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20061. }
  20062. m.SetPlanStartTime(v)
  20063. return nil
  20064. case soptask.FieldPlanEndTime:
  20065. v, ok := value.(time.Time)
  20066. if !ok {
  20067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20068. }
  20069. m.SetPlanEndTime(v)
  20070. return nil
  20071. case soptask.FieldCreatorID:
  20072. v, ok := value.(string)
  20073. if !ok {
  20074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20075. }
  20076. m.SetCreatorID(v)
  20077. return nil
  20078. case soptask.FieldOrganizationID:
  20079. v, ok := value.(uint64)
  20080. if !ok {
  20081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20082. }
  20083. m.SetOrganizationID(v)
  20084. return nil
  20085. }
  20086. return fmt.Errorf("unknown SopTask field %s", name)
  20087. }
  20088. // AddedFields returns all numeric fields that were incremented/decremented during
  20089. // this mutation.
  20090. func (m *SopTaskMutation) AddedFields() []string {
  20091. var fields []string
  20092. if m.addstatus != nil {
  20093. fields = append(fields, soptask.FieldStatus)
  20094. }
  20095. if m.add_type != nil {
  20096. fields = append(fields, soptask.FieldType)
  20097. }
  20098. if m.addorganization_id != nil {
  20099. fields = append(fields, soptask.FieldOrganizationID)
  20100. }
  20101. return fields
  20102. }
  20103. // AddedField returns the numeric value that was incremented/decremented on a field
  20104. // with the given name. The second boolean return value indicates that this field
  20105. // was not set, or was not defined in the schema.
  20106. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20107. switch name {
  20108. case soptask.FieldStatus:
  20109. return m.AddedStatus()
  20110. case soptask.FieldType:
  20111. return m.AddedType()
  20112. case soptask.FieldOrganizationID:
  20113. return m.AddedOrganizationID()
  20114. }
  20115. return nil, false
  20116. }
  20117. // AddField adds the value to the field with the given name. It returns an error if
  20118. // the field is not defined in the schema, or if the type mismatched the field
  20119. // type.
  20120. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20121. switch name {
  20122. case soptask.FieldStatus:
  20123. v, ok := value.(int8)
  20124. if !ok {
  20125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20126. }
  20127. m.AddStatus(v)
  20128. return nil
  20129. case soptask.FieldType:
  20130. v, ok := value.(int)
  20131. if !ok {
  20132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20133. }
  20134. m.AddType(v)
  20135. return nil
  20136. case soptask.FieldOrganizationID:
  20137. v, ok := value.(int64)
  20138. if !ok {
  20139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20140. }
  20141. m.AddOrganizationID(v)
  20142. return nil
  20143. }
  20144. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20145. }
  20146. // ClearedFields returns all nullable fields that were cleared during this
  20147. // mutation.
  20148. func (m *SopTaskMutation) ClearedFields() []string {
  20149. var fields []string
  20150. if m.FieldCleared(soptask.FieldStatus) {
  20151. fields = append(fields, soptask.FieldStatus)
  20152. }
  20153. if m.FieldCleared(soptask.FieldDeletedAt) {
  20154. fields = append(fields, soptask.FieldDeletedAt)
  20155. }
  20156. if m.FieldCleared(soptask.FieldBotWxidList) {
  20157. fields = append(fields, soptask.FieldBotWxidList)
  20158. }
  20159. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20160. fields = append(fields, soptask.FieldPlanStartTime)
  20161. }
  20162. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20163. fields = append(fields, soptask.FieldPlanEndTime)
  20164. }
  20165. if m.FieldCleared(soptask.FieldCreatorID) {
  20166. fields = append(fields, soptask.FieldCreatorID)
  20167. }
  20168. if m.FieldCleared(soptask.FieldOrganizationID) {
  20169. fields = append(fields, soptask.FieldOrganizationID)
  20170. }
  20171. return fields
  20172. }
  20173. // FieldCleared returns a boolean indicating if a field with the given name was
  20174. // cleared in this mutation.
  20175. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20176. _, ok := m.clearedFields[name]
  20177. return ok
  20178. }
  20179. // ClearField clears the value of the field with the given name. It returns an
  20180. // error if the field is not defined in the schema.
  20181. func (m *SopTaskMutation) ClearField(name string) error {
  20182. switch name {
  20183. case soptask.FieldStatus:
  20184. m.ClearStatus()
  20185. return nil
  20186. case soptask.FieldDeletedAt:
  20187. m.ClearDeletedAt()
  20188. return nil
  20189. case soptask.FieldBotWxidList:
  20190. m.ClearBotWxidList()
  20191. return nil
  20192. case soptask.FieldPlanStartTime:
  20193. m.ClearPlanStartTime()
  20194. return nil
  20195. case soptask.FieldPlanEndTime:
  20196. m.ClearPlanEndTime()
  20197. return nil
  20198. case soptask.FieldCreatorID:
  20199. m.ClearCreatorID()
  20200. return nil
  20201. case soptask.FieldOrganizationID:
  20202. m.ClearOrganizationID()
  20203. return nil
  20204. }
  20205. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20206. }
  20207. // ResetField resets all changes in the mutation for the field with the given name.
  20208. // It returns an error if the field is not defined in the schema.
  20209. func (m *SopTaskMutation) ResetField(name string) error {
  20210. switch name {
  20211. case soptask.FieldCreatedAt:
  20212. m.ResetCreatedAt()
  20213. return nil
  20214. case soptask.FieldUpdatedAt:
  20215. m.ResetUpdatedAt()
  20216. return nil
  20217. case soptask.FieldStatus:
  20218. m.ResetStatus()
  20219. return nil
  20220. case soptask.FieldDeletedAt:
  20221. m.ResetDeletedAt()
  20222. return nil
  20223. case soptask.FieldName:
  20224. m.ResetName()
  20225. return nil
  20226. case soptask.FieldBotWxidList:
  20227. m.ResetBotWxidList()
  20228. return nil
  20229. case soptask.FieldType:
  20230. m.ResetType()
  20231. return nil
  20232. case soptask.FieldPlanStartTime:
  20233. m.ResetPlanStartTime()
  20234. return nil
  20235. case soptask.FieldPlanEndTime:
  20236. m.ResetPlanEndTime()
  20237. return nil
  20238. case soptask.FieldCreatorID:
  20239. m.ResetCreatorID()
  20240. return nil
  20241. case soptask.FieldOrganizationID:
  20242. m.ResetOrganizationID()
  20243. return nil
  20244. }
  20245. return fmt.Errorf("unknown SopTask field %s", name)
  20246. }
  20247. // AddedEdges returns all edge names that were set/added in this mutation.
  20248. func (m *SopTaskMutation) AddedEdges() []string {
  20249. edges := make([]string, 0, 1)
  20250. if m.task_stages != nil {
  20251. edges = append(edges, soptask.EdgeTaskStages)
  20252. }
  20253. return edges
  20254. }
  20255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20256. // name in this mutation.
  20257. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20258. switch name {
  20259. case soptask.EdgeTaskStages:
  20260. ids := make([]ent.Value, 0, len(m.task_stages))
  20261. for id := range m.task_stages {
  20262. ids = append(ids, id)
  20263. }
  20264. return ids
  20265. }
  20266. return nil
  20267. }
  20268. // RemovedEdges returns all edge names that were removed in this mutation.
  20269. func (m *SopTaskMutation) RemovedEdges() []string {
  20270. edges := make([]string, 0, 1)
  20271. if m.removedtask_stages != nil {
  20272. edges = append(edges, soptask.EdgeTaskStages)
  20273. }
  20274. return edges
  20275. }
  20276. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20277. // the given name in this mutation.
  20278. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20279. switch name {
  20280. case soptask.EdgeTaskStages:
  20281. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20282. for id := range m.removedtask_stages {
  20283. ids = append(ids, id)
  20284. }
  20285. return ids
  20286. }
  20287. return nil
  20288. }
  20289. // ClearedEdges returns all edge names that were cleared in this mutation.
  20290. func (m *SopTaskMutation) ClearedEdges() []string {
  20291. edges := make([]string, 0, 1)
  20292. if m.clearedtask_stages {
  20293. edges = append(edges, soptask.EdgeTaskStages)
  20294. }
  20295. return edges
  20296. }
  20297. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20298. // was cleared in this mutation.
  20299. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20300. switch name {
  20301. case soptask.EdgeTaskStages:
  20302. return m.clearedtask_stages
  20303. }
  20304. return false
  20305. }
  20306. // ClearEdge clears the value of the edge with the given name. It returns an error
  20307. // if that edge is not defined in the schema.
  20308. func (m *SopTaskMutation) ClearEdge(name string) error {
  20309. switch name {
  20310. }
  20311. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20312. }
  20313. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20314. // It returns an error if the edge is not defined in the schema.
  20315. func (m *SopTaskMutation) ResetEdge(name string) error {
  20316. switch name {
  20317. case soptask.EdgeTaskStages:
  20318. m.ResetTaskStages()
  20319. return nil
  20320. }
  20321. return fmt.Errorf("unknown SopTask edge %s", name)
  20322. }
  20323. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20324. type TokenMutation struct {
  20325. config
  20326. op Op
  20327. typ string
  20328. id *uint64
  20329. created_at *time.Time
  20330. updated_at *time.Time
  20331. deleted_at *time.Time
  20332. expire_at *time.Time
  20333. token *string
  20334. mac *string
  20335. organization_id *uint64
  20336. addorganization_id *int64
  20337. custom_agent_base *string
  20338. custom_agent_key *string
  20339. openai_base *string
  20340. openai_key *string
  20341. clearedFields map[string]struct{}
  20342. agent *uint64
  20343. clearedagent bool
  20344. done bool
  20345. oldValue func(context.Context) (*Token, error)
  20346. predicates []predicate.Token
  20347. }
  20348. var _ ent.Mutation = (*TokenMutation)(nil)
  20349. // tokenOption allows management of the mutation configuration using functional options.
  20350. type tokenOption func(*TokenMutation)
  20351. // newTokenMutation creates new mutation for the Token entity.
  20352. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20353. m := &TokenMutation{
  20354. config: c,
  20355. op: op,
  20356. typ: TypeToken,
  20357. clearedFields: make(map[string]struct{}),
  20358. }
  20359. for _, opt := range opts {
  20360. opt(m)
  20361. }
  20362. return m
  20363. }
  20364. // withTokenID sets the ID field of the mutation.
  20365. func withTokenID(id uint64) tokenOption {
  20366. return func(m *TokenMutation) {
  20367. var (
  20368. err error
  20369. once sync.Once
  20370. value *Token
  20371. )
  20372. m.oldValue = func(ctx context.Context) (*Token, error) {
  20373. once.Do(func() {
  20374. if m.done {
  20375. err = errors.New("querying old values post mutation is not allowed")
  20376. } else {
  20377. value, err = m.Client().Token.Get(ctx, id)
  20378. }
  20379. })
  20380. return value, err
  20381. }
  20382. m.id = &id
  20383. }
  20384. }
  20385. // withToken sets the old Token of the mutation.
  20386. func withToken(node *Token) tokenOption {
  20387. return func(m *TokenMutation) {
  20388. m.oldValue = func(context.Context) (*Token, error) {
  20389. return node, nil
  20390. }
  20391. m.id = &node.ID
  20392. }
  20393. }
  20394. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20395. // executed in a transaction (ent.Tx), a transactional client is returned.
  20396. func (m TokenMutation) Client() *Client {
  20397. client := &Client{config: m.config}
  20398. client.init()
  20399. return client
  20400. }
  20401. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20402. // it returns an error otherwise.
  20403. func (m TokenMutation) Tx() (*Tx, error) {
  20404. if _, ok := m.driver.(*txDriver); !ok {
  20405. return nil, errors.New("ent: mutation is not running in a transaction")
  20406. }
  20407. tx := &Tx{config: m.config}
  20408. tx.init()
  20409. return tx, nil
  20410. }
  20411. // SetID sets the value of the id field. Note that this
  20412. // operation is only accepted on creation of Token entities.
  20413. func (m *TokenMutation) SetID(id uint64) {
  20414. m.id = &id
  20415. }
  20416. // ID returns the ID value in the mutation. Note that the ID is only available
  20417. // if it was provided to the builder or after it was returned from the database.
  20418. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20419. if m.id == nil {
  20420. return
  20421. }
  20422. return *m.id, true
  20423. }
  20424. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20425. // That means, if the mutation is applied within a transaction with an isolation level such
  20426. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20427. // or updated by the mutation.
  20428. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20429. switch {
  20430. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20431. id, exists := m.ID()
  20432. if exists {
  20433. return []uint64{id}, nil
  20434. }
  20435. fallthrough
  20436. case m.op.Is(OpUpdate | OpDelete):
  20437. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20438. default:
  20439. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20440. }
  20441. }
  20442. // SetCreatedAt sets the "created_at" field.
  20443. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20444. m.created_at = &t
  20445. }
  20446. // CreatedAt returns the value of the "created_at" field in the mutation.
  20447. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20448. v := m.created_at
  20449. if v == nil {
  20450. return
  20451. }
  20452. return *v, true
  20453. }
  20454. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20455. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20457. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20458. if !m.op.Is(OpUpdateOne) {
  20459. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20460. }
  20461. if m.id == nil || m.oldValue == nil {
  20462. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20463. }
  20464. oldValue, err := m.oldValue(ctx)
  20465. if err != nil {
  20466. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20467. }
  20468. return oldValue.CreatedAt, nil
  20469. }
  20470. // ResetCreatedAt resets all changes to the "created_at" field.
  20471. func (m *TokenMutation) ResetCreatedAt() {
  20472. m.created_at = nil
  20473. }
  20474. // SetUpdatedAt sets the "updated_at" field.
  20475. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20476. m.updated_at = &t
  20477. }
  20478. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20479. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20480. v := m.updated_at
  20481. if v == nil {
  20482. return
  20483. }
  20484. return *v, true
  20485. }
  20486. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20487. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20489. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20490. if !m.op.Is(OpUpdateOne) {
  20491. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20492. }
  20493. if m.id == nil || m.oldValue == nil {
  20494. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20495. }
  20496. oldValue, err := m.oldValue(ctx)
  20497. if err != nil {
  20498. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20499. }
  20500. return oldValue.UpdatedAt, nil
  20501. }
  20502. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20503. func (m *TokenMutation) ResetUpdatedAt() {
  20504. m.updated_at = nil
  20505. }
  20506. // SetDeletedAt sets the "deleted_at" field.
  20507. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20508. m.deleted_at = &t
  20509. }
  20510. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20511. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20512. v := m.deleted_at
  20513. if v == nil {
  20514. return
  20515. }
  20516. return *v, true
  20517. }
  20518. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20519. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20521. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20522. if !m.op.Is(OpUpdateOne) {
  20523. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20524. }
  20525. if m.id == nil || m.oldValue == nil {
  20526. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20527. }
  20528. oldValue, err := m.oldValue(ctx)
  20529. if err != nil {
  20530. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20531. }
  20532. return oldValue.DeletedAt, nil
  20533. }
  20534. // ClearDeletedAt clears the value of the "deleted_at" field.
  20535. func (m *TokenMutation) ClearDeletedAt() {
  20536. m.deleted_at = nil
  20537. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20538. }
  20539. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20540. func (m *TokenMutation) DeletedAtCleared() bool {
  20541. _, ok := m.clearedFields[token.FieldDeletedAt]
  20542. return ok
  20543. }
  20544. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20545. func (m *TokenMutation) ResetDeletedAt() {
  20546. m.deleted_at = nil
  20547. delete(m.clearedFields, token.FieldDeletedAt)
  20548. }
  20549. // SetExpireAt sets the "expire_at" field.
  20550. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20551. m.expire_at = &t
  20552. }
  20553. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20554. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20555. v := m.expire_at
  20556. if v == nil {
  20557. return
  20558. }
  20559. return *v, true
  20560. }
  20561. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20562. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20564. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20565. if !m.op.Is(OpUpdateOne) {
  20566. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20567. }
  20568. if m.id == nil || m.oldValue == nil {
  20569. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20570. }
  20571. oldValue, err := m.oldValue(ctx)
  20572. if err != nil {
  20573. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20574. }
  20575. return oldValue.ExpireAt, nil
  20576. }
  20577. // ClearExpireAt clears the value of the "expire_at" field.
  20578. func (m *TokenMutation) ClearExpireAt() {
  20579. m.expire_at = nil
  20580. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20581. }
  20582. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20583. func (m *TokenMutation) ExpireAtCleared() bool {
  20584. _, ok := m.clearedFields[token.FieldExpireAt]
  20585. return ok
  20586. }
  20587. // ResetExpireAt resets all changes to the "expire_at" field.
  20588. func (m *TokenMutation) ResetExpireAt() {
  20589. m.expire_at = nil
  20590. delete(m.clearedFields, token.FieldExpireAt)
  20591. }
  20592. // SetToken sets the "token" field.
  20593. func (m *TokenMutation) SetToken(s string) {
  20594. m.token = &s
  20595. }
  20596. // Token returns the value of the "token" field in the mutation.
  20597. func (m *TokenMutation) Token() (r string, exists bool) {
  20598. v := m.token
  20599. if v == nil {
  20600. return
  20601. }
  20602. return *v, true
  20603. }
  20604. // OldToken returns the old "token" field's value of the Token entity.
  20605. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20607. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20608. if !m.op.Is(OpUpdateOne) {
  20609. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20610. }
  20611. if m.id == nil || m.oldValue == nil {
  20612. return v, errors.New("OldToken requires an ID field in the mutation")
  20613. }
  20614. oldValue, err := m.oldValue(ctx)
  20615. if err != nil {
  20616. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20617. }
  20618. return oldValue.Token, nil
  20619. }
  20620. // ClearToken clears the value of the "token" field.
  20621. func (m *TokenMutation) ClearToken() {
  20622. m.token = nil
  20623. m.clearedFields[token.FieldToken] = struct{}{}
  20624. }
  20625. // TokenCleared returns if the "token" field was cleared in this mutation.
  20626. func (m *TokenMutation) TokenCleared() bool {
  20627. _, ok := m.clearedFields[token.FieldToken]
  20628. return ok
  20629. }
  20630. // ResetToken resets all changes to the "token" field.
  20631. func (m *TokenMutation) ResetToken() {
  20632. m.token = nil
  20633. delete(m.clearedFields, token.FieldToken)
  20634. }
  20635. // SetMAC sets the "mac" field.
  20636. func (m *TokenMutation) SetMAC(s string) {
  20637. m.mac = &s
  20638. }
  20639. // MAC returns the value of the "mac" field in the mutation.
  20640. func (m *TokenMutation) MAC() (r string, exists bool) {
  20641. v := m.mac
  20642. if v == nil {
  20643. return
  20644. }
  20645. return *v, true
  20646. }
  20647. // OldMAC returns the old "mac" field's value of the Token entity.
  20648. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20650. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20651. if !m.op.Is(OpUpdateOne) {
  20652. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20653. }
  20654. if m.id == nil || m.oldValue == nil {
  20655. return v, errors.New("OldMAC requires an ID field in the mutation")
  20656. }
  20657. oldValue, err := m.oldValue(ctx)
  20658. if err != nil {
  20659. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20660. }
  20661. return oldValue.MAC, nil
  20662. }
  20663. // ClearMAC clears the value of the "mac" field.
  20664. func (m *TokenMutation) ClearMAC() {
  20665. m.mac = nil
  20666. m.clearedFields[token.FieldMAC] = struct{}{}
  20667. }
  20668. // MACCleared returns if the "mac" field was cleared in this mutation.
  20669. func (m *TokenMutation) MACCleared() bool {
  20670. _, ok := m.clearedFields[token.FieldMAC]
  20671. return ok
  20672. }
  20673. // ResetMAC resets all changes to the "mac" field.
  20674. func (m *TokenMutation) ResetMAC() {
  20675. m.mac = nil
  20676. delete(m.clearedFields, token.FieldMAC)
  20677. }
  20678. // SetOrganizationID sets the "organization_id" field.
  20679. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20680. m.organization_id = &u
  20681. m.addorganization_id = nil
  20682. }
  20683. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20684. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20685. v := m.organization_id
  20686. if v == nil {
  20687. return
  20688. }
  20689. return *v, true
  20690. }
  20691. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20692. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20694. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20695. if !m.op.Is(OpUpdateOne) {
  20696. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20697. }
  20698. if m.id == nil || m.oldValue == nil {
  20699. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20700. }
  20701. oldValue, err := m.oldValue(ctx)
  20702. if err != nil {
  20703. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20704. }
  20705. return oldValue.OrganizationID, nil
  20706. }
  20707. // AddOrganizationID adds u to the "organization_id" field.
  20708. func (m *TokenMutation) AddOrganizationID(u int64) {
  20709. if m.addorganization_id != nil {
  20710. *m.addorganization_id += u
  20711. } else {
  20712. m.addorganization_id = &u
  20713. }
  20714. }
  20715. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20716. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20717. v := m.addorganization_id
  20718. if v == nil {
  20719. return
  20720. }
  20721. return *v, true
  20722. }
  20723. // ResetOrganizationID resets all changes to the "organization_id" field.
  20724. func (m *TokenMutation) ResetOrganizationID() {
  20725. m.organization_id = nil
  20726. m.addorganization_id = nil
  20727. }
  20728. // SetAgentID sets the "agent_id" field.
  20729. func (m *TokenMutation) SetAgentID(u uint64) {
  20730. m.agent = &u
  20731. }
  20732. // AgentID returns the value of the "agent_id" field in the mutation.
  20733. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20734. v := m.agent
  20735. if v == nil {
  20736. return
  20737. }
  20738. return *v, true
  20739. }
  20740. // OldAgentID returns the old "agent_id" 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) OldAgentID(ctx context.Context) (v uint64, err error) {
  20744. if !m.op.Is(OpUpdateOne) {
  20745. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20746. }
  20747. if m.id == nil || m.oldValue == nil {
  20748. return v, errors.New("OldAgentID 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 OldAgentID: %w", err)
  20753. }
  20754. return oldValue.AgentID, nil
  20755. }
  20756. // ResetAgentID resets all changes to the "agent_id" field.
  20757. func (m *TokenMutation) ResetAgentID() {
  20758. m.agent = nil
  20759. }
  20760. // SetCustomAgentBase sets the "custom_agent_base" field.
  20761. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20762. m.custom_agent_base = &s
  20763. }
  20764. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20765. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20766. v := m.custom_agent_base
  20767. if v == nil {
  20768. return
  20769. }
  20770. return *v, true
  20771. }
  20772. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20773. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20775. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20776. if !m.op.Is(OpUpdateOne) {
  20777. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20778. }
  20779. if m.id == nil || m.oldValue == nil {
  20780. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20781. }
  20782. oldValue, err := m.oldValue(ctx)
  20783. if err != nil {
  20784. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20785. }
  20786. return oldValue.CustomAgentBase, nil
  20787. }
  20788. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20789. func (m *TokenMutation) ClearCustomAgentBase() {
  20790. m.custom_agent_base = nil
  20791. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20792. }
  20793. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20794. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20795. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20796. return ok
  20797. }
  20798. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20799. func (m *TokenMutation) ResetCustomAgentBase() {
  20800. m.custom_agent_base = nil
  20801. delete(m.clearedFields, token.FieldCustomAgentBase)
  20802. }
  20803. // SetCustomAgentKey sets the "custom_agent_key" field.
  20804. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20805. m.custom_agent_key = &s
  20806. }
  20807. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20808. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20809. v := m.custom_agent_key
  20810. if v == nil {
  20811. return
  20812. }
  20813. return *v, true
  20814. }
  20815. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20816. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20818. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20819. if !m.op.Is(OpUpdateOne) {
  20820. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20821. }
  20822. if m.id == nil || m.oldValue == nil {
  20823. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20824. }
  20825. oldValue, err := m.oldValue(ctx)
  20826. if err != nil {
  20827. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20828. }
  20829. return oldValue.CustomAgentKey, nil
  20830. }
  20831. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20832. func (m *TokenMutation) ClearCustomAgentKey() {
  20833. m.custom_agent_key = nil
  20834. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20835. }
  20836. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20837. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20838. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20839. return ok
  20840. }
  20841. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20842. func (m *TokenMutation) ResetCustomAgentKey() {
  20843. m.custom_agent_key = nil
  20844. delete(m.clearedFields, token.FieldCustomAgentKey)
  20845. }
  20846. // SetOpenaiBase sets the "openai_base" field.
  20847. func (m *TokenMutation) SetOpenaiBase(s string) {
  20848. m.openai_base = &s
  20849. }
  20850. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20851. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20852. v := m.openai_base
  20853. if v == nil {
  20854. return
  20855. }
  20856. return *v, true
  20857. }
  20858. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20859. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20861. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  20862. if !m.op.Is(OpUpdateOne) {
  20863. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  20864. }
  20865. if m.id == nil || m.oldValue == nil {
  20866. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  20867. }
  20868. oldValue, err := m.oldValue(ctx)
  20869. if err != nil {
  20870. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  20871. }
  20872. return oldValue.OpenaiBase, nil
  20873. }
  20874. // ClearOpenaiBase clears the value of the "openai_base" field.
  20875. func (m *TokenMutation) ClearOpenaiBase() {
  20876. m.openai_base = nil
  20877. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  20878. }
  20879. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  20880. func (m *TokenMutation) OpenaiBaseCleared() bool {
  20881. _, ok := m.clearedFields[token.FieldOpenaiBase]
  20882. return ok
  20883. }
  20884. // ResetOpenaiBase resets all changes to the "openai_base" field.
  20885. func (m *TokenMutation) ResetOpenaiBase() {
  20886. m.openai_base = nil
  20887. delete(m.clearedFields, token.FieldOpenaiBase)
  20888. }
  20889. // SetOpenaiKey sets the "openai_key" field.
  20890. func (m *TokenMutation) SetOpenaiKey(s string) {
  20891. m.openai_key = &s
  20892. }
  20893. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  20894. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  20895. v := m.openai_key
  20896. if v == nil {
  20897. return
  20898. }
  20899. return *v, true
  20900. }
  20901. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  20902. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20904. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  20905. if !m.op.Is(OpUpdateOne) {
  20906. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  20907. }
  20908. if m.id == nil || m.oldValue == nil {
  20909. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  20910. }
  20911. oldValue, err := m.oldValue(ctx)
  20912. if err != nil {
  20913. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  20914. }
  20915. return oldValue.OpenaiKey, nil
  20916. }
  20917. // ClearOpenaiKey clears the value of the "openai_key" field.
  20918. func (m *TokenMutation) ClearOpenaiKey() {
  20919. m.openai_key = nil
  20920. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  20921. }
  20922. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  20923. func (m *TokenMutation) OpenaiKeyCleared() bool {
  20924. _, ok := m.clearedFields[token.FieldOpenaiKey]
  20925. return ok
  20926. }
  20927. // ResetOpenaiKey resets all changes to the "openai_key" field.
  20928. func (m *TokenMutation) ResetOpenaiKey() {
  20929. m.openai_key = nil
  20930. delete(m.clearedFields, token.FieldOpenaiKey)
  20931. }
  20932. // ClearAgent clears the "agent" edge to the Agent entity.
  20933. func (m *TokenMutation) ClearAgent() {
  20934. m.clearedagent = true
  20935. m.clearedFields[token.FieldAgentID] = struct{}{}
  20936. }
  20937. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  20938. func (m *TokenMutation) AgentCleared() bool {
  20939. return m.clearedagent
  20940. }
  20941. // AgentIDs returns the "agent" edge IDs in the mutation.
  20942. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20943. // AgentID instead. It exists only for internal usage by the builders.
  20944. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  20945. if id := m.agent; id != nil {
  20946. ids = append(ids, *id)
  20947. }
  20948. return
  20949. }
  20950. // ResetAgent resets all changes to the "agent" edge.
  20951. func (m *TokenMutation) ResetAgent() {
  20952. m.agent = nil
  20953. m.clearedagent = false
  20954. }
  20955. // Where appends a list predicates to the TokenMutation builder.
  20956. func (m *TokenMutation) Where(ps ...predicate.Token) {
  20957. m.predicates = append(m.predicates, ps...)
  20958. }
  20959. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  20960. // users can use type-assertion to append predicates that do not depend on any generated package.
  20961. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  20962. p := make([]predicate.Token, len(ps))
  20963. for i := range ps {
  20964. p[i] = ps[i]
  20965. }
  20966. m.Where(p...)
  20967. }
  20968. // Op returns the operation name.
  20969. func (m *TokenMutation) Op() Op {
  20970. return m.op
  20971. }
  20972. // SetOp allows setting the mutation operation.
  20973. func (m *TokenMutation) SetOp(op Op) {
  20974. m.op = op
  20975. }
  20976. // Type returns the node type of this mutation (Token).
  20977. func (m *TokenMutation) Type() string {
  20978. return m.typ
  20979. }
  20980. // Fields returns all fields that were changed during this mutation. Note that in
  20981. // order to get all numeric fields that were incremented/decremented, call
  20982. // AddedFields().
  20983. func (m *TokenMutation) Fields() []string {
  20984. fields := make([]string, 0, 12)
  20985. if m.created_at != nil {
  20986. fields = append(fields, token.FieldCreatedAt)
  20987. }
  20988. if m.updated_at != nil {
  20989. fields = append(fields, token.FieldUpdatedAt)
  20990. }
  20991. if m.deleted_at != nil {
  20992. fields = append(fields, token.FieldDeletedAt)
  20993. }
  20994. if m.expire_at != nil {
  20995. fields = append(fields, token.FieldExpireAt)
  20996. }
  20997. if m.token != nil {
  20998. fields = append(fields, token.FieldToken)
  20999. }
  21000. if m.mac != nil {
  21001. fields = append(fields, token.FieldMAC)
  21002. }
  21003. if m.organization_id != nil {
  21004. fields = append(fields, token.FieldOrganizationID)
  21005. }
  21006. if m.agent != nil {
  21007. fields = append(fields, token.FieldAgentID)
  21008. }
  21009. if m.custom_agent_base != nil {
  21010. fields = append(fields, token.FieldCustomAgentBase)
  21011. }
  21012. if m.custom_agent_key != nil {
  21013. fields = append(fields, token.FieldCustomAgentKey)
  21014. }
  21015. if m.openai_base != nil {
  21016. fields = append(fields, token.FieldOpenaiBase)
  21017. }
  21018. if m.openai_key != nil {
  21019. fields = append(fields, token.FieldOpenaiKey)
  21020. }
  21021. return fields
  21022. }
  21023. // Field returns the value of a field with the given name. The second boolean
  21024. // return value indicates that this field was not set, or was not defined in the
  21025. // schema.
  21026. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21027. switch name {
  21028. case token.FieldCreatedAt:
  21029. return m.CreatedAt()
  21030. case token.FieldUpdatedAt:
  21031. return m.UpdatedAt()
  21032. case token.FieldDeletedAt:
  21033. return m.DeletedAt()
  21034. case token.FieldExpireAt:
  21035. return m.ExpireAt()
  21036. case token.FieldToken:
  21037. return m.Token()
  21038. case token.FieldMAC:
  21039. return m.MAC()
  21040. case token.FieldOrganizationID:
  21041. return m.OrganizationID()
  21042. case token.FieldAgentID:
  21043. return m.AgentID()
  21044. case token.FieldCustomAgentBase:
  21045. return m.CustomAgentBase()
  21046. case token.FieldCustomAgentKey:
  21047. return m.CustomAgentKey()
  21048. case token.FieldOpenaiBase:
  21049. return m.OpenaiBase()
  21050. case token.FieldOpenaiKey:
  21051. return m.OpenaiKey()
  21052. }
  21053. return nil, false
  21054. }
  21055. // OldField returns the old value of the field from the database. An error is
  21056. // returned if the mutation operation is not UpdateOne, or the query to the
  21057. // database failed.
  21058. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21059. switch name {
  21060. case token.FieldCreatedAt:
  21061. return m.OldCreatedAt(ctx)
  21062. case token.FieldUpdatedAt:
  21063. return m.OldUpdatedAt(ctx)
  21064. case token.FieldDeletedAt:
  21065. return m.OldDeletedAt(ctx)
  21066. case token.FieldExpireAt:
  21067. return m.OldExpireAt(ctx)
  21068. case token.FieldToken:
  21069. return m.OldToken(ctx)
  21070. case token.FieldMAC:
  21071. return m.OldMAC(ctx)
  21072. case token.FieldOrganizationID:
  21073. return m.OldOrganizationID(ctx)
  21074. case token.FieldAgentID:
  21075. return m.OldAgentID(ctx)
  21076. case token.FieldCustomAgentBase:
  21077. return m.OldCustomAgentBase(ctx)
  21078. case token.FieldCustomAgentKey:
  21079. return m.OldCustomAgentKey(ctx)
  21080. case token.FieldOpenaiBase:
  21081. return m.OldOpenaiBase(ctx)
  21082. case token.FieldOpenaiKey:
  21083. return m.OldOpenaiKey(ctx)
  21084. }
  21085. return nil, fmt.Errorf("unknown Token field %s", name)
  21086. }
  21087. // SetField sets the value of a field with the given name. It returns an error if
  21088. // the field is not defined in the schema, or if the type mismatched the field
  21089. // type.
  21090. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21091. switch name {
  21092. case token.FieldCreatedAt:
  21093. v, ok := value.(time.Time)
  21094. if !ok {
  21095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21096. }
  21097. m.SetCreatedAt(v)
  21098. return nil
  21099. case token.FieldUpdatedAt:
  21100. v, ok := value.(time.Time)
  21101. if !ok {
  21102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21103. }
  21104. m.SetUpdatedAt(v)
  21105. return nil
  21106. case token.FieldDeletedAt:
  21107. v, ok := value.(time.Time)
  21108. if !ok {
  21109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21110. }
  21111. m.SetDeletedAt(v)
  21112. return nil
  21113. case token.FieldExpireAt:
  21114. v, ok := value.(time.Time)
  21115. if !ok {
  21116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21117. }
  21118. m.SetExpireAt(v)
  21119. return nil
  21120. case token.FieldToken:
  21121. v, ok := value.(string)
  21122. if !ok {
  21123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21124. }
  21125. m.SetToken(v)
  21126. return nil
  21127. case token.FieldMAC:
  21128. v, ok := value.(string)
  21129. if !ok {
  21130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21131. }
  21132. m.SetMAC(v)
  21133. return nil
  21134. case token.FieldOrganizationID:
  21135. v, ok := value.(uint64)
  21136. if !ok {
  21137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21138. }
  21139. m.SetOrganizationID(v)
  21140. return nil
  21141. case token.FieldAgentID:
  21142. v, ok := value.(uint64)
  21143. if !ok {
  21144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21145. }
  21146. m.SetAgentID(v)
  21147. return nil
  21148. case token.FieldCustomAgentBase:
  21149. v, ok := value.(string)
  21150. if !ok {
  21151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21152. }
  21153. m.SetCustomAgentBase(v)
  21154. return nil
  21155. case token.FieldCustomAgentKey:
  21156. v, ok := value.(string)
  21157. if !ok {
  21158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21159. }
  21160. m.SetCustomAgentKey(v)
  21161. return nil
  21162. case token.FieldOpenaiBase:
  21163. v, ok := value.(string)
  21164. if !ok {
  21165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21166. }
  21167. m.SetOpenaiBase(v)
  21168. return nil
  21169. case token.FieldOpenaiKey:
  21170. v, ok := value.(string)
  21171. if !ok {
  21172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21173. }
  21174. m.SetOpenaiKey(v)
  21175. return nil
  21176. }
  21177. return fmt.Errorf("unknown Token field %s", name)
  21178. }
  21179. // AddedFields returns all numeric fields that were incremented/decremented during
  21180. // this mutation.
  21181. func (m *TokenMutation) AddedFields() []string {
  21182. var fields []string
  21183. if m.addorganization_id != nil {
  21184. fields = append(fields, token.FieldOrganizationID)
  21185. }
  21186. return fields
  21187. }
  21188. // AddedField returns the numeric value that was incremented/decremented on a field
  21189. // with the given name. The second boolean return value indicates that this field
  21190. // was not set, or was not defined in the schema.
  21191. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21192. switch name {
  21193. case token.FieldOrganizationID:
  21194. return m.AddedOrganizationID()
  21195. }
  21196. return nil, false
  21197. }
  21198. // AddField adds the value to the field with the given name. It returns an error if
  21199. // the field is not defined in the schema, or if the type mismatched the field
  21200. // type.
  21201. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21202. switch name {
  21203. case token.FieldOrganizationID:
  21204. v, ok := value.(int64)
  21205. if !ok {
  21206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21207. }
  21208. m.AddOrganizationID(v)
  21209. return nil
  21210. }
  21211. return fmt.Errorf("unknown Token numeric field %s", name)
  21212. }
  21213. // ClearedFields returns all nullable fields that were cleared during this
  21214. // mutation.
  21215. func (m *TokenMutation) ClearedFields() []string {
  21216. var fields []string
  21217. if m.FieldCleared(token.FieldDeletedAt) {
  21218. fields = append(fields, token.FieldDeletedAt)
  21219. }
  21220. if m.FieldCleared(token.FieldExpireAt) {
  21221. fields = append(fields, token.FieldExpireAt)
  21222. }
  21223. if m.FieldCleared(token.FieldToken) {
  21224. fields = append(fields, token.FieldToken)
  21225. }
  21226. if m.FieldCleared(token.FieldMAC) {
  21227. fields = append(fields, token.FieldMAC)
  21228. }
  21229. if m.FieldCleared(token.FieldCustomAgentBase) {
  21230. fields = append(fields, token.FieldCustomAgentBase)
  21231. }
  21232. if m.FieldCleared(token.FieldCustomAgentKey) {
  21233. fields = append(fields, token.FieldCustomAgentKey)
  21234. }
  21235. if m.FieldCleared(token.FieldOpenaiBase) {
  21236. fields = append(fields, token.FieldOpenaiBase)
  21237. }
  21238. if m.FieldCleared(token.FieldOpenaiKey) {
  21239. fields = append(fields, token.FieldOpenaiKey)
  21240. }
  21241. return fields
  21242. }
  21243. // FieldCleared returns a boolean indicating if a field with the given name was
  21244. // cleared in this mutation.
  21245. func (m *TokenMutation) FieldCleared(name string) bool {
  21246. _, ok := m.clearedFields[name]
  21247. return ok
  21248. }
  21249. // ClearField clears the value of the field with the given name. It returns an
  21250. // error if the field is not defined in the schema.
  21251. func (m *TokenMutation) ClearField(name string) error {
  21252. switch name {
  21253. case token.FieldDeletedAt:
  21254. m.ClearDeletedAt()
  21255. return nil
  21256. case token.FieldExpireAt:
  21257. m.ClearExpireAt()
  21258. return nil
  21259. case token.FieldToken:
  21260. m.ClearToken()
  21261. return nil
  21262. case token.FieldMAC:
  21263. m.ClearMAC()
  21264. return nil
  21265. case token.FieldCustomAgentBase:
  21266. m.ClearCustomAgentBase()
  21267. return nil
  21268. case token.FieldCustomAgentKey:
  21269. m.ClearCustomAgentKey()
  21270. return nil
  21271. case token.FieldOpenaiBase:
  21272. m.ClearOpenaiBase()
  21273. return nil
  21274. case token.FieldOpenaiKey:
  21275. m.ClearOpenaiKey()
  21276. return nil
  21277. }
  21278. return fmt.Errorf("unknown Token nullable field %s", name)
  21279. }
  21280. // ResetField resets all changes in the mutation for the field with the given name.
  21281. // It returns an error if the field is not defined in the schema.
  21282. func (m *TokenMutation) ResetField(name string) error {
  21283. switch name {
  21284. case token.FieldCreatedAt:
  21285. m.ResetCreatedAt()
  21286. return nil
  21287. case token.FieldUpdatedAt:
  21288. m.ResetUpdatedAt()
  21289. return nil
  21290. case token.FieldDeletedAt:
  21291. m.ResetDeletedAt()
  21292. return nil
  21293. case token.FieldExpireAt:
  21294. m.ResetExpireAt()
  21295. return nil
  21296. case token.FieldToken:
  21297. m.ResetToken()
  21298. return nil
  21299. case token.FieldMAC:
  21300. m.ResetMAC()
  21301. return nil
  21302. case token.FieldOrganizationID:
  21303. m.ResetOrganizationID()
  21304. return nil
  21305. case token.FieldAgentID:
  21306. m.ResetAgentID()
  21307. return nil
  21308. case token.FieldCustomAgentBase:
  21309. m.ResetCustomAgentBase()
  21310. return nil
  21311. case token.FieldCustomAgentKey:
  21312. m.ResetCustomAgentKey()
  21313. return nil
  21314. case token.FieldOpenaiBase:
  21315. m.ResetOpenaiBase()
  21316. return nil
  21317. case token.FieldOpenaiKey:
  21318. m.ResetOpenaiKey()
  21319. return nil
  21320. }
  21321. return fmt.Errorf("unknown Token field %s", name)
  21322. }
  21323. // AddedEdges returns all edge names that were set/added in this mutation.
  21324. func (m *TokenMutation) AddedEdges() []string {
  21325. edges := make([]string, 0, 1)
  21326. if m.agent != nil {
  21327. edges = append(edges, token.EdgeAgent)
  21328. }
  21329. return edges
  21330. }
  21331. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21332. // name in this mutation.
  21333. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21334. switch name {
  21335. case token.EdgeAgent:
  21336. if id := m.agent; id != nil {
  21337. return []ent.Value{*id}
  21338. }
  21339. }
  21340. return nil
  21341. }
  21342. // RemovedEdges returns all edge names that were removed in this mutation.
  21343. func (m *TokenMutation) RemovedEdges() []string {
  21344. edges := make([]string, 0, 1)
  21345. return edges
  21346. }
  21347. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21348. // the given name in this mutation.
  21349. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21350. return nil
  21351. }
  21352. // ClearedEdges returns all edge names that were cleared in this mutation.
  21353. func (m *TokenMutation) ClearedEdges() []string {
  21354. edges := make([]string, 0, 1)
  21355. if m.clearedagent {
  21356. edges = append(edges, token.EdgeAgent)
  21357. }
  21358. return edges
  21359. }
  21360. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21361. // was cleared in this mutation.
  21362. func (m *TokenMutation) EdgeCleared(name string) bool {
  21363. switch name {
  21364. case token.EdgeAgent:
  21365. return m.clearedagent
  21366. }
  21367. return false
  21368. }
  21369. // ClearEdge clears the value of the edge with the given name. It returns an error
  21370. // if that edge is not defined in the schema.
  21371. func (m *TokenMutation) ClearEdge(name string) error {
  21372. switch name {
  21373. case token.EdgeAgent:
  21374. m.ClearAgent()
  21375. return nil
  21376. }
  21377. return fmt.Errorf("unknown Token unique edge %s", name)
  21378. }
  21379. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21380. // It returns an error if the edge is not defined in the schema.
  21381. func (m *TokenMutation) ResetEdge(name string) error {
  21382. switch name {
  21383. case token.EdgeAgent:
  21384. m.ResetAgent()
  21385. return nil
  21386. }
  21387. return fmt.Errorf("unknown Token edge %s", name)
  21388. }
  21389. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21390. type TutorialMutation struct {
  21391. config
  21392. op Op
  21393. typ string
  21394. id *uint64
  21395. created_at *time.Time
  21396. updated_at *time.Time
  21397. deleted_at *time.Time
  21398. index *int
  21399. addindex *int
  21400. title *string
  21401. content *string
  21402. organization_id *uint64
  21403. addorganization_id *int64
  21404. clearedFields map[string]struct{}
  21405. employee *uint64
  21406. clearedemployee bool
  21407. done bool
  21408. oldValue func(context.Context) (*Tutorial, error)
  21409. predicates []predicate.Tutorial
  21410. }
  21411. var _ ent.Mutation = (*TutorialMutation)(nil)
  21412. // tutorialOption allows management of the mutation configuration using functional options.
  21413. type tutorialOption func(*TutorialMutation)
  21414. // newTutorialMutation creates new mutation for the Tutorial entity.
  21415. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21416. m := &TutorialMutation{
  21417. config: c,
  21418. op: op,
  21419. typ: TypeTutorial,
  21420. clearedFields: make(map[string]struct{}),
  21421. }
  21422. for _, opt := range opts {
  21423. opt(m)
  21424. }
  21425. return m
  21426. }
  21427. // withTutorialID sets the ID field of the mutation.
  21428. func withTutorialID(id uint64) tutorialOption {
  21429. return func(m *TutorialMutation) {
  21430. var (
  21431. err error
  21432. once sync.Once
  21433. value *Tutorial
  21434. )
  21435. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21436. once.Do(func() {
  21437. if m.done {
  21438. err = errors.New("querying old values post mutation is not allowed")
  21439. } else {
  21440. value, err = m.Client().Tutorial.Get(ctx, id)
  21441. }
  21442. })
  21443. return value, err
  21444. }
  21445. m.id = &id
  21446. }
  21447. }
  21448. // withTutorial sets the old Tutorial of the mutation.
  21449. func withTutorial(node *Tutorial) tutorialOption {
  21450. return func(m *TutorialMutation) {
  21451. m.oldValue = func(context.Context) (*Tutorial, error) {
  21452. return node, nil
  21453. }
  21454. m.id = &node.ID
  21455. }
  21456. }
  21457. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21458. // executed in a transaction (ent.Tx), a transactional client is returned.
  21459. func (m TutorialMutation) Client() *Client {
  21460. client := &Client{config: m.config}
  21461. client.init()
  21462. return client
  21463. }
  21464. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21465. // it returns an error otherwise.
  21466. func (m TutorialMutation) Tx() (*Tx, error) {
  21467. if _, ok := m.driver.(*txDriver); !ok {
  21468. return nil, errors.New("ent: mutation is not running in a transaction")
  21469. }
  21470. tx := &Tx{config: m.config}
  21471. tx.init()
  21472. return tx, nil
  21473. }
  21474. // SetID sets the value of the id field. Note that this
  21475. // operation is only accepted on creation of Tutorial entities.
  21476. func (m *TutorialMutation) SetID(id uint64) {
  21477. m.id = &id
  21478. }
  21479. // ID returns the ID value in the mutation. Note that the ID is only available
  21480. // if it was provided to the builder or after it was returned from the database.
  21481. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21482. if m.id == nil {
  21483. return
  21484. }
  21485. return *m.id, true
  21486. }
  21487. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21488. // That means, if the mutation is applied within a transaction with an isolation level such
  21489. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21490. // or updated by the mutation.
  21491. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21492. switch {
  21493. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21494. id, exists := m.ID()
  21495. if exists {
  21496. return []uint64{id}, nil
  21497. }
  21498. fallthrough
  21499. case m.op.Is(OpUpdate | OpDelete):
  21500. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21501. default:
  21502. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21503. }
  21504. }
  21505. // SetCreatedAt sets the "created_at" field.
  21506. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21507. m.created_at = &t
  21508. }
  21509. // CreatedAt returns the value of the "created_at" field in the mutation.
  21510. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21511. v := m.created_at
  21512. if v == nil {
  21513. return
  21514. }
  21515. return *v, true
  21516. }
  21517. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21518. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21520. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21521. if !m.op.Is(OpUpdateOne) {
  21522. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21523. }
  21524. if m.id == nil || m.oldValue == nil {
  21525. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21526. }
  21527. oldValue, err := m.oldValue(ctx)
  21528. if err != nil {
  21529. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21530. }
  21531. return oldValue.CreatedAt, nil
  21532. }
  21533. // ResetCreatedAt resets all changes to the "created_at" field.
  21534. func (m *TutorialMutation) ResetCreatedAt() {
  21535. m.created_at = nil
  21536. }
  21537. // SetUpdatedAt sets the "updated_at" field.
  21538. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21539. m.updated_at = &t
  21540. }
  21541. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21542. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21543. v := m.updated_at
  21544. if v == nil {
  21545. return
  21546. }
  21547. return *v, true
  21548. }
  21549. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21550. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21552. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21553. if !m.op.Is(OpUpdateOne) {
  21554. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21555. }
  21556. if m.id == nil || m.oldValue == nil {
  21557. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21558. }
  21559. oldValue, err := m.oldValue(ctx)
  21560. if err != nil {
  21561. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21562. }
  21563. return oldValue.UpdatedAt, nil
  21564. }
  21565. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21566. func (m *TutorialMutation) ResetUpdatedAt() {
  21567. m.updated_at = nil
  21568. }
  21569. // SetDeletedAt sets the "deleted_at" field.
  21570. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21571. m.deleted_at = &t
  21572. }
  21573. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21574. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21575. v := m.deleted_at
  21576. if v == nil {
  21577. return
  21578. }
  21579. return *v, true
  21580. }
  21581. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21582. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21584. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21585. if !m.op.Is(OpUpdateOne) {
  21586. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21587. }
  21588. if m.id == nil || m.oldValue == nil {
  21589. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21590. }
  21591. oldValue, err := m.oldValue(ctx)
  21592. if err != nil {
  21593. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21594. }
  21595. return oldValue.DeletedAt, nil
  21596. }
  21597. // ClearDeletedAt clears the value of the "deleted_at" field.
  21598. func (m *TutorialMutation) ClearDeletedAt() {
  21599. m.deleted_at = nil
  21600. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21601. }
  21602. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21603. func (m *TutorialMutation) DeletedAtCleared() bool {
  21604. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21605. return ok
  21606. }
  21607. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21608. func (m *TutorialMutation) ResetDeletedAt() {
  21609. m.deleted_at = nil
  21610. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21611. }
  21612. // SetEmployeeID sets the "employee_id" field.
  21613. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21614. m.employee = &u
  21615. }
  21616. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21617. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21618. v := m.employee
  21619. if v == nil {
  21620. return
  21621. }
  21622. return *v, true
  21623. }
  21624. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21625. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21627. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21628. if !m.op.Is(OpUpdateOne) {
  21629. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21630. }
  21631. if m.id == nil || m.oldValue == nil {
  21632. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21633. }
  21634. oldValue, err := m.oldValue(ctx)
  21635. if err != nil {
  21636. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21637. }
  21638. return oldValue.EmployeeID, nil
  21639. }
  21640. // ResetEmployeeID resets all changes to the "employee_id" field.
  21641. func (m *TutorialMutation) ResetEmployeeID() {
  21642. m.employee = nil
  21643. }
  21644. // SetIndex sets the "index" field.
  21645. func (m *TutorialMutation) SetIndex(i int) {
  21646. m.index = &i
  21647. m.addindex = nil
  21648. }
  21649. // Index returns the value of the "index" field in the mutation.
  21650. func (m *TutorialMutation) Index() (r int, exists bool) {
  21651. v := m.index
  21652. if v == nil {
  21653. return
  21654. }
  21655. return *v, true
  21656. }
  21657. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21658. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21660. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21661. if !m.op.Is(OpUpdateOne) {
  21662. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21663. }
  21664. if m.id == nil || m.oldValue == nil {
  21665. return v, errors.New("OldIndex requires an ID field in the mutation")
  21666. }
  21667. oldValue, err := m.oldValue(ctx)
  21668. if err != nil {
  21669. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21670. }
  21671. return oldValue.Index, nil
  21672. }
  21673. // AddIndex adds i to the "index" field.
  21674. func (m *TutorialMutation) AddIndex(i int) {
  21675. if m.addindex != nil {
  21676. *m.addindex += i
  21677. } else {
  21678. m.addindex = &i
  21679. }
  21680. }
  21681. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21682. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21683. v := m.addindex
  21684. if v == nil {
  21685. return
  21686. }
  21687. return *v, true
  21688. }
  21689. // ResetIndex resets all changes to the "index" field.
  21690. func (m *TutorialMutation) ResetIndex() {
  21691. m.index = nil
  21692. m.addindex = nil
  21693. }
  21694. // SetTitle sets the "title" field.
  21695. func (m *TutorialMutation) SetTitle(s string) {
  21696. m.title = &s
  21697. }
  21698. // Title returns the value of the "title" field in the mutation.
  21699. func (m *TutorialMutation) Title() (r string, exists bool) {
  21700. v := m.title
  21701. if v == nil {
  21702. return
  21703. }
  21704. return *v, true
  21705. }
  21706. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21707. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21709. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21710. if !m.op.Is(OpUpdateOne) {
  21711. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21712. }
  21713. if m.id == nil || m.oldValue == nil {
  21714. return v, errors.New("OldTitle requires an ID field in the mutation")
  21715. }
  21716. oldValue, err := m.oldValue(ctx)
  21717. if err != nil {
  21718. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21719. }
  21720. return oldValue.Title, nil
  21721. }
  21722. // ResetTitle resets all changes to the "title" field.
  21723. func (m *TutorialMutation) ResetTitle() {
  21724. m.title = nil
  21725. }
  21726. // SetContent sets the "content" field.
  21727. func (m *TutorialMutation) SetContent(s string) {
  21728. m.content = &s
  21729. }
  21730. // Content returns the value of the "content" field in the mutation.
  21731. func (m *TutorialMutation) Content() (r string, exists bool) {
  21732. v := m.content
  21733. if v == nil {
  21734. return
  21735. }
  21736. return *v, true
  21737. }
  21738. // OldContent returns the old "content" field's value of the Tutorial entity.
  21739. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21741. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21742. if !m.op.Is(OpUpdateOne) {
  21743. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21744. }
  21745. if m.id == nil || m.oldValue == nil {
  21746. return v, errors.New("OldContent requires an ID field in the mutation")
  21747. }
  21748. oldValue, err := m.oldValue(ctx)
  21749. if err != nil {
  21750. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21751. }
  21752. return oldValue.Content, nil
  21753. }
  21754. // ResetContent resets all changes to the "content" field.
  21755. func (m *TutorialMutation) ResetContent() {
  21756. m.content = nil
  21757. }
  21758. // SetOrganizationID sets the "organization_id" field.
  21759. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21760. m.organization_id = &u
  21761. m.addorganization_id = nil
  21762. }
  21763. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21764. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21765. v := m.organization_id
  21766. if v == nil {
  21767. return
  21768. }
  21769. return *v, true
  21770. }
  21771. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21772. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21774. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21775. if !m.op.Is(OpUpdateOne) {
  21776. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21777. }
  21778. if m.id == nil || m.oldValue == nil {
  21779. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21780. }
  21781. oldValue, err := m.oldValue(ctx)
  21782. if err != nil {
  21783. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21784. }
  21785. return oldValue.OrganizationID, nil
  21786. }
  21787. // AddOrganizationID adds u to the "organization_id" field.
  21788. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21789. if m.addorganization_id != nil {
  21790. *m.addorganization_id += u
  21791. } else {
  21792. m.addorganization_id = &u
  21793. }
  21794. }
  21795. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21796. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21797. v := m.addorganization_id
  21798. if v == nil {
  21799. return
  21800. }
  21801. return *v, true
  21802. }
  21803. // ResetOrganizationID resets all changes to the "organization_id" field.
  21804. func (m *TutorialMutation) ResetOrganizationID() {
  21805. m.organization_id = nil
  21806. m.addorganization_id = nil
  21807. }
  21808. // ClearEmployee clears the "employee" edge to the Employee entity.
  21809. func (m *TutorialMutation) ClearEmployee() {
  21810. m.clearedemployee = true
  21811. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21812. }
  21813. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21814. func (m *TutorialMutation) EmployeeCleared() bool {
  21815. return m.clearedemployee
  21816. }
  21817. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21818. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21819. // EmployeeID instead. It exists only for internal usage by the builders.
  21820. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21821. if id := m.employee; id != nil {
  21822. ids = append(ids, *id)
  21823. }
  21824. return
  21825. }
  21826. // ResetEmployee resets all changes to the "employee" edge.
  21827. func (m *TutorialMutation) ResetEmployee() {
  21828. m.employee = nil
  21829. m.clearedemployee = false
  21830. }
  21831. // Where appends a list predicates to the TutorialMutation builder.
  21832. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21833. m.predicates = append(m.predicates, ps...)
  21834. }
  21835. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21836. // users can use type-assertion to append predicates that do not depend on any generated package.
  21837. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21838. p := make([]predicate.Tutorial, len(ps))
  21839. for i := range ps {
  21840. p[i] = ps[i]
  21841. }
  21842. m.Where(p...)
  21843. }
  21844. // Op returns the operation name.
  21845. func (m *TutorialMutation) Op() Op {
  21846. return m.op
  21847. }
  21848. // SetOp allows setting the mutation operation.
  21849. func (m *TutorialMutation) SetOp(op Op) {
  21850. m.op = op
  21851. }
  21852. // Type returns the node type of this mutation (Tutorial).
  21853. func (m *TutorialMutation) Type() string {
  21854. return m.typ
  21855. }
  21856. // Fields returns all fields that were changed during this mutation. Note that in
  21857. // order to get all numeric fields that were incremented/decremented, call
  21858. // AddedFields().
  21859. func (m *TutorialMutation) Fields() []string {
  21860. fields := make([]string, 0, 8)
  21861. if m.created_at != nil {
  21862. fields = append(fields, tutorial.FieldCreatedAt)
  21863. }
  21864. if m.updated_at != nil {
  21865. fields = append(fields, tutorial.FieldUpdatedAt)
  21866. }
  21867. if m.deleted_at != nil {
  21868. fields = append(fields, tutorial.FieldDeletedAt)
  21869. }
  21870. if m.employee != nil {
  21871. fields = append(fields, tutorial.FieldEmployeeID)
  21872. }
  21873. if m.index != nil {
  21874. fields = append(fields, tutorial.FieldIndex)
  21875. }
  21876. if m.title != nil {
  21877. fields = append(fields, tutorial.FieldTitle)
  21878. }
  21879. if m.content != nil {
  21880. fields = append(fields, tutorial.FieldContent)
  21881. }
  21882. if m.organization_id != nil {
  21883. fields = append(fields, tutorial.FieldOrganizationID)
  21884. }
  21885. return fields
  21886. }
  21887. // Field returns the value of a field with the given name. The second boolean
  21888. // return value indicates that this field was not set, or was not defined in the
  21889. // schema.
  21890. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  21891. switch name {
  21892. case tutorial.FieldCreatedAt:
  21893. return m.CreatedAt()
  21894. case tutorial.FieldUpdatedAt:
  21895. return m.UpdatedAt()
  21896. case tutorial.FieldDeletedAt:
  21897. return m.DeletedAt()
  21898. case tutorial.FieldEmployeeID:
  21899. return m.EmployeeID()
  21900. case tutorial.FieldIndex:
  21901. return m.Index()
  21902. case tutorial.FieldTitle:
  21903. return m.Title()
  21904. case tutorial.FieldContent:
  21905. return m.Content()
  21906. case tutorial.FieldOrganizationID:
  21907. return m.OrganizationID()
  21908. }
  21909. return nil, false
  21910. }
  21911. // OldField returns the old value of the field from the database. An error is
  21912. // returned if the mutation operation is not UpdateOne, or the query to the
  21913. // database failed.
  21914. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21915. switch name {
  21916. case tutorial.FieldCreatedAt:
  21917. return m.OldCreatedAt(ctx)
  21918. case tutorial.FieldUpdatedAt:
  21919. return m.OldUpdatedAt(ctx)
  21920. case tutorial.FieldDeletedAt:
  21921. return m.OldDeletedAt(ctx)
  21922. case tutorial.FieldEmployeeID:
  21923. return m.OldEmployeeID(ctx)
  21924. case tutorial.FieldIndex:
  21925. return m.OldIndex(ctx)
  21926. case tutorial.FieldTitle:
  21927. return m.OldTitle(ctx)
  21928. case tutorial.FieldContent:
  21929. return m.OldContent(ctx)
  21930. case tutorial.FieldOrganizationID:
  21931. return m.OldOrganizationID(ctx)
  21932. }
  21933. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  21934. }
  21935. // SetField sets the value of a field with the given name. It returns an error if
  21936. // the field is not defined in the schema, or if the type mismatched the field
  21937. // type.
  21938. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  21939. switch name {
  21940. case tutorial.FieldCreatedAt:
  21941. v, ok := value.(time.Time)
  21942. if !ok {
  21943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21944. }
  21945. m.SetCreatedAt(v)
  21946. return nil
  21947. case tutorial.FieldUpdatedAt:
  21948. v, ok := value.(time.Time)
  21949. if !ok {
  21950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21951. }
  21952. m.SetUpdatedAt(v)
  21953. return nil
  21954. case tutorial.FieldDeletedAt:
  21955. v, ok := value.(time.Time)
  21956. if !ok {
  21957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21958. }
  21959. m.SetDeletedAt(v)
  21960. return nil
  21961. case tutorial.FieldEmployeeID:
  21962. v, ok := value.(uint64)
  21963. if !ok {
  21964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21965. }
  21966. m.SetEmployeeID(v)
  21967. return nil
  21968. case tutorial.FieldIndex:
  21969. v, ok := value.(int)
  21970. if !ok {
  21971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21972. }
  21973. m.SetIndex(v)
  21974. return nil
  21975. case tutorial.FieldTitle:
  21976. v, ok := value.(string)
  21977. if !ok {
  21978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21979. }
  21980. m.SetTitle(v)
  21981. return nil
  21982. case tutorial.FieldContent:
  21983. v, ok := value.(string)
  21984. if !ok {
  21985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21986. }
  21987. m.SetContent(v)
  21988. return nil
  21989. case tutorial.FieldOrganizationID:
  21990. v, ok := value.(uint64)
  21991. if !ok {
  21992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21993. }
  21994. m.SetOrganizationID(v)
  21995. return nil
  21996. }
  21997. return fmt.Errorf("unknown Tutorial field %s", name)
  21998. }
  21999. // AddedFields returns all numeric fields that were incremented/decremented during
  22000. // this mutation.
  22001. func (m *TutorialMutation) AddedFields() []string {
  22002. var fields []string
  22003. if m.addindex != nil {
  22004. fields = append(fields, tutorial.FieldIndex)
  22005. }
  22006. if m.addorganization_id != nil {
  22007. fields = append(fields, tutorial.FieldOrganizationID)
  22008. }
  22009. return fields
  22010. }
  22011. // AddedField returns the numeric value that was incremented/decremented on a field
  22012. // with the given name. The second boolean return value indicates that this field
  22013. // was not set, or was not defined in the schema.
  22014. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22015. switch name {
  22016. case tutorial.FieldIndex:
  22017. return m.AddedIndex()
  22018. case tutorial.FieldOrganizationID:
  22019. return m.AddedOrganizationID()
  22020. }
  22021. return nil, false
  22022. }
  22023. // AddField adds the value to the field with the given name. It returns an error if
  22024. // the field is not defined in the schema, or if the type mismatched the field
  22025. // type.
  22026. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22027. switch name {
  22028. case tutorial.FieldIndex:
  22029. v, ok := value.(int)
  22030. if !ok {
  22031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22032. }
  22033. m.AddIndex(v)
  22034. return nil
  22035. case tutorial.FieldOrganizationID:
  22036. v, ok := value.(int64)
  22037. if !ok {
  22038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22039. }
  22040. m.AddOrganizationID(v)
  22041. return nil
  22042. }
  22043. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22044. }
  22045. // ClearedFields returns all nullable fields that were cleared during this
  22046. // mutation.
  22047. func (m *TutorialMutation) ClearedFields() []string {
  22048. var fields []string
  22049. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22050. fields = append(fields, tutorial.FieldDeletedAt)
  22051. }
  22052. return fields
  22053. }
  22054. // FieldCleared returns a boolean indicating if a field with the given name was
  22055. // cleared in this mutation.
  22056. func (m *TutorialMutation) FieldCleared(name string) bool {
  22057. _, ok := m.clearedFields[name]
  22058. return ok
  22059. }
  22060. // ClearField clears the value of the field with the given name. It returns an
  22061. // error if the field is not defined in the schema.
  22062. func (m *TutorialMutation) ClearField(name string) error {
  22063. switch name {
  22064. case tutorial.FieldDeletedAt:
  22065. m.ClearDeletedAt()
  22066. return nil
  22067. }
  22068. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22069. }
  22070. // ResetField resets all changes in the mutation for the field with the given name.
  22071. // It returns an error if the field is not defined in the schema.
  22072. func (m *TutorialMutation) ResetField(name string) error {
  22073. switch name {
  22074. case tutorial.FieldCreatedAt:
  22075. m.ResetCreatedAt()
  22076. return nil
  22077. case tutorial.FieldUpdatedAt:
  22078. m.ResetUpdatedAt()
  22079. return nil
  22080. case tutorial.FieldDeletedAt:
  22081. m.ResetDeletedAt()
  22082. return nil
  22083. case tutorial.FieldEmployeeID:
  22084. m.ResetEmployeeID()
  22085. return nil
  22086. case tutorial.FieldIndex:
  22087. m.ResetIndex()
  22088. return nil
  22089. case tutorial.FieldTitle:
  22090. m.ResetTitle()
  22091. return nil
  22092. case tutorial.FieldContent:
  22093. m.ResetContent()
  22094. return nil
  22095. case tutorial.FieldOrganizationID:
  22096. m.ResetOrganizationID()
  22097. return nil
  22098. }
  22099. return fmt.Errorf("unknown Tutorial field %s", name)
  22100. }
  22101. // AddedEdges returns all edge names that were set/added in this mutation.
  22102. func (m *TutorialMutation) AddedEdges() []string {
  22103. edges := make([]string, 0, 1)
  22104. if m.employee != nil {
  22105. edges = append(edges, tutorial.EdgeEmployee)
  22106. }
  22107. return edges
  22108. }
  22109. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22110. // name in this mutation.
  22111. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22112. switch name {
  22113. case tutorial.EdgeEmployee:
  22114. if id := m.employee; id != nil {
  22115. return []ent.Value{*id}
  22116. }
  22117. }
  22118. return nil
  22119. }
  22120. // RemovedEdges returns all edge names that were removed in this mutation.
  22121. func (m *TutorialMutation) RemovedEdges() []string {
  22122. edges := make([]string, 0, 1)
  22123. return edges
  22124. }
  22125. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22126. // the given name in this mutation.
  22127. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22128. return nil
  22129. }
  22130. // ClearedEdges returns all edge names that were cleared in this mutation.
  22131. func (m *TutorialMutation) ClearedEdges() []string {
  22132. edges := make([]string, 0, 1)
  22133. if m.clearedemployee {
  22134. edges = append(edges, tutorial.EdgeEmployee)
  22135. }
  22136. return edges
  22137. }
  22138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22139. // was cleared in this mutation.
  22140. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22141. switch name {
  22142. case tutorial.EdgeEmployee:
  22143. return m.clearedemployee
  22144. }
  22145. return false
  22146. }
  22147. // ClearEdge clears the value of the edge with the given name. It returns an error
  22148. // if that edge is not defined in the schema.
  22149. func (m *TutorialMutation) ClearEdge(name string) error {
  22150. switch name {
  22151. case tutorial.EdgeEmployee:
  22152. m.ClearEmployee()
  22153. return nil
  22154. }
  22155. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22156. }
  22157. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22158. // It returns an error if the edge is not defined in the schema.
  22159. func (m *TutorialMutation) ResetEdge(name string) error {
  22160. switch name {
  22161. case tutorial.EdgeEmployee:
  22162. m.ResetEmployee()
  22163. return nil
  22164. }
  22165. return fmt.Errorf("unknown Tutorial edge %s", name)
  22166. }
  22167. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  22168. type WorkExperienceMutation struct {
  22169. config
  22170. op Op
  22171. typ string
  22172. id *uint64
  22173. created_at *time.Time
  22174. updated_at *time.Time
  22175. deleted_at *time.Time
  22176. start_date *time.Time
  22177. end_date *time.Time
  22178. company *string
  22179. experience *string
  22180. organization_id *uint64
  22181. addorganization_id *int64
  22182. clearedFields map[string]struct{}
  22183. employee *uint64
  22184. clearedemployee bool
  22185. done bool
  22186. oldValue func(context.Context) (*WorkExperience, error)
  22187. predicates []predicate.WorkExperience
  22188. }
  22189. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  22190. // workexperienceOption allows management of the mutation configuration using functional options.
  22191. type workexperienceOption func(*WorkExperienceMutation)
  22192. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  22193. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  22194. m := &WorkExperienceMutation{
  22195. config: c,
  22196. op: op,
  22197. typ: TypeWorkExperience,
  22198. clearedFields: make(map[string]struct{}),
  22199. }
  22200. for _, opt := range opts {
  22201. opt(m)
  22202. }
  22203. return m
  22204. }
  22205. // withWorkExperienceID sets the ID field of the mutation.
  22206. func withWorkExperienceID(id uint64) workexperienceOption {
  22207. return func(m *WorkExperienceMutation) {
  22208. var (
  22209. err error
  22210. once sync.Once
  22211. value *WorkExperience
  22212. )
  22213. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  22214. once.Do(func() {
  22215. if m.done {
  22216. err = errors.New("querying old values post mutation is not allowed")
  22217. } else {
  22218. value, err = m.Client().WorkExperience.Get(ctx, id)
  22219. }
  22220. })
  22221. return value, err
  22222. }
  22223. m.id = &id
  22224. }
  22225. }
  22226. // withWorkExperience sets the old WorkExperience of the mutation.
  22227. func withWorkExperience(node *WorkExperience) workexperienceOption {
  22228. return func(m *WorkExperienceMutation) {
  22229. m.oldValue = func(context.Context) (*WorkExperience, error) {
  22230. return node, nil
  22231. }
  22232. m.id = &node.ID
  22233. }
  22234. }
  22235. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22236. // executed in a transaction (ent.Tx), a transactional client is returned.
  22237. func (m WorkExperienceMutation) Client() *Client {
  22238. client := &Client{config: m.config}
  22239. client.init()
  22240. return client
  22241. }
  22242. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22243. // it returns an error otherwise.
  22244. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  22245. if _, ok := m.driver.(*txDriver); !ok {
  22246. return nil, errors.New("ent: mutation is not running in a transaction")
  22247. }
  22248. tx := &Tx{config: m.config}
  22249. tx.init()
  22250. return tx, nil
  22251. }
  22252. // SetID sets the value of the id field. Note that this
  22253. // operation is only accepted on creation of WorkExperience entities.
  22254. func (m *WorkExperienceMutation) SetID(id uint64) {
  22255. m.id = &id
  22256. }
  22257. // ID returns the ID value in the mutation. Note that the ID is only available
  22258. // if it was provided to the builder or after it was returned from the database.
  22259. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  22260. if m.id == nil {
  22261. return
  22262. }
  22263. return *m.id, true
  22264. }
  22265. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22266. // That means, if the mutation is applied within a transaction with an isolation level such
  22267. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22268. // or updated by the mutation.
  22269. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  22270. switch {
  22271. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22272. id, exists := m.ID()
  22273. if exists {
  22274. return []uint64{id}, nil
  22275. }
  22276. fallthrough
  22277. case m.op.Is(OpUpdate | OpDelete):
  22278. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  22279. default:
  22280. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22281. }
  22282. }
  22283. // SetCreatedAt sets the "created_at" field.
  22284. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  22285. m.created_at = &t
  22286. }
  22287. // CreatedAt returns the value of the "created_at" field in the mutation.
  22288. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  22289. v := m.created_at
  22290. if v == nil {
  22291. return
  22292. }
  22293. return *v, true
  22294. }
  22295. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  22296. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22298. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22299. if !m.op.Is(OpUpdateOne) {
  22300. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22301. }
  22302. if m.id == nil || m.oldValue == nil {
  22303. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22304. }
  22305. oldValue, err := m.oldValue(ctx)
  22306. if err != nil {
  22307. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22308. }
  22309. return oldValue.CreatedAt, nil
  22310. }
  22311. // ResetCreatedAt resets all changes to the "created_at" field.
  22312. func (m *WorkExperienceMutation) ResetCreatedAt() {
  22313. m.created_at = nil
  22314. }
  22315. // SetUpdatedAt sets the "updated_at" field.
  22316. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  22317. m.updated_at = &t
  22318. }
  22319. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22320. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  22321. v := m.updated_at
  22322. if v == nil {
  22323. return
  22324. }
  22325. return *v, true
  22326. }
  22327. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  22328. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22330. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22331. if !m.op.Is(OpUpdateOne) {
  22332. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22333. }
  22334. if m.id == nil || m.oldValue == nil {
  22335. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22336. }
  22337. oldValue, err := m.oldValue(ctx)
  22338. if err != nil {
  22339. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22340. }
  22341. return oldValue.UpdatedAt, nil
  22342. }
  22343. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22344. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  22345. m.updated_at = nil
  22346. }
  22347. // SetDeletedAt sets the "deleted_at" field.
  22348. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  22349. m.deleted_at = &t
  22350. }
  22351. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22352. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  22353. v := m.deleted_at
  22354. if v == nil {
  22355. return
  22356. }
  22357. return *v, true
  22358. }
  22359. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  22360. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22362. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22363. if !m.op.Is(OpUpdateOne) {
  22364. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22365. }
  22366. if m.id == nil || m.oldValue == nil {
  22367. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22368. }
  22369. oldValue, err := m.oldValue(ctx)
  22370. if err != nil {
  22371. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22372. }
  22373. return oldValue.DeletedAt, nil
  22374. }
  22375. // ClearDeletedAt clears the value of the "deleted_at" field.
  22376. func (m *WorkExperienceMutation) ClearDeletedAt() {
  22377. m.deleted_at = nil
  22378. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  22379. }
  22380. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22381. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  22382. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  22383. return ok
  22384. }
  22385. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22386. func (m *WorkExperienceMutation) ResetDeletedAt() {
  22387. m.deleted_at = nil
  22388. delete(m.clearedFields, workexperience.FieldDeletedAt)
  22389. }
  22390. // SetEmployeeID sets the "employee_id" field.
  22391. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  22392. m.employee = &u
  22393. }
  22394. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22395. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  22396. v := m.employee
  22397. if v == nil {
  22398. return
  22399. }
  22400. return *v, true
  22401. }
  22402. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  22403. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22405. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22406. if !m.op.Is(OpUpdateOne) {
  22407. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22408. }
  22409. if m.id == nil || m.oldValue == nil {
  22410. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22411. }
  22412. oldValue, err := m.oldValue(ctx)
  22413. if err != nil {
  22414. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22415. }
  22416. return oldValue.EmployeeID, nil
  22417. }
  22418. // ResetEmployeeID resets all changes to the "employee_id" field.
  22419. func (m *WorkExperienceMutation) ResetEmployeeID() {
  22420. m.employee = nil
  22421. }
  22422. // SetStartDate sets the "start_date" field.
  22423. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  22424. m.start_date = &t
  22425. }
  22426. // StartDate returns the value of the "start_date" field in the mutation.
  22427. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  22428. v := m.start_date
  22429. if v == nil {
  22430. return
  22431. }
  22432. return *v, true
  22433. }
  22434. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  22435. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22437. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  22438. if !m.op.Is(OpUpdateOne) {
  22439. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  22440. }
  22441. if m.id == nil || m.oldValue == nil {
  22442. return v, errors.New("OldStartDate requires an ID field in the mutation")
  22443. }
  22444. oldValue, err := m.oldValue(ctx)
  22445. if err != nil {
  22446. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  22447. }
  22448. return oldValue.StartDate, nil
  22449. }
  22450. // ResetStartDate resets all changes to the "start_date" field.
  22451. func (m *WorkExperienceMutation) ResetStartDate() {
  22452. m.start_date = nil
  22453. }
  22454. // SetEndDate sets the "end_date" field.
  22455. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  22456. m.end_date = &t
  22457. }
  22458. // EndDate returns the value of the "end_date" field in the mutation.
  22459. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  22460. v := m.end_date
  22461. if v == nil {
  22462. return
  22463. }
  22464. return *v, true
  22465. }
  22466. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  22467. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22469. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  22470. if !m.op.Is(OpUpdateOne) {
  22471. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  22472. }
  22473. if m.id == nil || m.oldValue == nil {
  22474. return v, errors.New("OldEndDate requires an ID field in the mutation")
  22475. }
  22476. oldValue, err := m.oldValue(ctx)
  22477. if err != nil {
  22478. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  22479. }
  22480. return oldValue.EndDate, nil
  22481. }
  22482. // ResetEndDate resets all changes to the "end_date" field.
  22483. func (m *WorkExperienceMutation) ResetEndDate() {
  22484. m.end_date = nil
  22485. }
  22486. // SetCompany sets the "company" field.
  22487. func (m *WorkExperienceMutation) SetCompany(s string) {
  22488. m.company = &s
  22489. }
  22490. // Company returns the value of the "company" field in the mutation.
  22491. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  22492. v := m.company
  22493. if v == nil {
  22494. return
  22495. }
  22496. return *v, true
  22497. }
  22498. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  22499. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22501. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  22502. if !m.op.Is(OpUpdateOne) {
  22503. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  22504. }
  22505. if m.id == nil || m.oldValue == nil {
  22506. return v, errors.New("OldCompany requires an ID field in the mutation")
  22507. }
  22508. oldValue, err := m.oldValue(ctx)
  22509. if err != nil {
  22510. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  22511. }
  22512. return oldValue.Company, nil
  22513. }
  22514. // ResetCompany resets all changes to the "company" field.
  22515. func (m *WorkExperienceMutation) ResetCompany() {
  22516. m.company = nil
  22517. }
  22518. // SetExperience sets the "experience" field.
  22519. func (m *WorkExperienceMutation) SetExperience(s string) {
  22520. m.experience = &s
  22521. }
  22522. // Experience returns the value of the "experience" field in the mutation.
  22523. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  22524. v := m.experience
  22525. if v == nil {
  22526. return
  22527. }
  22528. return *v, true
  22529. }
  22530. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  22531. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22533. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  22534. if !m.op.Is(OpUpdateOne) {
  22535. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  22536. }
  22537. if m.id == nil || m.oldValue == nil {
  22538. return v, errors.New("OldExperience requires an ID field in the mutation")
  22539. }
  22540. oldValue, err := m.oldValue(ctx)
  22541. if err != nil {
  22542. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  22543. }
  22544. return oldValue.Experience, nil
  22545. }
  22546. // ResetExperience resets all changes to the "experience" field.
  22547. func (m *WorkExperienceMutation) ResetExperience() {
  22548. m.experience = nil
  22549. }
  22550. // SetOrganizationID sets the "organization_id" field.
  22551. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  22552. m.organization_id = &u
  22553. m.addorganization_id = nil
  22554. }
  22555. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22556. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  22557. v := m.organization_id
  22558. if v == nil {
  22559. return
  22560. }
  22561. return *v, true
  22562. }
  22563. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  22564. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22566. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22567. if !m.op.Is(OpUpdateOne) {
  22568. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22569. }
  22570. if m.id == nil || m.oldValue == nil {
  22571. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22572. }
  22573. oldValue, err := m.oldValue(ctx)
  22574. if err != nil {
  22575. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22576. }
  22577. return oldValue.OrganizationID, nil
  22578. }
  22579. // AddOrganizationID adds u to the "organization_id" field.
  22580. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  22581. if m.addorganization_id != nil {
  22582. *m.addorganization_id += u
  22583. } else {
  22584. m.addorganization_id = &u
  22585. }
  22586. }
  22587. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22588. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  22589. v := m.addorganization_id
  22590. if v == nil {
  22591. return
  22592. }
  22593. return *v, true
  22594. }
  22595. // ResetOrganizationID resets all changes to the "organization_id" field.
  22596. func (m *WorkExperienceMutation) ResetOrganizationID() {
  22597. m.organization_id = nil
  22598. m.addorganization_id = nil
  22599. }
  22600. // ClearEmployee clears the "employee" edge to the Employee entity.
  22601. func (m *WorkExperienceMutation) ClearEmployee() {
  22602. m.clearedemployee = true
  22603. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  22604. }
  22605. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22606. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  22607. return m.clearedemployee
  22608. }
  22609. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22610. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22611. // EmployeeID instead. It exists only for internal usage by the builders.
  22612. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  22613. if id := m.employee; id != nil {
  22614. ids = append(ids, *id)
  22615. }
  22616. return
  22617. }
  22618. // ResetEmployee resets all changes to the "employee" edge.
  22619. func (m *WorkExperienceMutation) ResetEmployee() {
  22620. m.employee = nil
  22621. m.clearedemployee = false
  22622. }
  22623. // Where appends a list predicates to the WorkExperienceMutation builder.
  22624. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  22625. m.predicates = append(m.predicates, ps...)
  22626. }
  22627. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  22628. // users can use type-assertion to append predicates that do not depend on any generated package.
  22629. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  22630. p := make([]predicate.WorkExperience, len(ps))
  22631. for i := range ps {
  22632. p[i] = ps[i]
  22633. }
  22634. m.Where(p...)
  22635. }
  22636. // Op returns the operation name.
  22637. func (m *WorkExperienceMutation) Op() Op {
  22638. return m.op
  22639. }
  22640. // SetOp allows setting the mutation operation.
  22641. func (m *WorkExperienceMutation) SetOp(op Op) {
  22642. m.op = op
  22643. }
  22644. // Type returns the node type of this mutation (WorkExperience).
  22645. func (m *WorkExperienceMutation) Type() string {
  22646. return m.typ
  22647. }
  22648. // Fields returns all fields that were changed during this mutation. Note that in
  22649. // order to get all numeric fields that were incremented/decremented, call
  22650. // AddedFields().
  22651. func (m *WorkExperienceMutation) Fields() []string {
  22652. fields := make([]string, 0, 9)
  22653. if m.created_at != nil {
  22654. fields = append(fields, workexperience.FieldCreatedAt)
  22655. }
  22656. if m.updated_at != nil {
  22657. fields = append(fields, workexperience.FieldUpdatedAt)
  22658. }
  22659. if m.deleted_at != nil {
  22660. fields = append(fields, workexperience.FieldDeletedAt)
  22661. }
  22662. if m.employee != nil {
  22663. fields = append(fields, workexperience.FieldEmployeeID)
  22664. }
  22665. if m.start_date != nil {
  22666. fields = append(fields, workexperience.FieldStartDate)
  22667. }
  22668. if m.end_date != nil {
  22669. fields = append(fields, workexperience.FieldEndDate)
  22670. }
  22671. if m.company != nil {
  22672. fields = append(fields, workexperience.FieldCompany)
  22673. }
  22674. if m.experience != nil {
  22675. fields = append(fields, workexperience.FieldExperience)
  22676. }
  22677. if m.organization_id != nil {
  22678. fields = append(fields, workexperience.FieldOrganizationID)
  22679. }
  22680. return fields
  22681. }
  22682. // Field returns the value of a field with the given name. The second boolean
  22683. // return value indicates that this field was not set, or was not defined in the
  22684. // schema.
  22685. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  22686. switch name {
  22687. case workexperience.FieldCreatedAt:
  22688. return m.CreatedAt()
  22689. case workexperience.FieldUpdatedAt:
  22690. return m.UpdatedAt()
  22691. case workexperience.FieldDeletedAt:
  22692. return m.DeletedAt()
  22693. case workexperience.FieldEmployeeID:
  22694. return m.EmployeeID()
  22695. case workexperience.FieldStartDate:
  22696. return m.StartDate()
  22697. case workexperience.FieldEndDate:
  22698. return m.EndDate()
  22699. case workexperience.FieldCompany:
  22700. return m.Company()
  22701. case workexperience.FieldExperience:
  22702. return m.Experience()
  22703. case workexperience.FieldOrganizationID:
  22704. return m.OrganizationID()
  22705. }
  22706. return nil, false
  22707. }
  22708. // OldField returns the old value of the field from the database. An error is
  22709. // returned if the mutation operation is not UpdateOne, or the query to the
  22710. // database failed.
  22711. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22712. switch name {
  22713. case workexperience.FieldCreatedAt:
  22714. return m.OldCreatedAt(ctx)
  22715. case workexperience.FieldUpdatedAt:
  22716. return m.OldUpdatedAt(ctx)
  22717. case workexperience.FieldDeletedAt:
  22718. return m.OldDeletedAt(ctx)
  22719. case workexperience.FieldEmployeeID:
  22720. return m.OldEmployeeID(ctx)
  22721. case workexperience.FieldStartDate:
  22722. return m.OldStartDate(ctx)
  22723. case workexperience.FieldEndDate:
  22724. return m.OldEndDate(ctx)
  22725. case workexperience.FieldCompany:
  22726. return m.OldCompany(ctx)
  22727. case workexperience.FieldExperience:
  22728. return m.OldExperience(ctx)
  22729. case workexperience.FieldOrganizationID:
  22730. return m.OldOrganizationID(ctx)
  22731. }
  22732. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  22733. }
  22734. // SetField sets the value of a field with the given name. It returns an error if
  22735. // the field is not defined in the schema, or if the type mismatched the field
  22736. // type.
  22737. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  22738. switch name {
  22739. case workexperience.FieldCreatedAt:
  22740. v, ok := value.(time.Time)
  22741. if !ok {
  22742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22743. }
  22744. m.SetCreatedAt(v)
  22745. return nil
  22746. case workexperience.FieldUpdatedAt:
  22747. v, ok := value.(time.Time)
  22748. if !ok {
  22749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22750. }
  22751. m.SetUpdatedAt(v)
  22752. return nil
  22753. case workexperience.FieldDeletedAt:
  22754. v, ok := value.(time.Time)
  22755. if !ok {
  22756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22757. }
  22758. m.SetDeletedAt(v)
  22759. return nil
  22760. case workexperience.FieldEmployeeID:
  22761. v, ok := value.(uint64)
  22762. if !ok {
  22763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22764. }
  22765. m.SetEmployeeID(v)
  22766. return nil
  22767. case workexperience.FieldStartDate:
  22768. v, ok := value.(time.Time)
  22769. if !ok {
  22770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22771. }
  22772. m.SetStartDate(v)
  22773. return nil
  22774. case workexperience.FieldEndDate:
  22775. v, ok := value.(time.Time)
  22776. if !ok {
  22777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22778. }
  22779. m.SetEndDate(v)
  22780. return nil
  22781. case workexperience.FieldCompany:
  22782. v, ok := value.(string)
  22783. if !ok {
  22784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22785. }
  22786. m.SetCompany(v)
  22787. return nil
  22788. case workexperience.FieldExperience:
  22789. v, ok := value.(string)
  22790. if !ok {
  22791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22792. }
  22793. m.SetExperience(v)
  22794. return nil
  22795. case workexperience.FieldOrganizationID:
  22796. v, ok := value.(uint64)
  22797. if !ok {
  22798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22799. }
  22800. m.SetOrganizationID(v)
  22801. return nil
  22802. }
  22803. return fmt.Errorf("unknown WorkExperience field %s", name)
  22804. }
  22805. // AddedFields returns all numeric fields that were incremented/decremented during
  22806. // this mutation.
  22807. func (m *WorkExperienceMutation) AddedFields() []string {
  22808. var fields []string
  22809. if m.addorganization_id != nil {
  22810. fields = append(fields, workexperience.FieldOrganizationID)
  22811. }
  22812. return fields
  22813. }
  22814. // AddedField returns the numeric value that was incremented/decremented on a field
  22815. // with the given name. The second boolean return value indicates that this field
  22816. // was not set, or was not defined in the schema.
  22817. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  22818. switch name {
  22819. case workexperience.FieldOrganizationID:
  22820. return m.AddedOrganizationID()
  22821. }
  22822. return nil, false
  22823. }
  22824. // AddField adds the value to the field with the given name. It returns an error if
  22825. // the field is not defined in the schema, or if the type mismatched the field
  22826. // type.
  22827. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  22828. switch name {
  22829. case workexperience.FieldOrganizationID:
  22830. v, ok := value.(int64)
  22831. if !ok {
  22832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22833. }
  22834. m.AddOrganizationID(v)
  22835. return nil
  22836. }
  22837. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  22838. }
  22839. // ClearedFields returns all nullable fields that were cleared during this
  22840. // mutation.
  22841. func (m *WorkExperienceMutation) ClearedFields() []string {
  22842. var fields []string
  22843. if m.FieldCleared(workexperience.FieldDeletedAt) {
  22844. fields = append(fields, workexperience.FieldDeletedAt)
  22845. }
  22846. return fields
  22847. }
  22848. // FieldCleared returns a boolean indicating if a field with the given name was
  22849. // cleared in this mutation.
  22850. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  22851. _, ok := m.clearedFields[name]
  22852. return ok
  22853. }
  22854. // ClearField clears the value of the field with the given name. It returns an
  22855. // error if the field is not defined in the schema.
  22856. func (m *WorkExperienceMutation) ClearField(name string) error {
  22857. switch name {
  22858. case workexperience.FieldDeletedAt:
  22859. m.ClearDeletedAt()
  22860. return nil
  22861. }
  22862. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  22863. }
  22864. // ResetField resets all changes in the mutation for the field with the given name.
  22865. // It returns an error if the field is not defined in the schema.
  22866. func (m *WorkExperienceMutation) ResetField(name string) error {
  22867. switch name {
  22868. case workexperience.FieldCreatedAt:
  22869. m.ResetCreatedAt()
  22870. return nil
  22871. case workexperience.FieldUpdatedAt:
  22872. m.ResetUpdatedAt()
  22873. return nil
  22874. case workexperience.FieldDeletedAt:
  22875. m.ResetDeletedAt()
  22876. return nil
  22877. case workexperience.FieldEmployeeID:
  22878. m.ResetEmployeeID()
  22879. return nil
  22880. case workexperience.FieldStartDate:
  22881. m.ResetStartDate()
  22882. return nil
  22883. case workexperience.FieldEndDate:
  22884. m.ResetEndDate()
  22885. return nil
  22886. case workexperience.FieldCompany:
  22887. m.ResetCompany()
  22888. return nil
  22889. case workexperience.FieldExperience:
  22890. m.ResetExperience()
  22891. return nil
  22892. case workexperience.FieldOrganizationID:
  22893. m.ResetOrganizationID()
  22894. return nil
  22895. }
  22896. return fmt.Errorf("unknown WorkExperience field %s", name)
  22897. }
  22898. // AddedEdges returns all edge names that were set/added in this mutation.
  22899. func (m *WorkExperienceMutation) AddedEdges() []string {
  22900. edges := make([]string, 0, 1)
  22901. if m.employee != nil {
  22902. edges = append(edges, workexperience.EdgeEmployee)
  22903. }
  22904. return edges
  22905. }
  22906. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22907. // name in this mutation.
  22908. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  22909. switch name {
  22910. case workexperience.EdgeEmployee:
  22911. if id := m.employee; id != nil {
  22912. return []ent.Value{*id}
  22913. }
  22914. }
  22915. return nil
  22916. }
  22917. // RemovedEdges returns all edge names that were removed in this mutation.
  22918. func (m *WorkExperienceMutation) RemovedEdges() []string {
  22919. edges := make([]string, 0, 1)
  22920. return edges
  22921. }
  22922. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22923. // the given name in this mutation.
  22924. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  22925. return nil
  22926. }
  22927. // ClearedEdges returns all edge names that were cleared in this mutation.
  22928. func (m *WorkExperienceMutation) ClearedEdges() []string {
  22929. edges := make([]string, 0, 1)
  22930. if m.clearedemployee {
  22931. edges = append(edges, workexperience.EdgeEmployee)
  22932. }
  22933. return edges
  22934. }
  22935. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22936. // was cleared in this mutation.
  22937. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  22938. switch name {
  22939. case workexperience.EdgeEmployee:
  22940. return m.clearedemployee
  22941. }
  22942. return false
  22943. }
  22944. // ClearEdge clears the value of the edge with the given name. It returns an error
  22945. // if that edge is not defined in the schema.
  22946. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  22947. switch name {
  22948. case workexperience.EdgeEmployee:
  22949. m.ClearEmployee()
  22950. return nil
  22951. }
  22952. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  22953. }
  22954. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22955. // It returns an error if the edge is not defined in the schema.
  22956. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  22957. switch name {
  22958. case workexperience.EdgeEmployee:
  22959. m.ResetEmployee()
  22960. return nil
  22961. }
  22962. return fmt.Errorf("unknown WorkExperience edge %s", name)
  22963. }
  22964. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  22965. type WxMutation struct {
  22966. config
  22967. op Op
  22968. typ string
  22969. id *uint64
  22970. created_at *time.Time
  22971. updated_at *time.Time
  22972. status *uint8
  22973. addstatus *int8
  22974. deleted_at *time.Time
  22975. port *string
  22976. process_id *string
  22977. callback *string
  22978. wxid *string
  22979. account *string
  22980. nickname *string
  22981. tel *string
  22982. head_big *string
  22983. organization_id *uint64
  22984. addorganization_id *int64
  22985. api_base *string
  22986. api_key *string
  22987. allow_list *[]string
  22988. appendallow_list []string
  22989. group_allow_list *[]string
  22990. appendgroup_allow_list []string
  22991. block_list *[]string
  22992. appendblock_list []string
  22993. group_block_list *[]string
  22994. appendgroup_block_list []string
  22995. clearedFields map[string]struct{}
  22996. server *uint64
  22997. clearedserver bool
  22998. agent *uint64
  22999. clearedagent bool
  23000. done bool
  23001. oldValue func(context.Context) (*Wx, error)
  23002. predicates []predicate.Wx
  23003. }
  23004. var _ ent.Mutation = (*WxMutation)(nil)
  23005. // wxOption allows management of the mutation configuration using functional options.
  23006. type wxOption func(*WxMutation)
  23007. // newWxMutation creates new mutation for the Wx entity.
  23008. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  23009. m := &WxMutation{
  23010. config: c,
  23011. op: op,
  23012. typ: TypeWx,
  23013. clearedFields: make(map[string]struct{}),
  23014. }
  23015. for _, opt := range opts {
  23016. opt(m)
  23017. }
  23018. return m
  23019. }
  23020. // withWxID sets the ID field of the mutation.
  23021. func withWxID(id uint64) wxOption {
  23022. return func(m *WxMutation) {
  23023. var (
  23024. err error
  23025. once sync.Once
  23026. value *Wx
  23027. )
  23028. m.oldValue = func(ctx context.Context) (*Wx, error) {
  23029. once.Do(func() {
  23030. if m.done {
  23031. err = errors.New("querying old values post mutation is not allowed")
  23032. } else {
  23033. value, err = m.Client().Wx.Get(ctx, id)
  23034. }
  23035. })
  23036. return value, err
  23037. }
  23038. m.id = &id
  23039. }
  23040. }
  23041. // withWx sets the old Wx of the mutation.
  23042. func withWx(node *Wx) wxOption {
  23043. return func(m *WxMutation) {
  23044. m.oldValue = func(context.Context) (*Wx, error) {
  23045. return node, nil
  23046. }
  23047. m.id = &node.ID
  23048. }
  23049. }
  23050. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23051. // executed in a transaction (ent.Tx), a transactional client is returned.
  23052. func (m WxMutation) Client() *Client {
  23053. client := &Client{config: m.config}
  23054. client.init()
  23055. return client
  23056. }
  23057. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23058. // it returns an error otherwise.
  23059. func (m WxMutation) Tx() (*Tx, error) {
  23060. if _, ok := m.driver.(*txDriver); !ok {
  23061. return nil, errors.New("ent: mutation is not running in a transaction")
  23062. }
  23063. tx := &Tx{config: m.config}
  23064. tx.init()
  23065. return tx, nil
  23066. }
  23067. // SetID sets the value of the id field. Note that this
  23068. // operation is only accepted on creation of Wx entities.
  23069. func (m *WxMutation) SetID(id uint64) {
  23070. m.id = &id
  23071. }
  23072. // ID returns the ID value in the mutation. Note that the ID is only available
  23073. // if it was provided to the builder or after it was returned from the database.
  23074. func (m *WxMutation) ID() (id uint64, exists bool) {
  23075. if m.id == nil {
  23076. return
  23077. }
  23078. return *m.id, true
  23079. }
  23080. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23081. // That means, if the mutation is applied within a transaction with an isolation level such
  23082. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23083. // or updated by the mutation.
  23084. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  23085. switch {
  23086. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23087. id, exists := m.ID()
  23088. if exists {
  23089. return []uint64{id}, nil
  23090. }
  23091. fallthrough
  23092. case m.op.Is(OpUpdate | OpDelete):
  23093. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  23094. default:
  23095. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23096. }
  23097. }
  23098. // SetCreatedAt sets the "created_at" field.
  23099. func (m *WxMutation) SetCreatedAt(t time.Time) {
  23100. m.created_at = &t
  23101. }
  23102. // CreatedAt returns the value of the "created_at" field in the mutation.
  23103. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  23104. v := m.created_at
  23105. if v == nil {
  23106. return
  23107. }
  23108. return *v, true
  23109. }
  23110. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  23111. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23113. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23114. if !m.op.Is(OpUpdateOne) {
  23115. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23116. }
  23117. if m.id == nil || m.oldValue == nil {
  23118. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23119. }
  23120. oldValue, err := m.oldValue(ctx)
  23121. if err != nil {
  23122. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23123. }
  23124. return oldValue.CreatedAt, nil
  23125. }
  23126. // ResetCreatedAt resets all changes to the "created_at" field.
  23127. func (m *WxMutation) ResetCreatedAt() {
  23128. m.created_at = nil
  23129. }
  23130. // SetUpdatedAt sets the "updated_at" field.
  23131. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  23132. m.updated_at = &t
  23133. }
  23134. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23135. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  23136. v := m.updated_at
  23137. if v == nil {
  23138. return
  23139. }
  23140. return *v, true
  23141. }
  23142. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  23143. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23145. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23146. if !m.op.Is(OpUpdateOne) {
  23147. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23148. }
  23149. if m.id == nil || m.oldValue == nil {
  23150. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23151. }
  23152. oldValue, err := m.oldValue(ctx)
  23153. if err != nil {
  23154. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23155. }
  23156. return oldValue.UpdatedAt, nil
  23157. }
  23158. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23159. func (m *WxMutation) ResetUpdatedAt() {
  23160. m.updated_at = nil
  23161. }
  23162. // SetStatus sets the "status" field.
  23163. func (m *WxMutation) SetStatus(u uint8) {
  23164. m.status = &u
  23165. m.addstatus = nil
  23166. }
  23167. // Status returns the value of the "status" field in the mutation.
  23168. func (m *WxMutation) Status() (r uint8, exists bool) {
  23169. v := m.status
  23170. if v == nil {
  23171. return
  23172. }
  23173. return *v, true
  23174. }
  23175. // OldStatus returns the old "status" field's value of the Wx entity.
  23176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23178. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23179. if !m.op.Is(OpUpdateOne) {
  23180. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23181. }
  23182. if m.id == nil || m.oldValue == nil {
  23183. return v, errors.New("OldStatus requires an ID field in the mutation")
  23184. }
  23185. oldValue, err := m.oldValue(ctx)
  23186. if err != nil {
  23187. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23188. }
  23189. return oldValue.Status, nil
  23190. }
  23191. // AddStatus adds u to the "status" field.
  23192. func (m *WxMutation) AddStatus(u int8) {
  23193. if m.addstatus != nil {
  23194. *m.addstatus += u
  23195. } else {
  23196. m.addstatus = &u
  23197. }
  23198. }
  23199. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23200. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  23201. v := m.addstatus
  23202. if v == nil {
  23203. return
  23204. }
  23205. return *v, true
  23206. }
  23207. // ClearStatus clears the value of the "status" field.
  23208. func (m *WxMutation) ClearStatus() {
  23209. m.status = nil
  23210. m.addstatus = nil
  23211. m.clearedFields[wx.FieldStatus] = struct{}{}
  23212. }
  23213. // StatusCleared returns if the "status" field was cleared in this mutation.
  23214. func (m *WxMutation) StatusCleared() bool {
  23215. _, ok := m.clearedFields[wx.FieldStatus]
  23216. return ok
  23217. }
  23218. // ResetStatus resets all changes to the "status" field.
  23219. func (m *WxMutation) ResetStatus() {
  23220. m.status = nil
  23221. m.addstatus = nil
  23222. delete(m.clearedFields, wx.FieldStatus)
  23223. }
  23224. // SetDeletedAt sets the "deleted_at" field.
  23225. func (m *WxMutation) SetDeletedAt(t time.Time) {
  23226. m.deleted_at = &t
  23227. }
  23228. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23229. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  23230. v := m.deleted_at
  23231. if v == nil {
  23232. return
  23233. }
  23234. return *v, true
  23235. }
  23236. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  23237. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23239. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23240. if !m.op.Is(OpUpdateOne) {
  23241. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23242. }
  23243. if m.id == nil || m.oldValue == nil {
  23244. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23245. }
  23246. oldValue, err := m.oldValue(ctx)
  23247. if err != nil {
  23248. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23249. }
  23250. return oldValue.DeletedAt, nil
  23251. }
  23252. // ClearDeletedAt clears the value of the "deleted_at" field.
  23253. func (m *WxMutation) ClearDeletedAt() {
  23254. m.deleted_at = nil
  23255. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  23256. }
  23257. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23258. func (m *WxMutation) DeletedAtCleared() bool {
  23259. _, ok := m.clearedFields[wx.FieldDeletedAt]
  23260. return ok
  23261. }
  23262. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23263. func (m *WxMutation) ResetDeletedAt() {
  23264. m.deleted_at = nil
  23265. delete(m.clearedFields, wx.FieldDeletedAt)
  23266. }
  23267. // SetServerID sets the "server_id" field.
  23268. func (m *WxMutation) SetServerID(u uint64) {
  23269. m.server = &u
  23270. }
  23271. // ServerID returns the value of the "server_id" field in the mutation.
  23272. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  23273. v := m.server
  23274. if v == nil {
  23275. return
  23276. }
  23277. return *v, true
  23278. }
  23279. // OldServerID returns the old "server_id" field's value of the Wx entity.
  23280. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23282. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  23283. if !m.op.Is(OpUpdateOne) {
  23284. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  23285. }
  23286. if m.id == nil || m.oldValue == nil {
  23287. return v, errors.New("OldServerID requires an ID field in the mutation")
  23288. }
  23289. oldValue, err := m.oldValue(ctx)
  23290. if err != nil {
  23291. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  23292. }
  23293. return oldValue.ServerID, nil
  23294. }
  23295. // ClearServerID clears the value of the "server_id" field.
  23296. func (m *WxMutation) ClearServerID() {
  23297. m.server = nil
  23298. m.clearedFields[wx.FieldServerID] = struct{}{}
  23299. }
  23300. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  23301. func (m *WxMutation) ServerIDCleared() bool {
  23302. _, ok := m.clearedFields[wx.FieldServerID]
  23303. return ok
  23304. }
  23305. // ResetServerID resets all changes to the "server_id" field.
  23306. func (m *WxMutation) ResetServerID() {
  23307. m.server = nil
  23308. delete(m.clearedFields, wx.FieldServerID)
  23309. }
  23310. // SetPort sets the "port" field.
  23311. func (m *WxMutation) SetPort(s string) {
  23312. m.port = &s
  23313. }
  23314. // Port returns the value of the "port" field in the mutation.
  23315. func (m *WxMutation) Port() (r string, exists bool) {
  23316. v := m.port
  23317. if v == nil {
  23318. return
  23319. }
  23320. return *v, true
  23321. }
  23322. // OldPort returns the old "port" field's value of the Wx entity.
  23323. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23325. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  23326. if !m.op.Is(OpUpdateOne) {
  23327. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  23328. }
  23329. if m.id == nil || m.oldValue == nil {
  23330. return v, errors.New("OldPort requires an ID field in the mutation")
  23331. }
  23332. oldValue, err := m.oldValue(ctx)
  23333. if err != nil {
  23334. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  23335. }
  23336. return oldValue.Port, nil
  23337. }
  23338. // ResetPort resets all changes to the "port" field.
  23339. func (m *WxMutation) ResetPort() {
  23340. m.port = nil
  23341. }
  23342. // SetProcessID sets the "process_id" field.
  23343. func (m *WxMutation) SetProcessID(s string) {
  23344. m.process_id = &s
  23345. }
  23346. // ProcessID returns the value of the "process_id" field in the mutation.
  23347. func (m *WxMutation) ProcessID() (r string, exists bool) {
  23348. v := m.process_id
  23349. if v == nil {
  23350. return
  23351. }
  23352. return *v, true
  23353. }
  23354. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  23355. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23357. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  23358. if !m.op.Is(OpUpdateOne) {
  23359. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  23360. }
  23361. if m.id == nil || m.oldValue == nil {
  23362. return v, errors.New("OldProcessID requires an ID field in the mutation")
  23363. }
  23364. oldValue, err := m.oldValue(ctx)
  23365. if err != nil {
  23366. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  23367. }
  23368. return oldValue.ProcessID, nil
  23369. }
  23370. // ResetProcessID resets all changes to the "process_id" field.
  23371. func (m *WxMutation) ResetProcessID() {
  23372. m.process_id = nil
  23373. }
  23374. // SetCallback sets the "callback" field.
  23375. func (m *WxMutation) SetCallback(s string) {
  23376. m.callback = &s
  23377. }
  23378. // Callback returns the value of the "callback" field in the mutation.
  23379. func (m *WxMutation) Callback() (r string, exists bool) {
  23380. v := m.callback
  23381. if v == nil {
  23382. return
  23383. }
  23384. return *v, true
  23385. }
  23386. // OldCallback returns the old "callback" field's value of the Wx entity.
  23387. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23389. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  23390. if !m.op.Is(OpUpdateOne) {
  23391. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  23392. }
  23393. if m.id == nil || m.oldValue == nil {
  23394. return v, errors.New("OldCallback requires an ID field in the mutation")
  23395. }
  23396. oldValue, err := m.oldValue(ctx)
  23397. if err != nil {
  23398. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  23399. }
  23400. return oldValue.Callback, nil
  23401. }
  23402. // ResetCallback resets all changes to the "callback" field.
  23403. func (m *WxMutation) ResetCallback() {
  23404. m.callback = nil
  23405. }
  23406. // SetWxid sets the "wxid" field.
  23407. func (m *WxMutation) SetWxid(s string) {
  23408. m.wxid = &s
  23409. }
  23410. // Wxid returns the value of the "wxid" field in the mutation.
  23411. func (m *WxMutation) Wxid() (r string, exists bool) {
  23412. v := m.wxid
  23413. if v == nil {
  23414. return
  23415. }
  23416. return *v, true
  23417. }
  23418. // OldWxid returns the old "wxid" field's value of the Wx entity.
  23419. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23421. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  23422. if !m.op.Is(OpUpdateOne) {
  23423. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23424. }
  23425. if m.id == nil || m.oldValue == nil {
  23426. return v, errors.New("OldWxid requires an ID field in the mutation")
  23427. }
  23428. oldValue, err := m.oldValue(ctx)
  23429. if err != nil {
  23430. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23431. }
  23432. return oldValue.Wxid, nil
  23433. }
  23434. // ResetWxid resets all changes to the "wxid" field.
  23435. func (m *WxMutation) ResetWxid() {
  23436. m.wxid = nil
  23437. }
  23438. // SetAccount sets the "account" field.
  23439. func (m *WxMutation) SetAccount(s string) {
  23440. m.account = &s
  23441. }
  23442. // Account returns the value of the "account" field in the mutation.
  23443. func (m *WxMutation) Account() (r string, exists bool) {
  23444. v := m.account
  23445. if v == nil {
  23446. return
  23447. }
  23448. return *v, true
  23449. }
  23450. // OldAccount returns the old "account" field's value of the Wx entity.
  23451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23453. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  23454. if !m.op.Is(OpUpdateOne) {
  23455. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  23456. }
  23457. if m.id == nil || m.oldValue == nil {
  23458. return v, errors.New("OldAccount requires an ID field in the mutation")
  23459. }
  23460. oldValue, err := m.oldValue(ctx)
  23461. if err != nil {
  23462. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  23463. }
  23464. return oldValue.Account, nil
  23465. }
  23466. // ResetAccount resets all changes to the "account" field.
  23467. func (m *WxMutation) ResetAccount() {
  23468. m.account = nil
  23469. }
  23470. // SetNickname sets the "nickname" field.
  23471. func (m *WxMutation) SetNickname(s string) {
  23472. m.nickname = &s
  23473. }
  23474. // Nickname returns the value of the "nickname" field in the mutation.
  23475. func (m *WxMutation) Nickname() (r string, exists bool) {
  23476. v := m.nickname
  23477. if v == nil {
  23478. return
  23479. }
  23480. return *v, true
  23481. }
  23482. // OldNickname returns the old "nickname" field's value of the Wx entity.
  23483. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23485. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  23486. if !m.op.Is(OpUpdateOne) {
  23487. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  23488. }
  23489. if m.id == nil || m.oldValue == nil {
  23490. return v, errors.New("OldNickname requires an ID field in the mutation")
  23491. }
  23492. oldValue, err := m.oldValue(ctx)
  23493. if err != nil {
  23494. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  23495. }
  23496. return oldValue.Nickname, nil
  23497. }
  23498. // ResetNickname resets all changes to the "nickname" field.
  23499. func (m *WxMutation) ResetNickname() {
  23500. m.nickname = nil
  23501. }
  23502. // SetTel sets the "tel" field.
  23503. func (m *WxMutation) SetTel(s string) {
  23504. m.tel = &s
  23505. }
  23506. // Tel returns the value of the "tel" field in the mutation.
  23507. func (m *WxMutation) Tel() (r string, exists bool) {
  23508. v := m.tel
  23509. if v == nil {
  23510. return
  23511. }
  23512. return *v, true
  23513. }
  23514. // OldTel returns the old "tel" field's value of the Wx entity.
  23515. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23517. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  23518. if !m.op.Is(OpUpdateOne) {
  23519. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  23520. }
  23521. if m.id == nil || m.oldValue == nil {
  23522. return v, errors.New("OldTel requires an ID field in the mutation")
  23523. }
  23524. oldValue, err := m.oldValue(ctx)
  23525. if err != nil {
  23526. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  23527. }
  23528. return oldValue.Tel, nil
  23529. }
  23530. // ResetTel resets all changes to the "tel" field.
  23531. func (m *WxMutation) ResetTel() {
  23532. m.tel = nil
  23533. }
  23534. // SetHeadBig sets the "head_big" field.
  23535. func (m *WxMutation) SetHeadBig(s string) {
  23536. m.head_big = &s
  23537. }
  23538. // HeadBig returns the value of the "head_big" field in the mutation.
  23539. func (m *WxMutation) HeadBig() (r string, exists bool) {
  23540. v := m.head_big
  23541. if v == nil {
  23542. return
  23543. }
  23544. return *v, true
  23545. }
  23546. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  23547. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23549. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  23550. if !m.op.Is(OpUpdateOne) {
  23551. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  23552. }
  23553. if m.id == nil || m.oldValue == nil {
  23554. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  23555. }
  23556. oldValue, err := m.oldValue(ctx)
  23557. if err != nil {
  23558. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  23559. }
  23560. return oldValue.HeadBig, nil
  23561. }
  23562. // ResetHeadBig resets all changes to the "head_big" field.
  23563. func (m *WxMutation) ResetHeadBig() {
  23564. m.head_big = nil
  23565. }
  23566. // SetOrganizationID sets the "organization_id" field.
  23567. func (m *WxMutation) SetOrganizationID(u uint64) {
  23568. m.organization_id = &u
  23569. m.addorganization_id = nil
  23570. }
  23571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23572. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  23573. v := m.organization_id
  23574. if v == nil {
  23575. return
  23576. }
  23577. return *v, true
  23578. }
  23579. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  23580. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23582. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23583. if !m.op.Is(OpUpdateOne) {
  23584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23585. }
  23586. if m.id == nil || m.oldValue == nil {
  23587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23588. }
  23589. oldValue, err := m.oldValue(ctx)
  23590. if err != nil {
  23591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23592. }
  23593. return oldValue.OrganizationID, nil
  23594. }
  23595. // AddOrganizationID adds u to the "organization_id" field.
  23596. func (m *WxMutation) AddOrganizationID(u int64) {
  23597. if m.addorganization_id != nil {
  23598. *m.addorganization_id += u
  23599. } else {
  23600. m.addorganization_id = &u
  23601. }
  23602. }
  23603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23604. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  23605. v := m.addorganization_id
  23606. if v == nil {
  23607. return
  23608. }
  23609. return *v, true
  23610. }
  23611. // ClearOrganizationID clears the value of the "organization_id" field.
  23612. func (m *WxMutation) ClearOrganizationID() {
  23613. m.organization_id = nil
  23614. m.addorganization_id = nil
  23615. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  23616. }
  23617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23618. func (m *WxMutation) OrganizationIDCleared() bool {
  23619. _, ok := m.clearedFields[wx.FieldOrganizationID]
  23620. return ok
  23621. }
  23622. // ResetOrganizationID resets all changes to the "organization_id" field.
  23623. func (m *WxMutation) ResetOrganizationID() {
  23624. m.organization_id = nil
  23625. m.addorganization_id = nil
  23626. delete(m.clearedFields, wx.FieldOrganizationID)
  23627. }
  23628. // SetAgentID sets the "agent_id" field.
  23629. func (m *WxMutation) SetAgentID(u uint64) {
  23630. m.agent = &u
  23631. }
  23632. // AgentID returns the value of the "agent_id" field in the mutation.
  23633. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  23634. v := m.agent
  23635. if v == nil {
  23636. return
  23637. }
  23638. return *v, true
  23639. }
  23640. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  23641. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23643. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  23644. if !m.op.Is(OpUpdateOne) {
  23645. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  23646. }
  23647. if m.id == nil || m.oldValue == nil {
  23648. return v, errors.New("OldAgentID requires an ID field in the mutation")
  23649. }
  23650. oldValue, err := m.oldValue(ctx)
  23651. if err != nil {
  23652. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  23653. }
  23654. return oldValue.AgentID, nil
  23655. }
  23656. // ResetAgentID resets all changes to the "agent_id" field.
  23657. func (m *WxMutation) ResetAgentID() {
  23658. m.agent = nil
  23659. }
  23660. // SetAPIBase sets the "api_base" field.
  23661. func (m *WxMutation) SetAPIBase(s string) {
  23662. m.api_base = &s
  23663. }
  23664. // APIBase returns the value of the "api_base" field in the mutation.
  23665. func (m *WxMutation) APIBase() (r string, exists bool) {
  23666. v := m.api_base
  23667. if v == nil {
  23668. return
  23669. }
  23670. return *v, true
  23671. }
  23672. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  23673. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23675. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23676. if !m.op.Is(OpUpdateOne) {
  23677. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23678. }
  23679. if m.id == nil || m.oldValue == nil {
  23680. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23681. }
  23682. oldValue, err := m.oldValue(ctx)
  23683. if err != nil {
  23684. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23685. }
  23686. return oldValue.APIBase, nil
  23687. }
  23688. // ClearAPIBase clears the value of the "api_base" field.
  23689. func (m *WxMutation) ClearAPIBase() {
  23690. m.api_base = nil
  23691. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  23692. }
  23693. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23694. func (m *WxMutation) APIBaseCleared() bool {
  23695. _, ok := m.clearedFields[wx.FieldAPIBase]
  23696. return ok
  23697. }
  23698. // ResetAPIBase resets all changes to the "api_base" field.
  23699. func (m *WxMutation) ResetAPIBase() {
  23700. m.api_base = nil
  23701. delete(m.clearedFields, wx.FieldAPIBase)
  23702. }
  23703. // SetAPIKey sets the "api_key" field.
  23704. func (m *WxMutation) SetAPIKey(s string) {
  23705. m.api_key = &s
  23706. }
  23707. // APIKey returns the value of the "api_key" field in the mutation.
  23708. func (m *WxMutation) APIKey() (r string, exists bool) {
  23709. v := m.api_key
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  23716. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23728. }
  23729. return oldValue.APIKey, nil
  23730. }
  23731. // ClearAPIKey clears the value of the "api_key" field.
  23732. func (m *WxMutation) ClearAPIKey() {
  23733. m.api_key = nil
  23734. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  23735. }
  23736. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23737. func (m *WxMutation) APIKeyCleared() bool {
  23738. _, ok := m.clearedFields[wx.FieldAPIKey]
  23739. return ok
  23740. }
  23741. // ResetAPIKey resets all changes to the "api_key" field.
  23742. func (m *WxMutation) ResetAPIKey() {
  23743. m.api_key = nil
  23744. delete(m.clearedFields, wx.FieldAPIKey)
  23745. }
  23746. // SetAllowList sets the "allow_list" field.
  23747. func (m *WxMutation) SetAllowList(s []string) {
  23748. m.allow_list = &s
  23749. m.appendallow_list = nil
  23750. }
  23751. // AllowList returns the value of the "allow_list" field in the mutation.
  23752. func (m *WxMutation) AllowList() (r []string, exists bool) {
  23753. v := m.allow_list
  23754. if v == nil {
  23755. return
  23756. }
  23757. return *v, true
  23758. }
  23759. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  23760. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23762. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  23763. if !m.op.Is(OpUpdateOne) {
  23764. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  23765. }
  23766. if m.id == nil || m.oldValue == nil {
  23767. return v, errors.New("OldAllowList requires an ID field in the mutation")
  23768. }
  23769. oldValue, err := m.oldValue(ctx)
  23770. if err != nil {
  23771. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  23772. }
  23773. return oldValue.AllowList, nil
  23774. }
  23775. // AppendAllowList adds s to the "allow_list" field.
  23776. func (m *WxMutation) AppendAllowList(s []string) {
  23777. m.appendallow_list = append(m.appendallow_list, s...)
  23778. }
  23779. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  23780. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  23781. if len(m.appendallow_list) == 0 {
  23782. return nil, false
  23783. }
  23784. return m.appendallow_list, true
  23785. }
  23786. // ResetAllowList resets all changes to the "allow_list" field.
  23787. func (m *WxMutation) ResetAllowList() {
  23788. m.allow_list = nil
  23789. m.appendallow_list = nil
  23790. }
  23791. // SetGroupAllowList sets the "group_allow_list" field.
  23792. func (m *WxMutation) SetGroupAllowList(s []string) {
  23793. m.group_allow_list = &s
  23794. m.appendgroup_allow_list = nil
  23795. }
  23796. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  23797. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  23798. v := m.group_allow_list
  23799. if v == nil {
  23800. return
  23801. }
  23802. return *v, true
  23803. }
  23804. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  23805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23807. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  23808. if !m.op.Is(OpUpdateOne) {
  23809. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  23810. }
  23811. if m.id == nil || m.oldValue == nil {
  23812. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  23813. }
  23814. oldValue, err := m.oldValue(ctx)
  23815. if err != nil {
  23816. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  23817. }
  23818. return oldValue.GroupAllowList, nil
  23819. }
  23820. // AppendGroupAllowList adds s to the "group_allow_list" field.
  23821. func (m *WxMutation) AppendGroupAllowList(s []string) {
  23822. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  23823. }
  23824. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  23825. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  23826. if len(m.appendgroup_allow_list) == 0 {
  23827. return nil, false
  23828. }
  23829. return m.appendgroup_allow_list, true
  23830. }
  23831. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  23832. func (m *WxMutation) ResetGroupAllowList() {
  23833. m.group_allow_list = nil
  23834. m.appendgroup_allow_list = nil
  23835. }
  23836. // SetBlockList sets the "block_list" field.
  23837. func (m *WxMutation) SetBlockList(s []string) {
  23838. m.block_list = &s
  23839. m.appendblock_list = nil
  23840. }
  23841. // BlockList returns the value of the "block_list" field in the mutation.
  23842. func (m *WxMutation) BlockList() (r []string, exists bool) {
  23843. v := m.block_list
  23844. if v == nil {
  23845. return
  23846. }
  23847. return *v, true
  23848. }
  23849. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  23850. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23852. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  23853. if !m.op.Is(OpUpdateOne) {
  23854. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  23855. }
  23856. if m.id == nil || m.oldValue == nil {
  23857. return v, errors.New("OldBlockList requires an ID field in the mutation")
  23858. }
  23859. oldValue, err := m.oldValue(ctx)
  23860. if err != nil {
  23861. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  23862. }
  23863. return oldValue.BlockList, nil
  23864. }
  23865. // AppendBlockList adds s to the "block_list" field.
  23866. func (m *WxMutation) AppendBlockList(s []string) {
  23867. m.appendblock_list = append(m.appendblock_list, s...)
  23868. }
  23869. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  23870. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  23871. if len(m.appendblock_list) == 0 {
  23872. return nil, false
  23873. }
  23874. return m.appendblock_list, true
  23875. }
  23876. // ResetBlockList resets all changes to the "block_list" field.
  23877. func (m *WxMutation) ResetBlockList() {
  23878. m.block_list = nil
  23879. m.appendblock_list = nil
  23880. }
  23881. // SetGroupBlockList sets the "group_block_list" field.
  23882. func (m *WxMutation) SetGroupBlockList(s []string) {
  23883. m.group_block_list = &s
  23884. m.appendgroup_block_list = nil
  23885. }
  23886. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  23887. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  23888. v := m.group_block_list
  23889. if v == nil {
  23890. return
  23891. }
  23892. return *v, true
  23893. }
  23894. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  23895. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23897. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  23898. if !m.op.Is(OpUpdateOne) {
  23899. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  23900. }
  23901. if m.id == nil || m.oldValue == nil {
  23902. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  23903. }
  23904. oldValue, err := m.oldValue(ctx)
  23905. if err != nil {
  23906. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  23907. }
  23908. return oldValue.GroupBlockList, nil
  23909. }
  23910. // AppendGroupBlockList adds s to the "group_block_list" field.
  23911. func (m *WxMutation) AppendGroupBlockList(s []string) {
  23912. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  23913. }
  23914. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  23915. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  23916. if len(m.appendgroup_block_list) == 0 {
  23917. return nil, false
  23918. }
  23919. return m.appendgroup_block_list, true
  23920. }
  23921. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  23922. func (m *WxMutation) ResetGroupBlockList() {
  23923. m.group_block_list = nil
  23924. m.appendgroup_block_list = nil
  23925. }
  23926. // ClearServer clears the "server" edge to the Server entity.
  23927. func (m *WxMutation) ClearServer() {
  23928. m.clearedserver = true
  23929. m.clearedFields[wx.FieldServerID] = struct{}{}
  23930. }
  23931. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  23932. func (m *WxMutation) ServerCleared() bool {
  23933. return m.ServerIDCleared() || m.clearedserver
  23934. }
  23935. // ServerIDs returns the "server" edge IDs in the mutation.
  23936. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23937. // ServerID instead. It exists only for internal usage by the builders.
  23938. func (m *WxMutation) ServerIDs() (ids []uint64) {
  23939. if id := m.server; id != nil {
  23940. ids = append(ids, *id)
  23941. }
  23942. return
  23943. }
  23944. // ResetServer resets all changes to the "server" edge.
  23945. func (m *WxMutation) ResetServer() {
  23946. m.server = nil
  23947. m.clearedserver = false
  23948. }
  23949. // ClearAgent clears the "agent" edge to the Agent entity.
  23950. func (m *WxMutation) ClearAgent() {
  23951. m.clearedagent = true
  23952. m.clearedFields[wx.FieldAgentID] = struct{}{}
  23953. }
  23954. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  23955. func (m *WxMutation) AgentCleared() bool {
  23956. return m.clearedagent
  23957. }
  23958. // AgentIDs returns the "agent" edge IDs in the mutation.
  23959. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23960. // AgentID instead. It exists only for internal usage by the builders.
  23961. func (m *WxMutation) AgentIDs() (ids []uint64) {
  23962. if id := m.agent; id != nil {
  23963. ids = append(ids, *id)
  23964. }
  23965. return
  23966. }
  23967. // ResetAgent resets all changes to the "agent" edge.
  23968. func (m *WxMutation) ResetAgent() {
  23969. m.agent = nil
  23970. m.clearedagent = false
  23971. }
  23972. // Where appends a list predicates to the WxMutation builder.
  23973. func (m *WxMutation) Where(ps ...predicate.Wx) {
  23974. m.predicates = append(m.predicates, ps...)
  23975. }
  23976. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  23977. // users can use type-assertion to append predicates that do not depend on any generated package.
  23978. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  23979. p := make([]predicate.Wx, len(ps))
  23980. for i := range ps {
  23981. p[i] = ps[i]
  23982. }
  23983. m.Where(p...)
  23984. }
  23985. // Op returns the operation name.
  23986. func (m *WxMutation) Op() Op {
  23987. return m.op
  23988. }
  23989. // SetOp allows setting the mutation operation.
  23990. func (m *WxMutation) SetOp(op Op) {
  23991. m.op = op
  23992. }
  23993. // Type returns the node type of this mutation (Wx).
  23994. func (m *WxMutation) Type() string {
  23995. return m.typ
  23996. }
  23997. // Fields returns all fields that were changed during this mutation. Note that in
  23998. // order to get all numeric fields that were incremented/decremented, call
  23999. // AddedFields().
  24000. func (m *WxMutation) Fields() []string {
  24001. fields := make([]string, 0, 21)
  24002. if m.created_at != nil {
  24003. fields = append(fields, wx.FieldCreatedAt)
  24004. }
  24005. if m.updated_at != nil {
  24006. fields = append(fields, wx.FieldUpdatedAt)
  24007. }
  24008. if m.status != nil {
  24009. fields = append(fields, wx.FieldStatus)
  24010. }
  24011. if m.deleted_at != nil {
  24012. fields = append(fields, wx.FieldDeletedAt)
  24013. }
  24014. if m.server != nil {
  24015. fields = append(fields, wx.FieldServerID)
  24016. }
  24017. if m.port != nil {
  24018. fields = append(fields, wx.FieldPort)
  24019. }
  24020. if m.process_id != nil {
  24021. fields = append(fields, wx.FieldProcessID)
  24022. }
  24023. if m.callback != nil {
  24024. fields = append(fields, wx.FieldCallback)
  24025. }
  24026. if m.wxid != nil {
  24027. fields = append(fields, wx.FieldWxid)
  24028. }
  24029. if m.account != nil {
  24030. fields = append(fields, wx.FieldAccount)
  24031. }
  24032. if m.nickname != nil {
  24033. fields = append(fields, wx.FieldNickname)
  24034. }
  24035. if m.tel != nil {
  24036. fields = append(fields, wx.FieldTel)
  24037. }
  24038. if m.head_big != nil {
  24039. fields = append(fields, wx.FieldHeadBig)
  24040. }
  24041. if m.organization_id != nil {
  24042. fields = append(fields, wx.FieldOrganizationID)
  24043. }
  24044. if m.agent != nil {
  24045. fields = append(fields, wx.FieldAgentID)
  24046. }
  24047. if m.api_base != nil {
  24048. fields = append(fields, wx.FieldAPIBase)
  24049. }
  24050. if m.api_key != nil {
  24051. fields = append(fields, wx.FieldAPIKey)
  24052. }
  24053. if m.allow_list != nil {
  24054. fields = append(fields, wx.FieldAllowList)
  24055. }
  24056. if m.group_allow_list != nil {
  24057. fields = append(fields, wx.FieldGroupAllowList)
  24058. }
  24059. if m.block_list != nil {
  24060. fields = append(fields, wx.FieldBlockList)
  24061. }
  24062. if m.group_block_list != nil {
  24063. fields = append(fields, wx.FieldGroupBlockList)
  24064. }
  24065. return fields
  24066. }
  24067. // Field returns the value of a field with the given name. The second boolean
  24068. // return value indicates that this field was not set, or was not defined in the
  24069. // schema.
  24070. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  24071. switch name {
  24072. case wx.FieldCreatedAt:
  24073. return m.CreatedAt()
  24074. case wx.FieldUpdatedAt:
  24075. return m.UpdatedAt()
  24076. case wx.FieldStatus:
  24077. return m.Status()
  24078. case wx.FieldDeletedAt:
  24079. return m.DeletedAt()
  24080. case wx.FieldServerID:
  24081. return m.ServerID()
  24082. case wx.FieldPort:
  24083. return m.Port()
  24084. case wx.FieldProcessID:
  24085. return m.ProcessID()
  24086. case wx.FieldCallback:
  24087. return m.Callback()
  24088. case wx.FieldWxid:
  24089. return m.Wxid()
  24090. case wx.FieldAccount:
  24091. return m.Account()
  24092. case wx.FieldNickname:
  24093. return m.Nickname()
  24094. case wx.FieldTel:
  24095. return m.Tel()
  24096. case wx.FieldHeadBig:
  24097. return m.HeadBig()
  24098. case wx.FieldOrganizationID:
  24099. return m.OrganizationID()
  24100. case wx.FieldAgentID:
  24101. return m.AgentID()
  24102. case wx.FieldAPIBase:
  24103. return m.APIBase()
  24104. case wx.FieldAPIKey:
  24105. return m.APIKey()
  24106. case wx.FieldAllowList:
  24107. return m.AllowList()
  24108. case wx.FieldGroupAllowList:
  24109. return m.GroupAllowList()
  24110. case wx.FieldBlockList:
  24111. return m.BlockList()
  24112. case wx.FieldGroupBlockList:
  24113. return m.GroupBlockList()
  24114. }
  24115. return nil, false
  24116. }
  24117. // OldField returns the old value of the field from the database. An error is
  24118. // returned if the mutation operation is not UpdateOne, or the query to the
  24119. // database failed.
  24120. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24121. switch name {
  24122. case wx.FieldCreatedAt:
  24123. return m.OldCreatedAt(ctx)
  24124. case wx.FieldUpdatedAt:
  24125. return m.OldUpdatedAt(ctx)
  24126. case wx.FieldStatus:
  24127. return m.OldStatus(ctx)
  24128. case wx.FieldDeletedAt:
  24129. return m.OldDeletedAt(ctx)
  24130. case wx.FieldServerID:
  24131. return m.OldServerID(ctx)
  24132. case wx.FieldPort:
  24133. return m.OldPort(ctx)
  24134. case wx.FieldProcessID:
  24135. return m.OldProcessID(ctx)
  24136. case wx.FieldCallback:
  24137. return m.OldCallback(ctx)
  24138. case wx.FieldWxid:
  24139. return m.OldWxid(ctx)
  24140. case wx.FieldAccount:
  24141. return m.OldAccount(ctx)
  24142. case wx.FieldNickname:
  24143. return m.OldNickname(ctx)
  24144. case wx.FieldTel:
  24145. return m.OldTel(ctx)
  24146. case wx.FieldHeadBig:
  24147. return m.OldHeadBig(ctx)
  24148. case wx.FieldOrganizationID:
  24149. return m.OldOrganizationID(ctx)
  24150. case wx.FieldAgentID:
  24151. return m.OldAgentID(ctx)
  24152. case wx.FieldAPIBase:
  24153. return m.OldAPIBase(ctx)
  24154. case wx.FieldAPIKey:
  24155. return m.OldAPIKey(ctx)
  24156. case wx.FieldAllowList:
  24157. return m.OldAllowList(ctx)
  24158. case wx.FieldGroupAllowList:
  24159. return m.OldGroupAllowList(ctx)
  24160. case wx.FieldBlockList:
  24161. return m.OldBlockList(ctx)
  24162. case wx.FieldGroupBlockList:
  24163. return m.OldGroupBlockList(ctx)
  24164. }
  24165. return nil, fmt.Errorf("unknown Wx field %s", name)
  24166. }
  24167. // SetField sets the value of a field with the given name. It returns an error if
  24168. // the field is not defined in the schema, or if the type mismatched the field
  24169. // type.
  24170. func (m *WxMutation) SetField(name string, value ent.Value) error {
  24171. switch name {
  24172. case wx.FieldCreatedAt:
  24173. v, ok := value.(time.Time)
  24174. if !ok {
  24175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24176. }
  24177. m.SetCreatedAt(v)
  24178. return nil
  24179. case wx.FieldUpdatedAt:
  24180. v, ok := value.(time.Time)
  24181. if !ok {
  24182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24183. }
  24184. m.SetUpdatedAt(v)
  24185. return nil
  24186. case wx.FieldStatus:
  24187. v, ok := value.(uint8)
  24188. if !ok {
  24189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24190. }
  24191. m.SetStatus(v)
  24192. return nil
  24193. case wx.FieldDeletedAt:
  24194. v, ok := value.(time.Time)
  24195. if !ok {
  24196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24197. }
  24198. m.SetDeletedAt(v)
  24199. return nil
  24200. case wx.FieldServerID:
  24201. v, ok := value.(uint64)
  24202. if !ok {
  24203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24204. }
  24205. m.SetServerID(v)
  24206. return nil
  24207. case wx.FieldPort:
  24208. v, ok := value.(string)
  24209. if !ok {
  24210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24211. }
  24212. m.SetPort(v)
  24213. return nil
  24214. case wx.FieldProcessID:
  24215. v, ok := value.(string)
  24216. if !ok {
  24217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24218. }
  24219. m.SetProcessID(v)
  24220. return nil
  24221. case wx.FieldCallback:
  24222. v, ok := value.(string)
  24223. if !ok {
  24224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24225. }
  24226. m.SetCallback(v)
  24227. return nil
  24228. case wx.FieldWxid:
  24229. v, ok := value.(string)
  24230. if !ok {
  24231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24232. }
  24233. m.SetWxid(v)
  24234. return nil
  24235. case wx.FieldAccount:
  24236. v, ok := value.(string)
  24237. if !ok {
  24238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24239. }
  24240. m.SetAccount(v)
  24241. return nil
  24242. case wx.FieldNickname:
  24243. v, ok := value.(string)
  24244. if !ok {
  24245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24246. }
  24247. m.SetNickname(v)
  24248. return nil
  24249. case wx.FieldTel:
  24250. v, ok := value.(string)
  24251. if !ok {
  24252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24253. }
  24254. m.SetTel(v)
  24255. return nil
  24256. case wx.FieldHeadBig:
  24257. v, ok := value.(string)
  24258. if !ok {
  24259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24260. }
  24261. m.SetHeadBig(v)
  24262. return nil
  24263. case wx.FieldOrganizationID:
  24264. v, ok := value.(uint64)
  24265. if !ok {
  24266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24267. }
  24268. m.SetOrganizationID(v)
  24269. return nil
  24270. case wx.FieldAgentID:
  24271. v, ok := value.(uint64)
  24272. if !ok {
  24273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24274. }
  24275. m.SetAgentID(v)
  24276. return nil
  24277. case wx.FieldAPIBase:
  24278. v, ok := value.(string)
  24279. if !ok {
  24280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24281. }
  24282. m.SetAPIBase(v)
  24283. return nil
  24284. case wx.FieldAPIKey:
  24285. v, ok := value.(string)
  24286. if !ok {
  24287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24288. }
  24289. m.SetAPIKey(v)
  24290. return nil
  24291. case wx.FieldAllowList:
  24292. v, ok := value.([]string)
  24293. if !ok {
  24294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24295. }
  24296. m.SetAllowList(v)
  24297. return nil
  24298. case wx.FieldGroupAllowList:
  24299. v, ok := value.([]string)
  24300. if !ok {
  24301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24302. }
  24303. m.SetGroupAllowList(v)
  24304. return nil
  24305. case wx.FieldBlockList:
  24306. v, ok := value.([]string)
  24307. if !ok {
  24308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24309. }
  24310. m.SetBlockList(v)
  24311. return nil
  24312. case wx.FieldGroupBlockList:
  24313. v, ok := value.([]string)
  24314. if !ok {
  24315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24316. }
  24317. m.SetGroupBlockList(v)
  24318. return nil
  24319. }
  24320. return fmt.Errorf("unknown Wx field %s", name)
  24321. }
  24322. // AddedFields returns all numeric fields that were incremented/decremented during
  24323. // this mutation.
  24324. func (m *WxMutation) AddedFields() []string {
  24325. var fields []string
  24326. if m.addstatus != nil {
  24327. fields = append(fields, wx.FieldStatus)
  24328. }
  24329. if m.addorganization_id != nil {
  24330. fields = append(fields, wx.FieldOrganizationID)
  24331. }
  24332. return fields
  24333. }
  24334. // AddedField returns the numeric value that was incremented/decremented on a field
  24335. // with the given name. The second boolean return value indicates that this field
  24336. // was not set, or was not defined in the schema.
  24337. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  24338. switch name {
  24339. case wx.FieldStatus:
  24340. return m.AddedStatus()
  24341. case wx.FieldOrganizationID:
  24342. return m.AddedOrganizationID()
  24343. }
  24344. return nil, false
  24345. }
  24346. // AddField adds the value to the field with the given name. It returns an error if
  24347. // the field is not defined in the schema, or if the type mismatched the field
  24348. // type.
  24349. func (m *WxMutation) AddField(name string, value ent.Value) error {
  24350. switch name {
  24351. case wx.FieldStatus:
  24352. v, ok := value.(int8)
  24353. if !ok {
  24354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24355. }
  24356. m.AddStatus(v)
  24357. return nil
  24358. case wx.FieldOrganizationID:
  24359. v, ok := value.(int64)
  24360. if !ok {
  24361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24362. }
  24363. m.AddOrganizationID(v)
  24364. return nil
  24365. }
  24366. return fmt.Errorf("unknown Wx numeric field %s", name)
  24367. }
  24368. // ClearedFields returns all nullable fields that were cleared during this
  24369. // mutation.
  24370. func (m *WxMutation) ClearedFields() []string {
  24371. var fields []string
  24372. if m.FieldCleared(wx.FieldStatus) {
  24373. fields = append(fields, wx.FieldStatus)
  24374. }
  24375. if m.FieldCleared(wx.FieldDeletedAt) {
  24376. fields = append(fields, wx.FieldDeletedAt)
  24377. }
  24378. if m.FieldCleared(wx.FieldServerID) {
  24379. fields = append(fields, wx.FieldServerID)
  24380. }
  24381. if m.FieldCleared(wx.FieldOrganizationID) {
  24382. fields = append(fields, wx.FieldOrganizationID)
  24383. }
  24384. if m.FieldCleared(wx.FieldAPIBase) {
  24385. fields = append(fields, wx.FieldAPIBase)
  24386. }
  24387. if m.FieldCleared(wx.FieldAPIKey) {
  24388. fields = append(fields, wx.FieldAPIKey)
  24389. }
  24390. return fields
  24391. }
  24392. // FieldCleared returns a boolean indicating if a field with the given name was
  24393. // cleared in this mutation.
  24394. func (m *WxMutation) FieldCleared(name string) bool {
  24395. _, ok := m.clearedFields[name]
  24396. return ok
  24397. }
  24398. // ClearField clears the value of the field with the given name. It returns an
  24399. // error if the field is not defined in the schema.
  24400. func (m *WxMutation) ClearField(name string) error {
  24401. switch name {
  24402. case wx.FieldStatus:
  24403. m.ClearStatus()
  24404. return nil
  24405. case wx.FieldDeletedAt:
  24406. m.ClearDeletedAt()
  24407. return nil
  24408. case wx.FieldServerID:
  24409. m.ClearServerID()
  24410. return nil
  24411. case wx.FieldOrganizationID:
  24412. m.ClearOrganizationID()
  24413. return nil
  24414. case wx.FieldAPIBase:
  24415. m.ClearAPIBase()
  24416. return nil
  24417. case wx.FieldAPIKey:
  24418. m.ClearAPIKey()
  24419. return nil
  24420. }
  24421. return fmt.Errorf("unknown Wx nullable field %s", name)
  24422. }
  24423. // ResetField resets all changes in the mutation for the field with the given name.
  24424. // It returns an error if the field is not defined in the schema.
  24425. func (m *WxMutation) ResetField(name string) error {
  24426. switch name {
  24427. case wx.FieldCreatedAt:
  24428. m.ResetCreatedAt()
  24429. return nil
  24430. case wx.FieldUpdatedAt:
  24431. m.ResetUpdatedAt()
  24432. return nil
  24433. case wx.FieldStatus:
  24434. m.ResetStatus()
  24435. return nil
  24436. case wx.FieldDeletedAt:
  24437. m.ResetDeletedAt()
  24438. return nil
  24439. case wx.FieldServerID:
  24440. m.ResetServerID()
  24441. return nil
  24442. case wx.FieldPort:
  24443. m.ResetPort()
  24444. return nil
  24445. case wx.FieldProcessID:
  24446. m.ResetProcessID()
  24447. return nil
  24448. case wx.FieldCallback:
  24449. m.ResetCallback()
  24450. return nil
  24451. case wx.FieldWxid:
  24452. m.ResetWxid()
  24453. return nil
  24454. case wx.FieldAccount:
  24455. m.ResetAccount()
  24456. return nil
  24457. case wx.FieldNickname:
  24458. m.ResetNickname()
  24459. return nil
  24460. case wx.FieldTel:
  24461. m.ResetTel()
  24462. return nil
  24463. case wx.FieldHeadBig:
  24464. m.ResetHeadBig()
  24465. return nil
  24466. case wx.FieldOrganizationID:
  24467. m.ResetOrganizationID()
  24468. return nil
  24469. case wx.FieldAgentID:
  24470. m.ResetAgentID()
  24471. return nil
  24472. case wx.FieldAPIBase:
  24473. m.ResetAPIBase()
  24474. return nil
  24475. case wx.FieldAPIKey:
  24476. m.ResetAPIKey()
  24477. return nil
  24478. case wx.FieldAllowList:
  24479. m.ResetAllowList()
  24480. return nil
  24481. case wx.FieldGroupAllowList:
  24482. m.ResetGroupAllowList()
  24483. return nil
  24484. case wx.FieldBlockList:
  24485. m.ResetBlockList()
  24486. return nil
  24487. case wx.FieldGroupBlockList:
  24488. m.ResetGroupBlockList()
  24489. return nil
  24490. }
  24491. return fmt.Errorf("unknown Wx field %s", name)
  24492. }
  24493. // AddedEdges returns all edge names that were set/added in this mutation.
  24494. func (m *WxMutation) AddedEdges() []string {
  24495. edges := make([]string, 0, 2)
  24496. if m.server != nil {
  24497. edges = append(edges, wx.EdgeServer)
  24498. }
  24499. if m.agent != nil {
  24500. edges = append(edges, wx.EdgeAgent)
  24501. }
  24502. return edges
  24503. }
  24504. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24505. // name in this mutation.
  24506. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  24507. switch name {
  24508. case wx.EdgeServer:
  24509. if id := m.server; id != nil {
  24510. return []ent.Value{*id}
  24511. }
  24512. case wx.EdgeAgent:
  24513. if id := m.agent; id != nil {
  24514. return []ent.Value{*id}
  24515. }
  24516. }
  24517. return nil
  24518. }
  24519. // RemovedEdges returns all edge names that were removed in this mutation.
  24520. func (m *WxMutation) RemovedEdges() []string {
  24521. edges := make([]string, 0, 2)
  24522. return edges
  24523. }
  24524. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24525. // the given name in this mutation.
  24526. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  24527. return nil
  24528. }
  24529. // ClearedEdges returns all edge names that were cleared in this mutation.
  24530. func (m *WxMutation) ClearedEdges() []string {
  24531. edges := make([]string, 0, 2)
  24532. if m.clearedserver {
  24533. edges = append(edges, wx.EdgeServer)
  24534. }
  24535. if m.clearedagent {
  24536. edges = append(edges, wx.EdgeAgent)
  24537. }
  24538. return edges
  24539. }
  24540. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24541. // was cleared in this mutation.
  24542. func (m *WxMutation) EdgeCleared(name string) bool {
  24543. switch name {
  24544. case wx.EdgeServer:
  24545. return m.clearedserver
  24546. case wx.EdgeAgent:
  24547. return m.clearedagent
  24548. }
  24549. return false
  24550. }
  24551. // ClearEdge clears the value of the edge with the given name. It returns an error
  24552. // if that edge is not defined in the schema.
  24553. func (m *WxMutation) ClearEdge(name string) error {
  24554. switch name {
  24555. case wx.EdgeServer:
  24556. m.ClearServer()
  24557. return nil
  24558. case wx.EdgeAgent:
  24559. m.ClearAgent()
  24560. return nil
  24561. }
  24562. return fmt.Errorf("unknown Wx unique edge %s", name)
  24563. }
  24564. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24565. // It returns an error if the edge is not defined in the schema.
  24566. func (m *WxMutation) ResetEdge(name string) error {
  24567. switch name {
  24568. case wx.EdgeServer:
  24569. m.ResetServer()
  24570. return nil
  24571. case wx.EdgeAgent:
  24572. m.ResetAgent()
  24573. return nil
  24574. }
  24575. return fmt.Errorf("unknown Wx edge %s", name)
  24576. }
  24577. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  24578. type WxCardMutation struct {
  24579. config
  24580. op Op
  24581. typ string
  24582. id *uint64
  24583. created_at *time.Time
  24584. updated_at *time.Time
  24585. deleted_at *time.Time
  24586. user_id *uint64
  24587. adduser_id *int64
  24588. wx_user_id *uint64
  24589. addwx_user_id *int64
  24590. avatar *string
  24591. logo *string
  24592. name *string
  24593. company *string
  24594. address *string
  24595. phone *string
  24596. official_account *string
  24597. wechat_account *string
  24598. email *string
  24599. api_base *string
  24600. api_key *string
  24601. ai_info *string
  24602. intro *string
  24603. clearedFields map[string]struct{}
  24604. done bool
  24605. oldValue func(context.Context) (*WxCard, error)
  24606. predicates []predicate.WxCard
  24607. }
  24608. var _ ent.Mutation = (*WxCardMutation)(nil)
  24609. // wxcardOption allows management of the mutation configuration using functional options.
  24610. type wxcardOption func(*WxCardMutation)
  24611. // newWxCardMutation creates new mutation for the WxCard entity.
  24612. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  24613. m := &WxCardMutation{
  24614. config: c,
  24615. op: op,
  24616. typ: TypeWxCard,
  24617. clearedFields: make(map[string]struct{}),
  24618. }
  24619. for _, opt := range opts {
  24620. opt(m)
  24621. }
  24622. return m
  24623. }
  24624. // withWxCardID sets the ID field of the mutation.
  24625. func withWxCardID(id uint64) wxcardOption {
  24626. return func(m *WxCardMutation) {
  24627. var (
  24628. err error
  24629. once sync.Once
  24630. value *WxCard
  24631. )
  24632. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  24633. once.Do(func() {
  24634. if m.done {
  24635. err = errors.New("querying old values post mutation is not allowed")
  24636. } else {
  24637. value, err = m.Client().WxCard.Get(ctx, id)
  24638. }
  24639. })
  24640. return value, err
  24641. }
  24642. m.id = &id
  24643. }
  24644. }
  24645. // withWxCard sets the old WxCard of the mutation.
  24646. func withWxCard(node *WxCard) wxcardOption {
  24647. return func(m *WxCardMutation) {
  24648. m.oldValue = func(context.Context) (*WxCard, error) {
  24649. return node, nil
  24650. }
  24651. m.id = &node.ID
  24652. }
  24653. }
  24654. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24655. // executed in a transaction (ent.Tx), a transactional client is returned.
  24656. func (m WxCardMutation) Client() *Client {
  24657. client := &Client{config: m.config}
  24658. client.init()
  24659. return client
  24660. }
  24661. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24662. // it returns an error otherwise.
  24663. func (m WxCardMutation) Tx() (*Tx, error) {
  24664. if _, ok := m.driver.(*txDriver); !ok {
  24665. return nil, errors.New("ent: mutation is not running in a transaction")
  24666. }
  24667. tx := &Tx{config: m.config}
  24668. tx.init()
  24669. return tx, nil
  24670. }
  24671. // SetID sets the value of the id field. Note that this
  24672. // operation is only accepted on creation of WxCard entities.
  24673. func (m *WxCardMutation) SetID(id uint64) {
  24674. m.id = &id
  24675. }
  24676. // ID returns the ID value in the mutation. Note that the ID is only available
  24677. // if it was provided to the builder or after it was returned from the database.
  24678. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  24679. if m.id == nil {
  24680. return
  24681. }
  24682. return *m.id, true
  24683. }
  24684. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24685. // That means, if the mutation is applied within a transaction with an isolation level such
  24686. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24687. // or updated by the mutation.
  24688. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  24689. switch {
  24690. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24691. id, exists := m.ID()
  24692. if exists {
  24693. return []uint64{id}, nil
  24694. }
  24695. fallthrough
  24696. case m.op.Is(OpUpdate | OpDelete):
  24697. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  24698. default:
  24699. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24700. }
  24701. }
  24702. // SetCreatedAt sets the "created_at" field.
  24703. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  24704. m.created_at = &t
  24705. }
  24706. // CreatedAt returns the value of the "created_at" field in the mutation.
  24707. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  24708. v := m.created_at
  24709. if v == nil {
  24710. return
  24711. }
  24712. return *v, true
  24713. }
  24714. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  24715. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24717. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24718. if !m.op.Is(OpUpdateOne) {
  24719. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24720. }
  24721. if m.id == nil || m.oldValue == nil {
  24722. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24723. }
  24724. oldValue, err := m.oldValue(ctx)
  24725. if err != nil {
  24726. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24727. }
  24728. return oldValue.CreatedAt, nil
  24729. }
  24730. // ResetCreatedAt resets all changes to the "created_at" field.
  24731. func (m *WxCardMutation) ResetCreatedAt() {
  24732. m.created_at = nil
  24733. }
  24734. // SetUpdatedAt sets the "updated_at" field.
  24735. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  24736. m.updated_at = &t
  24737. }
  24738. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24739. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  24740. v := m.updated_at
  24741. if v == nil {
  24742. return
  24743. }
  24744. return *v, true
  24745. }
  24746. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  24747. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24749. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24750. if !m.op.Is(OpUpdateOne) {
  24751. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24752. }
  24753. if m.id == nil || m.oldValue == nil {
  24754. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24755. }
  24756. oldValue, err := m.oldValue(ctx)
  24757. if err != nil {
  24758. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24759. }
  24760. return oldValue.UpdatedAt, nil
  24761. }
  24762. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24763. func (m *WxCardMutation) ResetUpdatedAt() {
  24764. m.updated_at = nil
  24765. }
  24766. // SetDeletedAt sets the "deleted_at" field.
  24767. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  24768. m.deleted_at = &t
  24769. }
  24770. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24771. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  24772. v := m.deleted_at
  24773. if v == nil {
  24774. return
  24775. }
  24776. return *v, true
  24777. }
  24778. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  24779. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24781. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24782. if !m.op.Is(OpUpdateOne) {
  24783. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24784. }
  24785. if m.id == nil || m.oldValue == nil {
  24786. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24787. }
  24788. oldValue, err := m.oldValue(ctx)
  24789. if err != nil {
  24790. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24791. }
  24792. return oldValue.DeletedAt, nil
  24793. }
  24794. // ClearDeletedAt clears the value of the "deleted_at" field.
  24795. func (m *WxCardMutation) ClearDeletedAt() {
  24796. m.deleted_at = nil
  24797. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  24798. }
  24799. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24800. func (m *WxCardMutation) DeletedAtCleared() bool {
  24801. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  24802. return ok
  24803. }
  24804. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24805. func (m *WxCardMutation) ResetDeletedAt() {
  24806. m.deleted_at = nil
  24807. delete(m.clearedFields, wxcard.FieldDeletedAt)
  24808. }
  24809. // SetUserID sets the "user_id" field.
  24810. func (m *WxCardMutation) SetUserID(u uint64) {
  24811. m.user_id = &u
  24812. m.adduser_id = nil
  24813. }
  24814. // UserID returns the value of the "user_id" field in the mutation.
  24815. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  24816. v := m.user_id
  24817. if v == nil {
  24818. return
  24819. }
  24820. return *v, true
  24821. }
  24822. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  24823. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24825. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  24826. if !m.op.Is(OpUpdateOne) {
  24827. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  24828. }
  24829. if m.id == nil || m.oldValue == nil {
  24830. return v, errors.New("OldUserID requires an ID field in the mutation")
  24831. }
  24832. oldValue, err := m.oldValue(ctx)
  24833. if err != nil {
  24834. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  24835. }
  24836. return oldValue.UserID, nil
  24837. }
  24838. // AddUserID adds u to the "user_id" field.
  24839. func (m *WxCardMutation) AddUserID(u int64) {
  24840. if m.adduser_id != nil {
  24841. *m.adduser_id += u
  24842. } else {
  24843. m.adduser_id = &u
  24844. }
  24845. }
  24846. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  24847. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  24848. v := m.adduser_id
  24849. if v == nil {
  24850. return
  24851. }
  24852. return *v, true
  24853. }
  24854. // ClearUserID clears the value of the "user_id" field.
  24855. func (m *WxCardMutation) ClearUserID() {
  24856. m.user_id = nil
  24857. m.adduser_id = nil
  24858. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  24859. }
  24860. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  24861. func (m *WxCardMutation) UserIDCleared() bool {
  24862. _, ok := m.clearedFields[wxcard.FieldUserID]
  24863. return ok
  24864. }
  24865. // ResetUserID resets all changes to the "user_id" field.
  24866. func (m *WxCardMutation) ResetUserID() {
  24867. m.user_id = nil
  24868. m.adduser_id = nil
  24869. delete(m.clearedFields, wxcard.FieldUserID)
  24870. }
  24871. // SetWxUserID sets the "wx_user_id" field.
  24872. func (m *WxCardMutation) SetWxUserID(u uint64) {
  24873. m.wx_user_id = &u
  24874. m.addwx_user_id = nil
  24875. }
  24876. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  24877. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  24878. v := m.wx_user_id
  24879. if v == nil {
  24880. return
  24881. }
  24882. return *v, true
  24883. }
  24884. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  24885. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24887. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  24888. if !m.op.Is(OpUpdateOne) {
  24889. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  24890. }
  24891. if m.id == nil || m.oldValue == nil {
  24892. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  24893. }
  24894. oldValue, err := m.oldValue(ctx)
  24895. if err != nil {
  24896. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  24897. }
  24898. return oldValue.WxUserID, nil
  24899. }
  24900. // AddWxUserID adds u to the "wx_user_id" field.
  24901. func (m *WxCardMutation) AddWxUserID(u int64) {
  24902. if m.addwx_user_id != nil {
  24903. *m.addwx_user_id += u
  24904. } else {
  24905. m.addwx_user_id = &u
  24906. }
  24907. }
  24908. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  24909. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  24910. v := m.addwx_user_id
  24911. if v == nil {
  24912. return
  24913. }
  24914. return *v, true
  24915. }
  24916. // ClearWxUserID clears the value of the "wx_user_id" field.
  24917. func (m *WxCardMutation) ClearWxUserID() {
  24918. m.wx_user_id = nil
  24919. m.addwx_user_id = nil
  24920. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  24921. }
  24922. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  24923. func (m *WxCardMutation) WxUserIDCleared() bool {
  24924. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  24925. return ok
  24926. }
  24927. // ResetWxUserID resets all changes to the "wx_user_id" field.
  24928. func (m *WxCardMutation) ResetWxUserID() {
  24929. m.wx_user_id = nil
  24930. m.addwx_user_id = nil
  24931. delete(m.clearedFields, wxcard.FieldWxUserID)
  24932. }
  24933. // SetAvatar sets the "avatar" field.
  24934. func (m *WxCardMutation) SetAvatar(s string) {
  24935. m.avatar = &s
  24936. }
  24937. // Avatar returns the value of the "avatar" field in the mutation.
  24938. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  24939. v := m.avatar
  24940. if v == nil {
  24941. return
  24942. }
  24943. return *v, true
  24944. }
  24945. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  24946. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24948. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24949. if !m.op.Is(OpUpdateOne) {
  24950. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24951. }
  24952. if m.id == nil || m.oldValue == nil {
  24953. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24954. }
  24955. oldValue, err := m.oldValue(ctx)
  24956. if err != nil {
  24957. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24958. }
  24959. return oldValue.Avatar, nil
  24960. }
  24961. // ResetAvatar resets all changes to the "avatar" field.
  24962. func (m *WxCardMutation) ResetAvatar() {
  24963. m.avatar = nil
  24964. }
  24965. // SetLogo sets the "logo" field.
  24966. func (m *WxCardMutation) SetLogo(s string) {
  24967. m.logo = &s
  24968. }
  24969. // Logo returns the value of the "logo" field in the mutation.
  24970. func (m *WxCardMutation) Logo() (r string, exists bool) {
  24971. v := m.logo
  24972. if v == nil {
  24973. return
  24974. }
  24975. return *v, true
  24976. }
  24977. // OldLogo returns the old "logo" field's value of the WxCard entity.
  24978. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24980. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  24981. if !m.op.Is(OpUpdateOne) {
  24982. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  24983. }
  24984. if m.id == nil || m.oldValue == nil {
  24985. return v, errors.New("OldLogo requires an ID field in the mutation")
  24986. }
  24987. oldValue, err := m.oldValue(ctx)
  24988. if err != nil {
  24989. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  24990. }
  24991. return oldValue.Logo, nil
  24992. }
  24993. // ResetLogo resets all changes to the "logo" field.
  24994. func (m *WxCardMutation) ResetLogo() {
  24995. m.logo = nil
  24996. }
  24997. // SetName sets the "name" field.
  24998. func (m *WxCardMutation) SetName(s string) {
  24999. m.name = &s
  25000. }
  25001. // Name returns the value of the "name" field in the mutation.
  25002. func (m *WxCardMutation) Name() (r string, exists bool) {
  25003. v := m.name
  25004. if v == nil {
  25005. return
  25006. }
  25007. return *v, true
  25008. }
  25009. // OldName returns the old "name" field's value of the WxCard entity.
  25010. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25012. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  25013. if !m.op.Is(OpUpdateOne) {
  25014. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25015. }
  25016. if m.id == nil || m.oldValue == nil {
  25017. return v, errors.New("OldName requires an ID field in the mutation")
  25018. }
  25019. oldValue, err := m.oldValue(ctx)
  25020. if err != nil {
  25021. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25022. }
  25023. return oldValue.Name, nil
  25024. }
  25025. // ResetName resets all changes to the "name" field.
  25026. func (m *WxCardMutation) ResetName() {
  25027. m.name = nil
  25028. }
  25029. // SetCompany sets the "company" field.
  25030. func (m *WxCardMutation) SetCompany(s string) {
  25031. m.company = &s
  25032. }
  25033. // Company returns the value of the "company" field in the mutation.
  25034. func (m *WxCardMutation) Company() (r string, exists bool) {
  25035. v := m.company
  25036. if v == nil {
  25037. return
  25038. }
  25039. return *v, true
  25040. }
  25041. // OldCompany returns the old "company" field's value of the WxCard entity.
  25042. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25044. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  25045. if !m.op.Is(OpUpdateOne) {
  25046. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  25047. }
  25048. if m.id == nil || m.oldValue == nil {
  25049. return v, errors.New("OldCompany requires an ID field in the mutation")
  25050. }
  25051. oldValue, err := m.oldValue(ctx)
  25052. if err != nil {
  25053. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  25054. }
  25055. return oldValue.Company, nil
  25056. }
  25057. // ResetCompany resets all changes to the "company" field.
  25058. func (m *WxCardMutation) ResetCompany() {
  25059. m.company = nil
  25060. }
  25061. // SetAddress sets the "address" field.
  25062. func (m *WxCardMutation) SetAddress(s string) {
  25063. m.address = &s
  25064. }
  25065. // Address returns the value of the "address" field in the mutation.
  25066. func (m *WxCardMutation) Address() (r string, exists bool) {
  25067. v := m.address
  25068. if v == nil {
  25069. return
  25070. }
  25071. return *v, true
  25072. }
  25073. // OldAddress returns the old "address" field's value of the WxCard entity.
  25074. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25076. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  25077. if !m.op.Is(OpUpdateOne) {
  25078. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  25079. }
  25080. if m.id == nil || m.oldValue == nil {
  25081. return v, errors.New("OldAddress requires an ID field in the mutation")
  25082. }
  25083. oldValue, err := m.oldValue(ctx)
  25084. if err != nil {
  25085. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  25086. }
  25087. return oldValue.Address, nil
  25088. }
  25089. // ResetAddress resets all changes to the "address" field.
  25090. func (m *WxCardMutation) ResetAddress() {
  25091. m.address = nil
  25092. }
  25093. // SetPhone sets the "phone" field.
  25094. func (m *WxCardMutation) SetPhone(s string) {
  25095. m.phone = &s
  25096. }
  25097. // Phone returns the value of the "phone" field in the mutation.
  25098. func (m *WxCardMutation) Phone() (r string, exists bool) {
  25099. v := m.phone
  25100. if v == nil {
  25101. return
  25102. }
  25103. return *v, true
  25104. }
  25105. // OldPhone returns the old "phone" field's value of the WxCard entity.
  25106. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25108. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  25109. if !m.op.Is(OpUpdateOne) {
  25110. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  25111. }
  25112. if m.id == nil || m.oldValue == nil {
  25113. return v, errors.New("OldPhone requires an ID field in the mutation")
  25114. }
  25115. oldValue, err := m.oldValue(ctx)
  25116. if err != nil {
  25117. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25118. }
  25119. return oldValue.Phone, nil
  25120. }
  25121. // ResetPhone resets all changes to the "phone" field.
  25122. func (m *WxCardMutation) ResetPhone() {
  25123. m.phone = nil
  25124. }
  25125. // SetOfficialAccount sets the "official_account" field.
  25126. func (m *WxCardMutation) SetOfficialAccount(s string) {
  25127. m.official_account = &s
  25128. }
  25129. // OfficialAccount returns the value of the "official_account" field in the mutation.
  25130. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  25131. v := m.official_account
  25132. if v == nil {
  25133. return
  25134. }
  25135. return *v, true
  25136. }
  25137. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  25138. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25140. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  25141. if !m.op.Is(OpUpdateOne) {
  25142. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  25143. }
  25144. if m.id == nil || m.oldValue == nil {
  25145. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  25146. }
  25147. oldValue, err := m.oldValue(ctx)
  25148. if err != nil {
  25149. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  25150. }
  25151. return oldValue.OfficialAccount, nil
  25152. }
  25153. // ResetOfficialAccount resets all changes to the "official_account" field.
  25154. func (m *WxCardMutation) ResetOfficialAccount() {
  25155. m.official_account = nil
  25156. }
  25157. // SetWechatAccount sets the "wechat_account" field.
  25158. func (m *WxCardMutation) SetWechatAccount(s string) {
  25159. m.wechat_account = &s
  25160. }
  25161. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  25162. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  25163. v := m.wechat_account
  25164. if v == nil {
  25165. return
  25166. }
  25167. return *v, true
  25168. }
  25169. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  25170. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25172. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  25173. if !m.op.Is(OpUpdateOne) {
  25174. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  25175. }
  25176. if m.id == nil || m.oldValue == nil {
  25177. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  25178. }
  25179. oldValue, err := m.oldValue(ctx)
  25180. if err != nil {
  25181. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  25182. }
  25183. return oldValue.WechatAccount, nil
  25184. }
  25185. // ResetWechatAccount resets all changes to the "wechat_account" field.
  25186. func (m *WxCardMutation) ResetWechatAccount() {
  25187. m.wechat_account = nil
  25188. }
  25189. // SetEmail sets the "email" field.
  25190. func (m *WxCardMutation) SetEmail(s string) {
  25191. m.email = &s
  25192. }
  25193. // Email returns the value of the "email" field in the mutation.
  25194. func (m *WxCardMutation) Email() (r string, exists bool) {
  25195. v := m.email
  25196. if v == nil {
  25197. return
  25198. }
  25199. return *v, true
  25200. }
  25201. // OldEmail returns the old "email" field's value of the WxCard entity.
  25202. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25204. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  25205. if !m.op.Is(OpUpdateOne) {
  25206. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  25207. }
  25208. if m.id == nil || m.oldValue == nil {
  25209. return v, errors.New("OldEmail requires an ID field in the mutation")
  25210. }
  25211. oldValue, err := m.oldValue(ctx)
  25212. if err != nil {
  25213. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  25214. }
  25215. return oldValue.Email, nil
  25216. }
  25217. // ClearEmail clears the value of the "email" field.
  25218. func (m *WxCardMutation) ClearEmail() {
  25219. m.email = nil
  25220. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  25221. }
  25222. // EmailCleared returns if the "email" field was cleared in this mutation.
  25223. func (m *WxCardMutation) EmailCleared() bool {
  25224. _, ok := m.clearedFields[wxcard.FieldEmail]
  25225. return ok
  25226. }
  25227. // ResetEmail resets all changes to the "email" field.
  25228. func (m *WxCardMutation) ResetEmail() {
  25229. m.email = nil
  25230. delete(m.clearedFields, wxcard.FieldEmail)
  25231. }
  25232. // SetAPIBase sets the "api_base" field.
  25233. func (m *WxCardMutation) SetAPIBase(s string) {
  25234. m.api_base = &s
  25235. }
  25236. // APIBase returns the value of the "api_base" field in the mutation.
  25237. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  25238. v := m.api_base
  25239. if v == nil {
  25240. return
  25241. }
  25242. return *v, true
  25243. }
  25244. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  25245. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25247. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  25248. if !m.op.Is(OpUpdateOne) {
  25249. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  25250. }
  25251. if m.id == nil || m.oldValue == nil {
  25252. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  25253. }
  25254. oldValue, err := m.oldValue(ctx)
  25255. if err != nil {
  25256. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  25257. }
  25258. return oldValue.APIBase, nil
  25259. }
  25260. // ClearAPIBase clears the value of the "api_base" field.
  25261. func (m *WxCardMutation) ClearAPIBase() {
  25262. m.api_base = nil
  25263. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  25264. }
  25265. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  25266. func (m *WxCardMutation) APIBaseCleared() bool {
  25267. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  25268. return ok
  25269. }
  25270. // ResetAPIBase resets all changes to the "api_base" field.
  25271. func (m *WxCardMutation) ResetAPIBase() {
  25272. m.api_base = nil
  25273. delete(m.clearedFields, wxcard.FieldAPIBase)
  25274. }
  25275. // SetAPIKey sets the "api_key" field.
  25276. func (m *WxCardMutation) SetAPIKey(s string) {
  25277. m.api_key = &s
  25278. }
  25279. // APIKey returns the value of the "api_key" field in the mutation.
  25280. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  25281. v := m.api_key
  25282. if v == nil {
  25283. return
  25284. }
  25285. return *v, true
  25286. }
  25287. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  25288. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25290. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  25291. if !m.op.Is(OpUpdateOne) {
  25292. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  25293. }
  25294. if m.id == nil || m.oldValue == nil {
  25295. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  25296. }
  25297. oldValue, err := m.oldValue(ctx)
  25298. if err != nil {
  25299. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  25300. }
  25301. return oldValue.APIKey, nil
  25302. }
  25303. // ClearAPIKey clears the value of the "api_key" field.
  25304. func (m *WxCardMutation) ClearAPIKey() {
  25305. m.api_key = nil
  25306. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  25307. }
  25308. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  25309. func (m *WxCardMutation) APIKeyCleared() bool {
  25310. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  25311. return ok
  25312. }
  25313. // ResetAPIKey resets all changes to the "api_key" field.
  25314. func (m *WxCardMutation) ResetAPIKey() {
  25315. m.api_key = nil
  25316. delete(m.clearedFields, wxcard.FieldAPIKey)
  25317. }
  25318. // SetAiInfo sets the "ai_info" field.
  25319. func (m *WxCardMutation) SetAiInfo(s string) {
  25320. m.ai_info = &s
  25321. }
  25322. // AiInfo returns the value of the "ai_info" field in the mutation.
  25323. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  25324. v := m.ai_info
  25325. if v == nil {
  25326. return
  25327. }
  25328. return *v, true
  25329. }
  25330. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  25331. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25333. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  25334. if !m.op.Is(OpUpdateOne) {
  25335. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  25336. }
  25337. if m.id == nil || m.oldValue == nil {
  25338. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  25339. }
  25340. oldValue, err := m.oldValue(ctx)
  25341. if err != nil {
  25342. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  25343. }
  25344. return oldValue.AiInfo, nil
  25345. }
  25346. // ClearAiInfo clears the value of the "ai_info" field.
  25347. func (m *WxCardMutation) ClearAiInfo() {
  25348. m.ai_info = nil
  25349. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  25350. }
  25351. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  25352. func (m *WxCardMutation) AiInfoCleared() bool {
  25353. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  25354. return ok
  25355. }
  25356. // ResetAiInfo resets all changes to the "ai_info" field.
  25357. func (m *WxCardMutation) ResetAiInfo() {
  25358. m.ai_info = nil
  25359. delete(m.clearedFields, wxcard.FieldAiInfo)
  25360. }
  25361. // SetIntro sets the "intro" field.
  25362. func (m *WxCardMutation) SetIntro(s string) {
  25363. m.intro = &s
  25364. }
  25365. // Intro returns the value of the "intro" field in the mutation.
  25366. func (m *WxCardMutation) Intro() (r string, exists bool) {
  25367. v := m.intro
  25368. if v == nil {
  25369. return
  25370. }
  25371. return *v, true
  25372. }
  25373. // OldIntro returns the old "intro" field's value of the WxCard entity.
  25374. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25376. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  25377. if !m.op.Is(OpUpdateOne) {
  25378. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  25379. }
  25380. if m.id == nil || m.oldValue == nil {
  25381. return v, errors.New("OldIntro requires an ID field in the mutation")
  25382. }
  25383. oldValue, err := m.oldValue(ctx)
  25384. if err != nil {
  25385. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  25386. }
  25387. return oldValue.Intro, nil
  25388. }
  25389. // ClearIntro clears the value of the "intro" field.
  25390. func (m *WxCardMutation) ClearIntro() {
  25391. m.intro = nil
  25392. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  25393. }
  25394. // IntroCleared returns if the "intro" field was cleared in this mutation.
  25395. func (m *WxCardMutation) IntroCleared() bool {
  25396. _, ok := m.clearedFields[wxcard.FieldIntro]
  25397. return ok
  25398. }
  25399. // ResetIntro resets all changes to the "intro" field.
  25400. func (m *WxCardMutation) ResetIntro() {
  25401. m.intro = nil
  25402. delete(m.clearedFields, wxcard.FieldIntro)
  25403. }
  25404. // Where appends a list predicates to the WxCardMutation builder.
  25405. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  25406. m.predicates = append(m.predicates, ps...)
  25407. }
  25408. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  25409. // users can use type-assertion to append predicates that do not depend on any generated package.
  25410. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  25411. p := make([]predicate.WxCard, len(ps))
  25412. for i := range ps {
  25413. p[i] = ps[i]
  25414. }
  25415. m.Where(p...)
  25416. }
  25417. // Op returns the operation name.
  25418. func (m *WxCardMutation) Op() Op {
  25419. return m.op
  25420. }
  25421. // SetOp allows setting the mutation operation.
  25422. func (m *WxCardMutation) SetOp(op Op) {
  25423. m.op = op
  25424. }
  25425. // Type returns the node type of this mutation (WxCard).
  25426. func (m *WxCardMutation) Type() string {
  25427. return m.typ
  25428. }
  25429. // Fields returns all fields that were changed during this mutation. Note that in
  25430. // order to get all numeric fields that were incremented/decremented, call
  25431. // AddedFields().
  25432. func (m *WxCardMutation) Fields() []string {
  25433. fields := make([]string, 0, 18)
  25434. if m.created_at != nil {
  25435. fields = append(fields, wxcard.FieldCreatedAt)
  25436. }
  25437. if m.updated_at != nil {
  25438. fields = append(fields, wxcard.FieldUpdatedAt)
  25439. }
  25440. if m.deleted_at != nil {
  25441. fields = append(fields, wxcard.FieldDeletedAt)
  25442. }
  25443. if m.user_id != nil {
  25444. fields = append(fields, wxcard.FieldUserID)
  25445. }
  25446. if m.wx_user_id != nil {
  25447. fields = append(fields, wxcard.FieldWxUserID)
  25448. }
  25449. if m.avatar != nil {
  25450. fields = append(fields, wxcard.FieldAvatar)
  25451. }
  25452. if m.logo != nil {
  25453. fields = append(fields, wxcard.FieldLogo)
  25454. }
  25455. if m.name != nil {
  25456. fields = append(fields, wxcard.FieldName)
  25457. }
  25458. if m.company != nil {
  25459. fields = append(fields, wxcard.FieldCompany)
  25460. }
  25461. if m.address != nil {
  25462. fields = append(fields, wxcard.FieldAddress)
  25463. }
  25464. if m.phone != nil {
  25465. fields = append(fields, wxcard.FieldPhone)
  25466. }
  25467. if m.official_account != nil {
  25468. fields = append(fields, wxcard.FieldOfficialAccount)
  25469. }
  25470. if m.wechat_account != nil {
  25471. fields = append(fields, wxcard.FieldWechatAccount)
  25472. }
  25473. if m.email != nil {
  25474. fields = append(fields, wxcard.FieldEmail)
  25475. }
  25476. if m.api_base != nil {
  25477. fields = append(fields, wxcard.FieldAPIBase)
  25478. }
  25479. if m.api_key != nil {
  25480. fields = append(fields, wxcard.FieldAPIKey)
  25481. }
  25482. if m.ai_info != nil {
  25483. fields = append(fields, wxcard.FieldAiInfo)
  25484. }
  25485. if m.intro != nil {
  25486. fields = append(fields, wxcard.FieldIntro)
  25487. }
  25488. return fields
  25489. }
  25490. // Field returns the value of a field with the given name. The second boolean
  25491. // return value indicates that this field was not set, or was not defined in the
  25492. // schema.
  25493. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  25494. switch name {
  25495. case wxcard.FieldCreatedAt:
  25496. return m.CreatedAt()
  25497. case wxcard.FieldUpdatedAt:
  25498. return m.UpdatedAt()
  25499. case wxcard.FieldDeletedAt:
  25500. return m.DeletedAt()
  25501. case wxcard.FieldUserID:
  25502. return m.UserID()
  25503. case wxcard.FieldWxUserID:
  25504. return m.WxUserID()
  25505. case wxcard.FieldAvatar:
  25506. return m.Avatar()
  25507. case wxcard.FieldLogo:
  25508. return m.Logo()
  25509. case wxcard.FieldName:
  25510. return m.Name()
  25511. case wxcard.FieldCompany:
  25512. return m.Company()
  25513. case wxcard.FieldAddress:
  25514. return m.Address()
  25515. case wxcard.FieldPhone:
  25516. return m.Phone()
  25517. case wxcard.FieldOfficialAccount:
  25518. return m.OfficialAccount()
  25519. case wxcard.FieldWechatAccount:
  25520. return m.WechatAccount()
  25521. case wxcard.FieldEmail:
  25522. return m.Email()
  25523. case wxcard.FieldAPIBase:
  25524. return m.APIBase()
  25525. case wxcard.FieldAPIKey:
  25526. return m.APIKey()
  25527. case wxcard.FieldAiInfo:
  25528. return m.AiInfo()
  25529. case wxcard.FieldIntro:
  25530. return m.Intro()
  25531. }
  25532. return nil, false
  25533. }
  25534. // OldField returns the old value of the field from the database. An error is
  25535. // returned if the mutation operation is not UpdateOne, or the query to the
  25536. // database failed.
  25537. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25538. switch name {
  25539. case wxcard.FieldCreatedAt:
  25540. return m.OldCreatedAt(ctx)
  25541. case wxcard.FieldUpdatedAt:
  25542. return m.OldUpdatedAt(ctx)
  25543. case wxcard.FieldDeletedAt:
  25544. return m.OldDeletedAt(ctx)
  25545. case wxcard.FieldUserID:
  25546. return m.OldUserID(ctx)
  25547. case wxcard.FieldWxUserID:
  25548. return m.OldWxUserID(ctx)
  25549. case wxcard.FieldAvatar:
  25550. return m.OldAvatar(ctx)
  25551. case wxcard.FieldLogo:
  25552. return m.OldLogo(ctx)
  25553. case wxcard.FieldName:
  25554. return m.OldName(ctx)
  25555. case wxcard.FieldCompany:
  25556. return m.OldCompany(ctx)
  25557. case wxcard.FieldAddress:
  25558. return m.OldAddress(ctx)
  25559. case wxcard.FieldPhone:
  25560. return m.OldPhone(ctx)
  25561. case wxcard.FieldOfficialAccount:
  25562. return m.OldOfficialAccount(ctx)
  25563. case wxcard.FieldWechatAccount:
  25564. return m.OldWechatAccount(ctx)
  25565. case wxcard.FieldEmail:
  25566. return m.OldEmail(ctx)
  25567. case wxcard.FieldAPIBase:
  25568. return m.OldAPIBase(ctx)
  25569. case wxcard.FieldAPIKey:
  25570. return m.OldAPIKey(ctx)
  25571. case wxcard.FieldAiInfo:
  25572. return m.OldAiInfo(ctx)
  25573. case wxcard.FieldIntro:
  25574. return m.OldIntro(ctx)
  25575. }
  25576. return nil, fmt.Errorf("unknown WxCard field %s", name)
  25577. }
  25578. // SetField sets the value of a field with the given name. It returns an error if
  25579. // the field is not defined in the schema, or if the type mismatched the field
  25580. // type.
  25581. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  25582. switch name {
  25583. case wxcard.FieldCreatedAt:
  25584. v, ok := value.(time.Time)
  25585. if !ok {
  25586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25587. }
  25588. m.SetCreatedAt(v)
  25589. return nil
  25590. case wxcard.FieldUpdatedAt:
  25591. v, ok := value.(time.Time)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.SetUpdatedAt(v)
  25596. return nil
  25597. case wxcard.FieldDeletedAt:
  25598. v, ok := value.(time.Time)
  25599. if !ok {
  25600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25601. }
  25602. m.SetDeletedAt(v)
  25603. return nil
  25604. case wxcard.FieldUserID:
  25605. v, ok := value.(uint64)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetUserID(v)
  25610. return nil
  25611. case wxcard.FieldWxUserID:
  25612. v, ok := value.(uint64)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetWxUserID(v)
  25617. return nil
  25618. case wxcard.FieldAvatar:
  25619. v, ok := value.(string)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetAvatar(v)
  25624. return nil
  25625. case wxcard.FieldLogo:
  25626. v, ok := value.(string)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetLogo(v)
  25631. return nil
  25632. case wxcard.FieldName:
  25633. v, ok := value.(string)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetName(v)
  25638. return nil
  25639. case wxcard.FieldCompany:
  25640. v, ok := value.(string)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetCompany(v)
  25645. return nil
  25646. case wxcard.FieldAddress:
  25647. v, ok := value.(string)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetAddress(v)
  25652. return nil
  25653. case wxcard.FieldPhone:
  25654. v, ok := value.(string)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetPhone(v)
  25659. return nil
  25660. case wxcard.FieldOfficialAccount:
  25661. v, ok := value.(string)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetOfficialAccount(v)
  25666. return nil
  25667. case wxcard.FieldWechatAccount:
  25668. v, ok := value.(string)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetWechatAccount(v)
  25673. return nil
  25674. case wxcard.FieldEmail:
  25675. v, ok := value.(string)
  25676. if !ok {
  25677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25678. }
  25679. m.SetEmail(v)
  25680. return nil
  25681. case wxcard.FieldAPIBase:
  25682. v, ok := value.(string)
  25683. if !ok {
  25684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25685. }
  25686. m.SetAPIBase(v)
  25687. return nil
  25688. case wxcard.FieldAPIKey:
  25689. v, ok := value.(string)
  25690. if !ok {
  25691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25692. }
  25693. m.SetAPIKey(v)
  25694. return nil
  25695. case wxcard.FieldAiInfo:
  25696. v, ok := value.(string)
  25697. if !ok {
  25698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25699. }
  25700. m.SetAiInfo(v)
  25701. return nil
  25702. case wxcard.FieldIntro:
  25703. v, ok := value.(string)
  25704. if !ok {
  25705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25706. }
  25707. m.SetIntro(v)
  25708. return nil
  25709. }
  25710. return fmt.Errorf("unknown WxCard field %s", name)
  25711. }
  25712. // AddedFields returns all numeric fields that were incremented/decremented during
  25713. // this mutation.
  25714. func (m *WxCardMutation) AddedFields() []string {
  25715. var fields []string
  25716. if m.adduser_id != nil {
  25717. fields = append(fields, wxcard.FieldUserID)
  25718. }
  25719. if m.addwx_user_id != nil {
  25720. fields = append(fields, wxcard.FieldWxUserID)
  25721. }
  25722. return fields
  25723. }
  25724. // AddedField returns the numeric value that was incremented/decremented on a field
  25725. // with the given name. The second boolean return value indicates that this field
  25726. // was not set, or was not defined in the schema.
  25727. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  25728. switch name {
  25729. case wxcard.FieldUserID:
  25730. return m.AddedUserID()
  25731. case wxcard.FieldWxUserID:
  25732. return m.AddedWxUserID()
  25733. }
  25734. return nil, false
  25735. }
  25736. // AddField adds the value to the field with the given name. It returns an error if
  25737. // the field is not defined in the schema, or if the type mismatched the field
  25738. // type.
  25739. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  25740. switch name {
  25741. case wxcard.FieldUserID:
  25742. v, ok := value.(int64)
  25743. if !ok {
  25744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25745. }
  25746. m.AddUserID(v)
  25747. return nil
  25748. case wxcard.FieldWxUserID:
  25749. v, ok := value.(int64)
  25750. if !ok {
  25751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25752. }
  25753. m.AddWxUserID(v)
  25754. return nil
  25755. }
  25756. return fmt.Errorf("unknown WxCard numeric field %s", name)
  25757. }
  25758. // ClearedFields returns all nullable fields that were cleared during this
  25759. // mutation.
  25760. func (m *WxCardMutation) ClearedFields() []string {
  25761. var fields []string
  25762. if m.FieldCleared(wxcard.FieldDeletedAt) {
  25763. fields = append(fields, wxcard.FieldDeletedAt)
  25764. }
  25765. if m.FieldCleared(wxcard.FieldUserID) {
  25766. fields = append(fields, wxcard.FieldUserID)
  25767. }
  25768. if m.FieldCleared(wxcard.FieldWxUserID) {
  25769. fields = append(fields, wxcard.FieldWxUserID)
  25770. }
  25771. if m.FieldCleared(wxcard.FieldEmail) {
  25772. fields = append(fields, wxcard.FieldEmail)
  25773. }
  25774. if m.FieldCleared(wxcard.FieldAPIBase) {
  25775. fields = append(fields, wxcard.FieldAPIBase)
  25776. }
  25777. if m.FieldCleared(wxcard.FieldAPIKey) {
  25778. fields = append(fields, wxcard.FieldAPIKey)
  25779. }
  25780. if m.FieldCleared(wxcard.FieldAiInfo) {
  25781. fields = append(fields, wxcard.FieldAiInfo)
  25782. }
  25783. if m.FieldCleared(wxcard.FieldIntro) {
  25784. fields = append(fields, wxcard.FieldIntro)
  25785. }
  25786. return fields
  25787. }
  25788. // FieldCleared returns a boolean indicating if a field with the given name was
  25789. // cleared in this mutation.
  25790. func (m *WxCardMutation) FieldCleared(name string) bool {
  25791. _, ok := m.clearedFields[name]
  25792. return ok
  25793. }
  25794. // ClearField clears the value of the field with the given name. It returns an
  25795. // error if the field is not defined in the schema.
  25796. func (m *WxCardMutation) ClearField(name string) error {
  25797. switch name {
  25798. case wxcard.FieldDeletedAt:
  25799. m.ClearDeletedAt()
  25800. return nil
  25801. case wxcard.FieldUserID:
  25802. m.ClearUserID()
  25803. return nil
  25804. case wxcard.FieldWxUserID:
  25805. m.ClearWxUserID()
  25806. return nil
  25807. case wxcard.FieldEmail:
  25808. m.ClearEmail()
  25809. return nil
  25810. case wxcard.FieldAPIBase:
  25811. m.ClearAPIBase()
  25812. return nil
  25813. case wxcard.FieldAPIKey:
  25814. m.ClearAPIKey()
  25815. return nil
  25816. case wxcard.FieldAiInfo:
  25817. m.ClearAiInfo()
  25818. return nil
  25819. case wxcard.FieldIntro:
  25820. m.ClearIntro()
  25821. return nil
  25822. }
  25823. return fmt.Errorf("unknown WxCard nullable field %s", name)
  25824. }
  25825. // ResetField resets all changes in the mutation for the field with the given name.
  25826. // It returns an error if the field is not defined in the schema.
  25827. func (m *WxCardMutation) ResetField(name string) error {
  25828. switch name {
  25829. case wxcard.FieldCreatedAt:
  25830. m.ResetCreatedAt()
  25831. return nil
  25832. case wxcard.FieldUpdatedAt:
  25833. m.ResetUpdatedAt()
  25834. return nil
  25835. case wxcard.FieldDeletedAt:
  25836. m.ResetDeletedAt()
  25837. return nil
  25838. case wxcard.FieldUserID:
  25839. m.ResetUserID()
  25840. return nil
  25841. case wxcard.FieldWxUserID:
  25842. m.ResetWxUserID()
  25843. return nil
  25844. case wxcard.FieldAvatar:
  25845. m.ResetAvatar()
  25846. return nil
  25847. case wxcard.FieldLogo:
  25848. m.ResetLogo()
  25849. return nil
  25850. case wxcard.FieldName:
  25851. m.ResetName()
  25852. return nil
  25853. case wxcard.FieldCompany:
  25854. m.ResetCompany()
  25855. return nil
  25856. case wxcard.FieldAddress:
  25857. m.ResetAddress()
  25858. return nil
  25859. case wxcard.FieldPhone:
  25860. m.ResetPhone()
  25861. return nil
  25862. case wxcard.FieldOfficialAccount:
  25863. m.ResetOfficialAccount()
  25864. return nil
  25865. case wxcard.FieldWechatAccount:
  25866. m.ResetWechatAccount()
  25867. return nil
  25868. case wxcard.FieldEmail:
  25869. m.ResetEmail()
  25870. return nil
  25871. case wxcard.FieldAPIBase:
  25872. m.ResetAPIBase()
  25873. return nil
  25874. case wxcard.FieldAPIKey:
  25875. m.ResetAPIKey()
  25876. return nil
  25877. case wxcard.FieldAiInfo:
  25878. m.ResetAiInfo()
  25879. return nil
  25880. case wxcard.FieldIntro:
  25881. m.ResetIntro()
  25882. return nil
  25883. }
  25884. return fmt.Errorf("unknown WxCard field %s", name)
  25885. }
  25886. // AddedEdges returns all edge names that were set/added in this mutation.
  25887. func (m *WxCardMutation) AddedEdges() []string {
  25888. edges := make([]string, 0, 0)
  25889. return edges
  25890. }
  25891. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25892. // name in this mutation.
  25893. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  25894. return nil
  25895. }
  25896. // RemovedEdges returns all edge names that were removed in this mutation.
  25897. func (m *WxCardMutation) RemovedEdges() []string {
  25898. edges := make([]string, 0, 0)
  25899. return edges
  25900. }
  25901. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25902. // the given name in this mutation.
  25903. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  25904. return nil
  25905. }
  25906. // ClearedEdges returns all edge names that were cleared in this mutation.
  25907. func (m *WxCardMutation) ClearedEdges() []string {
  25908. edges := make([]string, 0, 0)
  25909. return edges
  25910. }
  25911. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25912. // was cleared in this mutation.
  25913. func (m *WxCardMutation) EdgeCleared(name string) bool {
  25914. return false
  25915. }
  25916. // ClearEdge clears the value of the edge with the given name. It returns an error
  25917. // if that edge is not defined in the schema.
  25918. func (m *WxCardMutation) ClearEdge(name string) error {
  25919. return fmt.Errorf("unknown WxCard unique edge %s", name)
  25920. }
  25921. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25922. // It returns an error if the edge is not defined in the schema.
  25923. func (m *WxCardMutation) ResetEdge(name string) error {
  25924. return fmt.Errorf("unknown WxCard edge %s", name)
  25925. }
  25926. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  25927. type WxCardUserMutation struct {
  25928. config
  25929. op Op
  25930. typ string
  25931. id *uint64
  25932. created_at *time.Time
  25933. updated_at *time.Time
  25934. deleted_at *time.Time
  25935. wxid *string
  25936. account *string
  25937. avatar *string
  25938. nickname *string
  25939. remark *string
  25940. phone *string
  25941. open_id *string
  25942. union_id *string
  25943. session_key *string
  25944. is_vip *int
  25945. addis_vip *int
  25946. clearedFields map[string]struct{}
  25947. done bool
  25948. oldValue func(context.Context) (*WxCardUser, error)
  25949. predicates []predicate.WxCardUser
  25950. }
  25951. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  25952. // wxcarduserOption allows management of the mutation configuration using functional options.
  25953. type wxcarduserOption func(*WxCardUserMutation)
  25954. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  25955. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  25956. m := &WxCardUserMutation{
  25957. config: c,
  25958. op: op,
  25959. typ: TypeWxCardUser,
  25960. clearedFields: make(map[string]struct{}),
  25961. }
  25962. for _, opt := range opts {
  25963. opt(m)
  25964. }
  25965. return m
  25966. }
  25967. // withWxCardUserID sets the ID field of the mutation.
  25968. func withWxCardUserID(id uint64) wxcarduserOption {
  25969. return func(m *WxCardUserMutation) {
  25970. var (
  25971. err error
  25972. once sync.Once
  25973. value *WxCardUser
  25974. )
  25975. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  25976. once.Do(func() {
  25977. if m.done {
  25978. err = errors.New("querying old values post mutation is not allowed")
  25979. } else {
  25980. value, err = m.Client().WxCardUser.Get(ctx, id)
  25981. }
  25982. })
  25983. return value, err
  25984. }
  25985. m.id = &id
  25986. }
  25987. }
  25988. // withWxCardUser sets the old WxCardUser of the mutation.
  25989. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  25990. return func(m *WxCardUserMutation) {
  25991. m.oldValue = func(context.Context) (*WxCardUser, error) {
  25992. return node, nil
  25993. }
  25994. m.id = &node.ID
  25995. }
  25996. }
  25997. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25998. // executed in a transaction (ent.Tx), a transactional client is returned.
  25999. func (m WxCardUserMutation) Client() *Client {
  26000. client := &Client{config: m.config}
  26001. client.init()
  26002. return client
  26003. }
  26004. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26005. // it returns an error otherwise.
  26006. func (m WxCardUserMutation) Tx() (*Tx, error) {
  26007. if _, ok := m.driver.(*txDriver); !ok {
  26008. return nil, errors.New("ent: mutation is not running in a transaction")
  26009. }
  26010. tx := &Tx{config: m.config}
  26011. tx.init()
  26012. return tx, nil
  26013. }
  26014. // SetID sets the value of the id field. Note that this
  26015. // operation is only accepted on creation of WxCardUser entities.
  26016. func (m *WxCardUserMutation) SetID(id uint64) {
  26017. m.id = &id
  26018. }
  26019. // ID returns the ID value in the mutation. Note that the ID is only available
  26020. // if it was provided to the builder or after it was returned from the database.
  26021. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  26022. if m.id == nil {
  26023. return
  26024. }
  26025. return *m.id, true
  26026. }
  26027. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26028. // That means, if the mutation is applied within a transaction with an isolation level such
  26029. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26030. // or updated by the mutation.
  26031. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  26032. switch {
  26033. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26034. id, exists := m.ID()
  26035. if exists {
  26036. return []uint64{id}, nil
  26037. }
  26038. fallthrough
  26039. case m.op.Is(OpUpdate | OpDelete):
  26040. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  26041. default:
  26042. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26043. }
  26044. }
  26045. // SetCreatedAt sets the "created_at" field.
  26046. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  26047. m.created_at = &t
  26048. }
  26049. // CreatedAt returns the value of the "created_at" field in the mutation.
  26050. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  26051. v := m.created_at
  26052. if v == nil {
  26053. return
  26054. }
  26055. return *v, true
  26056. }
  26057. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  26058. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26060. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26061. if !m.op.Is(OpUpdateOne) {
  26062. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26063. }
  26064. if m.id == nil || m.oldValue == nil {
  26065. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26066. }
  26067. oldValue, err := m.oldValue(ctx)
  26068. if err != nil {
  26069. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26070. }
  26071. return oldValue.CreatedAt, nil
  26072. }
  26073. // ResetCreatedAt resets all changes to the "created_at" field.
  26074. func (m *WxCardUserMutation) ResetCreatedAt() {
  26075. m.created_at = nil
  26076. }
  26077. // SetUpdatedAt sets the "updated_at" field.
  26078. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  26079. m.updated_at = &t
  26080. }
  26081. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26082. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  26083. v := m.updated_at
  26084. if v == nil {
  26085. return
  26086. }
  26087. return *v, true
  26088. }
  26089. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  26090. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26092. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26093. if !m.op.Is(OpUpdateOne) {
  26094. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26095. }
  26096. if m.id == nil || m.oldValue == nil {
  26097. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26098. }
  26099. oldValue, err := m.oldValue(ctx)
  26100. if err != nil {
  26101. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26102. }
  26103. return oldValue.UpdatedAt, nil
  26104. }
  26105. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26106. func (m *WxCardUserMutation) ResetUpdatedAt() {
  26107. m.updated_at = nil
  26108. }
  26109. // SetDeletedAt sets the "deleted_at" field.
  26110. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  26111. m.deleted_at = &t
  26112. }
  26113. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26114. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  26115. v := m.deleted_at
  26116. if v == nil {
  26117. return
  26118. }
  26119. return *v, true
  26120. }
  26121. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  26122. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26124. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26125. if !m.op.Is(OpUpdateOne) {
  26126. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26127. }
  26128. if m.id == nil || m.oldValue == nil {
  26129. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26130. }
  26131. oldValue, err := m.oldValue(ctx)
  26132. if err != nil {
  26133. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26134. }
  26135. return oldValue.DeletedAt, nil
  26136. }
  26137. // ClearDeletedAt clears the value of the "deleted_at" field.
  26138. func (m *WxCardUserMutation) ClearDeletedAt() {
  26139. m.deleted_at = nil
  26140. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  26141. }
  26142. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26143. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  26144. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  26145. return ok
  26146. }
  26147. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26148. func (m *WxCardUserMutation) ResetDeletedAt() {
  26149. m.deleted_at = nil
  26150. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  26151. }
  26152. // SetWxid sets the "wxid" field.
  26153. func (m *WxCardUserMutation) SetWxid(s string) {
  26154. m.wxid = &s
  26155. }
  26156. // Wxid returns the value of the "wxid" field in the mutation.
  26157. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  26158. v := m.wxid
  26159. if v == nil {
  26160. return
  26161. }
  26162. return *v, true
  26163. }
  26164. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  26165. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26167. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  26168. if !m.op.Is(OpUpdateOne) {
  26169. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  26170. }
  26171. if m.id == nil || m.oldValue == nil {
  26172. return v, errors.New("OldWxid requires an ID field in the mutation")
  26173. }
  26174. oldValue, err := m.oldValue(ctx)
  26175. if err != nil {
  26176. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  26177. }
  26178. return oldValue.Wxid, nil
  26179. }
  26180. // ResetWxid resets all changes to the "wxid" field.
  26181. func (m *WxCardUserMutation) ResetWxid() {
  26182. m.wxid = nil
  26183. }
  26184. // SetAccount sets the "account" field.
  26185. func (m *WxCardUserMutation) SetAccount(s string) {
  26186. m.account = &s
  26187. }
  26188. // Account returns the value of the "account" field in the mutation.
  26189. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  26190. v := m.account
  26191. if v == nil {
  26192. return
  26193. }
  26194. return *v, true
  26195. }
  26196. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  26197. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26199. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  26200. if !m.op.Is(OpUpdateOne) {
  26201. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  26202. }
  26203. if m.id == nil || m.oldValue == nil {
  26204. return v, errors.New("OldAccount requires an ID field in the mutation")
  26205. }
  26206. oldValue, err := m.oldValue(ctx)
  26207. if err != nil {
  26208. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  26209. }
  26210. return oldValue.Account, nil
  26211. }
  26212. // ResetAccount resets all changes to the "account" field.
  26213. func (m *WxCardUserMutation) ResetAccount() {
  26214. m.account = nil
  26215. }
  26216. // SetAvatar sets the "avatar" field.
  26217. func (m *WxCardUserMutation) SetAvatar(s string) {
  26218. m.avatar = &s
  26219. }
  26220. // Avatar returns the value of the "avatar" field in the mutation.
  26221. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  26222. v := m.avatar
  26223. if v == nil {
  26224. return
  26225. }
  26226. return *v, true
  26227. }
  26228. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  26229. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26231. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26232. if !m.op.Is(OpUpdateOne) {
  26233. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26234. }
  26235. if m.id == nil || m.oldValue == nil {
  26236. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26237. }
  26238. oldValue, err := m.oldValue(ctx)
  26239. if err != nil {
  26240. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26241. }
  26242. return oldValue.Avatar, nil
  26243. }
  26244. // ResetAvatar resets all changes to the "avatar" field.
  26245. func (m *WxCardUserMutation) ResetAvatar() {
  26246. m.avatar = nil
  26247. }
  26248. // SetNickname sets the "nickname" field.
  26249. func (m *WxCardUserMutation) SetNickname(s string) {
  26250. m.nickname = &s
  26251. }
  26252. // Nickname returns the value of the "nickname" field in the mutation.
  26253. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  26254. v := m.nickname
  26255. if v == nil {
  26256. return
  26257. }
  26258. return *v, true
  26259. }
  26260. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  26261. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26263. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  26264. if !m.op.Is(OpUpdateOne) {
  26265. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26266. }
  26267. if m.id == nil || m.oldValue == nil {
  26268. return v, errors.New("OldNickname requires an ID field in the mutation")
  26269. }
  26270. oldValue, err := m.oldValue(ctx)
  26271. if err != nil {
  26272. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26273. }
  26274. return oldValue.Nickname, nil
  26275. }
  26276. // ResetNickname resets all changes to the "nickname" field.
  26277. func (m *WxCardUserMutation) ResetNickname() {
  26278. m.nickname = nil
  26279. }
  26280. // SetRemark sets the "remark" field.
  26281. func (m *WxCardUserMutation) SetRemark(s string) {
  26282. m.remark = &s
  26283. }
  26284. // Remark returns the value of the "remark" field in the mutation.
  26285. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  26286. v := m.remark
  26287. if v == nil {
  26288. return
  26289. }
  26290. return *v, true
  26291. }
  26292. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  26293. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26295. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  26296. if !m.op.Is(OpUpdateOne) {
  26297. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  26298. }
  26299. if m.id == nil || m.oldValue == nil {
  26300. return v, errors.New("OldRemark requires an ID field in the mutation")
  26301. }
  26302. oldValue, err := m.oldValue(ctx)
  26303. if err != nil {
  26304. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  26305. }
  26306. return oldValue.Remark, nil
  26307. }
  26308. // ResetRemark resets all changes to the "remark" field.
  26309. func (m *WxCardUserMutation) ResetRemark() {
  26310. m.remark = nil
  26311. }
  26312. // SetPhone sets the "phone" field.
  26313. func (m *WxCardUserMutation) SetPhone(s string) {
  26314. m.phone = &s
  26315. }
  26316. // Phone returns the value of the "phone" field in the mutation.
  26317. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  26318. v := m.phone
  26319. if v == nil {
  26320. return
  26321. }
  26322. return *v, true
  26323. }
  26324. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  26325. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26327. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  26328. if !m.op.Is(OpUpdateOne) {
  26329. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26330. }
  26331. if m.id == nil || m.oldValue == nil {
  26332. return v, errors.New("OldPhone requires an ID field in the mutation")
  26333. }
  26334. oldValue, err := m.oldValue(ctx)
  26335. if err != nil {
  26336. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26337. }
  26338. return oldValue.Phone, nil
  26339. }
  26340. // ResetPhone resets all changes to the "phone" field.
  26341. func (m *WxCardUserMutation) ResetPhone() {
  26342. m.phone = nil
  26343. }
  26344. // SetOpenID sets the "open_id" field.
  26345. func (m *WxCardUserMutation) SetOpenID(s string) {
  26346. m.open_id = &s
  26347. }
  26348. // OpenID returns the value of the "open_id" field in the mutation.
  26349. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  26350. v := m.open_id
  26351. if v == nil {
  26352. return
  26353. }
  26354. return *v, true
  26355. }
  26356. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  26357. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26359. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  26360. if !m.op.Is(OpUpdateOne) {
  26361. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  26362. }
  26363. if m.id == nil || m.oldValue == nil {
  26364. return v, errors.New("OldOpenID requires an ID field in the mutation")
  26365. }
  26366. oldValue, err := m.oldValue(ctx)
  26367. if err != nil {
  26368. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  26369. }
  26370. return oldValue.OpenID, nil
  26371. }
  26372. // ResetOpenID resets all changes to the "open_id" field.
  26373. func (m *WxCardUserMutation) ResetOpenID() {
  26374. m.open_id = nil
  26375. }
  26376. // SetUnionID sets the "union_id" field.
  26377. func (m *WxCardUserMutation) SetUnionID(s string) {
  26378. m.union_id = &s
  26379. }
  26380. // UnionID returns the value of the "union_id" field in the mutation.
  26381. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  26382. v := m.union_id
  26383. if v == nil {
  26384. return
  26385. }
  26386. return *v, true
  26387. }
  26388. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  26389. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26391. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  26392. if !m.op.Is(OpUpdateOne) {
  26393. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  26394. }
  26395. if m.id == nil || m.oldValue == nil {
  26396. return v, errors.New("OldUnionID requires an ID field in the mutation")
  26397. }
  26398. oldValue, err := m.oldValue(ctx)
  26399. if err != nil {
  26400. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  26401. }
  26402. return oldValue.UnionID, nil
  26403. }
  26404. // ResetUnionID resets all changes to the "union_id" field.
  26405. func (m *WxCardUserMutation) ResetUnionID() {
  26406. m.union_id = nil
  26407. }
  26408. // SetSessionKey sets the "session_key" field.
  26409. func (m *WxCardUserMutation) SetSessionKey(s string) {
  26410. m.session_key = &s
  26411. }
  26412. // SessionKey returns the value of the "session_key" field in the mutation.
  26413. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  26414. v := m.session_key
  26415. if v == nil {
  26416. return
  26417. }
  26418. return *v, true
  26419. }
  26420. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  26421. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26423. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  26424. if !m.op.Is(OpUpdateOne) {
  26425. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  26426. }
  26427. if m.id == nil || m.oldValue == nil {
  26428. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  26429. }
  26430. oldValue, err := m.oldValue(ctx)
  26431. if err != nil {
  26432. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  26433. }
  26434. return oldValue.SessionKey, nil
  26435. }
  26436. // ResetSessionKey resets all changes to the "session_key" field.
  26437. func (m *WxCardUserMutation) ResetSessionKey() {
  26438. m.session_key = nil
  26439. }
  26440. // SetIsVip sets the "is_vip" field.
  26441. func (m *WxCardUserMutation) SetIsVip(i int) {
  26442. m.is_vip = &i
  26443. m.addis_vip = nil
  26444. }
  26445. // IsVip returns the value of the "is_vip" field in the mutation.
  26446. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  26447. v := m.is_vip
  26448. if v == nil {
  26449. return
  26450. }
  26451. return *v, true
  26452. }
  26453. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  26454. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26456. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  26457. if !m.op.Is(OpUpdateOne) {
  26458. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  26459. }
  26460. if m.id == nil || m.oldValue == nil {
  26461. return v, errors.New("OldIsVip requires an ID field in the mutation")
  26462. }
  26463. oldValue, err := m.oldValue(ctx)
  26464. if err != nil {
  26465. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  26466. }
  26467. return oldValue.IsVip, nil
  26468. }
  26469. // AddIsVip adds i to the "is_vip" field.
  26470. func (m *WxCardUserMutation) AddIsVip(i int) {
  26471. if m.addis_vip != nil {
  26472. *m.addis_vip += i
  26473. } else {
  26474. m.addis_vip = &i
  26475. }
  26476. }
  26477. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  26478. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  26479. v := m.addis_vip
  26480. if v == nil {
  26481. return
  26482. }
  26483. return *v, true
  26484. }
  26485. // ResetIsVip resets all changes to the "is_vip" field.
  26486. func (m *WxCardUserMutation) ResetIsVip() {
  26487. m.is_vip = nil
  26488. m.addis_vip = nil
  26489. }
  26490. // Where appends a list predicates to the WxCardUserMutation builder.
  26491. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  26492. m.predicates = append(m.predicates, ps...)
  26493. }
  26494. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  26495. // users can use type-assertion to append predicates that do not depend on any generated package.
  26496. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  26497. p := make([]predicate.WxCardUser, len(ps))
  26498. for i := range ps {
  26499. p[i] = ps[i]
  26500. }
  26501. m.Where(p...)
  26502. }
  26503. // Op returns the operation name.
  26504. func (m *WxCardUserMutation) Op() Op {
  26505. return m.op
  26506. }
  26507. // SetOp allows setting the mutation operation.
  26508. func (m *WxCardUserMutation) SetOp(op Op) {
  26509. m.op = op
  26510. }
  26511. // Type returns the node type of this mutation (WxCardUser).
  26512. func (m *WxCardUserMutation) Type() string {
  26513. return m.typ
  26514. }
  26515. // Fields returns all fields that were changed during this mutation. Note that in
  26516. // order to get all numeric fields that were incremented/decremented, call
  26517. // AddedFields().
  26518. func (m *WxCardUserMutation) Fields() []string {
  26519. fields := make([]string, 0, 13)
  26520. if m.created_at != nil {
  26521. fields = append(fields, wxcarduser.FieldCreatedAt)
  26522. }
  26523. if m.updated_at != nil {
  26524. fields = append(fields, wxcarduser.FieldUpdatedAt)
  26525. }
  26526. if m.deleted_at != nil {
  26527. fields = append(fields, wxcarduser.FieldDeletedAt)
  26528. }
  26529. if m.wxid != nil {
  26530. fields = append(fields, wxcarduser.FieldWxid)
  26531. }
  26532. if m.account != nil {
  26533. fields = append(fields, wxcarduser.FieldAccount)
  26534. }
  26535. if m.avatar != nil {
  26536. fields = append(fields, wxcarduser.FieldAvatar)
  26537. }
  26538. if m.nickname != nil {
  26539. fields = append(fields, wxcarduser.FieldNickname)
  26540. }
  26541. if m.remark != nil {
  26542. fields = append(fields, wxcarduser.FieldRemark)
  26543. }
  26544. if m.phone != nil {
  26545. fields = append(fields, wxcarduser.FieldPhone)
  26546. }
  26547. if m.open_id != nil {
  26548. fields = append(fields, wxcarduser.FieldOpenID)
  26549. }
  26550. if m.union_id != nil {
  26551. fields = append(fields, wxcarduser.FieldUnionID)
  26552. }
  26553. if m.session_key != nil {
  26554. fields = append(fields, wxcarduser.FieldSessionKey)
  26555. }
  26556. if m.is_vip != nil {
  26557. fields = append(fields, wxcarduser.FieldIsVip)
  26558. }
  26559. return fields
  26560. }
  26561. // Field returns the value of a field with the given name. The second boolean
  26562. // return value indicates that this field was not set, or was not defined in the
  26563. // schema.
  26564. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  26565. switch name {
  26566. case wxcarduser.FieldCreatedAt:
  26567. return m.CreatedAt()
  26568. case wxcarduser.FieldUpdatedAt:
  26569. return m.UpdatedAt()
  26570. case wxcarduser.FieldDeletedAt:
  26571. return m.DeletedAt()
  26572. case wxcarduser.FieldWxid:
  26573. return m.Wxid()
  26574. case wxcarduser.FieldAccount:
  26575. return m.Account()
  26576. case wxcarduser.FieldAvatar:
  26577. return m.Avatar()
  26578. case wxcarduser.FieldNickname:
  26579. return m.Nickname()
  26580. case wxcarduser.FieldRemark:
  26581. return m.Remark()
  26582. case wxcarduser.FieldPhone:
  26583. return m.Phone()
  26584. case wxcarduser.FieldOpenID:
  26585. return m.OpenID()
  26586. case wxcarduser.FieldUnionID:
  26587. return m.UnionID()
  26588. case wxcarduser.FieldSessionKey:
  26589. return m.SessionKey()
  26590. case wxcarduser.FieldIsVip:
  26591. return m.IsVip()
  26592. }
  26593. return nil, false
  26594. }
  26595. // OldField returns the old value of the field from the database. An error is
  26596. // returned if the mutation operation is not UpdateOne, or the query to the
  26597. // database failed.
  26598. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26599. switch name {
  26600. case wxcarduser.FieldCreatedAt:
  26601. return m.OldCreatedAt(ctx)
  26602. case wxcarduser.FieldUpdatedAt:
  26603. return m.OldUpdatedAt(ctx)
  26604. case wxcarduser.FieldDeletedAt:
  26605. return m.OldDeletedAt(ctx)
  26606. case wxcarduser.FieldWxid:
  26607. return m.OldWxid(ctx)
  26608. case wxcarduser.FieldAccount:
  26609. return m.OldAccount(ctx)
  26610. case wxcarduser.FieldAvatar:
  26611. return m.OldAvatar(ctx)
  26612. case wxcarduser.FieldNickname:
  26613. return m.OldNickname(ctx)
  26614. case wxcarduser.FieldRemark:
  26615. return m.OldRemark(ctx)
  26616. case wxcarduser.FieldPhone:
  26617. return m.OldPhone(ctx)
  26618. case wxcarduser.FieldOpenID:
  26619. return m.OldOpenID(ctx)
  26620. case wxcarduser.FieldUnionID:
  26621. return m.OldUnionID(ctx)
  26622. case wxcarduser.FieldSessionKey:
  26623. return m.OldSessionKey(ctx)
  26624. case wxcarduser.FieldIsVip:
  26625. return m.OldIsVip(ctx)
  26626. }
  26627. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  26628. }
  26629. // SetField sets the value of a field with the given name. It returns an error if
  26630. // the field is not defined in the schema, or if the type mismatched the field
  26631. // type.
  26632. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  26633. switch name {
  26634. case wxcarduser.FieldCreatedAt:
  26635. v, ok := value.(time.Time)
  26636. if !ok {
  26637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26638. }
  26639. m.SetCreatedAt(v)
  26640. return nil
  26641. case wxcarduser.FieldUpdatedAt:
  26642. v, ok := value.(time.Time)
  26643. if !ok {
  26644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26645. }
  26646. m.SetUpdatedAt(v)
  26647. return nil
  26648. case wxcarduser.FieldDeletedAt:
  26649. v, ok := value.(time.Time)
  26650. if !ok {
  26651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26652. }
  26653. m.SetDeletedAt(v)
  26654. return nil
  26655. case wxcarduser.FieldWxid:
  26656. v, ok := value.(string)
  26657. if !ok {
  26658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26659. }
  26660. m.SetWxid(v)
  26661. return nil
  26662. case wxcarduser.FieldAccount:
  26663. v, ok := value.(string)
  26664. if !ok {
  26665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26666. }
  26667. m.SetAccount(v)
  26668. return nil
  26669. case wxcarduser.FieldAvatar:
  26670. v, ok := value.(string)
  26671. if !ok {
  26672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26673. }
  26674. m.SetAvatar(v)
  26675. return nil
  26676. case wxcarduser.FieldNickname:
  26677. v, ok := value.(string)
  26678. if !ok {
  26679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26680. }
  26681. m.SetNickname(v)
  26682. return nil
  26683. case wxcarduser.FieldRemark:
  26684. v, ok := value.(string)
  26685. if !ok {
  26686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26687. }
  26688. m.SetRemark(v)
  26689. return nil
  26690. case wxcarduser.FieldPhone:
  26691. v, ok := value.(string)
  26692. if !ok {
  26693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26694. }
  26695. m.SetPhone(v)
  26696. return nil
  26697. case wxcarduser.FieldOpenID:
  26698. v, ok := value.(string)
  26699. if !ok {
  26700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26701. }
  26702. m.SetOpenID(v)
  26703. return nil
  26704. case wxcarduser.FieldUnionID:
  26705. v, ok := value.(string)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.SetUnionID(v)
  26710. return nil
  26711. case wxcarduser.FieldSessionKey:
  26712. v, ok := value.(string)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.SetSessionKey(v)
  26717. return nil
  26718. case wxcarduser.FieldIsVip:
  26719. v, ok := value.(int)
  26720. if !ok {
  26721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26722. }
  26723. m.SetIsVip(v)
  26724. return nil
  26725. }
  26726. return fmt.Errorf("unknown WxCardUser field %s", name)
  26727. }
  26728. // AddedFields returns all numeric fields that were incremented/decremented during
  26729. // this mutation.
  26730. func (m *WxCardUserMutation) AddedFields() []string {
  26731. var fields []string
  26732. if m.addis_vip != nil {
  26733. fields = append(fields, wxcarduser.FieldIsVip)
  26734. }
  26735. return fields
  26736. }
  26737. // AddedField returns the numeric value that was incremented/decremented on a field
  26738. // with the given name. The second boolean return value indicates that this field
  26739. // was not set, or was not defined in the schema.
  26740. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  26741. switch name {
  26742. case wxcarduser.FieldIsVip:
  26743. return m.AddedIsVip()
  26744. }
  26745. return nil, false
  26746. }
  26747. // AddField adds the value to the field with the given name. It returns an error if
  26748. // the field is not defined in the schema, or if the type mismatched the field
  26749. // type.
  26750. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  26751. switch name {
  26752. case wxcarduser.FieldIsVip:
  26753. v, ok := value.(int)
  26754. if !ok {
  26755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26756. }
  26757. m.AddIsVip(v)
  26758. return nil
  26759. }
  26760. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  26761. }
  26762. // ClearedFields returns all nullable fields that were cleared during this
  26763. // mutation.
  26764. func (m *WxCardUserMutation) ClearedFields() []string {
  26765. var fields []string
  26766. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  26767. fields = append(fields, wxcarduser.FieldDeletedAt)
  26768. }
  26769. return fields
  26770. }
  26771. // FieldCleared returns a boolean indicating if a field with the given name was
  26772. // cleared in this mutation.
  26773. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  26774. _, ok := m.clearedFields[name]
  26775. return ok
  26776. }
  26777. // ClearField clears the value of the field with the given name. It returns an
  26778. // error if the field is not defined in the schema.
  26779. func (m *WxCardUserMutation) ClearField(name string) error {
  26780. switch name {
  26781. case wxcarduser.FieldDeletedAt:
  26782. m.ClearDeletedAt()
  26783. return nil
  26784. }
  26785. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  26786. }
  26787. // ResetField resets all changes in the mutation for the field with the given name.
  26788. // It returns an error if the field is not defined in the schema.
  26789. func (m *WxCardUserMutation) ResetField(name string) error {
  26790. switch name {
  26791. case wxcarduser.FieldCreatedAt:
  26792. m.ResetCreatedAt()
  26793. return nil
  26794. case wxcarduser.FieldUpdatedAt:
  26795. m.ResetUpdatedAt()
  26796. return nil
  26797. case wxcarduser.FieldDeletedAt:
  26798. m.ResetDeletedAt()
  26799. return nil
  26800. case wxcarduser.FieldWxid:
  26801. m.ResetWxid()
  26802. return nil
  26803. case wxcarduser.FieldAccount:
  26804. m.ResetAccount()
  26805. return nil
  26806. case wxcarduser.FieldAvatar:
  26807. m.ResetAvatar()
  26808. return nil
  26809. case wxcarduser.FieldNickname:
  26810. m.ResetNickname()
  26811. return nil
  26812. case wxcarduser.FieldRemark:
  26813. m.ResetRemark()
  26814. return nil
  26815. case wxcarduser.FieldPhone:
  26816. m.ResetPhone()
  26817. return nil
  26818. case wxcarduser.FieldOpenID:
  26819. m.ResetOpenID()
  26820. return nil
  26821. case wxcarduser.FieldUnionID:
  26822. m.ResetUnionID()
  26823. return nil
  26824. case wxcarduser.FieldSessionKey:
  26825. m.ResetSessionKey()
  26826. return nil
  26827. case wxcarduser.FieldIsVip:
  26828. m.ResetIsVip()
  26829. return nil
  26830. }
  26831. return fmt.Errorf("unknown WxCardUser field %s", name)
  26832. }
  26833. // AddedEdges returns all edge names that were set/added in this mutation.
  26834. func (m *WxCardUserMutation) AddedEdges() []string {
  26835. edges := make([]string, 0, 0)
  26836. return edges
  26837. }
  26838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26839. // name in this mutation.
  26840. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  26841. return nil
  26842. }
  26843. // RemovedEdges returns all edge names that were removed in this mutation.
  26844. func (m *WxCardUserMutation) RemovedEdges() []string {
  26845. edges := make([]string, 0, 0)
  26846. return edges
  26847. }
  26848. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26849. // the given name in this mutation.
  26850. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  26851. return nil
  26852. }
  26853. // ClearedEdges returns all edge names that were cleared in this mutation.
  26854. func (m *WxCardUserMutation) ClearedEdges() []string {
  26855. edges := make([]string, 0, 0)
  26856. return edges
  26857. }
  26858. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26859. // was cleared in this mutation.
  26860. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  26861. return false
  26862. }
  26863. // ClearEdge clears the value of the edge with the given name. It returns an error
  26864. // if that edge is not defined in the schema.
  26865. func (m *WxCardUserMutation) ClearEdge(name string) error {
  26866. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  26867. }
  26868. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26869. // It returns an error if the edge is not defined in the schema.
  26870. func (m *WxCardUserMutation) ResetEdge(name string) error {
  26871. return fmt.Errorf("unknown WxCardUser edge %s", name)
  26872. }
  26873. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  26874. type WxCardVisitMutation struct {
  26875. config
  26876. op Op
  26877. typ string
  26878. id *uint64
  26879. created_at *time.Time
  26880. updated_at *time.Time
  26881. deleted_at *time.Time
  26882. user_id *uint64
  26883. adduser_id *int64
  26884. bot_id *uint64
  26885. addbot_id *int64
  26886. bot_type *uint8
  26887. addbot_type *int8
  26888. clearedFields map[string]struct{}
  26889. done bool
  26890. oldValue func(context.Context) (*WxCardVisit, error)
  26891. predicates []predicate.WxCardVisit
  26892. }
  26893. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  26894. // wxcardvisitOption allows management of the mutation configuration using functional options.
  26895. type wxcardvisitOption func(*WxCardVisitMutation)
  26896. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  26897. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  26898. m := &WxCardVisitMutation{
  26899. config: c,
  26900. op: op,
  26901. typ: TypeWxCardVisit,
  26902. clearedFields: make(map[string]struct{}),
  26903. }
  26904. for _, opt := range opts {
  26905. opt(m)
  26906. }
  26907. return m
  26908. }
  26909. // withWxCardVisitID sets the ID field of the mutation.
  26910. func withWxCardVisitID(id uint64) wxcardvisitOption {
  26911. return func(m *WxCardVisitMutation) {
  26912. var (
  26913. err error
  26914. once sync.Once
  26915. value *WxCardVisit
  26916. )
  26917. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  26918. once.Do(func() {
  26919. if m.done {
  26920. err = errors.New("querying old values post mutation is not allowed")
  26921. } else {
  26922. value, err = m.Client().WxCardVisit.Get(ctx, id)
  26923. }
  26924. })
  26925. return value, err
  26926. }
  26927. m.id = &id
  26928. }
  26929. }
  26930. // withWxCardVisit sets the old WxCardVisit of the mutation.
  26931. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  26932. return func(m *WxCardVisitMutation) {
  26933. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  26934. return node, nil
  26935. }
  26936. m.id = &node.ID
  26937. }
  26938. }
  26939. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26940. // executed in a transaction (ent.Tx), a transactional client is returned.
  26941. func (m WxCardVisitMutation) Client() *Client {
  26942. client := &Client{config: m.config}
  26943. client.init()
  26944. return client
  26945. }
  26946. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26947. // it returns an error otherwise.
  26948. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  26949. if _, ok := m.driver.(*txDriver); !ok {
  26950. return nil, errors.New("ent: mutation is not running in a transaction")
  26951. }
  26952. tx := &Tx{config: m.config}
  26953. tx.init()
  26954. return tx, nil
  26955. }
  26956. // SetID sets the value of the id field. Note that this
  26957. // operation is only accepted on creation of WxCardVisit entities.
  26958. func (m *WxCardVisitMutation) SetID(id uint64) {
  26959. m.id = &id
  26960. }
  26961. // ID returns the ID value in the mutation. Note that the ID is only available
  26962. // if it was provided to the builder or after it was returned from the database.
  26963. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  26964. if m.id == nil {
  26965. return
  26966. }
  26967. return *m.id, true
  26968. }
  26969. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26970. // That means, if the mutation is applied within a transaction with an isolation level such
  26971. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26972. // or updated by the mutation.
  26973. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  26974. switch {
  26975. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26976. id, exists := m.ID()
  26977. if exists {
  26978. return []uint64{id}, nil
  26979. }
  26980. fallthrough
  26981. case m.op.Is(OpUpdate | OpDelete):
  26982. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  26983. default:
  26984. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26985. }
  26986. }
  26987. // SetCreatedAt sets the "created_at" field.
  26988. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  26989. m.created_at = &t
  26990. }
  26991. // CreatedAt returns the value of the "created_at" field in the mutation.
  26992. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  26993. v := m.created_at
  26994. if v == nil {
  26995. return
  26996. }
  26997. return *v, true
  26998. }
  26999. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  27000. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27002. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27003. if !m.op.Is(OpUpdateOne) {
  27004. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27005. }
  27006. if m.id == nil || m.oldValue == nil {
  27007. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27008. }
  27009. oldValue, err := m.oldValue(ctx)
  27010. if err != nil {
  27011. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27012. }
  27013. return oldValue.CreatedAt, nil
  27014. }
  27015. // ResetCreatedAt resets all changes to the "created_at" field.
  27016. func (m *WxCardVisitMutation) ResetCreatedAt() {
  27017. m.created_at = nil
  27018. }
  27019. // SetUpdatedAt sets the "updated_at" field.
  27020. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  27021. m.updated_at = &t
  27022. }
  27023. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27024. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  27025. v := m.updated_at
  27026. if v == nil {
  27027. return
  27028. }
  27029. return *v, true
  27030. }
  27031. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  27032. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27034. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27035. if !m.op.Is(OpUpdateOne) {
  27036. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27037. }
  27038. if m.id == nil || m.oldValue == nil {
  27039. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27040. }
  27041. oldValue, err := m.oldValue(ctx)
  27042. if err != nil {
  27043. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27044. }
  27045. return oldValue.UpdatedAt, nil
  27046. }
  27047. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27048. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  27049. m.updated_at = nil
  27050. }
  27051. // SetDeletedAt sets the "deleted_at" field.
  27052. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  27053. m.deleted_at = &t
  27054. }
  27055. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27056. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  27057. v := m.deleted_at
  27058. if v == nil {
  27059. return
  27060. }
  27061. return *v, true
  27062. }
  27063. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  27064. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27066. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27067. if !m.op.Is(OpUpdateOne) {
  27068. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27069. }
  27070. if m.id == nil || m.oldValue == nil {
  27071. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27072. }
  27073. oldValue, err := m.oldValue(ctx)
  27074. if err != nil {
  27075. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27076. }
  27077. return oldValue.DeletedAt, nil
  27078. }
  27079. // ClearDeletedAt clears the value of the "deleted_at" field.
  27080. func (m *WxCardVisitMutation) ClearDeletedAt() {
  27081. m.deleted_at = nil
  27082. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  27083. }
  27084. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27085. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  27086. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  27087. return ok
  27088. }
  27089. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27090. func (m *WxCardVisitMutation) ResetDeletedAt() {
  27091. m.deleted_at = nil
  27092. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  27093. }
  27094. // SetUserID sets the "user_id" field.
  27095. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  27096. m.user_id = &u
  27097. m.adduser_id = nil
  27098. }
  27099. // UserID returns the value of the "user_id" field in the mutation.
  27100. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  27101. v := m.user_id
  27102. if v == nil {
  27103. return
  27104. }
  27105. return *v, true
  27106. }
  27107. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  27108. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27110. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  27111. if !m.op.Is(OpUpdateOne) {
  27112. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  27113. }
  27114. if m.id == nil || m.oldValue == nil {
  27115. return v, errors.New("OldUserID requires an ID field in the mutation")
  27116. }
  27117. oldValue, err := m.oldValue(ctx)
  27118. if err != nil {
  27119. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  27120. }
  27121. return oldValue.UserID, nil
  27122. }
  27123. // AddUserID adds u to the "user_id" field.
  27124. func (m *WxCardVisitMutation) AddUserID(u int64) {
  27125. if m.adduser_id != nil {
  27126. *m.adduser_id += u
  27127. } else {
  27128. m.adduser_id = &u
  27129. }
  27130. }
  27131. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  27132. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  27133. v := m.adduser_id
  27134. if v == nil {
  27135. return
  27136. }
  27137. return *v, true
  27138. }
  27139. // ClearUserID clears the value of the "user_id" field.
  27140. func (m *WxCardVisitMutation) ClearUserID() {
  27141. m.user_id = nil
  27142. m.adduser_id = nil
  27143. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  27144. }
  27145. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  27146. func (m *WxCardVisitMutation) UserIDCleared() bool {
  27147. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  27148. return ok
  27149. }
  27150. // ResetUserID resets all changes to the "user_id" field.
  27151. func (m *WxCardVisitMutation) ResetUserID() {
  27152. m.user_id = nil
  27153. m.adduser_id = nil
  27154. delete(m.clearedFields, wxcardvisit.FieldUserID)
  27155. }
  27156. // SetBotID sets the "bot_id" field.
  27157. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  27158. m.bot_id = &u
  27159. m.addbot_id = nil
  27160. }
  27161. // BotID returns the value of the "bot_id" field in the mutation.
  27162. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  27163. v := m.bot_id
  27164. if v == nil {
  27165. return
  27166. }
  27167. return *v, true
  27168. }
  27169. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  27170. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27172. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  27173. if !m.op.Is(OpUpdateOne) {
  27174. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27175. }
  27176. if m.id == nil || m.oldValue == nil {
  27177. return v, errors.New("OldBotID requires an ID field in the mutation")
  27178. }
  27179. oldValue, err := m.oldValue(ctx)
  27180. if err != nil {
  27181. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27182. }
  27183. return oldValue.BotID, nil
  27184. }
  27185. // AddBotID adds u to the "bot_id" field.
  27186. func (m *WxCardVisitMutation) AddBotID(u int64) {
  27187. if m.addbot_id != nil {
  27188. *m.addbot_id += u
  27189. } else {
  27190. m.addbot_id = &u
  27191. }
  27192. }
  27193. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  27194. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  27195. v := m.addbot_id
  27196. if v == nil {
  27197. return
  27198. }
  27199. return *v, true
  27200. }
  27201. // ResetBotID resets all changes to the "bot_id" field.
  27202. func (m *WxCardVisitMutation) ResetBotID() {
  27203. m.bot_id = nil
  27204. m.addbot_id = nil
  27205. }
  27206. // SetBotType sets the "bot_type" field.
  27207. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  27208. m.bot_type = &u
  27209. m.addbot_type = nil
  27210. }
  27211. // BotType returns the value of the "bot_type" field in the mutation.
  27212. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  27213. v := m.bot_type
  27214. if v == nil {
  27215. return
  27216. }
  27217. return *v, true
  27218. }
  27219. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  27220. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27222. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  27223. if !m.op.Is(OpUpdateOne) {
  27224. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  27225. }
  27226. if m.id == nil || m.oldValue == nil {
  27227. return v, errors.New("OldBotType requires an ID field in the mutation")
  27228. }
  27229. oldValue, err := m.oldValue(ctx)
  27230. if err != nil {
  27231. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  27232. }
  27233. return oldValue.BotType, nil
  27234. }
  27235. // AddBotType adds u to the "bot_type" field.
  27236. func (m *WxCardVisitMutation) AddBotType(u int8) {
  27237. if m.addbot_type != nil {
  27238. *m.addbot_type += u
  27239. } else {
  27240. m.addbot_type = &u
  27241. }
  27242. }
  27243. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  27244. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  27245. v := m.addbot_type
  27246. if v == nil {
  27247. return
  27248. }
  27249. return *v, true
  27250. }
  27251. // ResetBotType resets all changes to the "bot_type" field.
  27252. func (m *WxCardVisitMutation) ResetBotType() {
  27253. m.bot_type = nil
  27254. m.addbot_type = nil
  27255. }
  27256. // Where appends a list predicates to the WxCardVisitMutation builder.
  27257. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  27258. m.predicates = append(m.predicates, ps...)
  27259. }
  27260. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  27261. // users can use type-assertion to append predicates that do not depend on any generated package.
  27262. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  27263. p := make([]predicate.WxCardVisit, len(ps))
  27264. for i := range ps {
  27265. p[i] = ps[i]
  27266. }
  27267. m.Where(p...)
  27268. }
  27269. // Op returns the operation name.
  27270. func (m *WxCardVisitMutation) Op() Op {
  27271. return m.op
  27272. }
  27273. // SetOp allows setting the mutation operation.
  27274. func (m *WxCardVisitMutation) SetOp(op Op) {
  27275. m.op = op
  27276. }
  27277. // Type returns the node type of this mutation (WxCardVisit).
  27278. func (m *WxCardVisitMutation) Type() string {
  27279. return m.typ
  27280. }
  27281. // Fields returns all fields that were changed during this mutation. Note that in
  27282. // order to get all numeric fields that were incremented/decremented, call
  27283. // AddedFields().
  27284. func (m *WxCardVisitMutation) Fields() []string {
  27285. fields := make([]string, 0, 6)
  27286. if m.created_at != nil {
  27287. fields = append(fields, wxcardvisit.FieldCreatedAt)
  27288. }
  27289. if m.updated_at != nil {
  27290. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  27291. }
  27292. if m.deleted_at != nil {
  27293. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27294. }
  27295. if m.user_id != nil {
  27296. fields = append(fields, wxcardvisit.FieldUserID)
  27297. }
  27298. if m.bot_id != nil {
  27299. fields = append(fields, wxcardvisit.FieldBotID)
  27300. }
  27301. if m.bot_type != nil {
  27302. fields = append(fields, wxcardvisit.FieldBotType)
  27303. }
  27304. return fields
  27305. }
  27306. // Field returns the value of a field with the given name. The second boolean
  27307. // return value indicates that this field was not set, or was not defined in the
  27308. // schema.
  27309. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  27310. switch name {
  27311. case wxcardvisit.FieldCreatedAt:
  27312. return m.CreatedAt()
  27313. case wxcardvisit.FieldUpdatedAt:
  27314. return m.UpdatedAt()
  27315. case wxcardvisit.FieldDeletedAt:
  27316. return m.DeletedAt()
  27317. case wxcardvisit.FieldUserID:
  27318. return m.UserID()
  27319. case wxcardvisit.FieldBotID:
  27320. return m.BotID()
  27321. case wxcardvisit.FieldBotType:
  27322. return m.BotType()
  27323. }
  27324. return nil, false
  27325. }
  27326. // OldField returns the old value of the field from the database. An error is
  27327. // returned if the mutation operation is not UpdateOne, or the query to the
  27328. // database failed.
  27329. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27330. switch name {
  27331. case wxcardvisit.FieldCreatedAt:
  27332. return m.OldCreatedAt(ctx)
  27333. case wxcardvisit.FieldUpdatedAt:
  27334. return m.OldUpdatedAt(ctx)
  27335. case wxcardvisit.FieldDeletedAt:
  27336. return m.OldDeletedAt(ctx)
  27337. case wxcardvisit.FieldUserID:
  27338. return m.OldUserID(ctx)
  27339. case wxcardvisit.FieldBotID:
  27340. return m.OldBotID(ctx)
  27341. case wxcardvisit.FieldBotType:
  27342. return m.OldBotType(ctx)
  27343. }
  27344. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  27345. }
  27346. // SetField sets the value of a field with the given name. It returns an error if
  27347. // the field is not defined in the schema, or if the type mismatched the field
  27348. // type.
  27349. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  27350. switch name {
  27351. case wxcardvisit.FieldCreatedAt:
  27352. v, ok := value.(time.Time)
  27353. if !ok {
  27354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27355. }
  27356. m.SetCreatedAt(v)
  27357. return nil
  27358. case wxcardvisit.FieldUpdatedAt:
  27359. v, ok := value.(time.Time)
  27360. if !ok {
  27361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27362. }
  27363. m.SetUpdatedAt(v)
  27364. return nil
  27365. case wxcardvisit.FieldDeletedAt:
  27366. v, ok := value.(time.Time)
  27367. if !ok {
  27368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27369. }
  27370. m.SetDeletedAt(v)
  27371. return nil
  27372. case wxcardvisit.FieldUserID:
  27373. v, ok := value.(uint64)
  27374. if !ok {
  27375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27376. }
  27377. m.SetUserID(v)
  27378. return nil
  27379. case wxcardvisit.FieldBotID:
  27380. v, ok := value.(uint64)
  27381. if !ok {
  27382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27383. }
  27384. m.SetBotID(v)
  27385. return nil
  27386. case wxcardvisit.FieldBotType:
  27387. v, ok := value.(uint8)
  27388. if !ok {
  27389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27390. }
  27391. m.SetBotType(v)
  27392. return nil
  27393. }
  27394. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27395. }
  27396. // AddedFields returns all numeric fields that were incremented/decremented during
  27397. // this mutation.
  27398. func (m *WxCardVisitMutation) AddedFields() []string {
  27399. var fields []string
  27400. if m.adduser_id != nil {
  27401. fields = append(fields, wxcardvisit.FieldUserID)
  27402. }
  27403. if m.addbot_id != nil {
  27404. fields = append(fields, wxcardvisit.FieldBotID)
  27405. }
  27406. if m.addbot_type != nil {
  27407. fields = append(fields, wxcardvisit.FieldBotType)
  27408. }
  27409. return fields
  27410. }
  27411. // AddedField returns the numeric value that was incremented/decremented on a field
  27412. // with the given name. The second boolean return value indicates that this field
  27413. // was not set, or was not defined in the schema.
  27414. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  27415. switch name {
  27416. case wxcardvisit.FieldUserID:
  27417. return m.AddedUserID()
  27418. case wxcardvisit.FieldBotID:
  27419. return m.AddedBotID()
  27420. case wxcardvisit.FieldBotType:
  27421. return m.AddedBotType()
  27422. }
  27423. return nil, false
  27424. }
  27425. // AddField adds the value to the field with the given name. It returns an error if
  27426. // the field is not defined in the schema, or if the type mismatched the field
  27427. // type.
  27428. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  27429. switch name {
  27430. case wxcardvisit.FieldUserID:
  27431. v, ok := value.(int64)
  27432. if !ok {
  27433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27434. }
  27435. m.AddUserID(v)
  27436. return nil
  27437. case wxcardvisit.FieldBotID:
  27438. v, ok := value.(int64)
  27439. if !ok {
  27440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27441. }
  27442. m.AddBotID(v)
  27443. return nil
  27444. case wxcardvisit.FieldBotType:
  27445. v, ok := value.(int8)
  27446. if !ok {
  27447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27448. }
  27449. m.AddBotType(v)
  27450. return nil
  27451. }
  27452. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  27453. }
  27454. // ClearedFields returns all nullable fields that were cleared during this
  27455. // mutation.
  27456. func (m *WxCardVisitMutation) ClearedFields() []string {
  27457. var fields []string
  27458. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  27459. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27460. }
  27461. if m.FieldCleared(wxcardvisit.FieldUserID) {
  27462. fields = append(fields, wxcardvisit.FieldUserID)
  27463. }
  27464. return fields
  27465. }
  27466. // FieldCleared returns a boolean indicating if a field with the given name was
  27467. // cleared in this mutation.
  27468. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  27469. _, ok := m.clearedFields[name]
  27470. return ok
  27471. }
  27472. // ClearField clears the value of the field with the given name. It returns an
  27473. // error if the field is not defined in the schema.
  27474. func (m *WxCardVisitMutation) ClearField(name string) error {
  27475. switch name {
  27476. case wxcardvisit.FieldDeletedAt:
  27477. m.ClearDeletedAt()
  27478. return nil
  27479. case wxcardvisit.FieldUserID:
  27480. m.ClearUserID()
  27481. return nil
  27482. }
  27483. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  27484. }
  27485. // ResetField resets all changes in the mutation for the field with the given name.
  27486. // It returns an error if the field is not defined in the schema.
  27487. func (m *WxCardVisitMutation) ResetField(name string) error {
  27488. switch name {
  27489. case wxcardvisit.FieldCreatedAt:
  27490. m.ResetCreatedAt()
  27491. return nil
  27492. case wxcardvisit.FieldUpdatedAt:
  27493. m.ResetUpdatedAt()
  27494. return nil
  27495. case wxcardvisit.FieldDeletedAt:
  27496. m.ResetDeletedAt()
  27497. return nil
  27498. case wxcardvisit.FieldUserID:
  27499. m.ResetUserID()
  27500. return nil
  27501. case wxcardvisit.FieldBotID:
  27502. m.ResetBotID()
  27503. return nil
  27504. case wxcardvisit.FieldBotType:
  27505. m.ResetBotType()
  27506. return nil
  27507. }
  27508. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27509. }
  27510. // AddedEdges returns all edge names that were set/added in this mutation.
  27511. func (m *WxCardVisitMutation) AddedEdges() []string {
  27512. edges := make([]string, 0, 0)
  27513. return edges
  27514. }
  27515. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27516. // name in this mutation.
  27517. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  27518. return nil
  27519. }
  27520. // RemovedEdges returns all edge names that were removed in this mutation.
  27521. func (m *WxCardVisitMutation) RemovedEdges() []string {
  27522. edges := make([]string, 0, 0)
  27523. return edges
  27524. }
  27525. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27526. // the given name in this mutation.
  27527. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  27528. return nil
  27529. }
  27530. // ClearedEdges returns all edge names that were cleared in this mutation.
  27531. func (m *WxCardVisitMutation) ClearedEdges() []string {
  27532. edges := make([]string, 0, 0)
  27533. return edges
  27534. }
  27535. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27536. // was cleared in this mutation.
  27537. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  27538. return false
  27539. }
  27540. // ClearEdge clears the value of the edge with the given name. It returns an error
  27541. // if that edge is not defined in the schema.
  27542. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  27543. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  27544. }
  27545. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27546. // It returns an error if the edge is not defined in the schema.
  27547. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  27548. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  27549. }