mutation.go 888 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085
  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. done bool
  99. oldValue func(context.Context) (*Agent, error)
  100. predicates []predicate.Agent
  101. }
  102. var _ ent.Mutation = (*AgentMutation)(nil)
  103. // agentOption allows management of the mutation configuration using functional options.
  104. type agentOption func(*AgentMutation)
  105. // newAgentMutation creates new mutation for the Agent entity.
  106. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  107. m := &AgentMutation{
  108. config: c,
  109. op: op,
  110. typ: TypeAgent,
  111. clearedFields: make(map[string]struct{}),
  112. }
  113. for _, opt := range opts {
  114. opt(m)
  115. }
  116. return m
  117. }
  118. // withAgentID sets the ID field of the mutation.
  119. func withAgentID(id uint64) agentOption {
  120. return func(m *AgentMutation) {
  121. var (
  122. err error
  123. once sync.Once
  124. value *Agent
  125. )
  126. m.oldValue = func(ctx context.Context) (*Agent, error) {
  127. once.Do(func() {
  128. if m.done {
  129. err = errors.New("querying old values post mutation is not allowed")
  130. } else {
  131. value, err = m.Client().Agent.Get(ctx, id)
  132. }
  133. })
  134. return value, err
  135. }
  136. m.id = &id
  137. }
  138. }
  139. // withAgent sets the old Agent of the mutation.
  140. func withAgent(node *Agent) agentOption {
  141. return func(m *AgentMutation) {
  142. m.oldValue = func(context.Context) (*Agent, error) {
  143. return node, nil
  144. }
  145. m.id = &node.ID
  146. }
  147. }
  148. // Client returns a new `ent.Client` from the mutation. If the mutation was
  149. // executed in a transaction (ent.Tx), a transactional client is returned.
  150. func (m AgentMutation) Client() *Client {
  151. client := &Client{config: m.config}
  152. client.init()
  153. return client
  154. }
  155. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  156. // it returns an error otherwise.
  157. func (m AgentMutation) Tx() (*Tx, error) {
  158. if _, ok := m.driver.(*txDriver); !ok {
  159. return nil, errors.New("ent: mutation is not running in a transaction")
  160. }
  161. tx := &Tx{config: m.config}
  162. tx.init()
  163. return tx, nil
  164. }
  165. // SetID sets the value of the id field. Note that this
  166. // operation is only accepted on creation of Agent entities.
  167. func (m *AgentMutation) SetID(id uint64) {
  168. m.id = &id
  169. }
  170. // ID returns the ID value in the mutation. Note that the ID is only available
  171. // if it was provided to the builder or after it was returned from the database.
  172. func (m *AgentMutation) ID() (id uint64, exists bool) {
  173. if m.id == nil {
  174. return
  175. }
  176. return *m.id, true
  177. }
  178. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  179. // That means, if the mutation is applied within a transaction with an isolation level such
  180. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  181. // or updated by the mutation.
  182. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  183. switch {
  184. case m.op.Is(OpUpdateOne | OpDeleteOne):
  185. id, exists := m.ID()
  186. if exists {
  187. return []uint64{id}, nil
  188. }
  189. fallthrough
  190. case m.op.Is(OpUpdate | OpDelete):
  191. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  192. default:
  193. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  194. }
  195. }
  196. // SetCreatedAt sets the "created_at" field.
  197. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  198. m.created_at = &t
  199. }
  200. // CreatedAt returns the value of the "created_at" field in the mutation.
  201. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  202. v := m.created_at
  203. if v == nil {
  204. return
  205. }
  206. return *v, true
  207. }
  208. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  209. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  211. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  212. if !m.op.Is(OpUpdateOne) {
  213. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  214. }
  215. if m.id == nil || m.oldValue == nil {
  216. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  217. }
  218. oldValue, err := m.oldValue(ctx)
  219. if err != nil {
  220. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  221. }
  222. return oldValue.CreatedAt, nil
  223. }
  224. // ResetCreatedAt resets all changes to the "created_at" field.
  225. func (m *AgentMutation) ResetCreatedAt() {
  226. m.created_at = nil
  227. }
  228. // SetUpdatedAt sets the "updated_at" field.
  229. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  230. m.updated_at = &t
  231. }
  232. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  233. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  234. v := m.updated_at
  235. if v == nil {
  236. return
  237. }
  238. return *v, true
  239. }
  240. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  241. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  243. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  244. if !m.op.Is(OpUpdateOne) {
  245. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  246. }
  247. if m.id == nil || m.oldValue == nil {
  248. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  249. }
  250. oldValue, err := m.oldValue(ctx)
  251. if err != nil {
  252. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  253. }
  254. return oldValue.UpdatedAt, nil
  255. }
  256. // ResetUpdatedAt resets all changes to the "updated_at" field.
  257. func (m *AgentMutation) ResetUpdatedAt() {
  258. m.updated_at = nil
  259. }
  260. // SetDeletedAt sets the "deleted_at" field.
  261. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  262. m.deleted_at = &t
  263. }
  264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  265. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  266. v := m.deleted_at
  267. if v == nil {
  268. return
  269. }
  270. return *v, true
  271. }
  272. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  273. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  275. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  276. if !m.op.Is(OpUpdateOne) {
  277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  278. }
  279. if m.id == nil || m.oldValue == nil {
  280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  281. }
  282. oldValue, err := m.oldValue(ctx)
  283. if err != nil {
  284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  285. }
  286. return oldValue.DeletedAt, nil
  287. }
  288. // ClearDeletedAt clears the value of the "deleted_at" field.
  289. func (m *AgentMutation) ClearDeletedAt() {
  290. m.deleted_at = nil
  291. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  292. }
  293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  294. func (m *AgentMutation) DeletedAtCleared() bool {
  295. _, ok := m.clearedFields[agent.FieldDeletedAt]
  296. return ok
  297. }
  298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  299. func (m *AgentMutation) ResetDeletedAt() {
  300. m.deleted_at = nil
  301. delete(m.clearedFields, agent.FieldDeletedAt)
  302. }
  303. // SetName sets the "name" field.
  304. func (m *AgentMutation) SetName(s string) {
  305. m.name = &s
  306. }
  307. // Name returns the value of the "name" field in the mutation.
  308. func (m *AgentMutation) Name() (r string, exists bool) {
  309. v := m.name
  310. if v == nil {
  311. return
  312. }
  313. return *v, true
  314. }
  315. // OldName returns the old "name" field's value of the Agent entity.
  316. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  318. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  319. if !m.op.Is(OpUpdateOne) {
  320. return v, errors.New("OldName is only allowed on UpdateOne operations")
  321. }
  322. if m.id == nil || m.oldValue == nil {
  323. return v, errors.New("OldName requires an ID field in the mutation")
  324. }
  325. oldValue, err := m.oldValue(ctx)
  326. if err != nil {
  327. return v, fmt.Errorf("querying old value for OldName: %w", err)
  328. }
  329. return oldValue.Name, nil
  330. }
  331. // ResetName resets all changes to the "name" field.
  332. func (m *AgentMutation) ResetName() {
  333. m.name = nil
  334. }
  335. // SetRole sets the "role" field.
  336. func (m *AgentMutation) SetRole(s string) {
  337. m.role = &s
  338. }
  339. // Role returns the value of the "role" field in the mutation.
  340. func (m *AgentMutation) Role() (r string, exists bool) {
  341. v := m.role
  342. if v == nil {
  343. return
  344. }
  345. return *v, true
  346. }
  347. // OldRole returns the old "role" field's value of the Agent entity.
  348. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  350. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  351. if !m.op.Is(OpUpdateOne) {
  352. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  353. }
  354. if m.id == nil || m.oldValue == nil {
  355. return v, errors.New("OldRole requires an ID field in the mutation")
  356. }
  357. oldValue, err := m.oldValue(ctx)
  358. if err != nil {
  359. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  360. }
  361. return oldValue.Role, nil
  362. }
  363. // ResetRole resets all changes to the "role" field.
  364. func (m *AgentMutation) ResetRole() {
  365. m.role = nil
  366. }
  367. // SetStatus sets the "status" field.
  368. func (m *AgentMutation) SetStatus(i int) {
  369. m.status = &i
  370. m.addstatus = nil
  371. }
  372. // Status returns the value of the "status" field in the mutation.
  373. func (m *AgentMutation) Status() (r int, exists bool) {
  374. v := m.status
  375. if v == nil {
  376. return
  377. }
  378. return *v, true
  379. }
  380. // OldStatus returns the old "status" field's value of the Agent entity.
  381. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  383. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  384. if !m.op.Is(OpUpdateOne) {
  385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  386. }
  387. if m.id == nil || m.oldValue == nil {
  388. return v, errors.New("OldStatus requires an ID field in the mutation")
  389. }
  390. oldValue, err := m.oldValue(ctx)
  391. if err != nil {
  392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  393. }
  394. return oldValue.Status, nil
  395. }
  396. // AddStatus adds i to the "status" field.
  397. func (m *AgentMutation) AddStatus(i int) {
  398. if m.addstatus != nil {
  399. *m.addstatus += i
  400. } else {
  401. m.addstatus = &i
  402. }
  403. }
  404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  405. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  406. v := m.addstatus
  407. if v == nil {
  408. return
  409. }
  410. return *v, true
  411. }
  412. // ClearStatus clears the value of the "status" field.
  413. func (m *AgentMutation) ClearStatus() {
  414. m.status = nil
  415. m.addstatus = nil
  416. m.clearedFields[agent.FieldStatus] = struct{}{}
  417. }
  418. // StatusCleared returns if the "status" field was cleared in this mutation.
  419. func (m *AgentMutation) StatusCleared() bool {
  420. _, ok := m.clearedFields[agent.FieldStatus]
  421. return ok
  422. }
  423. // ResetStatus resets all changes to the "status" field.
  424. func (m *AgentMutation) ResetStatus() {
  425. m.status = nil
  426. m.addstatus = nil
  427. delete(m.clearedFields, agent.FieldStatus)
  428. }
  429. // SetBackground sets the "background" field.
  430. func (m *AgentMutation) SetBackground(s string) {
  431. m.background = &s
  432. }
  433. // Background returns the value of the "background" field in the mutation.
  434. func (m *AgentMutation) Background() (r string, exists bool) {
  435. v := m.background
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // OldBackground returns the old "background" field's value of the Agent entity.
  442. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  444. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  445. if !m.op.Is(OpUpdateOne) {
  446. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  447. }
  448. if m.id == nil || m.oldValue == nil {
  449. return v, errors.New("OldBackground requires an ID field in the mutation")
  450. }
  451. oldValue, err := m.oldValue(ctx)
  452. if err != nil {
  453. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  454. }
  455. return oldValue.Background, nil
  456. }
  457. // ClearBackground clears the value of the "background" field.
  458. func (m *AgentMutation) ClearBackground() {
  459. m.background = nil
  460. m.clearedFields[agent.FieldBackground] = struct{}{}
  461. }
  462. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  463. func (m *AgentMutation) BackgroundCleared() bool {
  464. _, ok := m.clearedFields[agent.FieldBackground]
  465. return ok
  466. }
  467. // ResetBackground resets all changes to the "background" field.
  468. func (m *AgentMutation) ResetBackground() {
  469. m.background = nil
  470. delete(m.clearedFields, agent.FieldBackground)
  471. }
  472. // SetExamples sets the "examples" field.
  473. func (m *AgentMutation) SetExamples(s string) {
  474. m.examples = &s
  475. }
  476. // Examples returns the value of the "examples" field in the mutation.
  477. func (m *AgentMutation) Examples() (r string, exists bool) {
  478. v := m.examples
  479. if v == nil {
  480. return
  481. }
  482. return *v, true
  483. }
  484. // OldExamples returns the old "examples" field's value of the Agent entity.
  485. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  487. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  488. if !m.op.Is(OpUpdateOne) {
  489. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  490. }
  491. if m.id == nil || m.oldValue == nil {
  492. return v, errors.New("OldExamples requires an ID field in the mutation")
  493. }
  494. oldValue, err := m.oldValue(ctx)
  495. if err != nil {
  496. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  497. }
  498. return oldValue.Examples, nil
  499. }
  500. // ClearExamples clears the value of the "examples" field.
  501. func (m *AgentMutation) ClearExamples() {
  502. m.examples = nil
  503. m.clearedFields[agent.FieldExamples] = struct{}{}
  504. }
  505. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  506. func (m *AgentMutation) ExamplesCleared() bool {
  507. _, ok := m.clearedFields[agent.FieldExamples]
  508. return ok
  509. }
  510. // ResetExamples resets all changes to the "examples" field.
  511. func (m *AgentMutation) ResetExamples() {
  512. m.examples = nil
  513. delete(m.clearedFields, agent.FieldExamples)
  514. }
  515. // SetOrganizationID sets the "organization_id" field.
  516. func (m *AgentMutation) SetOrganizationID(u uint64) {
  517. m.organization_id = &u
  518. m.addorganization_id = nil
  519. }
  520. // OrganizationID returns the value of the "organization_id" field in the mutation.
  521. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  522. v := m.organization_id
  523. if v == nil {
  524. return
  525. }
  526. return *v, true
  527. }
  528. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  529. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  531. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  532. if !m.op.Is(OpUpdateOne) {
  533. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  534. }
  535. if m.id == nil || m.oldValue == nil {
  536. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  537. }
  538. oldValue, err := m.oldValue(ctx)
  539. if err != nil {
  540. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  541. }
  542. return oldValue.OrganizationID, nil
  543. }
  544. // AddOrganizationID adds u to the "organization_id" field.
  545. func (m *AgentMutation) AddOrganizationID(u int64) {
  546. if m.addorganization_id != nil {
  547. *m.addorganization_id += u
  548. } else {
  549. m.addorganization_id = &u
  550. }
  551. }
  552. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  553. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  554. v := m.addorganization_id
  555. if v == nil {
  556. return
  557. }
  558. return *v, true
  559. }
  560. // ResetOrganizationID resets all changes to the "organization_id" field.
  561. func (m *AgentMutation) ResetOrganizationID() {
  562. m.organization_id = nil
  563. m.addorganization_id = nil
  564. }
  565. // SetDatasetID sets the "dataset_id" field.
  566. func (m *AgentMutation) SetDatasetID(s string) {
  567. m.dataset_id = &s
  568. }
  569. // DatasetID returns the value of the "dataset_id" field in the mutation.
  570. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  571. v := m.dataset_id
  572. if v == nil {
  573. return
  574. }
  575. return *v, true
  576. }
  577. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  578. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  580. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  581. if !m.op.Is(OpUpdateOne) {
  582. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  583. }
  584. if m.id == nil || m.oldValue == nil {
  585. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  586. }
  587. oldValue, err := m.oldValue(ctx)
  588. if err != nil {
  589. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  590. }
  591. return oldValue.DatasetID, nil
  592. }
  593. // ResetDatasetID resets all changes to the "dataset_id" field.
  594. func (m *AgentMutation) ResetDatasetID() {
  595. m.dataset_id = nil
  596. }
  597. // SetCollectionID sets the "collection_id" field.
  598. func (m *AgentMutation) SetCollectionID(s string) {
  599. m.collection_id = &s
  600. }
  601. // CollectionID returns the value of the "collection_id" field in the mutation.
  602. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  603. v := m.collection_id
  604. if v == nil {
  605. return
  606. }
  607. return *v, true
  608. }
  609. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  610. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  612. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  613. if !m.op.Is(OpUpdateOne) {
  614. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  615. }
  616. if m.id == nil || m.oldValue == nil {
  617. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  618. }
  619. oldValue, err := m.oldValue(ctx)
  620. if err != nil {
  621. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  622. }
  623. return oldValue.CollectionID, nil
  624. }
  625. // ResetCollectionID resets all changes to the "collection_id" field.
  626. func (m *AgentMutation) ResetCollectionID() {
  627. m.collection_id = nil
  628. }
  629. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  630. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  631. if m.wx_agent == nil {
  632. m.wx_agent = make(map[uint64]struct{})
  633. }
  634. for i := range ids {
  635. m.wx_agent[ids[i]] = struct{}{}
  636. }
  637. }
  638. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  639. func (m *AgentMutation) ClearWxAgent() {
  640. m.clearedwx_agent = true
  641. }
  642. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  643. func (m *AgentMutation) WxAgentCleared() bool {
  644. return m.clearedwx_agent
  645. }
  646. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  647. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  648. if m.removedwx_agent == nil {
  649. m.removedwx_agent = make(map[uint64]struct{})
  650. }
  651. for i := range ids {
  652. delete(m.wx_agent, ids[i])
  653. m.removedwx_agent[ids[i]] = struct{}{}
  654. }
  655. }
  656. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  657. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  658. for id := range m.removedwx_agent {
  659. ids = append(ids, id)
  660. }
  661. return
  662. }
  663. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  664. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  665. for id := range m.wx_agent {
  666. ids = append(ids, id)
  667. }
  668. return
  669. }
  670. // ResetWxAgent resets all changes to the "wx_agent" edge.
  671. func (m *AgentMutation) ResetWxAgent() {
  672. m.wx_agent = nil
  673. m.clearedwx_agent = false
  674. m.removedwx_agent = nil
  675. }
  676. // Where appends a list predicates to the AgentMutation builder.
  677. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  678. m.predicates = append(m.predicates, ps...)
  679. }
  680. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  681. // users can use type-assertion to append predicates that do not depend on any generated package.
  682. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  683. p := make([]predicate.Agent, len(ps))
  684. for i := range ps {
  685. p[i] = ps[i]
  686. }
  687. m.Where(p...)
  688. }
  689. // Op returns the operation name.
  690. func (m *AgentMutation) Op() Op {
  691. return m.op
  692. }
  693. // SetOp allows setting the mutation operation.
  694. func (m *AgentMutation) SetOp(op Op) {
  695. m.op = op
  696. }
  697. // Type returns the node type of this mutation (Agent).
  698. func (m *AgentMutation) Type() string {
  699. return m.typ
  700. }
  701. // Fields returns all fields that were changed during this mutation. Note that in
  702. // order to get all numeric fields that were incremented/decremented, call
  703. // AddedFields().
  704. func (m *AgentMutation) Fields() []string {
  705. fields := make([]string, 0, 11)
  706. if m.created_at != nil {
  707. fields = append(fields, agent.FieldCreatedAt)
  708. }
  709. if m.updated_at != nil {
  710. fields = append(fields, agent.FieldUpdatedAt)
  711. }
  712. if m.deleted_at != nil {
  713. fields = append(fields, agent.FieldDeletedAt)
  714. }
  715. if m.name != nil {
  716. fields = append(fields, agent.FieldName)
  717. }
  718. if m.role != nil {
  719. fields = append(fields, agent.FieldRole)
  720. }
  721. if m.status != nil {
  722. fields = append(fields, agent.FieldStatus)
  723. }
  724. if m.background != nil {
  725. fields = append(fields, agent.FieldBackground)
  726. }
  727. if m.examples != nil {
  728. fields = append(fields, agent.FieldExamples)
  729. }
  730. if m.organization_id != nil {
  731. fields = append(fields, agent.FieldOrganizationID)
  732. }
  733. if m.dataset_id != nil {
  734. fields = append(fields, agent.FieldDatasetID)
  735. }
  736. if m.collection_id != nil {
  737. fields = append(fields, agent.FieldCollectionID)
  738. }
  739. return fields
  740. }
  741. // Field returns the value of a field with the given name. The second boolean
  742. // return value indicates that this field was not set, or was not defined in the
  743. // schema.
  744. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  745. switch name {
  746. case agent.FieldCreatedAt:
  747. return m.CreatedAt()
  748. case agent.FieldUpdatedAt:
  749. return m.UpdatedAt()
  750. case agent.FieldDeletedAt:
  751. return m.DeletedAt()
  752. case agent.FieldName:
  753. return m.Name()
  754. case agent.FieldRole:
  755. return m.Role()
  756. case agent.FieldStatus:
  757. return m.Status()
  758. case agent.FieldBackground:
  759. return m.Background()
  760. case agent.FieldExamples:
  761. return m.Examples()
  762. case agent.FieldOrganizationID:
  763. return m.OrganizationID()
  764. case agent.FieldDatasetID:
  765. return m.DatasetID()
  766. case agent.FieldCollectionID:
  767. return m.CollectionID()
  768. }
  769. return nil, false
  770. }
  771. // OldField returns the old value of the field from the database. An error is
  772. // returned if the mutation operation is not UpdateOne, or the query to the
  773. // database failed.
  774. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  775. switch name {
  776. case agent.FieldCreatedAt:
  777. return m.OldCreatedAt(ctx)
  778. case agent.FieldUpdatedAt:
  779. return m.OldUpdatedAt(ctx)
  780. case agent.FieldDeletedAt:
  781. return m.OldDeletedAt(ctx)
  782. case agent.FieldName:
  783. return m.OldName(ctx)
  784. case agent.FieldRole:
  785. return m.OldRole(ctx)
  786. case agent.FieldStatus:
  787. return m.OldStatus(ctx)
  788. case agent.FieldBackground:
  789. return m.OldBackground(ctx)
  790. case agent.FieldExamples:
  791. return m.OldExamples(ctx)
  792. case agent.FieldOrganizationID:
  793. return m.OldOrganizationID(ctx)
  794. case agent.FieldDatasetID:
  795. return m.OldDatasetID(ctx)
  796. case agent.FieldCollectionID:
  797. return m.OldCollectionID(ctx)
  798. }
  799. return nil, fmt.Errorf("unknown Agent field %s", name)
  800. }
  801. // SetField sets the value of a field with the given name. It returns an error if
  802. // the field is not defined in the schema, or if the type mismatched the field
  803. // type.
  804. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  805. switch name {
  806. case agent.FieldCreatedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetCreatedAt(v)
  812. return nil
  813. case agent.FieldUpdatedAt:
  814. v, ok := value.(time.Time)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetUpdatedAt(v)
  819. return nil
  820. case agent.FieldDeletedAt:
  821. v, ok := value.(time.Time)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetDeletedAt(v)
  826. return nil
  827. case agent.FieldName:
  828. v, ok := value.(string)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetName(v)
  833. return nil
  834. case agent.FieldRole:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetRole(v)
  840. return nil
  841. case agent.FieldStatus:
  842. v, ok := value.(int)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetStatus(v)
  847. return nil
  848. case agent.FieldBackground:
  849. v, ok := value.(string)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetBackground(v)
  854. return nil
  855. case agent.FieldExamples:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetExamples(v)
  861. return nil
  862. case agent.FieldOrganizationID:
  863. v, ok := value.(uint64)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetOrganizationID(v)
  868. return nil
  869. case agent.FieldDatasetID:
  870. v, ok := value.(string)
  871. if !ok {
  872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  873. }
  874. m.SetDatasetID(v)
  875. return nil
  876. case agent.FieldCollectionID:
  877. v, ok := value.(string)
  878. if !ok {
  879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  880. }
  881. m.SetCollectionID(v)
  882. return nil
  883. }
  884. return fmt.Errorf("unknown Agent field %s", name)
  885. }
  886. // AddedFields returns all numeric fields that were incremented/decremented during
  887. // this mutation.
  888. func (m *AgentMutation) AddedFields() []string {
  889. var fields []string
  890. if m.addstatus != nil {
  891. fields = append(fields, agent.FieldStatus)
  892. }
  893. if m.addorganization_id != nil {
  894. fields = append(fields, agent.FieldOrganizationID)
  895. }
  896. return fields
  897. }
  898. // AddedField returns the numeric value that was incremented/decremented on a field
  899. // with the given name. The second boolean return value indicates that this field
  900. // was not set, or was not defined in the schema.
  901. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  902. switch name {
  903. case agent.FieldStatus:
  904. return m.AddedStatus()
  905. case agent.FieldOrganizationID:
  906. return m.AddedOrganizationID()
  907. }
  908. return nil, false
  909. }
  910. // AddField adds the value to the field with the given name. It returns an error if
  911. // the field is not defined in the schema, or if the type mismatched the field
  912. // type.
  913. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  914. switch name {
  915. case agent.FieldStatus:
  916. v, ok := value.(int)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.AddStatus(v)
  921. return nil
  922. case agent.FieldOrganizationID:
  923. v, ok := value.(int64)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.AddOrganizationID(v)
  928. return nil
  929. }
  930. return fmt.Errorf("unknown Agent numeric field %s", name)
  931. }
  932. // ClearedFields returns all nullable fields that were cleared during this
  933. // mutation.
  934. func (m *AgentMutation) ClearedFields() []string {
  935. var fields []string
  936. if m.FieldCleared(agent.FieldDeletedAt) {
  937. fields = append(fields, agent.FieldDeletedAt)
  938. }
  939. if m.FieldCleared(agent.FieldStatus) {
  940. fields = append(fields, agent.FieldStatus)
  941. }
  942. if m.FieldCleared(agent.FieldBackground) {
  943. fields = append(fields, agent.FieldBackground)
  944. }
  945. if m.FieldCleared(agent.FieldExamples) {
  946. fields = append(fields, agent.FieldExamples)
  947. }
  948. return fields
  949. }
  950. // FieldCleared returns a boolean indicating if a field with the given name was
  951. // cleared in this mutation.
  952. func (m *AgentMutation) FieldCleared(name string) bool {
  953. _, ok := m.clearedFields[name]
  954. return ok
  955. }
  956. // ClearField clears the value of the field with the given name. It returns an
  957. // error if the field is not defined in the schema.
  958. func (m *AgentMutation) ClearField(name string) error {
  959. switch name {
  960. case agent.FieldDeletedAt:
  961. m.ClearDeletedAt()
  962. return nil
  963. case agent.FieldStatus:
  964. m.ClearStatus()
  965. return nil
  966. case agent.FieldBackground:
  967. m.ClearBackground()
  968. return nil
  969. case agent.FieldExamples:
  970. m.ClearExamples()
  971. return nil
  972. }
  973. return fmt.Errorf("unknown Agent nullable field %s", name)
  974. }
  975. // ResetField resets all changes in the mutation for the field with the given name.
  976. // It returns an error if the field is not defined in the schema.
  977. func (m *AgentMutation) ResetField(name string) error {
  978. switch name {
  979. case agent.FieldCreatedAt:
  980. m.ResetCreatedAt()
  981. return nil
  982. case agent.FieldUpdatedAt:
  983. m.ResetUpdatedAt()
  984. return nil
  985. case agent.FieldDeletedAt:
  986. m.ResetDeletedAt()
  987. return nil
  988. case agent.FieldName:
  989. m.ResetName()
  990. return nil
  991. case agent.FieldRole:
  992. m.ResetRole()
  993. return nil
  994. case agent.FieldStatus:
  995. m.ResetStatus()
  996. return nil
  997. case agent.FieldBackground:
  998. m.ResetBackground()
  999. return nil
  1000. case agent.FieldExamples:
  1001. m.ResetExamples()
  1002. return nil
  1003. case agent.FieldOrganizationID:
  1004. m.ResetOrganizationID()
  1005. return nil
  1006. case agent.FieldDatasetID:
  1007. m.ResetDatasetID()
  1008. return nil
  1009. case agent.FieldCollectionID:
  1010. m.ResetCollectionID()
  1011. return nil
  1012. }
  1013. return fmt.Errorf("unknown Agent field %s", name)
  1014. }
  1015. // AddedEdges returns all edge names that were set/added in this mutation.
  1016. func (m *AgentMutation) AddedEdges() []string {
  1017. edges := make([]string, 0, 1)
  1018. if m.wx_agent != nil {
  1019. edges = append(edges, agent.EdgeWxAgent)
  1020. }
  1021. return edges
  1022. }
  1023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1024. // name in this mutation.
  1025. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1026. switch name {
  1027. case agent.EdgeWxAgent:
  1028. ids := make([]ent.Value, 0, len(m.wx_agent))
  1029. for id := range m.wx_agent {
  1030. ids = append(ids, id)
  1031. }
  1032. return ids
  1033. }
  1034. return nil
  1035. }
  1036. // RemovedEdges returns all edge names that were removed in this mutation.
  1037. func (m *AgentMutation) RemovedEdges() []string {
  1038. edges := make([]string, 0, 1)
  1039. if m.removedwx_agent != nil {
  1040. edges = append(edges, agent.EdgeWxAgent)
  1041. }
  1042. return edges
  1043. }
  1044. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1045. // the given name in this mutation.
  1046. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1047. switch name {
  1048. case agent.EdgeWxAgent:
  1049. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1050. for id := range m.removedwx_agent {
  1051. ids = append(ids, id)
  1052. }
  1053. return ids
  1054. }
  1055. return nil
  1056. }
  1057. // ClearedEdges returns all edge names that were cleared in this mutation.
  1058. func (m *AgentMutation) ClearedEdges() []string {
  1059. edges := make([]string, 0, 1)
  1060. if m.clearedwx_agent {
  1061. edges = append(edges, agent.EdgeWxAgent)
  1062. }
  1063. return edges
  1064. }
  1065. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1066. // was cleared in this mutation.
  1067. func (m *AgentMutation) EdgeCleared(name string) bool {
  1068. switch name {
  1069. case agent.EdgeWxAgent:
  1070. return m.clearedwx_agent
  1071. }
  1072. return false
  1073. }
  1074. // ClearEdge clears the value of the edge with the given name. It returns an error
  1075. // if that edge is not defined in the schema.
  1076. func (m *AgentMutation) ClearEdge(name string) error {
  1077. switch name {
  1078. }
  1079. return fmt.Errorf("unknown Agent unique edge %s", name)
  1080. }
  1081. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1082. // It returns an error if the edge is not defined in the schema.
  1083. func (m *AgentMutation) ResetEdge(name string) error {
  1084. switch name {
  1085. case agent.EdgeWxAgent:
  1086. m.ResetWxAgent()
  1087. return nil
  1088. }
  1089. return fmt.Errorf("unknown Agent edge %s", name)
  1090. }
  1091. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1092. type AgentBaseMutation struct {
  1093. config
  1094. op Op
  1095. typ string
  1096. id *string
  1097. q *string
  1098. a *string
  1099. chunk_index *uint64
  1100. addchunk_index *int64
  1101. indexes *[]string
  1102. appendindexes []string
  1103. dataset_id *string
  1104. collection_id *string
  1105. source_name *string
  1106. can_write *[]bool
  1107. appendcan_write []bool
  1108. is_owner *[]bool
  1109. appendis_owner []bool
  1110. clearedFields map[string]struct{}
  1111. wx_agent map[uint64]struct{}
  1112. removedwx_agent map[uint64]struct{}
  1113. clearedwx_agent bool
  1114. done bool
  1115. oldValue func(context.Context) (*AgentBase, error)
  1116. predicates []predicate.AgentBase
  1117. }
  1118. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1119. // agentbaseOption allows management of the mutation configuration using functional options.
  1120. type agentbaseOption func(*AgentBaseMutation)
  1121. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1122. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1123. m := &AgentBaseMutation{
  1124. config: c,
  1125. op: op,
  1126. typ: TypeAgentBase,
  1127. clearedFields: make(map[string]struct{}),
  1128. }
  1129. for _, opt := range opts {
  1130. opt(m)
  1131. }
  1132. return m
  1133. }
  1134. // withAgentBaseID sets the ID field of the mutation.
  1135. func withAgentBaseID(id string) agentbaseOption {
  1136. return func(m *AgentBaseMutation) {
  1137. var (
  1138. err error
  1139. once sync.Once
  1140. value *AgentBase
  1141. )
  1142. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1143. once.Do(func() {
  1144. if m.done {
  1145. err = errors.New("querying old values post mutation is not allowed")
  1146. } else {
  1147. value, err = m.Client().AgentBase.Get(ctx, id)
  1148. }
  1149. })
  1150. return value, err
  1151. }
  1152. m.id = &id
  1153. }
  1154. }
  1155. // withAgentBase sets the old AgentBase of the mutation.
  1156. func withAgentBase(node *AgentBase) agentbaseOption {
  1157. return func(m *AgentBaseMutation) {
  1158. m.oldValue = func(context.Context) (*AgentBase, error) {
  1159. return node, nil
  1160. }
  1161. m.id = &node.ID
  1162. }
  1163. }
  1164. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1165. // executed in a transaction (ent.Tx), a transactional client is returned.
  1166. func (m AgentBaseMutation) Client() *Client {
  1167. client := &Client{config: m.config}
  1168. client.init()
  1169. return client
  1170. }
  1171. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1172. // it returns an error otherwise.
  1173. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1174. if _, ok := m.driver.(*txDriver); !ok {
  1175. return nil, errors.New("ent: mutation is not running in a transaction")
  1176. }
  1177. tx := &Tx{config: m.config}
  1178. tx.init()
  1179. return tx, nil
  1180. }
  1181. // SetID sets the value of the id field. Note that this
  1182. // operation is only accepted on creation of AgentBase entities.
  1183. func (m *AgentBaseMutation) SetID(id string) {
  1184. m.id = &id
  1185. }
  1186. // ID returns the ID value in the mutation. Note that the ID is only available
  1187. // if it was provided to the builder or after it was returned from the database.
  1188. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1189. if m.id == nil {
  1190. return
  1191. }
  1192. return *m.id, true
  1193. }
  1194. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1195. // That means, if the mutation is applied within a transaction with an isolation level such
  1196. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1197. // or updated by the mutation.
  1198. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1199. switch {
  1200. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1201. id, exists := m.ID()
  1202. if exists {
  1203. return []string{id}, nil
  1204. }
  1205. fallthrough
  1206. case m.op.Is(OpUpdate | OpDelete):
  1207. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1208. default:
  1209. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1210. }
  1211. }
  1212. // SetQ sets the "q" field.
  1213. func (m *AgentBaseMutation) SetQ(s string) {
  1214. m.q = &s
  1215. }
  1216. // Q returns the value of the "q" field in the mutation.
  1217. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1218. v := m.q
  1219. if v == nil {
  1220. return
  1221. }
  1222. return *v, true
  1223. }
  1224. // OldQ returns the old "q" field's value of the AgentBase entity.
  1225. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1227. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1228. if !m.op.Is(OpUpdateOne) {
  1229. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1230. }
  1231. if m.id == nil || m.oldValue == nil {
  1232. return v, errors.New("OldQ requires an ID field in the mutation")
  1233. }
  1234. oldValue, err := m.oldValue(ctx)
  1235. if err != nil {
  1236. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1237. }
  1238. return oldValue.Q, nil
  1239. }
  1240. // ClearQ clears the value of the "q" field.
  1241. func (m *AgentBaseMutation) ClearQ() {
  1242. m.q = nil
  1243. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1244. }
  1245. // QCleared returns if the "q" field was cleared in this mutation.
  1246. func (m *AgentBaseMutation) QCleared() bool {
  1247. _, ok := m.clearedFields[agentbase.FieldQ]
  1248. return ok
  1249. }
  1250. // ResetQ resets all changes to the "q" field.
  1251. func (m *AgentBaseMutation) ResetQ() {
  1252. m.q = nil
  1253. delete(m.clearedFields, agentbase.FieldQ)
  1254. }
  1255. // SetA sets the "a" field.
  1256. func (m *AgentBaseMutation) SetA(s string) {
  1257. m.a = &s
  1258. }
  1259. // A returns the value of the "a" field in the mutation.
  1260. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1261. v := m.a
  1262. if v == nil {
  1263. return
  1264. }
  1265. return *v, true
  1266. }
  1267. // OldA returns the old "a" field's value of the AgentBase entity.
  1268. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1270. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1271. if !m.op.Is(OpUpdateOne) {
  1272. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1273. }
  1274. if m.id == nil || m.oldValue == nil {
  1275. return v, errors.New("OldA requires an ID field in the mutation")
  1276. }
  1277. oldValue, err := m.oldValue(ctx)
  1278. if err != nil {
  1279. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1280. }
  1281. return oldValue.A, nil
  1282. }
  1283. // ClearA clears the value of the "a" field.
  1284. func (m *AgentBaseMutation) ClearA() {
  1285. m.a = nil
  1286. m.clearedFields[agentbase.FieldA] = struct{}{}
  1287. }
  1288. // ACleared returns if the "a" field was cleared in this mutation.
  1289. func (m *AgentBaseMutation) ACleared() bool {
  1290. _, ok := m.clearedFields[agentbase.FieldA]
  1291. return ok
  1292. }
  1293. // ResetA resets all changes to the "a" field.
  1294. func (m *AgentBaseMutation) ResetA() {
  1295. m.a = nil
  1296. delete(m.clearedFields, agentbase.FieldA)
  1297. }
  1298. // SetChunkIndex sets the "chunk_index" field.
  1299. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1300. m.chunk_index = &u
  1301. m.addchunk_index = nil
  1302. }
  1303. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1304. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1305. v := m.chunk_index
  1306. if v == nil {
  1307. return
  1308. }
  1309. return *v, true
  1310. }
  1311. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1312. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1314. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1315. if !m.op.Is(OpUpdateOne) {
  1316. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1317. }
  1318. if m.id == nil || m.oldValue == nil {
  1319. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1320. }
  1321. oldValue, err := m.oldValue(ctx)
  1322. if err != nil {
  1323. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1324. }
  1325. return oldValue.ChunkIndex, nil
  1326. }
  1327. // AddChunkIndex adds u to the "chunk_index" field.
  1328. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1329. if m.addchunk_index != nil {
  1330. *m.addchunk_index += u
  1331. } else {
  1332. m.addchunk_index = &u
  1333. }
  1334. }
  1335. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1336. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1337. v := m.addchunk_index
  1338. if v == nil {
  1339. return
  1340. }
  1341. return *v, true
  1342. }
  1343. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1344. func (m *AgentBaseMutation) ResetChunkIndex() {
  1345. m.chunk_index = nil
  1346. m.addchunk_index = nil
  1347. }
  1348. // SetIndexes sets the "indexes" field.
  1349. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1350. m.indexes = &s
  1351. m.appendindexes = nil
  1352. }
  1353. // Indexes returns the value of the "indexes" field in the mutation.
  1354. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1355. v := m.indexes
  1356. if v == nil {
  1357. return
  1358. }
  1359. return *v, true
  1360. }
  1361. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1362. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1364. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1365. if !m.op.Is(OpUpdateOne) {
  1366. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1367. }
  1368. if m.id == nil || m.oldValue == nil {
  1369. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1370. }
  1371. oldValue, err := m.oldValue(ctx)
  1372. if err != nil {
  1373. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1374. }
  1375. return oldValue.Indexes, nil
  1376. }
  1377. // AppendIndexes adds s to the "indexes" field.
  1378. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1379. m.appendindexes = append(m.appendindexes, s...)
  1380. }
  1381. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1382. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1383. if len(m.appendindexes) == 0 {
  1384. return nil, false
  1385. }
  1386. return m.appendindexes, true
  1387. }
  1388. // ClearIndexes clears the value of the "indexes" field.
  1389. func (m *AgentBaseMutation) ClearIndexes() {
  1390. m.indexes = nil
  1391. m.appendindexes = nil
  1392. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1393. }
  1394. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1395. func (m *AgentBaseMutation) IndexesCleared() bool {
  1396. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1397. return ok
  1398. }
  1399. // ResetIndexes resets all changes to the "indexes" field.
  1400. func (m *AgentBaseMutation) ResetIndexes() {
  1401. m.indexes = nil
  1402. m.appendindexes = nil
  1403. delete(m.clearedFields, agentbase.FieldIndexes)
  1404. }
  1405. // SetDatasetID sets the "dataset_id" field.
  1406. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1407. m.dataset_id = &s
  1408. }
  1409. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1410. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1411. v := m.dataset_id
  1412. if v == nil {
  1413. return
  1414. }
  1415. return *v, true
  1416. }
  1417. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1418. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1420. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1421. if !m.op.Is(OpUpdateOne) {
  1422. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1423. }
  1424. if m.id == nil || m.oldValue == nil {
  1425. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1426. }
  1427. oldValue, err := m.oldValue(ctx)
  1428. if err != nil {
  1429. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1430. }
  1431. return oldValue.DatasetID, nil
  1432. }
  1433. // ClearDatasetID clears the value of the "dataset_id" field.
  1434. func (m *AgentBaseMutation) ClearDatasetID() {
  1435. m.dataset_id = nil
  1436. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1437. }
  1438. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1439. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1440. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1441. return ok
  1442. }
  1443. // ResetDatasetID resets all changes to the "dataset_id" field.
  1444. func (m *AgentBaseMutation) ResetDatasetID() {
  1445. m.dataset_id = nil
  1446. delete(m.clearedFields, agentbase.FieldDatasetID)
  1447. }
  1448. // SetCollectionID sets the "collection_id" field.
  1449. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1450. m.collection_id = &s
  1451. }
  1452. // CollectionID returns the value of the "collection_id" field in the mutation.
  1453. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1454. v := m.collection_id
  1455. if v == nil {
  1456. return
  1457. }
  1458. return *v, true
  1459. }
  1460. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1461. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1463. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1464. if !m.op.Is(OpUpdateOne) {
  1465. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1466. }
  1467. if m.id == nil || m.oldValue == nil {
  1468. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1469. }
  1470. oldValue, err := m.oldValue(ctx)
  1471. if err != nil {
  1472. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1473. }
  1474. return oldValue.CollectionID, nil
  1475. }
  1476. // ClearCollectionID clears the value of the "collection_id" field.
  1477. func (m *AgentBaseMutation) ClearCollectionID() {
  1478. m.collection_id = nil
  1479. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1480. }
  1481. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1482. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1483. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1484. return ok
  1485. }
  1486. // ResetCollectionID resets all changes to the "collection_id" field.
  1487. func (m *AgentBaseMutation) ResetCollectionID() {
  1488. m.collection_id = nil
  1489. delete(m.clearedFields, agentbase.FieldCollectionID)
  1490. }
  1491. // SetSourceName sets the "source_name" field.
  1492. func (m *AgentBaseMutation) SetSourceName(s string) {
  1493. m.source_name = &s
  1494. }
  1495. // SourceName returns the value of the "source_name" field in the mutation.
  1496. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1497. v := m.source_name
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1504. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1506. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1507. if !m.op.Is(OpUpdateOne) {
  1508. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1509. }
  1510. if m.id == nil || m.oldValue == nil {
  1511. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1512. }
  1513. oldValue, err := m.oldValue(ctx)
  1514. if err != nil {
  1515. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1516. }
  1517. return oldValue.SourceName, nil
  1518. }
  1519. // ClearSourceName clears the value of the "source_name" field.
  1520. func (m *AgentBaseMutation) ClearSourceName() {
  1521. m.source_name = nil
  1522. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1523. }
  1524. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1525. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1526. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1527. return ok
  1528. }
  1529. // ResetSourceName resets all changes to the "source_name" field.
  1530. func (m *AgentBaseMutation) ResetSourceName() {
  1531. m.source_name = nil
  1532. delete(m.clearedFields, agentbase.FieldSourceName)
  1533. }
  1534. // SetCanWrite sets the "can_write" field.
  1535. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1536. m.can_write = &b
  1537. m.appendcan_write = nil
  1538. }
  1539. // CanWrite returns the value of the "can_write" field in the mutation.
  1540. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1541. v := m.can_write
  1542. if v == nil {
  1543. return
  1544. }
  1545. return *v, true
  1546. }
  1547. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1548. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1550. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1551. if !m.op.Is(OpUpdateOne) {
  1552. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1553. }
  1554. if m.id == nil || m.oldValue == nil {
  1555. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1556. }
  1557. oldValue, err := m.oldValue(ctx)
  1558. if err != nil {
  1559. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1560. }
  1561. return oldValue.CanWrite, nil
  1562. }
  1563. // AppendCanWrite adds b to the "can_write" field.
  1564. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1565. m.appendcan_write = append(m.appendcan_write, b...)
  1566. }
  1567. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1568. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1569. if len(m.appendcan_write) == 0 {
  1570. return nil, false
  1571. }
  1572. return m.appendcan_write, true
  1573. }
  1574. // ClearCanWrite clears the value of the "can_write" field.
  1575. func (m *AgentBaseMutation) ClearCanWrite() {
  1576. m.can_write = nil
  1577. m.appendcan_write = nil
  1578. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1579. }
  1580. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1581. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1582. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1583. return ok
  1584. }
  1585. // ResetCanWrite resets all changes to the "can_write" field.
  1586. func (m *AgentBaseMutation) ResetCanWrite() {
  1587. m.can_write = nil
  1588. m.appendcan_write = nil
  1589. delete(m.clearedFields, agentbase.FieldCanWrite)
  1590. }
  1591. // SetIsOwner sets the "is_owner" field.
  1592. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1593. m.is_owner = &b
  1594. m.appendis_owner = nil
  1595. }
  1596. // IsOwner returns the value of the "is_owner" field in the mutation.
  1597. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1598. v := m.is_owner
  1599. if v == nil {
  1600. return
  1601. }
  1602. return *v, true
  1603. }
  1604. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1605. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1607. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1608. if !m.op.Is(OpUpdateOne) {
  1609. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1610. }
  1611. if m.id == nil || m.oldValue == nil {
  1612. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1613. }
  1614. oldValue, err := m.oldValue(ctx)
  1615. if err != nil {
  1616. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1617. }
  1618. return oldValue.IsOwner, nil
  1619. }
  1620. // AppendIsOwner adds b to the "is_owner" field.
  1621. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1622. m.appendis_owner = append(m.appendis_owner, b...)
  1623. }
  1624. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1625. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1626. if len(m.appendis_owner) == 0 {
  1627. return nil, false
  1628. }
  1629. return m.appendis_owner, true
  1630. }
  1631. // ClearIsOwner clears the value of the "is_owner" field.
  1632. func (m *AgentBaseMutation) ClearIsOwner() {
  1633. m.is_owner = nil
  1634. m.appendis_owner = nil
  1635. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1636. }
  1637. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1638. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1639. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1640. return ok
  1641. }
  1642. // ResetIsOwner resets all changes to the "is_owner" field.
  1643. func (m *AgentBaseMutation) ResetIsOwner() {
  1644. m.is_owner = nil
  1645. m.appendis_owner = nil
  1646. delete(m.clearedFields, agentbase.FieldIsOwner)
  1647. }
  1648. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1649. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1650. if m.wx_agent == nil {
  1651. m.wx_agent = make(map[uint64]struct{})
  1652. }
  1653. for i := range ids {
  1654. m.wx_agent[ids[i]] = struct{}{}
  1655. }
  1656. }
  1657. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1658. func (m *AgentBaseMutation) ClearWxAgent() {
  1659. m.clearedwx_agent = true
  1660. }
  1661. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1662. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1663. return m.clearedwx_agent
  1664. }
  1665. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1666. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1667. if m.removedwx_agent == nil {
  1668. m.removedwx_agent = make(map[uint64]struct{})
  1669. }
  1670. for i := range ids {
  1671. delete(m.wx_agent, ids[i])
  1672. m.removedwx_agent[ids[i]] = struct{}{}
  1673. }
  1674. }
  1675. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1676. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1677. for id := range m.removedwx_agent {
  1678. ids = append(ids, id)
  1679. }
  1680. return
  1681. }
  1682. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1683. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1684. for id := range m.wx_agent {
  1685. ids = append(ids, id)
  1686. }
  1687. return
  1688. }
  1689. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1690. func (m *AgentBaseMutation) ResetWxAgent() {
  1691. m.wx_agent = nil
  1692. m.clearedwx_agent = false
  1693. m.removedwx_agent = nil
  1694. }
  1695. // Where appends a list predicates to the AgentBaseMutation builder.
  1696. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1697. m.predicates = append(m.predicates, ps...)
  1698. }
  1699. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1700. // users can use type-assertion to append predicates that do not depend on any generated package.
  1701. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1702. p := make([]predicate.AgentBase, len(ps))
  1703. for i := range ps {
  1704. p[i] = ps[i]
  1705. }
  1706. m.Where(p...)
  1707. }
  1708. // Op returns the operation name.
  1709. func (m *AgentBaseMutation) Op() Op {
  1710. return m.op
  1711. }
  1712. // SetOp allows setting the mutation operation.
  1713. func (m *AgentBaseMutation) SetOp(op Op) {
  1714. m.op = op
  1715. }
  1716. // Type returns the node type of this mutation (AgentBase).
  1717. func (m *AgentBaseMutation) Type() string {
  1718. return m.typ
  1719. }
  1720. // Fields returns all fields that were changed during this mutation. Note that in
  1721. // order to get all numeric fields that were incremented/decremented, call
  1722. // AddedFields().
  1723. func (m *AgentBaseMutation) Fields() []string {
  1724. fields := make([]string, 0, 9)
  1725. if m.q != nil {
  1726. fields = append(fields, agentbase.FieldQ)
  1727. }
  1728. if m.a != nil {
  1729. fields = append(fields, agentbase.FieldA)
  1730. }
  1731. if m.chunk_index != nil {
  1732. fields = append(fields, agentbase.FieldChunkIndex)
  1733. }
  1734. if m.indexes != nil {
  1735. fields = append(fields, agentbase.FieldIndexes)
  1736. }
  1737. if m.dataset_id != nil {
  1738. fields = append(fields, agentbase.FieldDatasetID)
  1739. }
  1740. if m.collection_id != nil {
  1741. fields = append(fields, agentbase.FieldCollectionID)
  1742. }
  1743. if m.source_name != nil {
  1744. fields = append(fields, agentbase.FieldSourceName)
  1745. }
  1746. if m.can_write != nil {
  1747. fields = append(fields, agentbase.FieldCanWrite)
  1748. }
  1749. if m.is_owner != nil {
  1750. fields = append(fields, agentbase.FieldIsOwner)
  1751. }
  1752. return fields
  1753. }
  1754. // Field returns the value of a field with the given name. The second boolean
  1755. // return value indicates that this field was not set, or was not defined in the
  1756. // schema.
  1757. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1758. switch name {
  1759. case agentbase.FieldQ:
  1760. return m.Q()
  1761. case agentbase.FieldA:
  1762. return m.A()
  1763. case agentbase.FieldChunkIndex:
  1764. return m.ChunkIndex()
  1765. case agentbase.FieldIndexes:
  1766. return m.Indexes()
  1767. case agentbase.FieldDatasetID:
  1768. return m.DatasetID()
  1769. case agentbase.FieldCollectionID:
  1770. return m.CollectionID()
  1771. case agentbase.FieldSourceName:
  1772. return m.SourceName()
  1773. case agentbase.FieldCanWrite:
  1774. return m.CanWrite()
  1775. case agentbase.FieldIsOwner:
  1776. return m.IsOwner()
  1777. }
  1778. return nil, false
  1779. }
  1780. // OldField returns the old value of the field from the database. An error is
  1781. // returned if the mutation operation is not UpdateOne, or the query to the
  1782. // database failed.
  1783. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1784. switch name {
  1785. case agentbase.FieldQ:
  1786. return m.OldQ(ctx)
  1787. case agentbase.FieldA:
  1788. return m.OldA(ctx)
  1789. case agentbase.FieldChunkIndex:
  1790. return m.OldChunkIndex(ctx)
  1791. case agentbase.FieldIndexes:
  1792. return m.OldIndexes(ctx)
  1793. case agentbase.FieldDatasetID:
  1794. return m.OldDatasetID(ctx)
  1795. case agentbase.FieldCollectionID:
  1796. return m.OldCollectionID(ctx)
  1797. case agentbase.FieldSourceName:
  1798. return m.OldSourceName(ctx)
  1799. case agentbase.FieldCanWrite:
  1800. return m.OldCanWrite(ctx)
  1801. case agentbase.FieldIsOwner:
  1802. return m.OldIsOwner(ctx)
  1803. }
  1804. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1805. }
  1806. // SetField sets the value of a field with the given name. It returns an error if
  1807. // the field is not defined in the schema, or if the type mismatched the field
  1808. // type.
  1809. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1810. switch name {
  1811. case agentbase.FieldQ:
  1812. v, ok := value.(string)
  1813. if !ok {
  1814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1815. }
  1816. m.SetQ(v)
  1817. return nil
  1818. case agentbase.FieldA:
  1819. v, ok := value.(string)
  1820. if !ok {
  1821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1822. }
  1823. m.SetA(v)
  1824. return nil
  1825. case agentbase.FieldChunkIndex:
  1826. v, ok := value.(uint64)
  1827. if !ok {
  1828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1829. }
  1830. m.SetChunkIndex(v)
  1831. return nil
  1832. case agentbase.FieldIndexes:
  1833. v, ok := value.([]string)
  1834. if !ok {
  1835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1836. }
  1837. m.SetIndexes(v)
  1838. return nil
  1839. case agentbase.FieldDatasetID:
  1840. v, ok := value.(string)
  1841. if !ok {
  1842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1843. }
  1844. m.SetDatasetID(v)
  1845. return nil
  1846. case agentbase.FieldCollectionID:
  1847. v, ok := value.(string)
  1848. if !ok {
  1849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1850. }
  1851. m.SetCollectionID(v)
  1852. return nil
  1853. case agentbase.FieldSourceName:
  1854. v, ok := value.(string)
  1855. if !ok {
  1856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1857. }
  1858. m.SetSourceName(v)
  1859. return nil
  1860. case agentbase.FieldCanWrite:
  1861. v, ok := value.([]bool)
  1862. if !ok {
  1863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1864. }
  1865. m.SetCanWrite(v)
  1866. return nil
  1867. case agentbase.FieldIsOwner:
  1868. v, ok := value.([]bool)
  1869. if !ok {
  1870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1871. }
  1872. m.SetIsOwner(v)
  1873. return nil
  1874. }
  1875. return fmt.Errorf("unknown AgentBase field %s", name)
  1876. }
  1877. // AddedFields returns all numeric fields that were incremented/decremented during
  1878. // this mutation.
  1879. func (m *AgentBaseMutation) AddedFields() []string {
  1880. var fields []string
  1881. if m.addchunk_index != nil {
  1882. fields = append(fields, agentbase.FieldChunkIndex)
  1883. }
  1884. return fields
  1885. }
  1886. // AddedField returns the numeric value that was incremented/decremented on a field
  1887. // with the given name. The second boolean return value indicates that this field
  1888. // was not set, or was not defined in the schema.
  1889. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1890. switch name {
  1891. case agentbase.FieldChunkIndex:
  1892. return m.AddedChunkIndex()
  1893. }
  1894. return nil, false
  1895. }
  1896. // AddField adds the value to the field with the given name. It returns an error if
  1897. // the field is not defined in the schema, or if the type mismatched the field
  1898. // type.
  1899. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1900. switch name {
  1901. case agentbase.FieldChunkIndex:
  1902. v, ok := value.(int64)
  1903. if !ok {
  1904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1905. }
  1906. m.AddChunkIndex(v)
  1907. return nil
  1908. }
  1909. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1910. }
  1911. // ClearedFields returns all nullable fields that were cleared during this
  1912. // mutation.
  1913. func (m *AgentBaseMutation) ClearedFields() []string {
  1914. var fields []string
  1915. if m.FieldCleared(agentbase.FieldQ) {
  1916. fields = append(fields, agentbase.FieldQ)
  1917. }
  1918. if m.FieldCleared(agentbase.FieldA) {
  1919. fields = append(fields, agentbase.FieldA)
  1920. }
  1921. if m.FieldCleared(agentbase.FieldIndexes) {
  1922. fields = append(fields, agentbase.FieldIndexes)
  1923. }
  1924. if m.FieldCleared(agentbase.FieldDatasetID) {
  1925. fields = append(fields, agentbase.FieldDatasetID)
  1926. }
  1927. if m.FieldCleared(agentbase.FieldCollectionID) {
  1928. fields = append(fields, agentbase.FieldCollectionID)
  1929. }
  1930. if m.FieldCleared(agentbase.FieldSourceName) {
  1931. fields = append(fields, agentbase.FieldSourceName)
  1932. }
  1933. if m.FieldCleared(agentbase.FieldCanWrite) {
  1934. fields = append(fields, agentbase.FieldCanWrite)
  1935. }
  1936. if m.FieldCleared(agentbase.FieldIsOwner) {
  1937. fields = append(fields, agentbase.FieldIsOwner)
  1938. }
  1939. return fields
  1940. }
  1941. // FieldCleared returns a boolean indicating if a field with the given name was
  1942. // cleared in this mutation.
  1943. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  1944. _, ok := m.clearedFields[name]
  1945. return ok
  1946. }
  1947. // ClearField clears the value of the field with the given name. It returns an
  1948. // error if the field is not defined in the schema.
  1949. func (m *AgentBaseMutation) ClearField(name string) error {
  1950. switch name {
  1951. case agentbase.FieldQ:
  1952. m.ClearQ()
  1953. return nil
  1954. case agentbase.FieldA:
  1955. m.ClearA()
  1956. return nil
  1957. case agentbase.FieldIndexes:
  1958. m.ClearIndexes()
  1959. return nil
  1960. case agentbase.FieldDatasetID:
  1961. m.ClearDatasetID()
  1962. return nil
  1963. case agentbase.FieldCollectionID:
  1964. m.ClearCollectionID()
  1965. return nil
  1966. case agentbase.FieldSourceName:
  1967. m.ClearSourceName()
  1968. return nil
  1969. case agentbase.FieldCanWrite:
  1970. m.ClearCanWrite()
  1971. return nil
  1972. case agentbase.FieldIsOwner:
  1973. m.ClearIsOwner()
  1974. return nil
  1975. }
  1976. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  1977. }
  1978. // ResetField resets all changes in the mutation for the field with the given name.
  1979. // It returns an error if the field is not defined in the schema.
  1980. func (m *AgentBaseMutation) ResetField(name string) error {
  1981. switch name {
  1982. case agentbase.FieldQ:
  1983. m.ResetQ()
  1984. return nil
  1985. case agentbase.FieldA:
  1986. m.ResetA()
  1987. return nil
  1988. case agentbase.FieldChunkIndex:
  1989. m.ResetChunkIndex()
  1990. return nil
  1991. case agentbase.FieldIndexes:
  1992. m.ResetIndexes()
  1993. return nil
  1994. case agentbase.FieldDatasetID:
  1995. m.ResetDatasetID()
  1996. return nil
  1997. case agentbase.FieldCollectionID:
  1998. m.ResetCollectionID()
  1999. return nil
  2000. case agentbase.FieldSourceName:
  2001. m.ResetSourceName()
  2002. return nil
  2003. case agentbase.FieldCanWrite:
  2004. m.ResetCanWrite()
  2005. return nil
  2006. case agentbase.FieldIsOwner:
  2007. m.ResetIsOwner()
  2008. return nil
  2009. }
  2010. return fmt.Errorf("unknown AgentBase field %s", name)
  2011. }
  2012. // AddedEdges returns all edge names that were set/added in this mutation.
  2013. func (m *AgentBaseMutation) AddedEdges() []string {
  2014. edges := make([]string, 0, 1)
  2015. if m.wx_agent != nil {
  2016. edges = append(edges, agentbase.EdgeWxAgent)
  2017. }
  2018. return edges
  2019. }
  2020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2021. // name in this mutation.
  2022. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2023. switch name {
  2024. case agentbase.EdgeWxAgent:
  2025. ids := make([]ent.Value, 0, len(m.wx_agent))
  2026. for id := range m.wx_agent {
  2027. ids = append(ids, id)
  2028. }
  2029. return ids
  2030. }
  2031. return nil
  2032. }
  2033. // RemovedEdges returns all edge names that were removed in this mutation.
  2034. func (m *AgentBaseMutation) RemovedEdges() []string {
  2035. edges := make([]string, 0, 1)
  2036. if m.removedwx_agent != nil {
  2037. edges = append(edges, agentbase.EdgeWxAgent)
  2038. }
  2039. return edges
  2040. }
  2041. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2042. // the given name in this mutation.
  2043. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2044. switch name {
  2045. case agentbase.EdgeWxAgent:
  2046. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2047. for id := range m.removedwx_agent {
  2048. ids = append(ids, id)
  2049. }
  2050. return ids
  2051. }
  2052. return nil
  2053. }
  2054. // ClearedEdges returns all edge names that were cleared in this mutation.
  2055. func (m *AgentBaseMutation) ClearedEdges() []string {
  2056. edges := make([]string, 0, 1)
  2057. if m.clearedwx_agent {
  2058. edges = append(edges, agentbase.EdgeWxAgent)
  2059. }
  2060. return edges
  2061. }
  2062. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2063. // was cleared in this mutation.
  2064. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2065. switch name {
  2066. case agentbase.EdgeWxAgent:
  2067. return m.clearedwx_agent
  2068. }
  2069. return false
  2070. }
  2071. // ClearEdge clears the value of the edge with the given name. It returns an error
  2072. // if that edge is not defined in the schema.
  2073. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2074. switch name {
  2075. }
  2076. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2077. }
  2078. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2079. // It returns an error if the edge is not defined in the schema.
  2080. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2081. switch name {
  2082. case agentbase.EdgeWxAgent:
  2083. m.ResetWxAgent()
  2084. return nil
  2085. }
  2086. return fmt.Errorf("unknown AgentBase edge %s", name)
  2087. }
  2088. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2089. type AliyunAvatarMutation struct {
  2090. config
  2091. op Op
  2092. typ string
  2093. id *uint64
  2094. created_at *time.Time
  2095. updated_at *time.Time
  2096. deleted_at *time.Time
  2097. user_id *uint64
  2098. adduser_id *int64
  2099. biz_id *string
  2100. access_key_id *string
  2101. access_key_secret *string
  2102. app_id *string
  2103. tenant_id *uint64
  2104. addtenant_id *int64
  2105. response *string
  2106. token *string
  2107. session_id *string
  2108. clearedFields map[string]struct{}
  2109. done bool
  2110. oldValue func(context.Context) (*AliyunAvatar, error)
  2111. predicates []predicate.AliyunAvatar
  2112. }
  2113. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2114. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2115. type aliyunavatarOption func(*AliyunAvatarMutation)
  2116. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2117. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2118. m := &AliyunAvatarMutation{
  2119. config: c,
  2120. op: op,
  2121. typ: TypeAliyunAvatar,
  2122. clearedFields: make(map[string]struct{}),
  2123. }
  2124. for _, opt := range opts {
  2125. opt(m)
  2126. }
  2127. return m
  2128. }
  2129. // withAliyunAvatarID sets the ID field of the mutation.
  2130. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2131. return func(m *AliyunAvatarMutation) {
  2132. var (
  2133. err error
  2134. once sync.Once
  2135. value *AliyunAvatar
  2136. )
  2137. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2138. once.Do(func() {
  2139. if m.done {
  2140. err = errors.New("querying old values post mutation is not allowed")
  2141. } else {
  2142. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2143. }
  2144. })
  2145. return value, err
  2146. }
  2147. m.id = &id
  2148. }
  2149. }
  2150. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2151. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2152. return func(m *AliyunAvatarMutation) {
  2153. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2154. return node, nil
  2155. }
  2156. m.id = &node.ID
  2157. }
  2158. }
  2159. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2160. // executed in a transaction (ent.Tx), a transactional client is returned.
  2161. func (m AliyunAvatarMutation) Client() *Client {
  2162. client := &Client{config: m.config}
  2163. client.init()
  2164. return client
  2165. }
  2166. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2167. // it returns an error otherwise.
  2168. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2169. if _, ok := m.driver.(*txDriver); !ok {
  2170. return nil, errors.New("ent: mutation is not running in a transaction")
  2171. }
  2172. tx := &Tx{config: m.config}
  2173. tx.init()
  2174. return tx, nil
  2175. }
  2176. // SetID sets the value of the id field. Note that this
  2177. // operation is only accepted on creation of AliyunAvatar entities.
  2178. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2179. m.id = &id
  2180. }
  2181. // ID returns the ID value in the mutation. Note that the ID is only available
  2182. // if it was provided to the builder or after it was returned from the database.
  2183. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2184. if m.id == nil {
  2185. return
  2186. }
  2187. return *m.id, true
  2188. }
  2189. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2190. // That means, if the mutation is applied within a transaction with an isolation level such
  2191. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2192. // or updated by the mutation.
  2193. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2194. switch {
  2195. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2196. id, exists := m.ID()
  2197. if exists {
  2198. return []uint64{id}, nil
  2199. }
  2200. fallthrough
  2201. case m.op.Is(OpUpdate | OpDelete):
  2202. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2203. default:
  2204. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2205. }
  2206. }
  2207. // SetCreatedAt sets the "created_at" field.
  2208. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2209. m.created_at = &t
  2210. }
  2211. // CreatedAt returns the value of the "created_at" field in the mutation.
  2212. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2213. v := m.created_at
  2214. if v == nil {
  2215. return
  2216. }
  2217. return *v, true
  2218. }
  2219. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2220. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2222. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2223. if !m.op.Is(OpUpdateOne) {
  2224. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2225. }
  2226. if m.id == nil || m.oldValue == nil {
  2227. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2228. }
  2229. oldValue, err := m.oldValue(ctx)
  2230. if err != nil {
  2231. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2232. }
  2233. return oldValue.CreatedAt, nil
  2234. }
  2235. // ResetCreatedAt resets all changes to the "created_at" field.
  2236. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2237. m.created_at = nil
  2238. }
  2239. // SetUpdatedAt sets the "updated_at" field.
  2240. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2241. m.updated_at = &t
  2242. }
  2243. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2244. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2245. v := m.updated_at
  2246. if v == nil {
  2247. return
  2248. }
  2249. return *v, true
  2250. }
  2251. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2252. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2254. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2255. if !m.op.Is(OpUpdateOne) {
  2256. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2257. }
  2258. if m.id == nil || m.oldValue == nil {
  2259. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2260. }
  2261. oldValue, err := m.oldValue(ctx)
  2262. if err != nil {
  2263. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2264. }
  2265. return oldValue.UpdatedAt, nil
  2266. }
  2267. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2268. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2269. m.updated_at = nil
  2270. }
  2271. // SetDeletedAt sets the "deleted_at" field.
  2272. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2273. m.deleted_at = &t
  2274. }
  2275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2276. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2277. v := m.deleted_at
  2278. if v == nil {
  2279. return
  2280. }
  2281. return *v, true
  2282. }
  2283. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2284. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2286. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2287. if !m.op.Is(OpUpdateOne) {
  2288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2289. }
  2290. if m.id == nil || m.oldValue == nil {
  2291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2292. }
  2293. oldValue, err := m.oldValue(ctx)
  2294. if err != nil {
  2295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2296. }
  2297. return oldValue.DeletedAt, nil
  2298. }
  2299. // ClearDeletedAt clears the value of the "deleted_at" field.
  2300. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2301. m.deleted_at = nil
  2302. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2303. }
  2304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2305. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2306. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2307. return ok
  2308. }
  2309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2310. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2311. m.deleted_at = nil
  2312. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2313. }
  2314. // SetUserID sets the "user_id" field.
  2315. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2316. m.user_id = &u
  2317. m.adduser_id = nil
  2318. }
  2319. // UserID returns the value of the "user_id" field in the mutation.
  2320. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2321. v := m.user_id
  2322. if v == nil {
  2323. return
  2324. }
  2325. return *v, true
  2326. }
  2327. // OldUserID returns the old "user_id" 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) OldUserID(ctx context.Context) (v uint64, err error) {
  2331. if !m.op.Is(OpUpdateOne) {
  2332. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2333. }
  2334. if m.id == nil || m.oldValue == nil {
  2335. return v, errors.New("OldUserID 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 OldUserID: %w", err)
  2340. }
  2341. return oldValue.UserID, nil
  2342. }
  2343. // AddUserID adds u to the "user_id" field.
  2344. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2345. if m.adduser_id != nil {
  2346. *m.adduser_id += u
  2347. } else {
  2348. m.adduser_id = &u
  2349. }
  2350. }
  2351. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2352. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2353. v := m.adduser_id
  2354. if v == nil {
  2355. return
  2356. }
  2357. return *v, true
  2358. }
  2359. // ResetUserID resets all changes to the "user_id" field.
  2360. func (m *AliyunAvatarMutation) ResetUserID() {
  2361. m.user_id = nil
  2362. m.adduser_id = nil
  2363. }
  2364. // SetBizID sets the "biz_id" field.
  2365. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2366. m.biz_id = &s
  2367. }
  2368. // BizID returns the value of the "biz_id" field in the mutation.
  2369. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2370. v := m.biz_id
  2371. if v == nil {
  2372. return
  2373. }
  2374. return *v, true
  2375. }
  2376. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2377. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2379. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2380. if !m.op.Is(OpUpdateOne) {
  2381. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2382. }
  2383. if m.id == nil || m.oldValue == nil {
  2384. return v, errors.New("OldBizID requires an ID field in the mutation")
  2385. }
  2386. oldValue, err := m.oldValue(ctx)
  2387. if err != nil {
  2388. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2389. }
  2390. return oldValue.BizID, nil
  2391. }
  2392. // ResetBizID resets all changes to the "biz_id" field.
  2393. func (m *AliyunAvatarMutation) ResetBizID() {
  2394. m.biz_id = nil
  2395. }
  2396. // SetAccessKeyID sets the "access_key_id" field.
  2397. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2398. m.access_key_id = &s
  2399. }
  2400. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2401. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2402. v := m.access_key_id
  2403. if v == nil {
  2404. return
  2405. }
  2406. return *v, true
  2407. }
  2408. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2409. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2411. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2412. if !m.op.Is(OpUpdateOne) {
  2413. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2414. }
  2415. if m.id == nil || m.oldValue == nil {
  2416. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2417. }
  2418. oldValue, err := m.oldValue(ctx)
  2419. if err != nil {
  2420. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2421. }
  2422. return oldValue.AccessKeyID, nil
  2423. }
  2424. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2425. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2426. m.access_key_id = nil
  2427. }
  2428. // SetAccessKeySecret sets the "access_key_secret" field.
  2429. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2430. m.access_key_secret = &s
  2431. }
  2432. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2433. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2434. v := m.access_key_secret
  2435. if v == nil {
  2436. return
  2437. }
  2438. return *v, true
  2439. }
  2440. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2441. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2443. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2444. if !m.op.Is(OpUpdateOne) {
  2445. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2446. }
  2447. if m.id == nil || m.oldValue == nil {
  2448. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2449. }
  2450. oldValue, err := m.oldValue(ctx)
  2451. if err != nil {
  2452. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2453. }
  2454. return oldValue.AccessKeySecret, nil
  2455. }
  2456. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2457. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2458. m.access_key_secret = nil
  2459. }
  2460. // SetAppID sets the "app_id" field.
  2461. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2462. m.app_id = &s
  2463. }
  2464. // AppID returns the value of the "app_id" field in the mutation.
  2465. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2466. v := m.app_id
  2467. if v == nil {
  2468. return
  2469. }
  2470. return *v, true
  2471. }
  2472. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2473. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2475. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2476. if !m.op.Is(OpUpdateOne) {
  2477. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2478. }
  2479. if m.id == nil || m.oldValue == nil {
  2480. return v, errors.New("OldAppID requires an ID field in the mutation")
  2481. }
  2482. oldValue, err := m.oldValue(ctx)
  2483. if err != nil {
  2484. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2485. }
  2486. return oldValue.AppID, nil
  2487. }
  2488. // ClearAppID clears the value of the "app_id" field.
  2489. func (m *AliyunAvatarMutation) ClearAppID() {
  2490. m.app_id = nil
  2491. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2492. }
  2493. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2494. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2495. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2496. return ok
  2497. }
  2498. // ResetAppID resets all changes to the "app_id" field.
  2499. func (m *AliyunAvatarMutation) ResetAppID() {
  2500. m.app_id = nil
  2501. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2502. }
  2503. // SetTenantID sets the "tenant_id" field.
  2504. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2505. m.tenant_id = &u
  2506. m.addtenant_id = nil
  2507. }
  2508. // TenantID returns the value of the "tenant_id" field in the mutation.
  2509. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2510. v := m.tenant_id
  2511. if v == nil {
  2512. return
  2513. }
  2514. return *v, true
  2515. }
  2516. // OldTenantID returns the old "tenant_id" 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) OldTenantID(ctx context.Context) (v uint64, err error) {
  2520. if !m.op.Is(OpUpdateOne) {
  2521. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2522. }
  2523. if m.id == nil || m.oldValue == nil {
  2524. return v, errors.New("OldTenantID 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 OldTenantID: %w", err)
  2529. }
  2530. return oldValue.TenantID, nil
  2531. }
  2532. // AddTenantID adds u to the "tenant_id" field.
  2533. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2534. if m.addtenant_id != nil {
  2535. *m.addtenant_id += u
  2536. } else {
  2537. m.addtenant_id = &u
  2538. }
  2539. }
  2540. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2541. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2542. v := m.addtenant_id
  2543. if v == nil {
  2544. return
  2545. }
  2546. return *v, true
  2547. }
  2548. // ResetTenantID resets all changes to the "tenant_id" field.
  2549. func (m *AliyunAvatarMutation) ResetTenantID() {
  2550. m.tenant_id = nil
  2551. m.addtenant_id = nil
  2552. }
  2553. // SetResponse sets the "response" field.
  2554. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2555. m.response = &s
  2556. }
  2557. // Response returns the value of the "response" field in the mutation.
  2558. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2559. v := m.response
  2560. if v == nil {
  2561. return
  2562. }
  2563. return *v, true
  2564. }
  2565. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2566. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2568. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2569. if !m.op.Is(OpUpdateOne) {
  2570. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2571. }
  2572. if m.id == nil || m.oldValue == nil {
  2573. return v, errors.New("OldResponse requires an ID field in the mutation")
  2574. }
  2575. oldValue, err := m.oldValue(ctx)
  2576. if err != nil {
  2577. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2578. }
  2579. return oldValue.Response, nil
  2580. }
  2581. // ResetResponse resets all changes to the "response" field.
  2582. func (m *AliyunAvatarMutation) ResetResponse() {
  2583. m.response = nil
  2584. }
  2585. // SetToken sets the "token" field.
  2586. func (m *AliyunAvatarMutation) SetToken(s string) {
  2587. m.token = &s
  2588. }
  2589. // Token returns the value of the "token" field in the mutation.
  2590. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2591. v := m.token
  2592. if v == nil {
  2593. return
  2594. }
  2595. return *v, true
  2596. }
  2597. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2598. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2600. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2601. if !m.op.Is(OpUpdateOne) {
  2602. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2603. }
  2604. if m.id == nil || m.oldValue == nil {
  2605. return v, errors.New("OldToken requires an ID field in the mutation")
  2606. }
  2607. oldValue, err := m.oldValue(ctx)
  2608. if err != nil {
  2609. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2610. }
  2611. return oldValue.Token, nil
  2612. }
  2613. // ResetToken resets all changes to the "token" field.
  2614. func (m *AliyunAvatarMutation) ResetToken() {
  2615. m.token = nil
  2616. }
  2617. // SetSessionID sets the "session_id" field.
  2618. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2619. m.session_id = &s
  2620. }
  2621. // SessionID returns the value of the "session_id" field in the mutation.
  2622. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2623. v := m.session_id
  2624. if v == nil {
  2625. return
  2626. }
  2627. return *v, true
  2628. }
  2629. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2630. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2632. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2633. if !m.op.Is(OpUpdateOne) {
  2634. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2635. }
  2636. if m.id == nil || m.oldValue == nil {
  2637. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2638. }
  2639. oldValue, err := m.oldValue(ctx)
  2640. if err != nil {
  2641. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2642. }
  2643. return oldValue.SessionID, nil
  2644. }
  2645. // ResetSessionID resets all changes to the "session_id" field.
  2646. func (m *AliyunAvatarMutation) ResetSessionID() {
  2647. m.session_id = nil
  2648. }
  2649. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2650. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2651. m.predicates = append(m.predicates, ps...)
  2652. }
  2653. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2654. // users can use type-assertion to append predicates that do not depend on any generated package.
  2655. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2656. p := make([]predicate.AliyunAvatar, len(ps))
  2657. for i := range ps {
  2658. p[i] = ps[i]
  2659. }
  2660. m.Where(p...)
  2661. }
  2662. // Op returns the operation name.
  2663. func (m *AliyunAvatarMutation) Op() Op {
  2664. return m.op
  2665. }
  2666. // SetOp allows setting the mutation operation.
  2667. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2668. m.op = op
  2669. }
  2670. // Type returns the node type of this mutation (AliyunAvatar).
  2671. func (m *AliyunAvatarMutation) Type() string {
  2672. return m.typ
  2673. }
  2674. // Fields returns all fields that were changed during this mutation. Note that in
  2675. // order to get all numeric fields that were incremented/decremented, call
  2676. // AddedFields().
  2677. func (m *AliyunAvatarMutation) Fields() []string {
  2678. fields := make([]string, 0, 12)
  2679. if m.created_at != nil {
  2680. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2681. }
  2682. if m.updated_at != nil {
  2683. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2684. }
  2685. if m.deleted_at != nil {
  2686. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2687. }
  2688. if m.user_id != nil {
  2689. fields = append(fields, aliyunavatar.FieldUserID)
  2690. }
  2691. if m.biz_id != nil {
  2692. fields = append(fields, aliyunavatar.FieldBizID)
  2693. }
  2694. if m.access_key_id != nil {
  2695. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2696. }
  2697. if m.access_key_secret != nil {
  2698. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2699. }
  2700. if m.app_id != nil {
  2701. fields = append(fields, aliyunavatar.FieldAppID)
  2702. }
  2703. if m.tenant_id != nil {
  2704. fields = append(fields, aliyunavatar.FieldTenantID)
  2705. }
  2706. if m.response != nil {
  2707. fields = append(fields, aliyunavatar.FieldResponse)
  2708. }
  2709. if m.token != nil {
  2710. fields = append(fields, aliyunavatar.FieldToken)
  2711. }
  2712. if m.session_id != nil {
  2713. fields = append(fields, aliyunavatar.FieldSessionID)
  2714. }
  2715. return fields
  2716. }
  2717. // Field returns the value of a field with the given name. The second boolean
  2718. // return value indicates that this field was not set, or was not defined in the
  2719. // schema.
  2720. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2721. switch name {
  2722. case aliyunavatar.FieldCreatedAt:
  2723. return m.CreatedAt()
  2724. case aliyunavatar.FieldUpdatedAt:
  2725. return m.UpdatedAt()
  2726. case aliyunavatar.FieldDeletedAt:
  2727. return m.DeletedAt()
  2728. case aliyunavatar.FieldUserID:
  2729. return m.UserID()
  2730. case aliyunavatar.FieldBizID:
  2731. return m.BizID()
  2732. case aliyunavatar.FieldAccessKeyID:
  2733. return m.AccessKeyID()
  2734. case aliyunavatar.FieldAccessKeySecret:
  2735. return m.AccessKeySecret()
  2736. case aliyunavatar.FieldAppID:
  2737. return m.AppID()
  2738. case aliyunavatar.FieldTenantID:
  2739. return m.TenantID()
  2740. case aliyunavatar.FieldResponse:
  2741. return m.Response()
  2742. case aliyunavatar.FieldToken:
  2743. return m.Token()
  2744. case aliyunavatar.FieldSessionID:
  2745. return m.SessionID()
  2746. }
  2747. return nil, false
  2748. }
  2749. // OldField returns the old value of the field from the database. An error is
  2750. // returned if the mutation operation is not UpdateOne, or the query to the
  2751. // database failed.
  2752. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2753. switch name {
  2754. case aliyunavatar.FieldCreatedAt:
  2755. return m.OldCreatedAt(ctx)
  2756. case aliyunavatar.FieldUpdatedAt:
  2757. return m.OldUpdatedAt(ctx)
  2758. case aliyunavatar.FieldDeletedAt:
  2759. return m.OldDeletedAt(ctx)
  2760. case aliyunavatar.FieldUserID:
  2761. return m.OldUserID(ctx)
  2762. case aliyunavatar.FieldBizID:
  2763. return m.OldBizID(ctx)
  2764. case aliyunavatar.FieldAccessKeyID:
  2765. return m.OldAccessKeyID(ctx)
  2766. case aliyunavatar.FieldAccessKeySecret:
  2767. return m.OldAccessKeySecret(ctx)
  2768. case aliyunavatar.FieldAppID:
  2769. return m.OldAppID(ctx)
  2770. case aliyunavatar.FieldTenantID:
  2771. return m.OldTenantID(ctx)
  2772. case aliyunavatar.FieldResponse:
  2773. return m.OldResponse(ctx)
  2774. case aliyunavatar.FieldToken:
  2775. return m.OldToken(ctx)
  2776. case aliyunavatar.FieldSessionID:
  2777. return m.OldSessionID(ctx)
  2778. }
  2779. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2780. }
  2781. // SetField sets the value of a field with the given name. It returns an error if
  2782. // the field is not defined in the schema, or if the type mismatched the field
  2783. // type.
  2784. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2785. switch name {
  2786. case aliyunavatar.FieldCreatedAt:
  2787. v, ok := value.(time.Time)
  2788. if !ok {
  2789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2790. }
  2791. m.SetCreatedAt(v)
  2792. return nil
  2793. case aliyunavatar.FieldUpdatedAt:
  2794. v, ok := value.(time.Time)
  2795. if !ok {
  2796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2797. }
  2798. m.SetUpdatedAt(v)
  2799. return nil
  2800. case aliyunavatar.FieldDeletedAt:
  2801. v, ok := value.(time.Time)
  2802. if !ok {
  2803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2804. }
  2805. m.SetDeletedAt(v)
  2806. return nil
  2807. case aliyunavatar.FieldUserID:
  2808. v, ok := value.(uint64)
  2809. if !ok {
  2810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2811. }
  2812. m.SetUserID(v)
  2813. return nil
  2814. case aliyunavatar.FieldBizID:
  2815. v, ok := value.(string)
  2816. if !ok {
  2817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2818. }
  2819. m.SetBizID(v)
  2820. return nil
  2821. case aliyunavatar.FieldAccessKeyID:
  2822. v, ok := value.(string)
  2823. if !ok {
  2824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2825. }
  2826. m.SetAccessKeyID(v)
  2827. return nil
  2828. case aliyunavatar.FieldAccessKeySecret:
  2829. v, ok := value.(string)
  2830. if !ok {
  2831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2832. }
  2833. m.SetAccessKeySecret(v)
  2834. return nil
  2835. case aliyunavatar.FieldAppID:
  2836. v, ok := value.(string)
  2837. if !ok {
  2838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2839. }
  2840. m.SetAppID(v)
  2841. return nil
  2842. case aliyunavatar.FieldTenantID:
  2843. v, ok := value.(uint64)
  2844. if !ok {
  2845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2846. }
  2847. m.SetTenantID(v)
  2848. return nil
  2849. case aliyunavatar.FieldResponse:
  2850. v, ok := value.(string)
  2851. if !ok {
  2852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2853. }
  2854. m.SetResponse(v)
  2855. return nil
  2856. case aliyunavatar.FieldToken:
  2857. v, ok := value.(string)
  2858. if !ok {
  2859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2860. }
  2861. m.SetToken(v)
  2862. return nil
  2863. case aliyunavatar.FieldSessionID:
  2864. v, ok := value.(string)
  2865. if !ok {
  2866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2867. }
  2868. m.SetSessionID(v)
  2869. return nil
  2870. }
  2871. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2872. }
  2873. // AddedFields returns all numeric fields that were incremented/decremented during
  2874. // this mutation.
  2875. func (m *AliyunAvatarMutation) AddedFields() []string {
  2876. var fields []string
  2877. if m.adduser_id != nil {
  2878. fields = append(fields, aliyunavatar.FieldUserID)
  2879. }
  2880. if m.addtenant_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldTenantID)
  2882. }
  2883. return fields
  2884. }
  2885. // AddedField returns the numeric value that was incremented/decremented on a field
  2886. // with the given name. The second boolean return value indicates that this field
  2887. // was not set, or was not defined in the schema.
  2888. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2889. switch name {
  2890. case aliyunavatar.FieldUserID:
  2891. return m.AddedUserID()
  2892. case aliyunavatar.FieldTenantID:
  2893. return m.AddedTenantID()
  2894. }
  2895. return nil, false
  2896. }
  2897. // AddField adds the value to the field with the given name. It returns an error if
  2898. // the field is not defined in the schema, or if the type mismatched the field
  2899. // type.
  2900. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2901. switch name {
  2902. case aliyunavatar.FieldUserID:
  2903. v, ok := value.(int64)
  2904. if !ok {
  2905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2906. }
  2907. m.AddUserID(v)
  2908. return nil
  2909. case aliyunavatar.FieldTenantID:
  2910. v, ok := value.(int64)
  2911. if !ok {
  2912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2913. }
  2914. m.AddTenantID(v)
  2915. return nil
  2916. }
  2917. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  2918. }
  2919. // ClearedFields returns all nullable fields that were cleared during this
  2920. // mutation.
  2921. func (m *AliyunAvatarMutation) ClearedFields() []string {
  2922. var fields []string
  2923. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  2924. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2925. }
  2926. if m.FieldCleared(aliyunavatar.FieldAppID) {
  2927. fields = append(fields, aliyunavatar.FieldAppID)
  2928. }
  2929. return fields
  2930. }
  2931. // FieldCleared returns a boolean indicating if a field with the given name was
  2932. // cleared in this mutation.
  2933. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  2934. _, ok := m.clearedFields[name]
  2935. return ok
  2936. }
  2937. // ClearField clears the value of the field with the given name. It returns an
  2938. // error if the field is not defined in the schema.
  2939. func (m *AliyunAvatarMutation) ClearField(name string) error {
  2940. switch name {
  2941. case aliyunavatar.FieldDeletedAt:
  2942. m.ClearDeletedAt()
  2943. return nil
  2944. case aliyunavatar.FieldAppID:
  2945. m.ClearAppID()
  2946. return nil
  2947. }
  2948. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  2949. }
  2950. // ResetField resets all changes in the mutation for the field with the given name.
  2951. // It returns an error if the field is not defined in the schema.
  2952. func (m *AliyunAvatarMutation) ResetField(name string) error {
  2953. switch name {
  2954. case aliyunavatar.FieldCreatedAt:
  2955. m.ResetCreatedAt()
  2956. return nil
  2957. case aliyunavatar.FieldUpdatedAt:
  2958. m.ResetUpdatedAt()
  2959. return nil
  2960. case aliyunavatar.FieldDeletedAt:
  2961. m.ResetDeletedAt()
  2962. return nil
  2963. case aliyunavatar.FieldUserID:
  2964. m.ResetUserID()
  2965. return nil
  2966. case aliyunavatar.FieldBizID:
  2967. m.ResetBizID()
  2968. return nil
  2969. case aliyunavatar.FieldAccessKeyID:
  2970. m.ResetAccessKeyID()
  2971. return nil
  2972. case aliyunavatar.FieldAccessKeySecret:
  2973. m.ResetAccessKeySecret()
  2974. return nil
  2975. case aliyunavatar.FieldAppID:
  2976. m.ResetAppID()
  2977. return nil
  2978. case aliyunavatar.FieldTenantID:
  2979. m.ResetTenantID()
  2980. return nil
  2981. case aliyunavatar.FieldResponse:
  2982. m.ResetResponse()
  2983. return nil
  2984. case aliyunavatar.FieldToken:
  2985. m.ResetToken()
  2986. return nil
  2987. case aliyunavatar.FieldSessionID:
  2988. m.ResetSessionID()
  2989. return nil
  2990. }
  2991. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2992. }
  2993. // AddedEdges returns all edge names that were set/added in this mutation.
  2994. func (m *AliyunAvatarMutation) AddedEdges() []string {
  2995. edges := make([]string, 0, 0)
  2996. return edges
  2997. }
  2998. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2999. // name in this mutation.
  3000. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3001. return nil
  3002. }
  3003. // RemovedEdges returns all edge names that were removed in this mutation.
  3004. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3005. edges := make([]string, 0, 0)
  3006. return edges
  3007. }
  3008. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3009. // the given name in this mutation.
  3010. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3011. return nil
  3012. }
  3013. // ClearedEdges returns all edge names that were cleared in this mutation.
  3014. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3015. edges := make([]string, 0, 0)
  3016. return edges
  3017. }
  3018. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3019. // was cleared in this mutation.
  3020. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3021. return false
  3022. }
  3023. // ClearEdge clears the value of the edge with the given name. It returns an error
  3024. // if that edge is not defined in the schema.
  3025. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3026. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3027. }
  3028. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3029. // It returns an error if the edge is not defined in the schema.
  3030. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3031. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3032. }
  3033. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3034. type BatchMsgMutation struct {
  3035. config
  3036. op Op
  3037. typ string
  3038. id *uint64
  3039. created_at *time.Time
  3040. updated_at *time.Time
  3041. deleted_at *time.Time
  3042. status *uint8
  3043. addstatus *int8
  3044. batch_no *string
  3045. task_name *string
  3046. fromwxid *string
  3047. msg *string
  3048. tag *string
  3049. tagids *string
  3050. total *int32
  3051. addtotal *int32
  3052. success *int32
  3053. addsuccess *int32
  3054. fail *int32
  3055. addfail *int32
  3056. start_time *time.Time
  3057. stop_time *time.Time
  3058. send_time *time.Time
  3059. _type *int32
  3060. add_type *int32
  3061. organization_id *uint64
  3062. addorganization_id *int64
  3063. clearedFields map[string]struct{}
  3064. done bool
  3065. oldValue func(context.Context) (*BatchMsg, error)
  3066. predicates []predicate.BatchMsg
  3067. }
  3068. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3069. // batchmsgOption allows management of the mutation configuration using functional options.
  3070. type batchmsgOption func(*BatchMsgMutation)
  3071. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3072. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3073. m := &BatchMsgMutation{
  3074. config: c,
  3075. op: op,
  3076. typ: TypeBatchMsg,
  3077. clearedFields: make(map[string]struct{}),
  3078. }
  3079. for _, opt := range opts {
  3080. opt(m)
  3081. }
  3082. return m
  3083. }
  3084. // withBatchMsgID sets the ID field of the mutation.
  3085. func withBatchMsgID(id uint64) batchmsgOption {
  3086. return func(m *BatchMsgMutation) {
  3087. var (
  3088. err error
  3089. once sync.Once
  3090. value *BatchMsg
  3091. )
  3092. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3093. once.Do(func() {
  3094. if m.done {
  3095. err = errors.New("querying old values post mutation is not allowed")
  3096. } else {
  3097. value, err = m.Client().BatchMsg.Get(ctx, id)
  3098. }
  3099. })
  3100. return value, err
  3101. }
  3102. m.id = &id
  3103. }
  3104. }
  3105. // withBatchMsg sets the old BatchMsg of the mutation.
  3106. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3107. return func(m *BatchMsgMutation) {
  3108. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3109. return node, nil
  3110. }
  3111. m.id = &node.ID
  3112. }
  3113. }
  3114. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3115. // executed in a transaction (ent.Tx), a transactional client is returned.
  3116. func (m BatchMsgMutation) Client() *Client {
  3117. client := &Client{config: m.config}
  3118. client.init()
  3119. return client
  3120. }
  3121. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3122. // it returns an error otherwise.
  3123. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3124. if _, ok := m.driver.(*txDriver); !ok {
  3125. return nil, errors.New("ent: mutation is not running in a transaction")
  3126. }
  3127. tx := &Tx{config: m.config}
  3128. tx.init()
  3129. return tx, nil
  3130. }
  3131. // SetID sets the value of the id field. Note that this
  3132. // operation is only accepted on creation of BatchMsg entities.
  3133. func (m *BatchMsgMutation) SetID(id uint64) {
  3134. m.id = &id
  3135. }
  3136. // ID returns the ID value in the mutation. Note that the ID is only available
  3137. // if it was provided to the builder or after it was returned from the database.
  3138. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3139. if m.id == nil {
  3140. return
  3141. }
  3142. return *m.id, true
  3143. }
  3144. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3145. // That means, if the mutation is applied within a transaction with an isolation level such
  3146. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3147. // or updated by the mutation.
  3148. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3149. switch {
  3150. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3151. id, exists := m.ID()
  3152. if exists {
  3153. return []uint64{id}, nil
  3154. }
  3155. fallthrough
  3156. case m.op.Is(OpUpdate | OpDelete):
  3157. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3158. default:
  3159. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3160. }
  3161. }
  3162. // SetCreatedAt sets the "created_at" field.
  3163. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3164. m.created_at = &t
  3165. }
  3166. // CreatedAt returns the value of the "created_at" field in the mutation.
  3167. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3168. v := m.created_at
  3169. if v == nil {
  3170. return
  3171. }
  3172. return *v, true
  3173. }
  3174. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3175. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3177. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3178. if !m.op.Is(OpUpdateOne) {
  3179. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3180. }
  3181. if m.id == nil || m.oldValue == nil {
  3182. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3183. }
  3184. oldValue, err := m.oldValue(ctx)
  3185. if err != nil {
  3186. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3187. }
  3188. return oldValue.CreatedAt, nil
  3189. }
  3190. // ResetCreatedAt resets all changes to the "created_at" field.
  3191. func (m *BatchMsgMutation) ResetCreatedAt() {
  3192. m.created_at = nil
  3193. }
  3194. // SetUpdatedAt sets the "updated_at" field.
  3195. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3196. m.updated_at = &t
  3197. }
  3198. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3199. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3200. v := m.updated_at
  3201. if v == nil {
  3202. return
  3203. }
  3204. return *v, true
  3205. }
  3206. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3207. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3209. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3210. if !m.op.Is(OpUpdateOne) {
  3211. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3212. }
  3213. if m.id == nil || m.oldValue == nil {
  3214. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3215. }
  3216. oldValue, err := m.oldValue(ctx)
  3217. if err != nil {
  3218. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3219. }
  3220. return oldValue.UpdatedAt, nil
  3221. }
  3222. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3223. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3224. m.updated_at = nil
  3225. }
  3226. // SetDeletedAt sets the "deleted_at" field.
  3227. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3228. m.deleted_at = &t
  3229. }
  3230. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3231. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3232. v := m.deleted_at
  3233. if v == nil {
  3234. return
  3235. }
  3236. return *v, true
  3237. }
  3238. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3239. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3241. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3242. if !m.op.Is(OpUpdateOne) {
  3243. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3244. }
  3245. if m.id == nil || m.oldValue == nil {
  3246. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3247. }
  3248. oldValue, err := m.oldValue(ctx)
  3249. if err != nil {
  3250. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3251. }
  3252. return oldValue.DeletedAt, nil
  3253. }
  3254. // ClearDeletedAt clears the value of the "deleted_at" field.
  3255. func (m *BatchMsgMutation) ClearDeletedAt() {
  3256. m.deleted_at = nil
  3257. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3258. }
  3259. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3260. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3261. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3262. return ok
  3263. }
  3264. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3265. func (m *BatchMsgMutation) ResetDeletedAt() {
  3266. m.deleted_at = nil
  3267. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3268. }
  3269. // SetStatus sets the "status" field.
  3270. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3271. m.status = &u
  3272. m.addstatus = nil
  3273. }
  3274. // Status returns the value of the "status" field in the mutation.
  3275. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3276. v := m.status
  3277. if v == nil {
  3278. return
  3279. }
  3280. return *v, true
  3281. }
  3282. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  3286. if !m.op.Is(OpUpdateOne) {
  3287. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3288. }
  3289. if m.id == nil || m.oldValue == nil {
  3290. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  3295. }
  3296. return oldValue.Status, nil
  3297. }
  3298. // AddStatus adds u to the "status" field.
  3299. func (m *BatchMsgMutation) AddStatus(u int8) {
  3300. if m.addstatus != nil {
  3301. *m.addstatus += u
  3302. } else {
  3303. m.addstatus = &u
  3304. }
  3305. }
  3306. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3307. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3308. v := m.addstatus
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // ClearStatus clears the value of the "status" field.
  3315. func (m *BatchMsgMutation) ClearStatus() {
  3316. m.status = nil
  3317. m.addstatus = nil
  3318. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3319. }
  3320. // StatusCleared returns if the "status" field was cleared in this mutation.
  3321. func (m *BatchMsgMutation) StatusCleared() bool {
  3322. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3323. return ok
  3324. }
  3325. // ResetStatus resets all changes to the "status" field.
  3326. func (m *BatchMsgMutation) ResetStatus() {
  3327. m.status = nil
  3328. m.addstatus = nil
  3329. delete(m.clearedFields, batchmsg.FieldStatus)
  3330. }
  3331. // SetBatchNo sets the "batch_no" field.
  3332. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3333. m.batch_no = &s
  3334. }
  3335. // BatchNo returns the value of the "batch_no" field in the mutation.
  3336. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3337. v := m.batch_no
  3338. if v == nil {
  3339. return
  3340. }
  3341. return *v, true
  3342. }
  3343. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3344. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3346. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3347. if !m.op.Is(OpUpdateOne) {
  3348. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3349. }
  3350. if m.id == nil || m.oldValue == nil {
  3351. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3352. }
  3353. oldValue, err := m.oldValue(ctx)
  3354. if err != nil {
  3355. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3356. }
  3357. return oldValue.BatchNo, nil
  3358. }
  3359. // ClearBatchNo clears the value of the "batch_no" field.
  3360. func (m *BatchMsgMutation) ClearBatchNo() {
  3361. m.batch_no = nil
  3362. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3363. }
  3364. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3365. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3366. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3367. return ok
  3368. }
  3369. // ResetBatchNo resets all changes to the "batch_no" field.
  3370. func (m *BatchMsgMutation) ResetBatchNo() {
  3371. m.batch_no = nil
  3372. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3373. }
  3374. // SetTaskName sets the "task_name" field.
  3375. func (m *BatchMsgMutation) SetTaskName(s string) {
  3376. m.task_name = &s
  3377. }
  3378. // TaskName returns the value of the "task_name" field in the mutation.
  3379. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3380. v := m.task_name
  3381. if v == nil {
  3382. return
  3383. }
  3384. return *v, true
  3385. }
  3386. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3387. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3389. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3390. if !m.op.Is(OpUpdateOne) {
  3391. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3392. }
  3393. if m.id == nil || m.oldValue == nil {
  3394. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3395. }
  3396. oldValue, err := m.oldValue(ctx)
  3397. if err != nil {
  3398. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3399. }
  3400. return oldValue.TaskName, nil
  3401. }
  3402. // ClearTaskName clears the value of the "task_name" field.
  3403. func (m *BatchMsgMutation) ClearTaskName() {
  3404. m.task_name = nil
  3405. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3406. }
  3407. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3408. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3409. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3410. return ok
  3411. }
  3412. // ResetTaskName resets all changes to the "task_name" field.
  3413. func (m *BatchMsgMutation) ResetTaskName() {
  3414. m.task_name = nil
  3415. delete(m.clearedFields, batchmsg.FieldTaskName)
  3416. }
  3417. // SetFromwxid sets the "fromwxid" field.
  3418. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3419. m.fromwxid = &s
  3420. }
  3421. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3422. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3423. v := m.fromwxid
  3424. if v == nil {
  3425. return
  3426. }
  3427. return *v, true
  3428. }
  3429. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3430. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3432. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3433. if !m.op.Is(OpUpdateOne) {
  3434. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3435. }
  3436. if m.id == nil || m.oldValue == nil {
  3437. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3438. }
  3439. oldValue, err := m.oldValue(ctx)
  3440. if err != nil {
  3441. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3442. }
  3443. return oldValue.Fromwxid, nil
  3444. }
  3445. // ClearFromwxid clears the value of the "fromwxid" field.
  3446. func (m *BatchMsgMutation) ClearFromwxid() {
  3447. m.fromwxid = nil
  3448. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3449. }
  3450. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3451. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3452. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3453. return ok
  3454. }
  3455. // ResetFromwxid resets all changes to the "fromwxid" field.
  3456. func (m *BatchMsgMutation) ResetFromwxid() {
  3457. m.fromwxid = nil
  3458. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3459. }
  3460. // SetMsg sets the "msg" field.
  3461. func (m *BatchMsgMutation) SetMsg(s string) {
  3462. m.msg = &s
  3463. }
  3464. // Msg returns the value of the "msg" field in the mutation.
  3465. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3466. v := m.msg
  3467. if v == nil {
  3468. return
  3469. }
  3470. return *v, true
  3471. }
  3472. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3473. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3475. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3476. if !m.op.Is(OpUpdateOne) {
  3477. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3478. }
  3479. if m.id == nil || m.oldValue == nil {
  3480. return v, errors.New("OldMsg requires an ID field in the mutation")
  3481. }
  3482. oldValue, err := m.oldValue(ctx)
  3483. if err != nil {
  3484. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3485. }
  3486. return oldValue.Msg, nil
  3487. }
  3488. // ClearMsg clears the value of the "msg" field.
  3489. func (m *BatchMsgMutation) ClearMsg() {
  3490. m.msg = nil
  3491. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3492. }
  3493. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3494. func (m *BatchMsgMutation) MsgCleared() bool {
  3495. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3496. return ok
  3497. }
  3498. // ResetMsg resets all changes to the "msg" field.
  3499. func (m *BatchMsgMutation) ResetMsg() {
  3500. m.msg = nil
  3501. delete(m.clearedFields, batchmsg.FieldMsg)
  3502. }
  3503. // SetTag sets the "tag" field.
  3504. func (m *BatchMsgMutation) SetTag(s string) {
  3505. m.tag = &s
  3506. }
  3507. // Tag returns the value of the "tag" field in the mutation.
  3508. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3509. v := m.tag
  3510. if v == nil {
  3511. return
  3512. }
  3513. return *v, true
  3514. }
  3515. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3516. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3518. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3519. if !m.op.Is(OpUpdateOne) {
  3520. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3521. }
  3522. if m.id == nil || m.oldValue == nil {
  3523. return v, errors.New("OldTag requires an ID field in the mutation")
  3524. }
  3525. oldValue, err := m.oldValue(ctx)
  3526. if err != nil {
  3527. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3528. }
  3529. return oldValue.Tag, nil
  3530. }
  3531. // ClearTag clears the value of the "tag" field.
  3532. func (m *BatchMsgMutation) ClearTag() {
  3533. m.tag = nil
  3534. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3535. }
  3536. // TagCleared returns if the "tag" field was cleared in this mutation.
  3537. func (m *BatchMsgMutation) TagCleared() bool {
  3538. _, ok := m.clearedFields[batchmsg.FieldTag]
  3539. return ok
  3540. }
  3541. // ResetTag resets all changes to the "tag" field.
  3542. func (m *BatchMsgMutation) ResetTag() {
  3543. m.tag = nil
  3544. delete(m.clearedFields, batchmsg.FieldTag)
  3545. }
  3546. // SetTagids sets the "tagids" field.
  3547. func (m *BatchMsgMutation) SetTagids(s string) {
  3548. m.tagids = &s
  3549. }
  3550. // Tagids returns the value of the "tagids" field in the mutation.
  3551. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3552. v := m.tagids
  3553. if v == nil {
  3554. return
  3555. }
  3556. return *v, true
  3557. }
  3558. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3559. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3561. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3562. if !m.op.Is(OpUpdateOne) {
  3563. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3564. }
  3565. if m.id == nil || m.oldValue == nil {
  3566. return v, errors.New("OldTagids requires an ID field in the mutation")
  3567. }
  3568. oldValue, err := m.oldValue(ctx)
  3569. if err != nil {
  3570. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3571. }
  3572. return oldValue.Tagids, nil
  3573. }
  3574. // ClearTagids clears the value of the "tagids" field.
  3575. func (m *BatchMsgMutation) ClearTagids() {
  3576. m.tagids = nil
  3577. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3578. }
  3579. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3580. func (m *BatchMsgMutation) TagidsCleared() bool {
  3581. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3582. return ok
  3583. }
  3584. // ResetTagids resets all changes to the "tagids" field.
  3585. func (m *BatchMsgMutation) ResetTagids() {
  3586. m.tagids = nil
  3587. delete(m.clearedFields, batchmsg.FieldTagids)
  3588. }
  3589. // SetTotal sets the "total" field.
  3590. func (m *BatchMsgMutation) SetTotal(i int32) {
  3591. m.total = &i
  3592. m.addtotal = nil
  3593. }
  3594. // Total returns the value of the "total" field in the mutation.
  3595. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3596. v := m.total
  3597. if v == nil {
  3598. return
  3599. }
  3600. return *v, true
  3601. }
  3602. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3605. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3606. if !m.op.Is(OpUpdateOne) {
  3607. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3608. }
  3609. if m.id == nil || m.oldValue == nil {
  3610. return v, errors.New("OldTotal requires an ID field in the mutation")
  3611. }
  3612. oldValue, err := m.oldValue(ctx)
  3613. if err != nil {
  3614. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3615. }
  3616. return oldValue.Total, nil
  3617. }
  3618. // AddTotal adds i to the "total" field.
  3619. func (m *BatchMsgMutation) AddTotal(i int32) {
  3620. if m.addtotal != nil {
  3621. *m.addtotal += i
  3622. } else {
  3623. m.addtotal = &i
  3624. }
  3625. }
  3626. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3627. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3628. v := m.addtotal
  3629. if v == nil {
  3630. return
  3631. }
  3632. return *v, true
  3633. }
  3634. // ClearTotal clears the value of the "total" field.
  3635. func (m *BatchMsgMutation) ClearTotal() {
  3636. m.total = nil
  3637. m.addtotal = nil
  3638. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3639. }
  3640. // TotalCleared returns if the "total" field was cleared in this mutation.
  3641. func (m *BatchMsgMutation) TotalCleared() bool {
  3642. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3643. return ok
  3644. }
  3645. // ResetTotal resets all changes to the "total" field.
  3646. func (m *BatchMsgMutation) ResetTotal() {
  3647. m.total = nil
  3648. m.addtotal = nil
  3649. delete(m.clearedFields, batchmsg.FieldTotal)
  3650. }
  3651. // SetSuccess sets the "success" field.
  3652. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3653. m.success = &i
  3654. m.addsuccess = nil
  3655. }
  3656. // Success returns the value of the "success" field in the mutation.
  3657. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3658. v := m.success
  3659. if v == nil {
  3660. return
  3661. }
  3662. return *v, true
  3663. }
  3664. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3665. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3667. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3668. if !m.op.Is(OpUpdateOne) {
  3669. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3670. }
  3671. if m.id == nil || m.oldValue == nil {
  3672. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3673. }
  3674. oldValue, err := m.oldValue(ctx)
  3675. if err != nil {
  3676. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3677. }
  3678. return oldValue.Success, nil
  3679. }
  3680. // AddSuccess adds i to the "success" field.
  3681. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3682. if m.addsuccess != nil {
  3683. *m.addsuccess += i
  3684. } else {
  3685. m.addsuccess = &i
  3686. }
  3687. }
  3688. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3689. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3690. v := m.addsuccess
  3691. if v == nil {
  3692. return
  3693. }
  3694. return *v, true
  3695. }
  3696. // ClearSuccess clears the value of the "success" field.
  3697. func (m *BatchMsgMutation) ClearSuccess() {
  3698. m.success = nil
  3699. m.addsuccess = nil
  3700. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3701. }
  3702. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3703. func (m *BatchMsgMutation) SuccessCleared() bool {
  3704. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3705. return ok
  3706. }
  3707. // ResetSuccess resets all changes to the "success" field.
  3708. func (m *BatchMsgMutation) ResetSuccess() {
  3709. m.success = nil
  3710. m.addsuccess = nil
  3711. delete(m.clearedFields, batchmsg.FieldSuccess)
  3712. }
  3713. // SetFail sets the "fail" field.
  3714. func (m *BatchMsgMutation) SetFail(i int32) {
  3715. m.fail = &i
  3716. m.addfail = nil
  3717. }
  3718. // Fail returns the value of the "fail" field in the mutation.
  3719. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3720. v := m.fail
  3721. if v == nil {
  3722. return
  3723. }
  3724. return *v, true
  3725. }
  3726. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3727. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3729. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3730. if !m.op.Is(OpUpdateOne) {
  3731. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3732. }
  3733. if m.id == nil || m.oldValue == nil {
  3734. return v, errors.New("OldFail requires an ID field in the mutation")
  3735. }
  3736. oldValue, err := m.oldValue(ctx)
  3737. if err != nil {
  3738. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3739. }
  3740. return oldValue.Fail, nil
  3741. }
  3742. // AddFail adds i to the "fail" field.
  3743. func (m *BatchMsgMutation) AddFail(i int32) {
  3744. if m.addfail != nil {
  3745. *m.addfail += i
  3746. } else {
  3747. m.addfail = &i
  3748. }
  3749. }
  3750. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3751. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3752. v := m.addfail
  3753. if v == nil {
  3754. return
  3755. }
  3756. return *v, true
  3757. }
  3758. // ClearFail clears the value of the "fail" field.
  3759. func (m *BatchMsgMutation) ClearFail() {
  3760. m.fail = nil
  3761. m.addfail = nil
  3762. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3763. }
  3764. // FailCleared returns if the "fail" field was cleared in this mutation.
  3765. func (m *BatchMsgMutation) FailCleared() bool {
  3766. _, ok := m.clearedFields[batchmsg.FieldFail]
  3767. return ok
  3768. }
  3769. // ResetFail resets all changes to the "fail" field.
  3770. func (m *BatchMsgMutation) ResetFail() {
  3771. m.fail = nil
  3772. m.addfail = nil
  3773. delete(m.clearedFields, batchmsg.FieldFail)
  3774. }
  3775. // SetStartTime sets the "start_time" field.
  3776. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3777. m.start_time = &t
  3778. }
  3779. // StartTime returns the value of the "start_time" field in the mutation.
  3780. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3781. v := m.start_time
  3782. if v == nil {
  3783. return
  3784. }
  3785. return *v, true
  3786. }
  3787. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3788. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3790. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3791. if !m.op.Is(OpUpdateOne) {
  3792. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3793. }
  3794. if m.id == nil || m.oldValue == nil {
  3795. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3796. }
  3797. oldValue, err := m.oldValue(ctx)
  3798. if err != nil {
  3799. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3800. }
  3801. return oldValue.StartTime, nil
  3802. }
  3803. // ClearStartTime clears the value of the "start_time" field.
  3804. func (m *BatchMsgMutation) ClearStartTime() {
  3805. m.start_time = nil
  3806. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3807. }
  3808. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3809. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3810. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3811. return ok
  3812. }
  3813. // ResetStartTime resets all changes to the "start_time" field.
  3814. func (m *BatchMsgMutation) ResetStartTime() {
  3815. m.start_time = nil
  3816. delete(m.clearedFields, batchmsg.FieldStartTime)
  3817. }
  3818. // SetStopTime sets the "stop_time" field.
  3819. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3820. m.stop_time = &t
  3821. }
  3822. // StopTime returns the value of the "stop_time" field in the mutation.
  3823. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3824. v := m.stop_time
  3825. if v == nil {
  3826. return
  3827. }
  3828. return *v, true
  3829. }
  3830. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3831. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3833. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3834. if !m.op.Is(OpUpdateOne) {
  3835. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3836. }
  3837. if m.id == nil || m.oldValue == nil {
  3838. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3839. }
  3840. oldValue, err := m.oldValue(ctx)
  3841. if err != nil {
  3842. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3843. }
  3844. return oldValue.StopTime, nil
  3845. }
  3846. // ClearStopTime clears the value of the "stop_time" field.
  3847. func (m *BatchMsgMutation) ClearStopTime() {
  3848. m.stop_time = nil
  3849. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3850. }
  3851. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3852. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3853. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3854. return ok
  3855. }
  3856. // ResetStopTime resets all changes to the "stop_time" field.
  3857. func (m *BatchMsgMutation) ResetStopTime() {
  3858. m.stop_time = nil
  3859. delete(m.clearedFields, batchmsg.FieldStopTime)
  3860. }
  3861. // SetSendTime sets the "send_time" field.
  3862. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3863. m.send_time = &t
  3864. }
  3865. // SendTime returns the value of the "send_time" field in the mutation.
  3866. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3867. v := m.send_time
  3868. if v == nil {
  3869. return
  3870. }
  3871. return *v, true
  3872. }
  3873. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3876. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3877. if !m.op.Is(OpUpdateOne) {
  3878. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3879. }
  3880. if m.id == nil || m.oldValue == nil {
  3881. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3882. }
  3883. oldValue, err := m.oldValue(ctx)
  3884. if err != nil {
  3885. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3886. }
  3887. return oldValue.SendTime, nil
  3888. }
  3889. // ClearSendTime clears the value of the "send_time" field.
  3890. func (m *BatchMsgMutation) ClearSendTime() {
  3891. m.send_time = nil
  3892. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3893. }
  3894. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3895. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3896. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3897. return ok
  3898. }
  3899. // ResetSendTime resets all changes to the "send_time" field.
  3900. func (m *BatchMsgMutation) ResetSendTime() {
  3901. m.send_time = nil
  3902. delete(m.clearedFields, batchmsg.FieldSendTime)
  3903. }
  3904. // SetType sets the "type" field.
  3905. func (m *BatchMsgMutation) SetType(i int32) {
  3906. m._type = &i
  3907. m.add_type = nil
  3908. }
  3909. // GetType returns the value of the "type" field in the mutation.
  3910. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3911. v := m._type
  3912. if v == nil {
  3913. return
  3914. }
  3915. return *v, true
  3916. }
  3917. // OldType returns the old "type" field's value of the BatchMsg entity.
  3918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3920. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  3921. if !m.op.Is(OpUpdateOne) {
  3922. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3923. }
  3924. if m.id == nil || m.oldValue == nil {
  3925. return v, errors.New("OldType requires an ID field in the mutation")
  3926. }
  3927. oldValue, err := m.oldValue(ctx)
  3928. if err != nil {
  3929. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3930. }
  3931. return oldValue.Type, nil
  3932. }
  3933. // AddType adds i to the "type" field.
  3934. func (m *BatchMsgMutation) AddType(i int32) {
  3935. if m.add_type != nil {
  3936. *m.add_type += i
  3937. } else {
  3938. m.add_type = &i
  3939. }
  3940. }
  3941. // AddedType returns the value that was added to the "type" field in this mutation.
  3942. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  3943. v := m.add_type
  3944. if v == nil {
  3945. return
  3946. }
  3947. return *v, true
  3948. }
  3949. // ClearType clears the value of the "type" field.
  3950. func (m *BatchMsgMutation) ClearType() {
  3951. m._type = nil
  3952. m.add_type = nil
  3953. m.clearedFields[batchmsg.FieldType] = struct{}{}
  3954. }
  3955. // TypeCleared returns if the "type" field was cleared in this mutation.
  3956. func (m *BatchMsgMutation) TypeCleared() bool {
  3957. _, ok := m.clearedFields[batchmsg.FieldType]
  3958. return ok
  3959. }
  3960. // ResetType resets all changes to the "type" field.
  3961. func (m *BatchMsgMutation) ResetType() {
  3962. m._type = nil
  3963. m.add_type = nil
  3964. delete(m.clearedFields, batchmsg.FieldType)
  3965. }
  3966. // SetOrganizationID sets the "organization_id" field.
  3967. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  3968. m.organization_id = &u
  3969. m.addorganization_id = nil
  3970. }
  3971. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3972. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  3973. v := m.organization_id
  3974. if v == nil {
  3975. return
  3976. }
  3977. return *v, true
  3978. }
  3979. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  3980. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3982. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3983. if !m.op.Is(OpUpdateOne) {
  3984. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3985. }
  3986. if m.id == nil || m.oldValue == nil {
  3987. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3988. }
  3989. oldValue, err := m.oldValue(ctx)
  3990. if err != nil {
  3991. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3992. }
  3993. return oldValue.OrganizationID, nil
  3994. }
  3995. // AddOrganizationID adds u to the "organization_id" field.
  3996. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  3997. if m.addorganization_id != nil {
  3998. *m.addorganization_id += u
  3999. } else {
  4000. m.addorganization_id = &u
  4001. }
  4002. }
  4003. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4004. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4005. v := m.addorganization_id
  4006. if v == nil {
  4007. return
  4008. }
  4009. return *v, true
  4010. }
  4011. // ResetOrganizationID resets all changes to the "organization_id" field.
  4012. func (m *BatchMsgMutation) ResetOrganizationID() {
  4013. m.organization_id = nil
  4014. m.addorganization_id = nil
  4015. }
  4016. // Where appends a list predicates to the BatchMsgMutation builder.
  4017. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4018. m.predicates = append(m.predicates, ps...)
  4019. }
  4020. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4021. // users can use type-assertion to append predicates that do not depend on any generated package.
  4022. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4023. p := make([]predicate.BatchMsg, len(ps))
  4024. for i := range ps {
  4025. p[i] = ps[i]
  4026. }
  4027. m.Where(p...)
  4028. }
  4029. // Op returns the operation name.
  4030. func (m *BatchMsgMutation) Op() Op {
  4031. return m.op
  4032. }
  4033. // SetOp allows setting the mutation operation.
  4034. func (m *BatchMsgMutation) SetOp(op Op) {
  4035. m.op = op
  4036. }
  4037. // Type returns the node type of this mutation (BatchMsg).
  4038. func (m *BatchMsgMutation) Type() string {
  4039. return m.typ
  4040. }
  4041. // Fields returns all fields that were changed during this mutation. Note that in
  4042. // order to get all numeric fields that were incremented/decremented, call
  4043. // AddedFields().
  4044. func (m *BatchMsgMutation) Fields() []string {
  4045. fields := make([]string, 0, 18)
  4046. if m.created_at != nil {
  4047. fields = append(fields, batchmsg.FieldCreatedAt)
  4048. }
  4049. if m.updated_at != nil {
  4050. fields = append(fields, batchmsg.FieldUpdatedAt)
  4051. }
  4052. if m.deleted_at != nil {
  4053. fields = append(fields, batchmsg.FieldDeletedAt)
  4054. }
  4055. if m.status != nil {
  4056. fields = append(fields, batchmsg.FieldStatus)
  4057. }
  4058. if m.batch_no != nil {
  4059. fields = append(fields, batchmsg.FieldBatchNo)
  4060. }
  4061. if m.task_name != nil {
  4062. fields = append(fields, batchmsg.FieldTaskName)
  4063. }
  4064. if m.fromwxid != nil {
  4065. fields = append(fields, batchmsg.FieldFromwxid)
  4066. }
  4067. if m.msg != nil {
  4068. fields = append(fields, batchmsg.FieldMsg)
  4069. }
  4070. if m.tag != nil {
  4071. fields = append(fields, batchmsg.FieldTag)
  4072. }
  4073. if m.tagids != nil {
  4074. fields = append(fields, batchmsg.FieldTagids)
  4075. }
  4076. if m.total != nil {
  4077. fields = append(fields, batchmsg.FieldTotal)
  4078. }
  4079. if m.success != nil {
  4080. fields = append(fields, batchmsg.FieldSuccess)
  4081. }
  4082. if m.fail != nil {
  4083. fields = append(fields, batchmsg.FieldFail)
  4084. }
  4085. if m.start_time != nil {
  4086. fields = append(fields, batchmsg.FieldStartTime)
  4087. }
  4088. if m.stop_time != nil {
  4089. fields = append(fields, batchmsg.FieldStopTime)
  4090. }
  4091. if m.send_time != nil {
  4092. fields = append(fields, batchmsg.FieldSendTime)
  4093. }
  4094. if m._type != nil {
  4095. fields = append(fields, batchmsg.FieldType)
  4096. }
  4097. if m.organization_id != nil {
  4098. fields = append(fields, batchmsg.FieldOrganizationID)
  4099. }
  4100. return fields
  4101. }
  4102. // Field returns the value of a field with the given name. The second boolean
  4103. // return value indicates that this field was not set, or was not defined in the
  4104. // schema.
  4105. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4106. switch name {
  4107. case batchmsg.FieldCreatedAt:
  4108. return m.CreatedAt()
  4109. case batchmsg.FieldUpdatedAt:
  4110. return m.UpdatedAt()
  4111. case batchmsg.FieldDeletedAt:
  4112. return m.DeletedAt()
  4113. case batchmsg.FieldStatus:
  4114. return m.Status()
  4115. case batchmsg.FieldBatchNo:
  4116. return m.BatchNo()
  4117. case batchmsg.FieldTaskName:
  4118. return m.TaskName()
  4119. case batchmsg.FieldFromwxid:
  4120. return m.Fromwxid()
  4121. case batchmsg.FieldMsg:
  4122. return m.Msg()
  4123. case batchmsg.FieldTag:
  4124. return m.Tag()
  4125. case batchmsg.FieldTagids:
  4126. return m.Tagids()
  4127. case batchmsg.FieldTotal:
  4128. return m.Total()
  4129. case batchmsg.FieldSuccess:
  4130. return m.Success()
  4131. case batchmsg.FieldFail:
  4132. return m.Fail()
  4133. case batchmsg.FieldStartTime:
  4134. return m.StartTime()
  4135. case batchmsg.FieldStopTime:
  4136. return m.StopTime()
  4137. case batchmsg.FieldSendTime:
  4138. return m.SendTime()
  4139. case batchmsg.FieldType:
  4140. return m.GetType()
  4141. case batchmsg.FieldOrganizationID:
  4142. return m.OrganizationID()
  4143. }
  4144. return nil, false
  4145. }
  4146. // OldField returns the old value of the field from the database. An error is
  4147. // returned if the mutation operation is not UpdateOne, or the query to the
  4148. // database failed.
  4149. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4150. switch name {
  4151. case batchmsg.FieldCreatedAt:
  4152. return m.OldCreatedAt(ctx)
  4153. case batchmsg.FieldUpdatedAt:
  4154. return m.OldUpdatedAt(ctx)
  4155. case batchmsg.FieldDeletedAt:
  4156. return m.OldDeletedAt(ctx)
  4157. case batchmsg.FieldStatus:
  4158. return m.OldStatus(ctx)
  4159. case batchmsg.FieldBatchNo:
  4160. return m.OldBatchNo(ctx)
  4161. case batchmsg.FieldTaskName:
  4162. return m.OldTaskName(ctx)
  4163. case batchmsg.FieldFromwxid:
  4164. return m.OldFromwxid(ctx)
  4165. case batchmsg.FieldMsg:
  4166. return m.OldMsg(ctx)
  4167. case batchmsg.FieldTag:
  4168. return m.OldTag(ctx)
  4169. case batchmsg.FieldTagids:
  4170. return m.OldTagids(ctx)
  4171. case batchmsg.FieldTotal:
  4172. return m.OldTotal(ctx)
  4173. case batchmsg.FieldSuccess:
  4174. return m.OldSuccess(ctx)
  4175. case batchmsg.FieldFail:
  4176. return m.OldFail(ctx)
  4177. case batchmsg.FieldStartTime:
  4178. return m.OldStartTime(ctx)
  4179. case batchmsg.FieldStopTime:
  4180. return m.OldStopTime(ctx)
  4181. case batchmsg.FieldSendTime:
  4182. return m.OldSendTime(ctx)
  4183. case batchmsg.FieldType:
  4184. return m.OldType(ctx)
  4185. case batchmsg.FieldOrganizationID:
  4186. return m.OldOrganizationID(ctx)
  4187. }
  4188. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4189. }
  4190. // SetField sets the value of a field with the given name. It returns an error if
  4191. // the field is not defined in the schema, or if the type mismatched the field
  4192. // type.
  4193. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4194. switch name {
  4195. case batchmsg.FieldCreatedAt:
  4196. v, ok := value.(time.Time)
  4197. if !ok {
  4198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4199. }
  4200. m.SetCreatedAt(v)
  4201. return nil
  4202. case batchmsg.FieldUpdatedAt:
  4203. v, ok := value.(time.Time)
  4204. if !ok {
  4205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4206. }
  4207. m.SetUpdatedAt(v)
  4208. return nil
  4209. case batchmsg.FieldDeletedAt:
  4210. v, ok := value.(time.Time)
  4211. if !ok {
  4212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4213. }
  4214. m.SetDeletedAt(v)
  4215. return nil
  4216. case batchmsg.FieldStatus:
  4217. v, ok := value.(uint8)
  4218. if !ok {
  4219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4220. }
  4221. m.SetStatus(v)
  4222. return nil
  4223. case batchmsg.FieldBatchNo:
  4224. v, ok := value.(string)
  4225. if !ok {
  4226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4227. }
  4228. m.SetBatchNo(v)
  4229. return nil
  4230. case batchmsg.FieldTaskName:
  4231. v, ok := value.(string)
  4232. if !ok {
  4233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4234. }
  4235. m.SetTaskName(v)
  4236. return nil
  4237. case batchmsg.FieldFromwxid:
  4238. v, ok := value.(string)
  4239. if !ok {
  4240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4241. }
  4242. m.SetFromwxid(v)
  4243. return nil
  4244. case batchmsg.FieldMsg:
  4245. v, ok := value.(string)
  4246. if !ok {
  4247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4248. }
  4249. m.SetMsg(v)
  4250. return nil
  4251. case batchmsg.FieldTag:
  4252. v, ok := value.(string)
  4253. if !ok {
  4254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4255. }
  4256. m.SetTag(v)
  4257. return nil
  4258. case batchmsg.FieldTagids:
  4259. v, ok := value.(string)
  4260. if !ok {
  4261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4262. }
  4263. m.SetTagids(v)
  4264. return nil
  4265. case batchmsg.FieldTotal:
  4266. v, ok := value.(int32)
  4267. if !ok {
  4268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4269. }
  4270. m.SetTotal(v)
  4271. return nil
  4272. case batchmsg.FieldSuccess:
  4273. v, ok := value.(int32)
  4274. if !ok {
  4275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4276. }
  4277. m.SetSuccess(v)
  4278. return nil
  4279. case batchmsg.FieldFail:
  4280. v, ok := value.(int32)
  4281. if !ok {
  4282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4283. }
  4284. m.SetFail(v)
  4285. return nil
  4286. case batchmsg.FieldStartTime:
  4287. v, ok := value.(time.Time)
  4288. if !ok {
  4289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4290. }
  4291. m.SetStartTime(v)
  4292. return nil
  4293. case batchmsg.FieldStopTime:
  4294. v, ok := value.(time.Time)
  4295. if !ok {
  4296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4297. }
  4298. m.SetStopTime(v)
  4299. return nil
  4300. case batchmsg.FieldSendTime:
  4301. v, ok := value.(time.Time)
  4302. if !ok {
  4303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4304. }
  4305. m.SetSendTime(v)
  4306. return nil
  4307. case batchmsg.FieldType:
  4308. v, ok := value.(int32)
  4309. if !ok {
  4310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4311. }
  4312. m.SetType(v)
  4313. return nil
  4314. case batchmsg.FieldOrganizationID:
  4315. v, ok := value.(uint64)
  4316. if !ok {
  4317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4318. }
  4319. m.SetOrganizationID(v)
  4320. return nil
  4321. }
  4322. return fmt.Errorf("unknown BatchMsg field %s", name)
  4323. }
  4324. // AddedFields returns all numeric fields that were incremented/decremented during
  4325. // this mutation.
  4326. func (m *BatchMsgMutation) AddedFields() []string {
  4327. var fields []string
  4328. if m.addstatus != nil {
  4329. fields = append(fields, batchmsg.FieldStatus)
  4330. }
  4331. if m.addtotal != nil {
  4332. fields = append(fields, batchmsg.FieldTotal)
  4333. }
  4334. if m.addsuccess != nil {
  4335. fields = append(fields, batchmsg.FieldSuccess)
  4336. }
  4337. if m.addfail != nil {
  4338. fields = append(fields, batchmsg.FieldFail)
  4339. }
  4340. if m.add_type != nil {
  4341. fields = append(fields, batchmsg.FieldType)
  4342. }
  4343. if m.addorganization_id != nil {
  4344. fields = append(fields, batchmsg.FieldOrganizationID)
  4345. }
  4346. return fields
  4347. }
  4348. // AddedField returns the numeric value that was incremented/decremented on a field
  4349. // with the given name. The second boolean return value indicates that this field
  4350. // was not set, or was not defined in the schema.
  4351. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4352. switch name {
  4353. case batchmsg.FieldStatus:
  4354. return m.AddedStatus()
  4355. case batchmsg.FieldTotal:
  4356. return m.AddedTotal()
  4357. case batchmsg.FieldSuccess:
  4358. return m.AddedSuccess()
  4359. case batchmsg.FieldFail:
  4360. return m.AddedFail()
  4361. case batchmsg.FieldType:
  4362. return m.AddedType()
  4363. case batchmsg.FieldOrganizationID:
  4364. return m.AddedOrganizationID()
  4365. }
  4366. return nil, false
  4367. }
  4368. // AddField adds the value to the field with the given name. It returns an error if
  4369. // the field is not defined in the schema, or if the type mismatched the field
  4370. // type.
  4371. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4372. switch name {
  4373. case batchmsg.FieldStatus:
  4374. v, ok := value.(int8)
  4375. if !ok {
  4376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4377. }
  4378. m.AddStatus(v)
  4379. return nil
  4380. case batchmsg.FieldTotal:
  4381. v, ok := value.(int32)
  4382. if !ok {
  4383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4384. }
  4385. m.AddTotal(v)
  4386. return nil
  4387. case batchmsg.FieldSuccess:
  4388. v, ok := value.(int32)
  4389. if !ok {
  4390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4391. }
  4392. m.AddSuccess(v)
  4393. return nil
  4394. case batchmsg.FieldFail:
  4395. v, ok := value.(int32)
  4396. if !ok {
  4397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4398. }
  4399. m.AddFail(v)
  4400. return nil
  4401. case batchmsg.FieldType:
  4402. v, ok := value.(int32)
  4403. if !ok {
  4404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4405. }
  4406. m.AddType(v)
  4407. return nil
  4408. case batchmsg.FieldOrganizationID:
  4409. v, ok := value.(int64)
  4410. if !ok {
  4411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4412. }
  4413. m.AddOrganizationID(v)
  4414. return nil
  4415. }
  4416. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4417. }
  4418. // ClearedFields returns all nullable fields that were cleared during this
  4419. // mutation.
  4420. func (m *BatchMsgMutation) ClearedFields() []string {
  4421. var fields []string
  4422. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4423. fields = append(fields, batchmsg.FieldDeletedAt)
  4424. }
  4425. if m.FieldCleared(batchmsg.FieldStatus) {
  4426. fields = append(fields, batchmsg.FieldStatus)
  4427. }
  4428. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4429. fields = append(fields, batchmsg.FieldBatchNo)
  4430. }
  4431. if m.FieldCleared(batchmsg.FieldTaskName) {
  4432. fields = append(fields, batchmsg.FieldTaskName)
  4433. }
  4434. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4435. fields = append(fields, batchmsg.FieldFromwxid)
  4436. }
  4437. if m.FieldCleared(batchmsg.FieldMsg) {
  4438. fields = append(fields, batchmsg.FieldMsg)
  4439. }
  4440. if m.FieldCleared(batchmsg.FieldTag) {
  4441. fields = append(fields, batchmsg.FieldTag)
  4442. }
  4443. if m.FieldCleared(batchmsg.FieldTagids) {
  4444. fields = append(fields, batchmsg.FieldTagids)
  4445. }
  4446. if m.FieldCleared(batchmsg.FieldTotal) {
  4447. fields = append(fields, batchmsg.FieldTotal)
  4448. }
  4449. if m.FieldCleared(batchmsg.FieldSuccess) {
  4450. fields = append(fields, batchmsg.FieldSuccess)
  4451. }
  4452. if m.FieldCleared(batchmsg.FieldFail) {
  4453. fields = append(fields, batchmsg.FieldFail)
  4454. }
  4455. if m.FieldCleared(batchmsg.FieldStartTime) {
  4456. fields = append(fields, batchmsg.FieldStartTime)
  4457. }
  4458. if m.FieldCleared(batchmsg.FieldStopTime) {
  4459. fields = append(fields, batchmsg.FieldStopTime)
  4460. }
  4461. if m.FieldCleared(batchmsg.FieldSendTime) {
  4462. fields = append(fields, batchmsg.FieldSendTime)
  4463. }
  4464. if m.FieldCleared(batchmsg.FieldType) {
  4465. fields = append(fields, batchmsg.FieldType)
  4466. }
  4467. return fields
  4468. }
  4469. // FieldCleared returns a boolean indicating if a field with the given name was
  4470. // cleared in this mutation.
  4471. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4472. _, ok := m.clearedFields[name]
  4473. return ok
  4474. }
  4475. // ClearField clears the value of the field with the given name. It returns an
  4476. // error if the field is not defined in the schema.
  4477. func (m *BatchMsgMutation) ClearField(name string) error {
  4478. switch name {
  4479. case batchmsg.FieldDeletedAt:
  4480. m.ClearDeletedAt()
  4481. return nil
  4482. case batchmsg.FieldStatus:
  4483. m.ClearStatus()
  4484. return nil
  4485. case batchmsg.FieldBatchNo:
  4486. m.ClearBatchNo()
  4487. return nil
  4488. case batchmsg.FieldTaskName:
  4489. m.ClearTaskName()
  4490. return nil
  4491. case batchmsg.FieldFromwxid:
  4492. m.ClearFromwxid()
  4493. return nil
  4494. case batchmsg.FieldMsg:
  4495. m.ClearMsg()
  4496. return nil
  4497. case batchmsg.FieldTag:
  4498. m.ClearTag()
  4499. return nil
  4500. case batchmsg.FieldTagids:
  4501. m.ClearTagids()
  4502. return nil
  4503. case batchmsg.FieldTotal:
  4504. m.ClearTotal()
  4505. return nil
  4506. case batchmsg.FieldSuccess:
  4507. m.ClearSuccess()
  4508. return nil
  4509. case batchmsg.FieldFail:
  4510. m.ClearFail()
  4511. return nil
  4512. case batchmsg.FieldStartTime:
  4513. m.ClearStartTime()
  4514. return nil
  4515. case batchmsg.FieldStopTime:
  4516. m.ClearStopTime()
  4517. return nil
  4518. case batchmsg.FieldSendTime:
  4519. m.ClearSendTime()
  4520. return nil
  4521. case batchmsg.FieldType:
  4522. m.ClearType()
  4523. return nil
  4524. }
  4525. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4526. }
  4527. // ResetField resets all changes in the mutation for the field with the given name.
  4528. // It returns an error if the field is not defined in the schema.
  4529. func (m *BatchMsgMutation) ResetField(name string) error {
  4530. switch name {
  4531. case batchmsg.FieldCreatedAt:
  4532. m.ResetCreatedAt()
  4533. return nil
  4534. case batchmsg.FieldUpdatedAt:
  4535. m.ResetUpdatedAt()
  4536. return nil
  4537. case batchmsg.FieldDeletedAt:
  4538. m.ResetDeletedAt()
  4539. return nil
  4540. case batchmsg.FieldStatus:
  4541. m.ResetStatus()
  4542. return nil
  4543. case batchmsg.FieldBatchNo:
  4544. m.ResetBatchNo()
  4545. return nil
  4546. case batchmsg.FieldTaskName:
  4547. m.ResetTaskName()
  4548. return nil
  4549. case batchmsg.FieldFromwxid:
  4550. m.ResetFromwxid()
  4551. return nil
  4552. case batchmsg.FieldMsg:
  4553. m.ResetMsg()
  4554. return nil
  4555. case batchmsg.FieldTag:
  4556. m.ResetTag()
  4557. return nil
  4558. case batchmsg.FieldTagids:
  4559. m.ResetTagids()
  4560. return nil
  4561. case batchmsg.FieldTotal:
  4562. m.ResetTotal()
  4563. return nil
  4564. case batchmsg.FieldSuccess:
  4565. m.ResetSuccess()
  4566. return nil
  4567. case batchmsg.FieldFail:
  4568. m.ResetFail()
  4569. return nil
  4570. case batchmsg.FieldStartTime:
  4571. m.ResetStartTime()
  4572. return nil
  4573. case batchmsg.FieldStopTime:
  4574. m.ResetStopTime()
  4575. return nil
  4576. case batchmsg.FieldSendTime:
  4577. m.ResetSendTime()
  4578. return nil
  4579. case batchmsg.FieldType:
  4580. m.ResetType()
  4581. return nil
  4582. case batchmsg.FieldOrganizationID:
  4583. m.ResetOrganizationID()
  4584. return nil
  4585. }
  4586. return fmt.Errorf("unknown BatchMsg field %s", name)
  4587. }
  4588. // AddedEdges returns all edge names that were set/added in this mutation.
  4589. func (m *BatchMsgMutation) AddedEdges() []string {
  4590. edges := make([]string, 0, 0)
  4591. return edges
  4592. }
  4593. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4594. // name in this mutation.
  4595. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4596. return nil
  4597. }
  4598. // RemovedEdges returns all edge names that were removed in this mutation.
  4599. func (m *BatchMsgMutation) RemovedEdges() []string {
  4600. edges := make([]string, 0, 0)
  4601. return edges
  4602. }
  4603. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4604. // the given name in this mutation.
  4605. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4606. return nil
  4607. }
  4608. // ClearedEdges returns all edge names that were cleared in this mutation.
  4609. func (m *BatchMsgMutation) ClearedEdges() []string {
  4610. edges := make([]string, 0, 0)
  4611. return edges
  4612. }
  4613. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4614. // was cleared in this mutation.
  4615. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4616. return false
  4617. }
  4618. // ClearEdge clears the value of the edge with the given name. It returns an error
  4619. // if that edge is not defined in the schema.
  4620. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4621. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4622. }
  4623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4624. // It returns an error if the edge is not defined in the schema.
  4625. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4626. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4627. }
  4628. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4629. type CategoryMutation struct {
  4630. config
  4631. op Op
  4632. typ string
  4633. id *uint64
  4634. created_at *time.Time
  4635. updated_at *time.Time
  4636. deleted_at *time.Time
  4637. name *string
  4638. organization_id *uint64
  4639. addorganization_id *int64
  4640. clearedFields map[string]struct{}
  4641. done bool
  4642. oldValue func(context.Context) (*Category, error)
  4643. predicates []predicate.Category
  4644. }
  4645. var _ ent.Mutation = (*CategoryMutation)(nil)
  4646. // categoryOption allows management of the mutation configuration using functional options.
  4647. type categoryOption func(*CategoryMutation)
  4648. // newCategoryMutation creates new mutation for the Category entity.
  4649. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4650. m := &CategoryMutation{
  4651. config: c,
  4652. op: op,
  4653. typ: TypeCategory,
  4654. clearedFields: make(map[string]struct{}),
  4655. }
  4656. for _, opt := range opts {
  4657. opt(m)
  4658. }
  4659. return m
  4660. }
  4661. // withCategoryID sets the ID field of the mutation.
  4662. func withCategoryID(id uint64) categoryOption {
  4663. return func(m *CategoryMutation) {
  4664. var (
  4665. err error
  4666. once sync.Once
  4667. value *Category
  4668. )
  4669. m.oldValue = func(ctx context.Context) (*Category, error) {
  4670. once.Do(func() {
  4671. if m.done {
  4672. err = errors.New("querying old values post mutation is not allowed")
  4673. } else {
  4674. value, err = m.Client().Category.Get(ctx, id)
  4675. }
  4676. })
  4677. return value, err
  4678. }
  4679. m.id = &id
  4680. }
  4681. }
  4682. // withCategory sets the old Category of the mutation.
  4683. func withCategory(node *Category) categoryOption {
  4684. return func(m *CategoryMutation) {
  4685. m.oldValue = func(context.Context) (*Category, error) {
  4686. return node, nil
  4687. }
  4688. m.id = &node.ID
  4689. }
  4690. }
  4691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4692. // executed in a transaction (ent.Tx), a transactional client is returned.
  4693. func (m CategoryMutation) Client() *Client {
  4694. client := &Client{config: m.config}
  4695. client.init()
  4696. return client
  4697. }
  4698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4699. // it returns an error otherwise.
  4700. func (m CategoryMutation) Tx() (*Tx, error) {
  4701. if _, ok := m.driver.(*txDriver); !ok {
  4702. return nil, errors.New("ent: mutation is not running in a transaction")
  4703. }
  4704. tx := &Tx{config: m.config}
  4705. tx.init()
  4706. return tx, nil
  4707. }
  4708. // SetID sets the value of the id field. Note that this
  4709. // operation is only accepted on creation of Category entities.
  4710. func (m *CategoryMutation) SetID(id uint64) {
  4711. m.id = &id
  4712. }
  4713. // ID returns the ID value in the mutation. Note that the ID is only available
  4714. // if it was provided to the builder or after it was returned from the database.
  4715. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4716. if m.id == nil {
  4717. return
  4718. }
  4719. return *m.id, true
  4720. }
  4721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4722. // That means, if the mutation is applied within a transaction with an isolation level such
  4723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4724. // or updated by the mutation.
  4725. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4726. switch {
  4727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4728. id, exists := m.ID()
  4729. if exists {
  4730. return []uint64{id}, nil
  4731. }
  4732. fallthrough
  4733. case m.op.Is(OpUpdate | OpDelete):
  4734. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4735. default:
  4736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4737. }
  4738. }
  4739. // SetCreatedAt sets the "created_at" field.
  4740. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4741. m.created_at = &t
  4742. }
  4743. // CreatedAt returns the value of the "created_at" field in the mutation.
  4744. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4745. v := m.created_at
  4746. if v == nil {
  4747. return
  4748. }
  4749. return *v, true
  4750. }
  4751. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4752. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4754. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4755. if !m.op.Is(OpUpdateOne) {
  4756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4757. }
  4758. if m.id == nil || m.oldValue == nil {
  4759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4760. }
  4761. oldValue, err := m.oldValue(ctx)
  4762. if err != nil {
  4763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4764. }
  4765. return oldValue.CreatedAt, nil
  4766. }
  4767. // ResetCreatedAt resets all changes to the "created_at" field.
  4768. func (m *CategoryMutation) ResetCreatedAt() {
  4769. m.created_at = nil
  4770. }
  4771. // SetUpdatedAt sets the "updated_at" field.
  4772. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4773. m.updated_at = &t
  4774. }
  4775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4776. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4777. v := m.updated_at
  4778. if v == nil {
  4779. return
  4780. }
  4781. return *v, true
  4782. }
  4783. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4786. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4787. if !m.op.Is(OpUpdateOne) {
  4788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4789. }
  4790. if m.id == nil || m.oldValue == nil {
  4791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4792. }
  4793. oldValue, err := m.oldValue(ctx)
  4794. if err != nil {
  4795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4796. }
  4797. return oldValue.UpdatedAt, nil
  4798. }
  4799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4800. func (m *CategoryMutation) ResetUpdatedAt() {
  4801. m.updated_at = nil
  4802. }
  4803. // SetDeletedAt sets the "deleted_at" field.
  4804. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4805. m.deleted_at = &t
  4806. }
  4807. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4808. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4809. v := m.deleted_at
  4810. if v == nil {
  4811. return
  4812. }
  4813. return *v, true
  4814. }
  4815. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4816. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4818. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4819. if !m.op.Is(OpUpdateOne) {
  4820. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4821. }
  4822. if m.id == nil || m.oldValue == nil {
  4823. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4824. }
  4825. oldValue, err := m.oldValue(ctx)
  4826. if err != nil {
  4827. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4828. }
  4829. return oldValue.DeletedAt, nil
  4830. }
  4831. // ClearDeletedAt clears the value of the "deleted_at" field.
  4832. func (m *CategoryMutation) ClearDeletedAt() {
  4833. m.deleted_at = nil
  4834. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4835. }
  4836. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4837. func (m *CategoryMutation) DeletedAtCleared() bool {
  4838. _, ok := m.clearedFields[category.FieldDeletedAt]
  4839. return ok
  4840. }
  4841. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4842. func (m *CategoryMutation) ResetDeletedAt() {
  4843. m.deleted_at = nil
  4844. delete(m.clearedFields, category.FieldDeletedAt)
  4845. }
  4846. // SetName sets the "name" field.
  4847. func (m *CategoryMutation) SetName(s string) {
  4848. m.name = &s
  4849. }
  4850. // Name returns the value of the "name" field in the mutation.
  4851. func (m *CategoryMutation) Name() (r string, exists bool) {
  4852. v := m.name
  4853. if v == nil {
  4854. return
  4855. }
  4856. return *v, true
  4857. }
  4858. // OldName returns the old "name" field's value of the Category entity.
  4859. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4861. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4862. if !m.op.Is(OpUpdateOne) {
  4863. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4864. }
  4865. if m.id == nil || m.oldValue == nil {
  4866. return v, errors.New("OldName requires an ID field in the mutation")
  4867. }
  4868. oldValue, err := m.oldValue(ctx)
  4869. if err != nil {
  4870. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4871. }
  4872. return oldValue.Name, nil
  4873. }
  4874. // ResetName resets all changes to the "name" field.
  4875. func (m *CategoryMutation) ResetName() {
  4876. m.name = nil
  4877. }
  4878. // SetOrganizationID sets the "organization_id" field.
  4879. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4880. m.organization_id = &u
  4881. m.addorganization_id = nil
  4882. }
  4883. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4884. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4885. v := m.organization_id
  4886. if v == nil {
  4887. return
  4888. }
  4889. return *v, true
  4890. }
  4891. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4895. if !m.op.Is(OpUpdateOne) {
  4896. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4897. }
  4898. if m.id == nil || m.oldValue == nil {
  4899. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  4904. }
  4905. return oldValue.OrganizationID, nil
  4906. }
  4907. // AddOrganizationID adds u to the "organization_id" field.
  4908. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4909. if m.addorganization_id != nil {
  4910. *m.addorganization_id += u
  4911. } else {
  4912. m.addorganization_id = &u
  4913. }
  4914. }
  4915. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4916. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  4917. v := m.addorganization_id
  4918. if v == nil {
  4919. return
  4920. }
  4921. return *v, true
  4922. }
  4923. // ResetOrganizationID resets all changes to the "organization_id" field.
  4924. func (m *CategoryMutation) ResetOrganizationID() {
  4925. m.organization_id = nil
  4926. m.addorganization_id = nil
  4927. }
  4928. // Where appends a list predicates to the CategoryMutation builder.
  4929. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  4930. m.predicates = append(m.predicates, ps...)
  4931. }
  4932. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  4933. // users can use type-assertion to append predicates that do not depend on any generated package.
  4934. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  4935. p := make([]predicate.Category, len(ps))
  4936. for i := range ps {
  4937. p[i] = ps[i]
  4938. }
  4939. m.Where(p...)
  4940. }
  4941. // Op returns the operation name.
  4942. func (m *CategoryMutation) Op() Op {
  4943. return m.op
  4944. }
  4945. // SetOp allows setting the mutation operation.
  4946. func (m *CategoryMutation) SetOp(op Op) {
  4947. m.op = op
  4948. }
  4949. // Type returns the node type of this mutation (Category).
  4950. func (m *CategoryMutation) Type() string {
  4951. return m.typ
  4952. }
  4953. // Fields returns all fields that were changed during this mutation. Note that in
  4954. // order to get all numeric fields that were incremented/decremented, call
  4955. // AddedFields().
  4956. func (m *CategoryMutation) Fields() []string {
  4957. fields := make([]string, 0, 5)
  4958. if m.created_at != nil {
  4959. fields = append(fields, category.FieldCreatedAt)
  4960. }
  4961. if m.updated_at != nil {
  4962. fields = append(fields, category.FieldUpdatedAt)
  4963. }
  4964. if m.deleted_at != nil {
  4965. fields = append(fields, category.FieldDeletedAt)
  4966. }
  4967. if m.name != nil {
  4968. fields = append(fields, category.FieldName)
  4969. }
  4970. if m.organization_id != nil {
  4971. fields = append(fields, category.FieldOrganizationID)
  4972. }
  4973. return fields
  4974. }
  4975. // Field returns the value of a field with the given name. The second boolean
  4976. // return value indicates that this field was not set, or was not defined in the
  4977. // schema.
  4978. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  4979. switch name {
  4980. case category.FieldCreatedAt:
  4981. return m.CreatedAt()
  4982. case category.FieldUpdatedAt:
  4983. return m.UpdatedAt()
  4984. case category.FieldDeletedAt:
  4985. return m.DeletedAt()
  4986. case category.FieldName:
  4987. return m.Name()
  4988. case category.FieldOrganizationID:
  4989. return m.OrganizationID()
  4990. }
  4991. return nil, false
  4992. }
  4993. // OldField returns the old value of the field from the database. An error is
  4994. // returned if the mutation operation is not UpdateOne, or the query to the
  4995. // database failed.
  4996. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4997. switch name {
  4998. case category.FieldCreatedAt:
  4999. return m.OldCreatedAt(ctx)
  5000. case category.FieldUpdatedAt:
  5001. return m.OldUpdatedAt(ctx)
  5002. case category.FieldDeletedAt:
  5003. return m.OldDeletedAt(ctx)
  5004. case category.FieldName:
  5005. return m.OldName(ctx)
  5006. case category.FieldOrganizationID:
  5007. return m.OldOrganizationID(ctx)
  5008. }
  5009. return nil, fmt.Errorf("unknown Category field %s", name)
  5010. }
  5011. // SetField sets the value of a field with the given name. It returns an error if
  5012. // the field is not defined in the schema, or if the type mismatched the field
  5013. // type.
  5014. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5015. switch name {
  5016. case category.FieldCreatedAt:
  5017. v, ok := value.(time.Time)
  5018. if !ok {
  5019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5020. }
  5021. m.SetCreatedAt(v)
  5022. return nil
  5023. case category.FieldUpdatedAt:
  5024. v, ok := value.(time.Time)
  5025. if !ok {
  5026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5027. }
  5028. m.SetUpdatedAt(v)
  5029. return nil
  5030. case category.FieldDeletedAt:
  5031. v, ok := value.(time.Time)
  5032. if !ok {
  5033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5034. }
  5035. m.SetDeletedAt(v)
  5036. return nil
  5037. case category.FieldName:
  5038. v, ok := value.(string)
  5039. if !ok {
  5040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5041. }
  5042. m.SetName(v)
  5043. return nil
  5044. case category.FieldOrganizationID:
  5045. v, ok := value.(uint64)
  5046. if !ok {
  5047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5048. }
  5049. m.SetOrganizationID(v)
  5050. return nil
  5051. }
  5052. return fmt.Errorf("unknown Category field %s", name)
  5053. }
  5054. // AddedFields returns all numeric fields that were incremented/decremented during
  5055. // this mutation.
  5056. func (m *CategoryMutation) AddedFields() []string {
  5057. var fields []string
  5058. if m.addorganization_id != nil {
  5059. fields = append(fields, category.FieldOrganizationID)
  5060. }
  5061. return fields
  5062. }
  5063. // AddedField returns the numeric value that was incremented/decremented on a field
  5064. // with the given name. The second boolean return value indicates that this field
  5065. // was not set, or was not defined in the schema.
  5066. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5067. switch name {
  5068. case category.FieldOrganizationID:
  5069. return m.AddedOrganizationID()
  5070. }
  5071. return nil, false
  5072. }
  5073. // AddField adds the value to the field with the given name. It returns an error if
  5074. // the field is not defined in the schema, or if the type mismatched the field
  5075. // type.
  5076. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5077. switch name {
  5078. case category.FieldOrganizationID:
  5079. v, ok := value.(int64)
  5080. if !ok {
  5081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5082. }
  5083. m.AddOrganizationID(v)
  5084. return nil
  5085. }
  5086. return fmt.Errorf("unknown Category numeric field %s", name)
  5087. }
  5088. // ClearedFields returns all nullable fields that were cleared during this
  5089. // mutation.
  5090. func (m *CategoryMutation) ClearedFields() []string {
  5091. var fields []string
  5092. if m.FieldCleared(category.FieldDeletedAt) {
  5093. fields = append(fields, category.FieldDeletedAt)
  5094. }
  5095. return fields
  5096. }
  5097. // FieldCleared returns a boolean indicating if a field with the given name was
  5098. // cleared in this mutation.
  5099. func (m *CategoryMutation) FieldCleared(name string) bool {
  5100. _, ok := m.clearedFields[name]
  5101. return ok
  5102. }
  5103. // ClearField clears the value of the field with the given name. It returns an
  5104. // error if the field is not defined in the schema.
  5105. func (m *CategoryMutation) ClearField(name string) error {
  5106. switch name {
  5107. case category.FieldDeletedAt:
  5108. m.ClearDeletedAt()
  5109. return nil
  5110. }
  5111. return fmt.Errorf("unknown Category nullable field %s", name)
  5112. }
  5113. // ResetField resets all changes in the mutation for the field with the given name.
  5114. // It returns an error if the field is not defined in the schema.
  5115. func (m *CategoryMutation) ResetField(name string) error {
  5116. switch name {
  5117. case category.FieldCreatedAt:
  5118. m.ResetCreatedAt()
  5119. return nil
  5120. case category.FieldUpdatedAt:
  5121. m.ResetUpdatedAt()
  5122. return nil
  5123. case category.FieldDeletedAt:
  5124. m.ResetDeletedAt()
  5125. return nil
  5126. case category.FieldName:
  5127. m.ResetName()
  5128. return nil
  5129. case category.FieldOrganizationID:
  5130. m.ResetOrganizationID()
  5131. return nil
  5132. }
  5133. return fmt.Errorf("unknown Category field %s", name)
  5134. }
  5135. // AddedEdges returns all edge names that were set/added in this mutation.
  5136. func (m *CategoryMutation) AddedEdges() []string {
  5137. edges := make([]string, 0, 0)
  5138. return edges
  5139. }
  5140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5141. // name in this mutation.
  5142. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5143. return nil
  5144. }
  5145. // RemovedEdges returns all edge names that were removed in this mutation.
  5146. func (m *CategoryMutation) RemovedEdges() []string {
  5147. edges := make([]string, 0, 0)
  5148. return edges
  5149. }
  5150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5151. // the given name in this mutation.
  5152. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5153. return nil
  5154. }
  5155. // ClearedEdges returns all edge names that were cleared in this mutation.
  5156. func (m *CategoryMutation) ClearedEdges() []string {
  5157. edges := make([]string, 0, 0)
  5158. return edges
  5159. }
  5160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5161. // was cleared in this mutation.
  5162. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5163. return false
  5164. }
  5165. // ClearEdge clears the value of the edge with the given name. It returns an error
  5166. // if that edge is not defined in the schema.
  5167. func (m *CategoryMutation) ClearEdge(name string) error {
  5168. return fmt.Errorf("unknown Category unique edge %s", name)
  5169. }
  5170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5171. // It returns an error if the edge is not defined in the schema.
  5172. func (m *CategoryMutation) ResetEdge(name string) error {
  5173. return fmt.Errorf("unknown Category edge %s", name)
  5174. }
  5175. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5176. type ChatRecordsMutation struct {
  5177. config
  5178. op Op
  5179. typ string
  5180. id *uint64
  5181. created_at *time.Time
  5182. updated_at *time.Time
  5183. deleted_at *time.Time
  5184. content *string
  5185. content_type *uint8
  5186. addcontent_type *int8
  5187. session_id *uint64
  5188. addsession_id *int64
  5189. user_id *uint64
  5190. adduser_id *int64
  5191. bot_id *uint64
  5192. addbot_id *int64
  5193. bot_type *uint8
  5194. addbot_type *int8
  5195. clearedFields map[string]struct{}
  5196. done bool
  5197. oldValue func(context.Context) (*ChatRecords, error)
  5198. predicates []predicate.ChatRecords
  5199. }
  5200. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5201. // chatrecordsOption allows management of the mutation configuration using functional options.
  5202. type chatrecordsOption func(*ChatRecordsMutation)
  5203. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5204. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5205. m := &ChatRecordsMutation{
  5206. config: c,
  5207. op: op,
  5208. typ: TypeChatRecords,
  5209. clearedFields: make(map[string]struct{}),
  5210. }
  5211. for _, opt := range opts {
  5212. opt(m)
  5213. }
  5214. return m
  5215. }
  5216. // withChatRecordsID sets the ID field of the mutation.
  5217. func withChatRecordsID(id uint64) chatrecordsOption {
  5218. return func(m *ChatRecordsMutation) {
  5219. var (
  5220. err error
  5221. once sync.Once
  5222. value *ChatRecords
  5223. )
  5224. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5225. once.Do(func() {
  5226. if m.done {
  5227. err = errors.New("querying old values post mutation is not allowed")
  5228. } else {
  5229. value, err = m.Client().ChatRecords.Get(ctx, id)
  5230. }
  5231. })
  5232. return value, err
  5233. }
  5234. m.id = &id
  5235. }
  5236. }
  5237. // withChatRecords sets the old ChatRecords of the mutation.
  5238. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5239. return func(m *ChatRecordsMutation) {
  5240. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5241. return node, nil
  5242. }
  5243. m.id = &node.ID
  5244. }
  5245. }
  5246. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5247. // executed in a transaction (ent.Tx), a transactional client is returned.
  5248. func (m ChatRecordsMutation) Client() *Client {
  5249. client := &Client{config: m.config}
  5250. client.init()
  5251. return client
  5252. }
  5253. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5254. // it returns an error otherwise.
  5255. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5256. if _, ok := m.driver.(*txDriver); !ok {
  5257. return nil, errors.New("ent: mutation is not running in a transaction")
  5258. }
  5259. tx := &Tx{config: m.config}
  5260. tx.init()
  5261. return tx, nil
  5262. }
  5263. // SetID sets the value of the id field. Note that this
  5264. // operation is only accepted on creation of ChatRecords entities.
  5265. func (m *ChatRecordsMutation) SetID(id uint64) {
  5266. m.id = &id
  5267. }
  5268. // ID returns the ID value in the mutation. Note that the ID is only available
  5269. // if it was provided to the builder or after it was returned from the database.
  5270. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5271. if m.id == nil {
  5272. return
  5273. }
  5274. return *m.id, true
  5275. }
  5276. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5277. // That means, if the mutation is applied within a transaction with an isolation level such
  5278. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5279. // or updated by the mutation.
  5280. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5281. switch {
  5282. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5283. id, exists := m.ID()
  5284. if exists {
  5285. return []uint64{id}, nil
  5286. }
  5287. fallthrough
  5288. case m.op.Is(OpUpdate | OpDelete):
  5289. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5290. default:
  5291. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5292. }
  5293. }
  5294. // SetCreatedAt sets the "created_at" field.
  5295. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5296. m.created_at = &t
  5297. }
  5298. // CreatedAt returns the value of the "created_at" field in the mutation.
  5299. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5300. v := m.created_at
  5301. if v == nil {
  5302. return
  5303. }
  5304. return *v, true
  5305. }
  5306. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5307. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5309. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5310. if !m.op.Is(OpUpdateOne) {
  5311. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5312. }
  5313. if m.id == nil || m.oldValue == nil {
  5314. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5315. }
  5316. oldValue, err := m.oldValue(ctx)
  5317. if err != nil {
  5318. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5319. }
  5320. return oldValue.CreatedAt, nil
  5321. }
  5322. // ResetCreatedAt resets all changes to the "created_at" field.
  5323. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5324. m.created_at = nil
  5325. }
  5326. // SetUpdatedAt sets the "updated_at" field.
  5327. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5328. m.updated_at = &t
  5329. }
  5330. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5331. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5332. v := m.updated_at
  5333. if v == nil {
  5334. return
  5335. }
  5336. return *v, true
  5337. }
  5338. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5341. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5342. if !m.op.Is(OpUpdateOne) {
  5343. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5344. }
  5345. if m.id == nil || m.oldValue == nil {
  5346. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5347. }
  5348. oldValue, err := m.oldValue(ctx)
  5349. if err != nil {
  5350. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5351. }
  5352. return oldValue.UpdatedAt, nil
  5353. }
  5354. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5355. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5356. m.updated_at = nil
  5357. }
  5358. // SetDeletedAt sets the "deleted_at" field.
  5359. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5360. m.deleted_at = &t
  5361. }
  5362. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5363. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5364. v := m.deleted_at
  5365. if v == nil {
  5366. return
  5367. }
  5368. return *v, true
  5369. }
  5370. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5371. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5373. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5374. if !m.op.Is(OpUpdateOne) {
  5375. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5376. }
  5377. if m.id == nil || m.oldValue == nil {
  5378. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5379. }
  5380. oldValue, err := m.oldValue(ctx)
  5381. if err != nil {
  5382. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5383. }
  5384. return oldValue.DeletedAt, nil
  5385. }
  5386. // ClearDeletedAt clears the value of the "deleted_at" field.
  5387. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5388. m.deleted_at = nil
  5389. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5390. }
  5391. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5392. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5393. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5394. return ok
  5395. }
  5396. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5397. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5398. m.deleted_at = nil
  5399. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5400. }
  5401. // SetContent sets the "content" field.
  5402. func (m *ChatRecordsMutation) SetContent(s string) {
  5403. m.content = &s
  5404. }
  5405. // Content returns the value of the "content" field in the mutation.
  5406. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5407. v := m.content
  5408. if v == nil {
  5409. return
  5410. }
  5411. return *v, true
  5412. }
  5413. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5414. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5416. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5417. if !m.op.Is(OpUpdateOne) {
  5418. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5419. }
  5420. if m.id == nil || m.oldValue == nil {
  5421. return v, errors.New("OldContent requires an ID field in the mutation")
  5422. }
  5423. oldValue, err := m.oldValue(ctx)
  5424. if err != nil {
  5425. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5426. }
  5427. return oldValue.Content, nil
  5428. }
  5429. // ResetContent resets all changes to the "content" field.
  5430. func (m *ChatRecordsMutation) ResetContent() {
  5431. m.content = nil
  5432. }
  5433. // SetContentType sets the "content_type" field.
  5434. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5435. m.content_type = &u
  5436. m.addcontent_type = nil
  5437. }
  5438. // ContentType returns the value of the "content_type" field in the mutation.
  5439. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5440. v := m.content_type
  5441. if v == nil {
  5442. return
  5443. }
  5444. return *v, true
  5445. }
  5446. // OldContentType returns the old "content_type" 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) OldContentType(ctx context.Context) (v uint8, err error) {
  5450. if !m.op.Is(OpUpdateOne) {
  5451. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5452. }
  5453. if m.id == nil || m.oldValue == nil {
  5454. return v, errors.New("OldContentType 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 OldContentType: %w", err)
  5459. }
  5460. return oldValue.ContentType, nil
  5461. }
  5462. // AddContentType adds u to the "content_type" field.
  5463. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5464. if m.addcontent_type != nil {
  5465. *m.addcontent_type += u
  5466. } else {
  5467. m.addcontent_type = &u
  5468. }
  5469. }
  5470. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5471. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5472. v := m.addcontent_type
  5473. if v == nil {
  5474. return
  5475. }
  5476. return *v, true
  5477. }
  5478. // ResetContentType resets all changes to the "content_type" field.
  5479. func (m *ChatRecordsMutation) ResetContentType() {
  5480. m.content_type = nil
  5481. m.addcontent_type = nil
  5482. }
  5483. // SetSessionID sets the "session_id" field.
  5484. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5485. m.session_id = &u
  5486. m.addsession_id = nil
  5487. }
  5488. // SessionID returns the value of the "session_id" field in the mutation.
  5489. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5490. v := m.session_id
  5491. if v == nil {
  5492. return
  5493. }
  5494. return *v, true
  5495. }
  5496. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5497. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5499. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5500. if !m.op.Is(OpUpdateOne) {
  5501. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5502. }
  5503. if m.id == nil || m.oldValue == nil {
  5504. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5505. }
  5506. oldValue, err := m.oldValue(ctx)
  5507. if err != nil {
  5508. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5509. }
  5510. return oldValue.SessionID, nil
  5511. }
  5512. // AddSessionID adds u to the "session_id" field.
  5513. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5514. if m.addsession_id != nil {
  5515. *m.addsession_id += u
  5516. } else {
  5517. m.addsession_id = &u
  5518. }
  5519. }
  5520. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5521. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5522. v := m.addsession_id
  5523. if v == nil {
  5524. return
  5525. }
  5526. return *v, true
  5527. }
  5528. // ResetSessionID resets all changes to the "session_id" field.
  5529. func (m *ChatRecordsMutation) ResetSessionID() {
  5530. m.session_id = nil
  5531. m.addsession_id = nil
  5532. }
  5533. // SetUserID sets the "user_id" field.
  5534. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5535. m.user_id = &u
  5536. m.adduser_id = nil
  5537. }
  5538. // UserID returns the value of the "user_id" field in the mutation.
  5539. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5540. v := m.user_id
  5541. if v == nil {
  5542. return
  5543. }
  5544. return *v, true
  5545. }
  5546. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5547. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5549. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5550. if !m.op.Is(OpUpdateOne) {
  5551. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5552. }
  5553. if m.id == nil || m.oldValue == nil {
  5554. return v, errors.New("OldUserID requires an ID field in the mutation")
  5555. }
  5556. oldValue, err := m.oldValue(ctx)
  5557. if err != nil {
  5558. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5559. }
  5560. return oldValue.UserID, nil
  5561. }
  5562. // AddUserID adds u to the "user_id" field.
  5563. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5564. if m.adduser_id != nil {
  5565. *m.adduser_id += u
  5566. } else {
  5567. m.adduser_id = &u
  5568. }
  5569. }
  5570. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5571. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5572. v := m.adduser_id
  5573. if v == nil {
  5574. return
  5575. }
  5576. return *v, true
  5577. }
  5578. // ResetUserID resets all changes to the "user_id" field.
  5579. func (m *ChatRecordsMutation) ResetUserID() {
  5580. m.user_id = nil
  5581. m.adduser_id = nil
  5582. }
  5583. // SetBotID sets the "bot_id" field.
  5584. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5585. m.bot_id = &u
  5586. m.addbot_id = nil
  5587. }
  5588. // BotID returns the value of the "bot_id" field in the mutation.
  5589. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5590. v := m.bot_id
  5591. if v == nil {
  5592. return
  5593. }
  5594. return *v, true
  5595. }
  5596. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5597. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5599. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5600. if !m.op.Is(OpUpdateOne) {
  5601. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5602. }
  5603. if m.id == nil || m.oldValue == nil {
  5604. return v, errors.New("OldBotID requires an ID field in the mutation")
  5605. }
  5606. oldValue, err := m.oldValue(ctx)
  5607. if err != nil {
  5608. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5609. }
  5610. return oldValue.BotID, nil
  5611. }
  5612. // AddBotID adds u to the "bot_id" field.
  5613. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5614. if m.addbot_id != nil {
  5615. *m.addbot_id += u
  5616. } else {
  5617. m.addbot_id = &u
  5618. }
  5619. }
  5620. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5621. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5622. v := m.addbot_id
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // ResetBotID resets all changes to the "bot_id" field.
  5629. func (m *ChatRecordsMutation) ResetBotID() {
  5630. m.bot_id = nil
  5631. m.addbot_id = nil
  5632. }
  5633. // SetBotType sets the "bot_type" field.
  5634. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5635. m.bot_type = &u
  5636. m.addbot_type = nil
  5637. }
  5638. // BotType returns the value of the "bot_type" field in the mutation.
  5639. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5640. v := m.bot_type
  5641. if v == nil {
  5642. return
  5643. }
  5644. return *v, true
  5645. }
  5646. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5647. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5649. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5650. if !m.op.Is(OpUpdateOne) {
  5651. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5652. }
  5653. if m.id == nil || m.oldValue == nil {
  5654. return v, errors.New("OldBotType requires an ID field in the mutation")
  5655. }
  5656. oldValue, err := m.oldValue(ctx)
  5657. if err != nil {
  5658. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5659. }
  5660. return oldValue.BotType, nil
  5661. }
  5662. // AddBotType adds u to the "bot_type" field.
  5663. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5664. if m.addbot_type != nil {
  5665. *m.addbot_type += u
  5666. } else {
  5667. m.addbot_type = &u
  5668. }
  5669. }
  5670. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5671. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5672. v := m.addbot_type
  5673. if v == nil {
  5674. return
  5675. }
  5676. return *v, true
  5677. }
  5678. // ResetBotType resets all changes to the "bot_type" field.
  5679. func (m *ChatRecordsMutation) ResetBotType() {
  5680. m.bot_type = nil
  5681. m.addbot_type = nil
  5682. }
  5683. // Where appends a list predicates to the ChatRecordsMutation builder.
  5684. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5685. m.predicates = append(m.predicates, ps...)
  5686. }
  5687. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5688. // users can use type-assertion to append predicates that do not depend on any generated package.
  5689. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5690. p := make([]predicate.ChatRecords, len(ps))
  5691. for i := range ps {
  5692. p[i] = ps[i]
  5693. }
  5694. m.Where(p...)
  5695. }
  5696. // Op returns the operation name.
  5697. func (m *ChatRecordsMutation) Op() Op {
  5698. return m.op
  5699. }
  5700. // SetOp allows setting the mutation operation.
  5701. func (m *ChatRecordsMutation) SetOp(op Op) {
  5702. m.op = op
  5703. }
  5704. // Type returns the node type of this mutation (ChatRecords).
  5705. func (m *ChatRecordsMutation) Type() string {
  5706. return m.typ
  5707. }
  5708. // Fields returns all fields that were changed during this mutation. Note that in
  5709. // order to get all numeric fields that were incremented/decremented, call
  5710. // AddedFields().
  5711. func (m *ChatRecordsMutation) Fields() []string {
  5712. fields := make([]string, 0, 9)
  5713. if m.created_at != nil {
  5714. fields = append(fields, chatrecords.FieldCreatedAt)
  5715. }
  5716. if m.updated_at != nil {
  5717. fields = append(fields, chatrecords.FieldUpdatedAt)
  5718. }
  5719. if m.deleted_at != nil {
  5720. fields = append(fields, chatrecords.FieldDeletedAt)
  5721. }
  5722. if m.content != nil {
  5723. fields = append(fields, chatrecords.FieldContent)
  5724. }
  5725. if m.content_type != nil {
  5726. fields = append(fields, chatrecords.FieldContentType)
  5727. }
  5728. if m.session_id != nil {
  5729. fields = append(fields, chatrecords.FieldSessionID)
  5730. }
  5731. if m.user_id != nil {
  5732. fields = append(fields, chatrecords.FieldUserID)
  5733. }
  5734. if m.bot_id != nil {
  5735. fields = append(fields, chatrecords.FieldBotID)
  5736. }
  5737. if m.bot_type != nil {
  5738. fields = append(fields, chatrecords.FieldBotType)
  5739. }
  5740. return fields
  5741. }
  5742. // Field returns the value of a field with the given name. The second boolean
  5743. // return value indicates that this field was not set, or was not defined in the
  5744. // schema.
  5745. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5746. switch name {
  5747. case chatrecords.FieldCreatedAt:
  5748. return m.CreatedAt()
  5749. case chatrecords.FieldUpdatedAt:
  5750. return m.UpdatedAt()
  5751. case chatrecords.FieldDeletedAt:
  5752. return m.DeletedAt()
  5753. case chatrecords.FieldContent:
  5754. return m.Content()
  5755. case chatrecords.FieldContentType:
  5756. return m.ContentType()
  5757. case chatrecords.FieldSessionID:
  5758. return m.SessionID()
  5759. case chatrecords.FieldUserID:
  5760. return m.UserID()
  5761. case chatrecords.FieldBotID:
  5762. return m.BotID()
  5763. case chatrecords.FieldBotType:
  5764. return m.BotType()
  5765. }
  5766. return nil, false
  5767. }
  5768. // OldField returns the old value of the field from the database. An error is
  5769. // returned if the mutation operation is not UpdateOne, or the query to the
  5770. // database failed.
  5771. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5772. switch name {
  5773. case chatrecords.FieldCreatedAt:
  5774. return m.OldCreatedAt(ctx)
  5775. case chatrecords.FieldUpdatedAt:
  5776. return m.OldUpdatedAt(ctx)
  5777. case chatrecords.FieldDeletedAt:
  5778. return m.OldDeletedAt(ctx)
  5779. case chatrecords.FieldContent:
  5780. return m.OldContent(ctx)
  5781. case chatrecords.FieldContentType:
  5782. return m.OldContentType(ctx)
  5783. case chatrecords.FieldSessionID:
  5784. return m.OldSessionID(ctx)
  5785. case chatrecords.FieldUserID:
  5786. return m.OldUserID(ctx)
  5787. case chatrecords.FieldBotID:
  5788. return m.OldBotID(ctx)
  5789. case chatrecords.FieldBotType:
  5790. return m.OldBotType(ctx)
  5791. }
  5792. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5793. }
  5794. // SetField sets the value of a field with the given name. It returns an error if
  5795. // the field is not defined in the schema, or if the type mismatched the field
  5796. // type.
  5797. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5798. switch name {
  5799. case chatrecords.FieldCreatedAt:
  5800. v, ok := value.(time.Time)
  5801. if !ok {
  5802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5803. }
  5804. m.SetCreatedAt(v)
  5805. return nil
  5806. case chatrecords.FieldUpdatedAt:
  5807. v, ok := value.(time.Time)
  5808. if !ok {
  5809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5810. }
  5811. m.SetUpdatedAt(v)
  5812. return nil
  5813. case chatrecords.FieldDeletedAt:
  5814. v, ok := value.(time.Time)
  5815. if !ok {
  5816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5817. }
  5818. m.SetDeletedAt(v)
  5819. return nil
  5820. case chatrecords.FieldContent:
  5821. v, ok := value.(string)
  5822. if !ok {
  5823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5824. }
  5825. m.SetContent(v)
  5826. return nil
  5827. case chatrecords.FieldContentType:
  5828. v, ok := value.(uint8)
  5829. if !ok {
  5830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5831. }
  5832. m.SetContentType(v)
  5833. return nil
  5834. case chatrecords.FieldSessionID:
  5835. v, ok := value.(uint64)
  5836. if !ok {
  5837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5838. }
  5839. m.SetSessionID(v)
  5840. return nil
  5841. case chatrecords.FieldUserID:
  5842. v, ok := value.(uint64)
  5843. if !ok {
  5844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5845. }
  5846. m.SetUserID(v)
  5847. return nil
  5848. case chatrecords.FieldBotID:
  5849. v, ok := value.(uint64)
  5850. if !ok {
  5851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5852. }
  5853. m.SetBotID(v)
  5854. return nil
  5855. case chatrecords.FieldBotType:
  5856. v, ok := value.(uint8)
  5857. if !ok {
  5858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5859. }
  5860. m.SetBotType(v)
  5861. return nil
  5862. }
  5863. return fmt.Errorf("unknown ChatRecords field %s", name)
  5864. }
  5865. // AddedFields returns all numeric fields that were incremented/decremented during
  5866. // this mutation.
  5867. func (m *ChatRecordsMutation) AddedFields() []string {
  5868. var fields []string
  5869. if m.addcontent_type != nil {
  5870. fields = append(fields, chatrecords.FieldContentType)
  5871. }
  5872. if m.addsession_id != nil {
  5873. fields = append(fields, chatrecords.FieldSessionID)
  5874. }
  5875. if m.adduser_id != nil {
  5876. fields = append(fields, chatrecords.FieldUserID)
  5877. }
  5878. if m.addbot_id != nil {
  5879. fields = append(fields, chatrecords.FieldBotID)
  5880. }
  5881. if m.addbot_type != nil {
  5882. fields = append(fields, chatrecords.FieldBotType)
  5883. }
  5884. return fields
  5885. }
  5886. // AddedField returns the numeric value that was incremented/decremented on a field
  5887. // with the given name. The second boolean return value indicates that this field
  5888. // was not set, or was not defined in the schema.
  5889. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5890. switch name {
  5891. case chatrecords.FieldContentType:
  5892. return m.AddedContentType()
  5893. case chatrecords.FieldSessionID:
  5894. return m.AddedSessionID()
  5895. case chatrecords.FieldUserID:
  5896. return m.AddedUserID()
  5897. case chatrecords.FieldBotID:
  5898. return m.AddedBotID()
  5899. case chatrecords.FieldBotType:
  5900. return m.AddedBotType()
  5901. }
  5902. return nil, false
  5903. }
  5904. // AddField adds the value to the field with the given name. It returns an error if
  5905. // the field is not defined in the schema, or if the type mismatched the field
  5906. // type.
  5907. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5908. switch name {
  5909. case chatrecords.FieldContentType:
  5910. v, ok := value.(int8)
  5911. if !ok {
  5912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5913. }
  5914. m.AddContentType(v)
  5915. return nil
  5916. case chatrecords.FieldSessionID:
  5917. v, ok := value.(int64)
  5918. if !ok {
  5919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5920. }
  5921. m.AddSessionID(v)
  5922. return nil
  5923. case chatrecords.FieldUserID:
  5924. v, ok := value.(int64)
  5925. if !ok {
  5926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5927. }
  5928. m.AddUserID(v)
  5929. return nil
  5930. case chatrecords.FieldBotID:
  5931. v, ok := value.(int64)
  5932. if !ok {
  5933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5934. }
  5935. m.AddBotID(v)
  5936. return nil
  5937. case chatrecords.FieldBotType:
  5938. v, ok := value.(int8)
  5939. if !ok {
  5940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5941. }
  5942. m.AddBotType(v)
  5943. return nil
  5944. }
  5945. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  5946. }
  5947. // ClearedFields returns all nullable fields that were cleared during this
  5948. // mutation.
  5949. func (m *ChatRecordsMutation) ClearedFields() []string {
  5950. var fields []string
  5951. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  5952. fields = append(fields, chatrecords.FieldDeletedAt)
  5953. }
  5954. return fields
  5955. }
  5956. // FieldCleared returns a boolean indicating if a field with the given name was
  5957. // cleared in this mutation.
  5958. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  5959. _, ok := m.clearedFields[name]
  5960. return ok
  5961. }
  5962. // ClearField clears the value of the field with the given name. It returns an
  5963. // error if the field is not defined in the schema.
  5964. func (m *ChatRecordsMutation) ClearField(name string) error {
  5965. switch name {
  5966. case chatrecords.FieldDeletedAt:
  5967. m.ClearDeletedAt()
  5968. return nil
  5969. }
  5970. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  5971. }
  5972. // ResetField resets all changes in the mutation for the field with the given name.
  5973. // It returns an error if the field is not defined in the schema.
  5974. func (m *ChatRecordsMutation) ResetField(name string) error {
  5975. switch name {
  5976. case chatrecords.FieldCreatedAt:
  5977. m.ResetCreatedAt()
  5978. return nil
  5979. case chatrecords.FieldUpdatedAt:
  5980. m.ResetUpdatedAt()
  5981. return nil
  5982. case chatrecords.FieldDeletedAt:
  5983. m.ResetDeletedAt()
  5984. return nil
  5985. case chatrecords.FieldContent:
  5986. m.ResetContent()
  5987. return nil
  5988. case chatrecords.FieldContentType:
  5989. m.ResetContentType()
  5990. return nil
  5991. case chatrecords.FieldSessionID:
  5992. m.ResetSessionID()
  5993. return nil
  5994. case chatrecords.FieldUserID:
  5995. m.ResetUserID()
  5996. return nil
  5997. case chatrecords.FieldBotID:
  5998. m.ResetBotID()
  5999. return nil
  6000. case chatrecords.FieldBotType:
  6001. m.ResetBotType()
  6002. return nil
  6003. }
  6004. return fmt.Errorf("unknown ChatRecords field %s", name)
  6005. }
  6006. // AddedEdges returns all edge names that were set/added in this mutation.
  6007. func (m *ChatRecordsMutation) AddedEdges() []string {
  6008. edges := make([]string, 0, 0)
  6009. return edges
  6010. }
  6011. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6012. // name in this mutation.
  6013. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6014. return nil
  6015. }
  6016. // RemovedEdges returns all edge names that were removed in this mutation.
  6017. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6018. edges := make([]string, 0, 0)
  6019. return edges
  6020. }
  6021. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6022. // the given name in this mutation.
  6023. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6024. return nil
  6025. }
  6026. // ClearedEdges returns all edge names that were cleared in this mutation.
  6027. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6028. edges := make([]string, 0, 0)
  6029. return edges
  6030. }
  6031. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6032. // was cleared in this mutation.
  6033. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6034. return false
  6035. }
  6036. // ClearEdge clears the value of the edge with the given name. It returns an error
  6037. // if that edge is not defined in the schema.
  6038. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6039. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6040. }
  6041. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6042. // It returns an error if the edge is not defined in the schema.
  6043. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6044. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6045. }
  6046. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6047. type ChatSessionMutation struct {
  6048. config
  6049. op Op
  6050. typ string
  6051. id *uint64
  6052. created_at *time.Time
  6053. updated_at *time.Time
  6054. deleted_at *time.Time
  6055. name *string
  6056. user_id *uint64
  6057. adduser_id *int64
  6058. bot_id *uint64
  6059. addbot_id *int64
  6060. bot_type *uint8
  6061. addbot_type *int8
  6062. clearedFields map[string]struct{}
  6063. done bool
  6064. oldValue func(context.Context) (*ChatSession, error)
  6065. predicates []predicate.ChatSession
  6066. }
  6067. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6068. // chatsessionOption allows management of the mutation configuration using functional options.
  6069. type chatsessionOption func(*ChatSessionMutation)
  6070. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6071. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6072. m := &ChatSessionMutation{
  6073. config: c,
  6074. op: op,
  6075. typ: TypeChatSession,
  6076. clearedFields: make(map[string]struct{}),
  6077. }
  6078. for _, opt := range opts {
  6079. opt(m)
  6080. }
  6081. return m
  6082. }
  6083. // withChatSessionID sets the ID field of the mutation.
  6084. func withChatSessionID(id uint64) chatsessionOption {
  6085. return func(m *ChatSessionMutation) {
  6086. var (
  6087. err error
  6088. once sync.Once
  6089. value *ChatSession
  6090. )
  6091. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6092. once.Do(func() {
  6093. if m.done {
  6094. err = errors.New("querying old values post mutation is not allowed")
  6095. } else {
  6096. value, err = m.Client().ChatSession.Get(ctx, id)
  6097. }
  6098. })
  6099. return value, err
  6100. }
  6101. m.id = &id
  6102. }
  6103. }
  6104. // withChatSession sets the old ChatSession of the mutation.
  6105. func withChatSession(node *ChatSession) chatsessionOption {
  6106. return func(m *ChatSessionMutation) {
  6107. m.oldValue = func(context.Context) (*ChatSession, error) {
  6108. return node, nil
  6109. }
  6110. m.id = &node.ID
  6111. }
  6112. }
  6113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6114. // executed in a transaction (ent.Tx), a transactional client is returned.
  6115. func (m ChatSessionMutation) Client() *Client {
  6116. client := &Client{config: m.config}
  6117. client.init()
  6118. return client
  6119. }
  6120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6121. // it returns an error otherwise.
  6122. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6123. if _, ok := m.driver.(*txDriver); !ok {
  6124. return nil, errors.New("ent: mutation is not running in a transaction")
  6125. }
  6126. tx := &Tx{config: m.config}
  6127. tx.init()
  6128. return tx, nil
  6129. }
  6130. // SetID sets the value of the id field. Note that this
  6131. // operation is only accepted on creation of ChatSession entities.
  6132. func (m *ChatSessionMutation) SetID(id uint64) {
  6133. m.id = &id
  6134. }
  6135. // ID returns the ID value in the mutation. Note that the ID is only available
  6136. // if it was provided to the builder or after it was returned from the database.
  6137. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6138. if m.id == nil {
  6139. return
  6140. }
  6141. return *m.id, true
  6142. }
  6143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6144. // That means, if the mutation is applied within a transaction with an isolation level such
  6145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6146. // or updated by the mutation.
  6147. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6148. switch {
  6149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6150. id, exists := m.ID()
  6151. if exists {
  6152. return []uint64{id}, nil
  6153. }
  6154. fallthrough
  6155. case m.op.Is(OpUpdate | OpDelete):
  6156. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6157. default:
  6158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6159. }
  6160. }
  6161. // SetCreatedAt sets the "created_at" field.
  6162. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6163. m.created_at = &t
  6164. }
  6165. // CreatedAt returns the value of the "created_at" field in the mutation.
  6166. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6167. v := m.created_at
  6168. if v == nil {
  6169. return
  6170. }
  6171. return *v, true
  6172. }
  6173. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6174. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6176. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6177. if !m.op.Is(OpUpdateOne) {
  6178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6179. }
  6180. if m.id == nil || m.oldValue == nil {
  6181. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6182. }
  6183. oldValue, err := m.oldValue(ctx)
  6184. if err != nil {
  6185. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6186. }
  6187. return oldValue.CreatedAt, nil
  6188. }
  6189. // ResetCreatedAt resets all changes to the "created_at" field.
  6190. func (m *ChatSessionMutation) ResetCreatedAt() {
  6191. m.created_at = nil
  6192. }
  6193. // SetUpdatedAt sets the "updated_at" field.
  6194. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6195. m.updated_at = &t
  6196. }
  6197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6198. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6199. v := m.updated_at
  6200. if v == nil {
  6201. return
  6202. }
  6203. return *v, true
  6204. }
  6205. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6208. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6209. if !m.op.Is(OpUpdateOne) {
  6210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6211. }
  6212. if m.id == nil || m.oldValue == nil {
  6213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6214. }
  6215. oldValue, err := m.oldValue(ctx)
  6216. if err != nil {
  6217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6218. }
  6219. return oldValue.UpdatedAt, nil
  6220. }
  6221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6222. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6223. m.updated_at = nil
  6224. }
  6225. // SetDeletedAt sets the "deleted_at" field.
  6226. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6227. m.deleted_at = &t
  6228. }
  6229. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6230. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6231. v := m.deleted_at
  6232. if v == nil {
  6233. return
  6234. }
  6235. return *v, true
  6236. }
  6237. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6238. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6240. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6241. if !m.op.Is(OpUpdateOne) {
  6242. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6243. }
  6244. if m.id == nil || m.oldValue == nil {
  6245. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6246. }
  6247. oldValue, err := m.oldValue(ctx)
  6248. if err != nil {
  6249. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6250. }
  6251. return oldValue.DeletedAt, nil
  6252. }
  6253. // ClearDeletedAt clears the value of the "deleted_at" field.
  6254. func (m *ChatSessionMutation) ClearDeletedAt() {
  6255. m.deleted_at = nil
  6256. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6257. }
  6258. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6259. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6260. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6261. return ok
  6262. }
  6263. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6264. func (m *ChatSessionMutation) ResetDeletedAt() {
  6265. m.deleted_at = nil
  6266. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6267. }
  6268. // SetName sets the "name" field.
  6269. func (m *ChatSessionMutation) SetName(s string) {
  6270. m.name = &s
  6271. }
  6272. // Name returns the value of the "name" field in the mutation.
  6273. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6274. v := m.name
  6275. if v == nil {
  6276. return
  6277. }
  6278. return *v, true
  6279. }
  6280. // OldName returns the old "name" field's value of the ChatSession entity.
  6281. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6283. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6284. if !m.op.Is(OpUpdateOne) {
  6285. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6286. }
  6287. if m.id == nil || m.oldValue == nil {
  6288. return v, errors.New("OldName requires an ID field in the mutation")
  6289. }
  6290. oldValue, err := m.oldValue(ctx)
  6291. if err != nil {
  6292. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6293. }
  6294. return oldValue.Name, nil
  6295. }
  6296. // ResetName resets all changes to the "name" field.
  6297. func (m *ChatSessionMutation) ResetName() {
  6298. m.name = nil
  6299. }
  6300. // SetUserID sets the "user_id" field.
  6301. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6302. m.user_id = &u
  6303. m.adduser_id = nil
  6304. }
  6305. // UserID returns the value of the "user_id" field in the mutation.
  6306. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6307. v := m.user_id
  6308. if v == nil {
  6309. return
  6310. }
  6311. return *v, true
  6312. }
  6313. // OldUserID returns the old "user_id" 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) OldUserID(ctx context.Context) (v uint64, err error) {
  6317. if !m.op.Is(OpUpdateOne) {
  6318. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6319. }
  6320. if m.id == nil || m.oldValue == nil {
  6321. return v, errors.New("OldUserID 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 OldUserID: %w", err)
  6326. }
  6327. return oldValue.UserID, nil
  6328. }
  6329. // AddUserID adds u to the "user_id" field.
  6330. func (m *ChatSessionMutation) AddUserID(u int64) {
  6331. if m.adduser_id != nil {
  6332. *m.adduser_id += u
  6333. } else {
  6334. m.adduser_id = &u
  6335. }
  6336. }
  6337. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6338. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6339. v := m.adduser_id
  6340. if v == nil {
  6341. return
  6342. }
  6343. return *v, true
  6344. }
  6345. // ResetUserID resets all changes to the "user_id" field.
  6346. func (m *ChatSessionMutation) ResetUserID() {
  6347. m.user_id = nil
  6348. m.adduser_id = nil
  6349. }
  6350. // SetBotID sets the "bot_id" field.
  6351. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6352. m.bot_id = &u
  6353. m.addbot_id = nil
  6354. }
  6355. // BotID returns the value of the "bot_id" field in the mutation.
  6356. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6357. v := m.bot_id
  6358. if v == nil {
  6359. return
  6360. }
  6361. return *v, true
  6362. }
  6363. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6364. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6366. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6367. if !m.op.Is(OpUpdateOne) {
  6368. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6369. }
  6370. if m.id == nil || m.oldValue == nil {
  6371. return v, errors.New("OldBotID requires an ID field in the mutation")
  6372. }
  6373. oldValue, err := m.oldValue(ctx)
  6374. if err != nil {
  6375. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6376. }
  6377. return oldValue.BotID, nil
  6378. }
  6379. // AddBotID adds u to the "bot_id" field.
  6380. func (m *ChatSessionMutation) AddBotID(u int64) {
  6381. if m.addbot_id != nil {
  6382. *m.addbot_id += u
  6383. } else {
  6384. m.addbot_id = &u
  6385. }
  6386. }
  6387. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6388. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6389. v := m.addbot_id
  6390. if v == nil {
  6391. return
  6392. }
  6393. return *v, true
  6394. }
  6395. // ResetBotID resets all changes to the "bot_id" field.
  6396. func (m *ChatSessionMutation) ResetBotID() {
  6397. m.bot_id = nil
  6398. m.addbot_id = nil
  6399. }
  6400. // SetBotType sets the "bot_type" field.
  6401. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6402. m.bot_type = &u
  6403. m.addbot_type = nil
  6404. }
  6405. // BotType returns the value of the "bot_type" field in the mutation.
  6406. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6407. v := m.bot_type
  6408. if v == nil {
  6409. return
  6410. }
  6411. return *v, true
  6412. }
  6413. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6414. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6416. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6417. if !m.op.Is(OpUpdateOne) {
  6418. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6419. }
  6420. if m.id == nil || m.oldValue == nil {
  6421. return v, errors.New("OldBotType requires an ID field in the mutation")
  6422. }
  6423. oldValue, err := m.oldValue(ctx)
  6424. if err != nil {
  6425. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6426. }
  6427. return oldValue.BotType, nil
  6428. }
  6429. // AddBotType adds u to the "bot_type" field.
  6430. func (m *ChatSessionMutation) AddBotType(u int8) {
  6431. if m.addbot_type != nil {
  6432. *m.addbot_type += u
  6433. } else {
  6434. m.addbot_type = &u
  6435. }
  6436. }
  6437. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6438. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6439. v := m.addbot_type
  6440. if v == nil {
  6441. return
  6442. }
  6443. return *v, true
  6444. }
  6445. // ResetBotType resets all changes to the "bot_type" field.
  6446. func (m *ChatSessionMutation) ResetBotType() {
  6447. m.bot_type = nil
  6448. m.addbot_type = nil
  6449. }
  6450. // Where appends a list predicates to the ChatSessionMutation builder.
  6451. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6452. m.predicates = append(m.predicates, ps...)
  6453. }
  6454. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6455. // users can use type-assertion to append predicates that do not depend on any generated package.
  6456. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6457. p := make([]predicate.ChatSession, len(ps))
  6458. for i := range ps {
  6459. p[i] = ps[i]
  6460. }
  6461. m.Where(p...)
  6462. }
  6463. // Op returns the operation name.
  6464. func (m *ChatSessionMutation) Op() Op {
  6465. return m.op
  6466. }
  6467. // SetOp allows setting the mutation operation.
  6468. func (m *ChatSessionMutation) SetOp(op Op) {
  6469. m.op = op
  6470. }
  6471. // Type returns the node type of this mutation (ChatSession).
  6472. func (m *ChatSessionMutation) Type() string {
  6473. return m.typ
  6474. }
  6475. // Fields returns all fields that were changed during this mutation. Note that in
  6476. // order to get all numeric fields that were incremented/decremented, call
  6477. // AddedFields().
  6478. func (m *ChatSessionMutation) Fields() []string {
  6479. fields := make([]string, 0, 7)
  6480. if m.created_at != nil {
  6481. fields = append(fields, chatsession.FieldCreatedAt)
  6482. }
  6483. if m.updated_at != nil {
  6484. fields = append(fields, chatsession.FieldUpdatedAt)
  6485. }
  6486. if m.deleted_at != nil {
  6487. fields = append(fields, chatsession.FieldDeletedAt)
  6488. }
  6489. if m.name != nil {
  6490. fields = append(fields, chatsession.FieldName)
  6491. }
  6492. if m.user_id != nil {
  6493. fields = append(fields, chatsession.FieldUserID)
  6494. }
  6495. if m.bot_id != nil {
  6496. fields = append(fields, chatsession.FieldBotID)
  6497. }
  6498. if m.bot_type != nil {
  6499. fields = append(fields, chatsession.FieldBotType)
  6500. }
  6501. return fields
  6502. }
  6503. // Field returns the value of a field with the given name. The second boolean
  6504. // return value indicates that this field was not set, or was not defined in the
  6505. // schema.
  6506. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6507. switch name {
  6508. case chatsession.FieldCreatedAt:
  6509. return m.CreatedAt()
  6510. case chatsession.FieldUpdatedAt:
  6511. return m.UpdatedAt()
  6512. case chatsession.FieldDeletedAt:
  6513. return m.DeletedAt()
  6514. case chatsession.FieldName:
  6515. return m.Name()
  6516. case chatsession.FieldUserID:
  6517. return m.UserID()
  6518. case chatsession.FieldBotID:
  6519. return m.BotID()
  6520. case chatsession.FieldBotType:
  6521. return m.BotType()
  6522. }
  6523. return nil, false
  6524. }
  6525. // OldField returns the old value of the field from the database. An error is
  6526. // returned if the mutation operation is not UpdateOne, or the query to the
  6527. // database failed.
  6528. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6529. switch name {
  6530. case chatsession.FieldCreatedAt:
  6531. return m.OldCreatedAt(ctx)
  6532. case chatsession.FieldUpdatedAt:
  6533. return m.OldUpdatedAt(ctx)
  6534. case chatsession.FieldDeletedAt:
  6535. return m.OldDeletedAt(ctx)
  6536. case chatsession.FieldName:
  6537. return m.OldName(ctx)
  6538. case chatsession.FieldUserID:
  6539. return m.OldUserID(ctx)
  6540. case chatsession.FieldBotID:
  6541. return m.OldBotID(ctx)
  6542. case chatsession.FieldBotType:
  6543. return m.OldBotType(ctx)
  6544. }
  6545. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6546. }
  6547. // SetField sets the value of a field with the given name. It returns an error if
  6548. // the field is not defined in the schema, or if the type mismatched the field
  6549. // type.
  6550. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6551. switch name {
  6552. case chatsession.FieldCreatedAt:
  6553. v, ok := value.(time.Time)
  6554. if !ok {
  6555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6556. }
  6557. m.SetCreatedAt(v)
  6558. return nil
  6559. case chatsession.FieldUpdatedAt:
  6560. v, ok := value.(time.Time)
  6561. if !ok {
  6562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6563. }
  6564. m.SetUpdatedAt(v)
  6565. return nil
  6566. case chatsession.FieldDeletedAt:
  6567. v, ok := value.(time.Time)
  6568. if !ok {
  6569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6570. }
  6571. m.SetDeletedAt(v)
  6572. return nil
  6573. case chatsession.FieldName:
  6574. v, ok := value.(string)
  6575. if !ok {
  6576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6577. }
  6578. m.SetName(v)
  6579. return nil
  6580. case chatsession.FieldUserID:
  6581. v, ok := value.(uint64)
  6582. if !ok {
  6583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6584. }
  6585. m.SetUserID(v)
  6586. return nil
  6587. case chatsession.FieldBotID:
  6588. v, ok := value.(uint64)
  6589. if !ok {
  6590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6591. }
  6592. m.SetBotID(v)
  6593. return nil
  6594. case chatsession.FieldBotType:
  6595. v, ok := value.(uint8)
  6596. if !ok {
  6597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6598. }
  6599. m.SetBotType(v)
  6600. return nil
  6601. }
  6602. return fmt.Errorf("unknown ChatSession field %s", name)
  6603. }
  6604. // AddedFields returns all numeric fields that were incremented/decremented during
  6605. // this mutation.
  6606. func (m *ChatSessionMutation) AddedFields() []string {
  6607. var fields []string
  6608. if m.adduser_id != nil {
  6609. fields = append(fields, chatsession.FieldUserID)
  6610. }
  6611. if m.addbot_id != nil {
  6612. fields = append(fields, chatsession.FieldBotID)
  6613. }
  6614. if m.addbot_type != nil {
  6615. fields = append(fields, chatsession.FieldBotType)
  6616. }
  6617. return fields
  6618. }
  6619. // AddedField returns the numeric value that was incremented/decremented on a field
  6620. // with the given name. The second boolean return value indicates that this field
  6621. // was not set, or was not defined in the schema.
  6622. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6623. switch name {
  6624. case chatsession.FieldUserID:
  6625. return m.AddedUserID()
  6626. case chatsession.FieldBotID:
  6627. return m.AddedBotID()
  6628. case chatsession.FieldBotType:
  6629. return m.AddedBotType()
  6630. }
  6631. return nil, false
  6632. }
  6633. // AddField adds the value to the field with the given name. It returns an error if
  6634. // the field is not defined in the schema, or if the type mismatched the field
  6635. // type.
  6636. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6637. switch name {
  6638. case chatsession.FieldUserID:
  6639. v, ok := value.(int64)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.AddUserID(v)
  6644. return nil
  6645. case chatsession.FieldBotID:
  6646. v, ok := value.(int64)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.AddBotID(v)
  6651. return nil
  6652. case chatsession.FieldBotType:
  6653. v, ok := value.(int8)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.AddBotType(v)
  6658. return nil
  6659. }
  6660. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6661. }
  6662. // ClearedFields returns all nullable fields that were cleared during this
  6663. // mutation.
  6664. func (m *ChatSessionMutation) ClearedFields() []string {
  6665. var fields []string
  6666. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6667. fields = append(fields, chatsession.FieldDeletedAt)
  6668. }
  6669. return fields
  6670. }
  6671. // FieldCleared returns a boolean indicating if a field with the given name was
  6672. // cleared in this mutation.
  6673. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6674. _, ok := m.clearedFields[name]
  6675. return ok
  6676. }
  6677. // ClearField clears the value of the field with the given name. It returns an
  6678. // error if the field is not defined in the schema.
  6679. func (m *ChatSessionMutation) ClearField(name string) error {
  6680. switch name {
  6681. case chatsession.FieldDeletedAt:
  6682. m.ClearDeletedAt()
  6683. return nil
  6684. }
  6685. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6686. }
  6687. // ResetField resets all changes in the mutation for the field with the given name.
  6688. // It returns an error if the field is not defined in the schema.
  6689. func (m *ChatSessionMutation) ResetField(name string) error {
  6690. switch name {
  6691. case chatsession.FieldCreatedAt:
  6692. m.ResetCreatedAt()
  6693. return nil
  6694. case chatsession.FieldUpdatedAt:
  6695. m.ResetUpdatedAt()
  6696. return nil
  6697. case chatsession.FieldDeletedAt:
  6698. m.ResetDeletedAt()
  6699. return nil
  6700. case chatsession.FieldName:
  6701. m.ResetName()
  6702. return nil
  6703. case chatsession.FieldUserID:
  6704. m.ResetUserID()
  6705. return nil
  6706. case chatsession.FieldBotID:
  6707. m.ResetBotID()
  6708. return nil
  6709. case chatsession.FieldBotType:
  6710. m.ResetBotType()
  6711. return nil
  6712. }
  6713. return fmt.Errorf("unknown ChatSession field %s", name)
  6714. }
  6715. // AddedEdges returns all edge names that were set/added in this mutation.
  6716. func (m *ChatSessionMutation) AddedEdges() []string {
  6717. edges := make([]string, 0, 0)
  6718. return edges
  6719. }
  6720. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6721. // name in this mutation.
  6722. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6723. return nil
  6724. }
  6725. // RemovedEdges returns all edge names that were removed in this mutation.
  6726. func (m *ChatSessionMutation) RemovedEdges() []string {
  6727. edges := make([]string, 0, 0)
  6728. return edges
  6729. }
  6730. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6731. // the given name in this mutation.
  6732. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6733. return nil
  6734. }
  6735. // ClearedEdges returns all edge names that were cleared in this mutation.
  6736. func (m *ChatSessionMutation) ClearedEdges() []string {
  6737. edges := make([]string, 0, 0)
  6738. return edges
  6739. }
  6740. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6741. // was cleared in this mutation.
  6742. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6743. return false
  6744. }
  6745. // ClearEdge clears the value of the edge with the given name. It returns an error
  6746. // if that edge is not defined in the schema.
  6747. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6748. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6749. }
  6750. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6751. // It returns an error if the edge is not defined in the schema.
  6752. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6753. return fmt.Errorf("unknown ChatSession edge %s", name)
  6754. }
  6755. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6756. type ContactMutation struct {
  6757. config
  6758. op Op
  6759. typ string
  6760. id *uint64
  6761. created_at *time.Time
  6762. updated_at *time.Time
  6763. status *uint8
  6764. addstatus *int8
  6765. deleted_at *time.Time
  6766. wx_wxid *string
  6767. _type *int
  6768. add_type *int
  6769. wxid *string
  6770. account *string
  6771. nickname *string
  6772. markname *string
  6773. headimg *string
  6774. sex *int
  6775. addsex *int
  6776. starrole *string
  6777. dontseeit *int
  6778. adddontseeit *int
  6779. dontseeme *int
  6780. adddontseeme *int
  6781. lag *string
  6782. gid *string
  6783. gname *string
  6784. v3 *string
  6785. organization_id *uint64
  6786. addorganization_id *int64
  6787. clearedFields map[string]struct{}
  6788. contact_relationships map[uint64]struct{}
  6789. removedcontact_relationships map[uint64]struct{}
  6790. clearedcontact_relationships bool
  6791. contact_messages map[uint64]struct{}
  6792. removedcontact_messages map[uint64]struct{}
  6793. clearedcontact_messages bool
  6794. done bool
  6795. oldValue func(context.Context) (*Contact, error)
  6796. predicates []predicate.Contact
  6797. }
  6798. var _ ent.Mutation = (*ContactMutation)(nil)
  6799. // contactOption allows management of the mutation configuration using functional options.
  6800. type contactOption func(*ContactMutation)
  6801. // newContactMutation creates new mutation for the Contact entity.
  6802. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6803. m := &ContactMutation{
  6804. config: c,
  6805. op: op,
  6806. typ: TypeContact,
  6807. clearedFields: make(map[string]struct{}),
  6808. }
  6809. for _, opt := range opts {
  6810. opt(m)
  6811. }
  6812. return m
  6813. }
  6814. // withContactID sets the ID field of the mutation.
  6815. func withContactID(id uint64) contactOption {
  6816. return func(m *ContactMutation) {
  6817. var (
  6818. err error
  6819. once sync.Once
  6820. value *Contact
  6821. )
  6822. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6823. once.Do(func() {
  6824. if m.done {
  6825. err = errors.New("querying old values post mutation is not allowed")
  6826. } else {
  6827. value, err = m.Client().Contact.Get(ctx, id)
  6828. }
  6829. })
  6830. return value, err
  6831. }
  6832. m.id = &id
  6833. }
  6834. }
  6835. // withContact sets the old Contact of the mutation.
  6836. func withContact(node *Contact) contactOption {
  6837. return func(m *ContactMutation) {
  6838. m.oldValue = func(context.Context) (*Contact, error) {
  6839. return node, nil
  6840. }
  6841. m.id = &node.ID
  6842. }
  6843. }
  6844. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6845. // executed in a transaction (ent.Tx), a transactional client is returned.
  6846. func (m ContactMutation) Client() *Client {
  6847. client := &Client{config: m.config}
  6848. client.init()
  6849. return client
  6850. }
  6851. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6852. // it returns an error otherwise.
  6853. func (m ContactMutation) Tx() (*Tx, error) {
  6854. if _, ok := m.driver.(*txDriver); !ok {
  6855. return nil, errors.New("ent: mutation is not running in a transaction")
  6856. }
  6857. tx := &Tx{config: m.config}
  6858. tx.init()
  6859. return tx, nil
  6860. }
  6861. // SetID sets the value of the id field. Note that this
  6862. // operation is only accepted on creation of Contact entities.
  6863. func (m *ContactMutation) SetID(id uint64) {
  6864. m.id = &id
  6865. }
  6866. // ID returns the ID value in the mutation. Note that the ID is only available
  6867. // if it was provided to the builder or after it was returned from the database.
  6868. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6869. if m.id == nil {
  6870. return
  6871. }
  6872. return *m.id, true
  6873. }
  6874. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6875. // That means, if the mutation is applied within a transaction with an isolation level such
  6876. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6877. // or updated by the mutation.
  6878. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6879. switch {
  6880. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6881. id, exists := m.ID()
  6882. if exists {
  6883. return []uint64{id}, nil
  6884. }
  6885. fallthrough
  6886. case m.op.Is(OpUpdate | OpDelete):
  6887. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6888. default:
  6889. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6890. }
  6891. }
  6892. // SetCreatedAt sets the "created_at" field.
  6893. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6894. m.created_at = &t
  6895. }
  6896. // CreatedAt returns the value of the "created_at" field in the mutation.
  6897. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6898. v := m.created_at
  6899. if v == nil {
  6900. return
  6901. }
  6902. return *v, true
  6903. }
  6904. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6905. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6907. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6908. if !m.op.Is(OpUpdateOne) {
  6909. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6910. }
  6911. if m.id == nil || m.oldValue == nil {
  6912. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6913. }
  6914. oldValue, err := m.oldValue(ctx)
  6915. if err != nil {
  6916. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6917. }
  6918. return oldValue.CreatedAt, nil
  6919. }
  6920. // ResetCreatedAt resets all changes to the "created_at" field.
  6921. func (m *ContactMutation) ResetCreatedAt() {
  6922. m.created_at = nil
  6923. }
  6924. // SetUpdatedAt sets the "updated_at" field.
  6925. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  6926. m.updated_at = &t
  6927. }
  6928. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6929. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  6930. v := m.updated_at
  6931. if v == nil {
  6932. return
  6933. }
  6934. return *v, true
  6935. }
  6936. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  6937. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6939. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6940. if !m.op.Is(OpUpdateOne) {
  6941. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6942. }
  6943. if m.id == nil || m.oldValue == nil {
  6944. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6945. }
  6946. oldValue, err := m.oldValue(ctx)
  6947. if err != nil {
  6948. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6949. }
  6950. return oldValue.UpdatedAt, nil
  6951. }
  6952. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6953. func (m *ContactMutation) ResetUpdatedAt() {
  6954. m.updated_at = nil
  6955. }
  6956. // SetStatus sets the "status" field.
  6957. func (m *ContactMutation) SetStatus(u uint8) {
  6958. m.status = &u
  6959. m.addstatus = nil
  6960. }
  6961. // Status returns the value of the "status" field in the mutation.
  6962. func (m *ContactMutation) Status() (r uint8, exists bool) {
  6963. v := m.status
  6964. if v == nil {
  6965. return
  6966. }
  6967. return *v, true
  6968. }
  6969. // OldStatus returns the old "status" field's value of the Contact entity.
  6970. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6972. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6973. if !m.op.Is(OpUpdateOne) {
  6974. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6975. }
  6976. if m.id == nil || m.oldValue == nil {
  6977. return v, errors.New("OldStatus requires an ID field in the mutation")
  6978. }
  6979. oldValue, err := m.oldValue(ctx)
  6980. if err != nil {
  6981. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6982. }
  6983. return oldValue.Status, nil
  6984. }
  6985. // AddStatus adds u to the "status" field.
  6986. func (m *ContactMutation) AddStatus(u int8) {
  6987. if m.addstatus != nil {
  6988. *m.addstatus += u
  6989. } else {
  6990. m.addstatus = &u
  6991. }
  6992. }
  6993. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6994. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  6995. v := m.addstatus
  6996. if v == nil {
  6997. return
  6998. }
  6999. return *v, true
  7000. }
  7001. // ClearStatus clears the value of the "status" field.
  7002. func (m *ContactMutation) ClearStatus() {
  7003. m.status = nil
  7004. m.addstatus = nil
  7005. m.clearedFields[contact.FieldStatus] = struct{}{}
  7006. }
  7007. // StatusCleared returns if the "status" field was cleared in this mutation.
  7008. func (m *ContactMutation) StatusCleared() bool {
  7009. _, ok := m.clearedFields[contact.FieldStatus]
  7010. return ok
  7011. }
  7012. // ResetStatus resets all changes to the "status" field.
  7013. func (m *ContactMutation) ResetStatus() {
  7014. m.status = nil
  7015. m.addstatus = nil
  7016. delete(m.clearedFields, contact.FieldStatus)
  7017. }
  7018. // SetDeletedAt sets the "deleted_at" field.
  7019. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7020. m.deleted_at = &t
  7021. }
  7022. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7023. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7024. v := m.deleted_at
  7025. if v == nil {
  7026. return
  7027. }
  7028. return *v, true
  7029. }
  7030. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7031. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7033. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7034. if !m.op.Is(OpUpdateOne) {
  7035. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7036. }
  7037. if m.id == nil || m.oldValue == nil {
  7038. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7039. }
  7040. oldValue, err := m.oldValue(ctx)
  7041. if err != nil {
  7042. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7043. }
  7044. return oldValue.DeletedAt, nil
  7045. }
  7046. // ClearDeletedAt clears the value of the "deleted_at" field.
  7047. func (m *ContactMutation) ClearDeletedAt() {
  7048. m.deleted_at = nil
  7049. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7050. }
  7051. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7052. func (m *ContactMutation) DeletedAtCleared() bool {
  7053. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7054. return ok
  7055. }
  7056. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7057. func (m *ContactMutation) ResetDeletedAt() {
  7058. m.deleted_at = nil
  7059. delete(m.clearedFields, contact.FieldDeletedAt)
  7060. }
  7061. // SetWxWxid sets the "wx_wxid" field.
  7062. func (m *ContactMutation) SetWxWxid(s string) {
  7063. m.wx_wxid = &s
  7064. }
  7065. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7066. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7067. v := m.wx_wxid
  7068. if v == nil {
  7069. return
  7070. }
  7071. return *v, true
  7072. }
  7073. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7076. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7077. if !m.op.Is(OpUpdateOne) {
  7078. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7079. }
  7080. if m.id == nil || m.oldValue == nil {
  7081. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7082. }
  7083. oldValue, err := m.oldValue(ctx)
  7084. if err != nil {
  7085. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7086. }
  7087. return oldValue.WxWxid, nil
  7088. }
  7089. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7090. func (m *ContactMutation) ResetWxWxid() {
  7091. m.wx_wxid = nil
  7092. }
  7093. // SetType sets the "type" field.
  7094. func (m *ContactMutation) SetType(i int) {
  7095. m._type = &i
  7096. m.add_type = nil
  7097. }
  7098. // GetType returns the value of the "type" field in the mutation.
  7099. func (m *ContactMutation) GetType() (r int, exists bool) {
  7100. v := m._type
  7101. if v == nil {
  7102. return
  7103. }
  7104. return *v, true
  7105. }
  7106. // OldType returns the old "type" 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) OldType(ctx context.Context) (v int, err error) {
  7110. if !m.op.Is(OpUpdateOne) {
  7111. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7112. }
  7113. if m.id == nil || m.oldValue == nil {
  7114. return v, errors.New("OldType 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 OldType: %w", err)
  7119. }
  7120. return oldValue.Type, nil
  7121. }
  7122. // AddType adds i to the "type" field.
  7123. func (m *ContactMutation) AddType(i int) {
  7124. if m.add_type != nil {
  7125. *m.add_type += i
  7126. } else {
  7127. m.add_type = &i
  7128. }
  7129. }
  7130. // AddedType returns the value that was added to the "type" field in this mutation.
  7131. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7132. v := m.add_type
  7133. if v == nil {
  7134. return
  7135. }
  7136. return *v, true
  7137. }
  7138. // ClearType clears the value of the "type" field.
  7139. func (m *ContactMutation) ClearType() {
  7140. m._type = nil
  7141. m.add_type = nil
  7142. m.clearedFields[contact.FieldType] = struct{}{}
  7143. }
  7144. // TypeCleared returns if the "type" field was cleared in this mutation.
  7145. func (m *ContactMutation) TypeCleared() bool {
  7146. _, ok := m.clearedFields[contact.FieldType]
  7147. return ok
  7148. }
  7149. // ResetType resets all changes to the "type" field.
  7150. func (m *ContactMutation) ResetType() {
  7151. m._type = nil
  7152. m.add_type = nil
  7153. delete(m.clearedFields, contact.FieldType)
  7154. }
  7155. // SetWxid sets the "wxid" field.
  7156. func (m *ContactMutation) SetWxid(s string) {
  7157. m.wxid = &s
  7158. }
  7159. // Wxid returns the value of the "wxid" field in the mutation.
  7160. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7161. v := m.wxid
  7162. if v == nil {
  7163. return
  7164. }
  7165. return *v, true
  7166. }
  7167. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7168. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7170. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7171. if !m.op.Is(OpUpdateOne) {
  7172. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7173. }
  7174. if m.id == nil || m.oldValue == nil {
  7175. return v, errors.New("OldWxid requires an ID field in the mutation")
  7176. }
  7177. oldValue, err := m.oldValue(ctx)
  7178. if err != nil {
  7179. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7180. }
  7181. return oldValue.Wxid, nil
  7182. }
  7183. // ResetWxid resets all changes to the "wxid" field.
  7184. func (m *ContactMutation) ResetWxid() {
  7185. m.wxid = nil
  7186. }
  7187. // SetAccount sets the "account" field.
  7188. func (m *ContactMutation) SetAccount(s string) {
  7189. m.account = &s
  7190. }
  7191. // Account returns the value of the "account" field in the mutation.
  7192. func (m *ContactMutation) Account() (r string, exists bool) {
  7193. v := m.account
  7194. if v == nil {
  7195. return
  7196. }
  7197. return *v, true
  7198. }
  7199. // OldAccount returns the old "account" field's value of the Contact entity.
  7200. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7202. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7203. if !m.op.Is(OpUpdateOne) {
  7204. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7205. }
  7206. if m.id == nil || m.oldValue == nil {
  7207. return v, errors.New("OldAccount requires an ID field in the mutation")
  7208. }
  7209. oldValue, err := m.oldValue(ctx)
  7210. if err != nil {
  7211. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7212. }
  7213. return oldValue.Account, nil
  7214. }
  7215. // ResetAccount resets all changes to the "account" field.
  7216. func (m *ContactMutation) ResetAccount() {
  7217. m.account = nil
  7218. }
  7219. // SetNickname sets the "nickname" field.
  7220. func (m *ContactMutation) SetNickname(s string) {
  7221. m.nickname = &s
  7222. }
  7223. // Nickname returns the value of the "nickname" field in the mutation.
  7224. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7225. v := m.nickname
  7226. if v == nil {
  7227. return
  7228. }
  7229. return *v, true
  7230. }
  7231. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7234. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7235. if !m.op.Is(OpUpdateOne) {
  7236. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7237. }
  7238. if m.id == nil || m.oldValue == nil {
  7239. return v, errors.New("OldNickname requires an ID field in the mutation")
  7240. }
  7241. oldValue, err := m.oldValue(ctx)
  7242. if err != nil {
  7243. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7244. }
  7245. return oldValue.Nickname, nil
  7246. }
  7247. // ResetNickname resets all changes to the "nickname" field.
  7248. func (m *ContactMutation) ResetNickname() {
  7249. m.nickname = nil
  7250. }
  7251. // SetMarkname sets the "markname" field.
  7252. func (m *ContactMutation) SetMarkname(s string) {
  7253. m.markname = &s
  7254. }
  7255. // Markname returns the value of the "markname" field in the mutation.
  7256. func (m *ContactMutation) Markname() (r string, exists bool) {
  7257. v := m.markname
  7258. if v == nil {
  7259. return
  7260. }
  7261. return *v, true
  7262. }
  7263. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7266. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7267. if !m.op.Is(OpUpdateOne) {
  7268. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7269. }
  7270. if m.id == nil || m.oldValue == nil {
  7271. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7272. }
  7273. oldValue, err := m.oldValue(ctx)
  7274. if err != nil {
  7275. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7276. }
  7277. return oldValue.Markname, nil
  7278. }
  7279. // ResetMarkname resets all changes to the "markname" field.
  7280. func (m *ContactMutation) ResetMarkname() {
  7281. m.markname = nil
  7282. }
  7283. // SetHeadimg sets the "headimg" field.
  7284. func (m *ContactMutation) SetHeadimg(s string) {
  7285. m.headimg = &s
  7286. }
  7287. // Headimg returns the value of the "headimg" field in the mutation.
  7288. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7289. v := m.headimg
  7290. if v == nil {
  7291. return
  7292. }
  7293. return *v, true
  7294. }
  7295. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7298. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7299. if !m.op.Is(OpUpdateOne) {
  7300. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7301. }
  7302. if m.id == nil || m.oldValue == nil {
  7303. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7304. }
  7305. oldValue, err := m.oldValue(ctx)
  7306. if err != nil {
  7307. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7308. }
  7309. return oldValue.Headimg, nil
  7310. }
  7311. // ResetHeadimg resets all changes to the "headimg" field.
  7312. func (m *ContactMutation) ResetHeadimg() {
  7313. m.headimg = nil
  7314. }
  7315. // SetSex sets the "sex" field.
  7316. func (m *ContactMutation) SetSex(i int) {
  7317. m.sex = &i
  7318. m.addsex = nil
  7319. }
  7320. // Sex returns the value of the "sex" field in the mutation.
  7321. func (m *ContactMutation) Sex() (r int, exists bool) {
  7322. v := m.sex
  7323. if v == nil {
  7324. return
  7325. }
  7326. return *v, true
  7327. }
  7328. // OldSex returns the old "sex" field's value of the Contact entity.
  7329. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7331. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7332. if !m.op.Is(OpUpdateOne) {
  7333. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7334. }
  7335. if m.id == nil || m.oldValue == nil {
  7336. return v, errors.New("OldSex requires an ID field in the mutation")
  7337. }
  7338. oldValue, err := m.oldValue(ctx)
  7339. if err != nil {
  7340. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7341. }
  7342. return oldValue.Sex, nil
  7343. }
  7344. // AddSex adds i to the "sex" field.
  7345. func (m *ContactMutation) AddSex(i int) {
  7346. if m.addsex != nil {
  7347. *m.addsex += i
  7348. } else {
  7349. m.addsex = &i
  7350. }
  7351. }
  7352. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7353. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7354. v := m.addsex
  7355. if v == nil {
  7356. return
  7357. }
  7358. return *v, true
  7359. }
  7360. // ResetSex resets all changes to the "sex" field.
  7361. func (m *ContactMutation) ResetSex() {
  7362. m.sex = nil
  7363. m.addsex = nil
  7364. }
  7365. // SetStarrole sets the "starrole" field.
  7366. func (m *ContactMutation) SetStarrole(s string) {
  7367. m.starrole = &s
  7368. }
  7369. // Starrole returns the value of the "starrole" field in the mutation.
  7370. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7371. v := m.starrole
  7372. if v == nil {
  7373. return
  7374. }
  7375. return *v, true
  7376. }
  7377. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7378. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7380. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7381. if !m.op.Is(OpUpdateOne) {
  7382. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7383. }
  7384. if m.id == nil || m.oldValue == nil {
  7385. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7386. }
  7387. oldValue, err := m.oldValue(ctx)
  7388. if err != nil {
  7389. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7390. }
  7391. return oldValue.Starrole, nil
  7392. }
  7393. // ResetStarrole resets all changes to the "starrole" field.
  7394. func (m *ContactMutation) ResetStarrole() {
  7395. m.starrole = nil
  7396. }
  7397. // SetDontseeit sets the "dontseeit" field.
  7398. func (m *ContactMutation) SetDontseeit(i int) {
  7399. m.dontseeit = &i
  7400. m.adddontseeit = nil
  7401. }
  7402. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7403. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7404. v := m.dontseeit
  7405. if v == nil {
  7406. return
  7407. }
  7408. return *v, true
  7409. }
  7410. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7411. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7413. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7414. if !m.op.Is(OpUpdateOne) {
  7415. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7416. }
  7417. if m.id == nil || m.oldValue == nil {
  7418. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7419. }
  7420. oldValue, err := m.oldValue(ctx)
  7421. if err != nil {
  7422. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7423. }
  7424. return oldValue.Dontseeit, nil
  7425. }
  7426. // AddDontseeit adds i to the "dontseeit" field.
  7427. func (m *ContactMutation) AddDontseeit(i int) {
  7428. if m.adddontseeit != nil {
  7429. *m.adddontseeit += i
  7430. } else {
  7431. m.adddontseeit = &i
  7432. }
  7433. }
  7434. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7435. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7436. v := m.adddontseeit
  7437. if v == nil {
  7438. return
  7439. }
  7440. return *v, true
  7441. }
  7442. // ResetDontseeit resets all changes to the "dontseeit" field.
  7443. func (m *ContactMutation) ResetDontseeit() {
  7444. m.dontseeit = nil
  7445. m.adddontseeit = nil
  7446. }
  7447. // SetDontseeme sets the "dontseeme" field.
  7448. func (m *ContactMutation) SetDontseeme(i int) {
  7449. m.dontseeme = &i
  7450. m.adddontseeme = nil
  7451. }
  7452. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7453. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7454. v := m.dontseeme
  7455. if v == nil {
  7456. return
  7457. }
  7458. return *v, true
  7459. }
  7460. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7461. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7463. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7464. if !m.op.Is(OpUpdateOne) {
  7465. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7466. }
  7467. if m.id == nil || m.oldValue == nil {
  7468. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7469. }
  7470. oldValue, err := m.oldValue(ctx)
  7471. if err != nil {
  7472. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7473. }
  7474. return oldValue.Dontseeme, nil
  7475. }
  7476. // AddDontseeme adds i to the "dontseeme" field.
  7477. func (m *ContactMutation) AddDontseeme(i int) {
  7478. if m.adddontseeme != nil {
  7479. *m.adddontseeme += i
  7480. } else {
  7481. m.adddontseeme = &i
  7482. }
  7483. }
  7484. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7485. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7486. v := m.adddontseeme
  7487. if v == nil {
  7488. return
  7489. }
  7490. return *v, true
  7491. }
  7492. // ResetDontseeme resets all changes to the "dontseeme" field.
  7493. func (m *ContactMutation) ResetDontseeme() {
  7494. m.dontseeme = nil
  7495. m.adddontseeme = nil
  7496. }
  7497. // SetLag sets the "lag" field.
  7498. func (m *ContactMutation) SetLag(s string) {
  7499. m.lag = &s
  7500. }
  7501. // Lag returns the value of the "lag" field in the mutation.
  7502. func (m *ContactMutation) Lag() (r string, exists bool) {
  7503. v := m.lag
  7504. if v == nil {
  7505. return
  7506. }
  7507. return *v, true
  7508. }
  7509. // OldLag returns the old "lag" field's value of the Contact entity.
  7510. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7512. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7513. if !m.op.Is(OpUpdateOne) {
  7514. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7515. }
  7516. if m.id == nil || m.oldValue == nil {
  7517. return v, errors.New("OldLag requires an ID field in the mutation")
  7518. }
  7519. oldValue, err := m.oldValue(ctx)
  7520. if err != nil {
  7521. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7522. }
  7523. return oldValue.Lag, nil
  7524. }
  7525. // ResetLag resets all changes to the "lag" field.
  7526. func (m *ContactMutation) ResetLag() {
  7527. m.lag = nil
  7528. }
  7529. // SetGid sets the "gid" field.
  7530. func (m *ContactMutation) SetGid(s string) {
  7531. m.gid = &s
  7532. }
  7533. // Gid returns the value of the "gid" field in the mutation.
  7534. func (m *ContactMutation) Gid() (r string, exists bool) {
  7535. v := m.gid
  7536. if v == nil {
  7537. return
  7538. }
  7539. return *v, true
  7540. }
  7541. // OldGid returns the old "gid" field's value of the Contact entity.
  7542. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7544. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7545. if !m.op.Is(OpUpdateOne) {
  7546. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7547. }
  7548. if m.id == nil || m.oldValue == nil {
  7549. return v, errors.New("OldGid requires an ID field in the mutation")
  7550. }
  7551. oldValue, err := m.oldValue(ctx)
  7552. if err != nil {
  7553. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7554. }
  7555. return oldValue.Gid, nil
  7556. }
  7557. // ResetGid resets all changes to the "gid" field.
  7558. func (m *ContactMutation) ResetGid() {
  7559. m.gid = nil
  7560. }
  7561. // SetGname sets the "gname" field.
  7562. func (m *ContactMutation) SetGname(s string) {
  7563. m.gname = &s
  7564. }
  7565. // Gname returns the value of the "gname" field in the mutation.
  7566. func (m *ContactMutation) Gname() (r string, exists bool) {
  7567. v := m.gname
  7568. if v == nil {
  7569. return
  7570. }
  7571. return *v, true
  7572. }
  7573. // OldGname returns the old "gname" field's value of the Contact entity.
  7574. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7576. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7577. if !m.op.Is(OpUpdateOne) {
  7578. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7579. }
  7580. if m.id == nil || m.oldValue == nil {
  7581. return v, errors.New("OldGname requires an ID field in the mutation")
  7582. }
  7583. oldValue, err := m.oldValue(ctx)
  7584. if err != nil {
  7585. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7586. }
  7587. return oldValue.Gname, nil
  7588. }
  7589. // ResetGname resets all changes to the "gname" field.
  7590. func (m *ContactMutation) ResetGname() {
  7591. m.gname = nil
  7592. }
  7593. // SetV3 sets the "v3" field.
  7594. func (m *ContactMutation) SetV3(s string) {
  7595. m.v3 = &s
  7596. }
  7597. // V3 returns the value of the "v3" field in the mutation.
  7598. func (m *ContactMutation) V3() (r string, exists bool) {
  7599. v := m.v3
  7600. if v == nil {
  7601. return
  7602. }
  7603. return *v, true
  7604. }
  7605. // OldV3 returns the old "v3" field's value of the Contact entity.
  7606. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7608. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7609. if !m.op.Is(OpUpdateOne) {
  7610. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7611. }
  7612. if m.id == nil || m.oldValue == nil {
  7613. return v, errors.New("OldV3 requires an ID field in the mutation")
  7614. }
  7615. oldValue, err := m.oldValue(ctx)
  7616. if err != nil {
  7617. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7618. }
  7619. return oldValue.V3, nil
  7620. }
  7621. // ResetV3 resets all changes to the "v3" field.
  7622. func (m *ContactMutation) ResetV3() {
  7623. m.v3 = nil
  7624. }
  7625. // SetOrganizationID sets the "organization_id" field.
  7626. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7627. m.organization_id = &u
  7628. m.addorganization_id = nil
  7629. }
  7630. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7631. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7632. v := m.organization_id
  7633. if v == nil {
  7634. return
  7635. }
  7636. return *v, true
  7637. }
  7638. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7639. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7641. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7642. if !m.op.Is(OpUpdateOne) {
  7643. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7644. }
  7645. if m.id == nil || m.oldValue == nil {
  7646. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7647. }
  7648. oldValue, err := m.oldValue(ctx)
  7649. if err != nil {
  7650. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7651. }
  7652. return oldValue.OrganizationID, nil
  7653. }
  7654. // AddOrganizationID adds u to the "organization_id" field.
  7655. func (m *ContactMutation) AddOrganizationID(u int64) {
  7656. if m.addorganization_id != nil {
  7657. *m.addorganization_id += u
  7658. } else {
  7659. m.addorganization_id = &u
  7660. }
  7661. }
  7662. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7663. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7664. v := m.addorganization_id
  7665. if v == nil {
  7666. return
  7667. }
  7668. return *v, true
  7669. }
  7670. // ClearOrganizationID clears the value of the "organization_id" field.
  7671. func (m *ContactMutation) ClearOrganizationID() {
  7672. m.organization_id = nil
  7673. m.addorganization_id = nil
  7674. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7675. }
  7676. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7677. func (m *ContactMutation) OrganizationIDCleared() bool {
  7678. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7679. return ok
  7680. }
  7681. // ResetOrganizationID resets all changes to the "organization_id" field.
  7682. func (m *ContactMutation) ResetOrganizationID() {
  7683. m.organization_id = nil
  7684. m.addorganization_id = nil
  7685. delete(m.clearedFields, contact.FieldOrganizationID)
  7686. }
  7687. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7688. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7689. if m.contact_relationships == nil {
  7690. m.contact_relationships = make(map[uint64]struct{})
  7691. }
  7692. for i := range ids {
  7693. m.contact_relationships[ids[i]] = struct{}{}
  7694. }
  7695. }
  7696. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7697. func (m *ContactMutation) ClearContactRelationships() {
  7698. m.clearedcontact_relationships = true
  7699. }
  7700. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7701. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7702. return m.clearedcontact_relationships
  7703. }
  7704. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7705. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7706. if m.removedcontact_relationships == nil {
  7707. m.removedcontact_relationships = make(map[uint64]struct{})
  7708. }
  7709. for i := range ids {
  7710. delete(m.contact_relationships, ids[i])
  7711. m.removedcontact_relationships[ids[i]] = struct{}{}
  7712. }
  7713. }
  7714. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7715. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7716. for id := range m.removedcontact_relationships {
  7717. ids = append(ids, id)
  7718. }
  7719. return
  7720. }
  7721. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7722. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7723. for id := range m.contact_relationships {
  7724. ids = append(ids, id)
  7725. }
  7726. return
  7727. }
  7728. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7729. func (m *ContactMutation) ResetContactRelationships() {
  7730. m.contact_relationships = nil
  7731. m.clearedcontact_relationships = false
  7732. m.removedcontact_relationships = nil
  7733. }
  7734. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7735. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7736. if m.contact_messages == nil {
  7737. m.contact_messages = make(map[uint64]struct{})
  7738. }
  7739. for i := range ids {
  7740. m.contact_messages[ids[i]] = struct{}{}
  7741. }
  7742. }
  7743. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7744. func (m *ContactMutation) ClearContactMessages() {
  7745. m.clearedcontact_messages = true
  7746. }
  7747. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7748. func (m *ContactMutation) ContactMessagesCleared() bool {
  7749. return m.clearedcontact_messages
  7750. }
  7751. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7752. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7753. if m.removedcontact_messages == nil {
  7754. m.removedcontact_messages = make(map[uint64]struct{})
  7755. }
  7756. for i := range ids {
  7757. delete(m.contact_messages, ids[i])
  7758. m.removedcontact_messages[ids[i]] = struct{}{}
  7759. }
  7760. }
  7761. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7762. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7763. for id := range m.removedcontact_messages {
  7764. ids = append(ids, id)
  7765. }
  7766. return
  7767. }
  7768. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7769. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7770. for id := range m.contact_messages {
  7771. ids = append(ids, id)
  7772. }
  7773. return
  7774. }
  7775. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7776. func (m *ContactMutation) ResetContactMessages() {
  7777. m.contact_messages = nil
  7778. m.clearedcontact_messages = false
  7779. m.removedcontact_messages = nil
  7780. }
  7781. // Where appends a list predicates to the ContactMutation builder.
  7782. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7783. m.predicates = append(m.predicates, ps...)
  7784. }
  7785. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7786. // users can use type-assertion to append predicates that do not depend on any generated package.
  7787. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7788. p := make([]predicate.Contact, len(ps))
  7789. for i := range ps {
  7790. p[i] = ps[i]
  7791. }
  7792. m.Where(p...)
  7793. }
  7794. // Op returns the operation name.
  7795. func (m *ContactMutation) Op() Op {
  7796. return m.op
  7797. }
  7798. // SetOp allows setting the mutation operation.
  7799. func (m *ContactMutation) SetOp(op Op) {
  7800. m.op = op
  7801. }
  7802. // Type returns the node type of this mutation (Contact).
  7803. func (m *ContactMutation) Type() string {
  7804. return m.typ
  7805. }
  7806. // Fields returns all fields that were changed during this mutation. Note that in
  7807. // order to get all numeric fields that were incremented/decremented, call
  7808. // AddedFields().
  7809. func (m *ContactMutation) Fields() []string {
  7810. fields := make([]string, 0, 20)
  7811. if m.created_at != nil {
  7812. fields = append(fields, contact.FieldCreatedAt)
  7813. }
  7814. if m.updated_at != nil {
  7815. fields = append(fields, contact.FieldUpdatedAt)
  7816. }
  7817. if m.status != nil {
  7818. fields = append(fields, contact.FieldStatus)
  7819. }
  7820. if m.deleted_at != nil {
  7821. fields = append(fields, contact.FieldDeletedAt)
  7822. }
  7823. if m.wx_wxid != nil {
  7824. fields = append(fields, contact.FieldWxWxid)
  7825. }
  7826. if m._type != nil {
  7827. fields = append(fields, contact.FieldType)
  7828. }
  7829. if m.wxid != nil {
  7830. fields = append(fields, contact.FieldWxid)
  7831. }
  7832. if m.account != nil {
  7833. fields = append(fields, contact.FieldAccount)
  7834. }
  7835. if m.nickname != nil {
  7836. fields = append(fields, contact.FieldNickname)
  7837. }
  7838. if m.markname != nil {
  7839. fields = append(fields, contact.FieldMarkname)
  7840. }
  7841. if m.headimg != nil {
  7842. fields = append(fields, contact.FieldHeadimg)
  7843. }
  7844. if m.sex != nil {
  7845. fields = append(fields, contact.FieldSex)
  7846. }
  7847. if m.starrole != nil {
  7848. fields = append(fields, contact.FieldStarrole)
  7849. }
  7850. if m.dontseeit != nil {
  7851. fields = append(fields, contact.FieldDontseeit)
  7852. }
  7853. if m.dontseeme != nil {
  7854. fields = append(fields, contact.FieldDontseeme)
  7855. }
  7856. if m.lag != nil {
  7857. fields = append(fields, contact.FieldLag)
  7858. }
  7859. if m.gid != nil {
  7860. fields = append(fields, contact.FieldGid)
  7861. }
  7862. if m.gname != nil {
  7863. fields = append(fields, contact.FieldGname)
  7864. }
  7865. if m.v3 != nil {
  7866. fields = append(fields, contact.FieldV3)
  7867. }
  7868. if m.organization_id != nil {
  7869. fields = append(fields, contact.FieldOrganizationID)
  7870. }
  7871. return fields
  7872. }
  7873. // Field returns the value of a field with the given name. The second boolean
  7874. // return value indicates that this field was not set, or was not defined in the
  7875. // schema.
  7876. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7877. switch name {
  7878. case contact.FieldCreatedAt:
  7879. return m.CreatedAt()
  7880. case contact.FieldUpdatedAt:
  7881. return m.UpdatedAt()
  7882. case contact.FieldStatus:
  7883. return m.Status()
  7884. case contact.FieldDeletedAt:
  7885. return m.DeletedAt()
  7886. case contact.FieldWxWxid:
  7887. return m.WxWxid()
  7888. case contact.FieldType:
  7889. return m.GetType()
  7890. case contact.FieldWxid:
  7891. return m.Wxid()
  7892. case contact.FieldAccount:
  7893. return m.Account()
  7894. case contact.FieldNickname:
  7895. return m.Nickname()
  7896. case contact.FieldMarkname:
  7897. return m.Markname()
  7898. case contact.FieldHeadimg:
  7899. return m.Headimg()
  7900. case contact.FieldSex:
  7901. return m.Sex()
  7902. case contact.FieldStarrole:
  7903. return m.Starrole()
  7904. case contact.FieldDontseeit:
  7905. return m.Dontseeit()
  7906. case contact.FieldDontseeme:
  7907. return m.Dontseeme()
  7908. case contact.FieldLag:
  7909. return m.Lag()
  7910. case contact.FieldGid:
  7911. return m.Gid()
  7912. case contact.FieldGname:
  7913. return m.Gname()
  7914. case contact.FieldV3:
  7915. return m.V3()
  7916. case contact.FieldOrganizationID:
  7917. return m.OrganizationID()
  7918. }
  7919. return nil, false
  7920. }
  7921. // OldField returns the old value of the field from the database. An error is
  7922. // returned if the mutation operation is not UpdateOne, or the query to the
  7923. // database failed.
  7924. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7925. switch name {
  7926. case contact.FieldCreatedAt:
  7927. return m.OldCreatedAt(ctx)
  7928. case contact.FieldUpdatedAt:
  7929. return m.OldUpdatedAt(ctx)
  7930. case contact.FieldStatus:
  7931. return m.OldStatus(ctx)
  7932. case contact.FieldDeletedAt:
  7933. return m.OldDeletedAt(ctx)
  7934. case contact.FieldWxWxid:
  7935. return m.OldWxWxid(ctx)
  7936. case contact.FieldType:
  7937. return m.OldType(ctx)
  7938. case contact.FieldWxid:
  7939. return m.OldWxid(ctx)
  7940. case contact.FieldAccount:
  7941. return m.OldAccount(ctx)
  7942. case contact.FieldNickname:
  7943. return m.OldNickname(ctx)
  7944. case contact.FieldMarkname:
  7945. return m.OldMarkname(ctx)
  7946. case contact.FieldHeadimg:
  7947. return m.OldHeadimg(ctx)
  7948. case contact.FieldSex:
  7949. return m.OldSex(ctx)
  7950. case contact.FieldStarrole:
  7951. return m.OldStarrole(ctx)
  7952. case contact.FieldDontseeit:
  7953. return m.OldDontseeit(ctx)
  7954. case contact.FieldDontseeme:
  7955. return m.OldDontseeme(ctx)
  7956. case contact.FieldLag:
  7957. return m.OldLag(ctx)
  7958. case contact.FieldGid:
  7959. return m.OldGid(ctx)
  7960. case contact.FieldGname:
  7961. return m.OldGname(ctx)
  7962. case contact.FieldV3:
  7963. return m.OldV3(ctx)
  7964. case contact.FieldOrganizationID:
  7965. return m.OldOrganizationID(ctx)
  7966. }
  7967. return nil, fmt.Errorf("unknown Contact field %s", name)
  7968. }
  7969. // SetField sets the value of a field with the given name. It returns an error if
  7970. // the field is not defined in the schema, or if the type mismatched the field
  7971. // type.
  7972. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  7973. switch name {
  7974. case contact.FieldCreatedAt:
  7975. v, ok := value.(time.Time)
  7976. if !ok {
  7977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7978. }
  7979. m.SetCreatedAt(v)
  7980. return nil
  7981. case contact.FieldUpdatedAt:
  7982. v, ok := value.(time.Time)
  7983. if !ok {
  7984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7985. }
  7986. m.SetUpdatedAt(v)
  7987. return nil
  7988. case contact.FieldStatus:
  7989. v, ok := value.(uint8)
  7990. if !ok {
  7991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7992. }
  7993. m.SetStatus(v)
  7994. return nil
  7995. case contact.FieldDeletedAt:
  7996. v, ok := value.(time.Time)
  7997. if !ok {
  7998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7999. }
  8000. m.SetDeletedAt(v)
  8001. return nil
  8002. case contact.FieldWxWxid:
  8003. v, ok := value.(string)
  8004. if !ok {
  8005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8006. }
  8007. m.SetWxWxid(v)
  8008. return nil
  8009. case contact.FieldType:
  8010. v, ok := value.(int)
  8011. if !ok {
  8012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8013. }
  8014. m.SetType(v)
  8015. return nil
  8016. case contact.FieldWxid:
  8017. v, ok := value.(string)
  8018. if !ok {
  8019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8020. }
  8021. m.SetWxid(v)
  8022. return nil
  8023. case contact.FieldAccount:
  8024. v, ok := value.(string)
  8025. if !ok {
  8026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8027. }
  8028. m.SetAccount(v)
  8029. return nil
  8030. case contact.FieldNickname:
  8031. v, ok := value.(string)
  8032. if !ok {
  8033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8034. }
  8035. m.SetNickname(v)
  8036. return nil
  8037. case contact.FieldMarkname:
  8038. v, ok := value.(string)
  8039. if !ok {
  8040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8041. }
  8042. m.SetMarkname(v)
  8043. return nil
  8044. case contact.FieldHeadimg:
  8045. v, ok := value.(string)
  8046. if !ok {
  8047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8048. }
  8049. m.SetHeadimg(v)
  8050. return nil
  8051. case contact.FieldSex:
  8052. v, ok := value.(int)
  8053. if !ok {
  8054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8055. }
  8056. m.SetSex(v)
  8057. return nil
  8058. case contact.FieldStarrole:
  8059. v, ok := value.(string)
  8060. if !ok {
  8061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8062. }
  8063. m.SetStarrole(v)
  8064. return nil
  8065. case contact.FieldDontseeit:
  8066. v, ok := value.(int)
  8067. if !ok {
  8068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8069. }
  8070. m.SetDontseeit(v)
  8071. return nil
  8072. case contact.FieldDontseeme:
  8073. v, ok := value.(int)
  8074. if !ok {
  8075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8076. }
  8077. m.SetDontseeme(v)
  8078. return nil
  8079. case contact.FieldLag:
  8080. v, ok := value.(string)
  8081. if !ok {
  8082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8083. }
  8084. m.SetLag(v)
  8085. return nil
  8086. case contact.FieldGid:
  8087. v, ok := value.(string)
  8088. if !ok {
  8089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8090. }
  8091. m.SetGid(v)
  8092. return nil
  8093. case contact.FieldGname:
  8094. v, ok := value.(string)
  8095. if !ok {
  8096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8097. }
  8098. m.SetGname(v)
  8099. return nil
  8100. case contact.FieldV3:
  8101. v, ok := value.(string)
  8102. if !ok {
  8103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8104. }
  8105. m.SetV3(v)
  8106. return nil
  8107. case contact.FieldOrganizationID:
  8108. v, ok := value.(uint64)
  8109. if !ok {
  8110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8111. }
  8112. m.SetOrganizationID(v)
  8113. return nil
  8114. }
  8115. return fmt.Errorf("unknown Contact field %s", name)
  8116. }
  8117. // AddedFields returns all numeric fields that were incremented/decremented during
  8118. // this mutation.
  8119. func (m *ContactMutation) AddedFields() []string {
  8120. var fields []string
  8121. if m.addstatus != nil {
  8122. fields = append(fields, contact.FieldStatus)
  8123. }
  8124. if m.add_type != nil {
  8125. fields = append(fields, contact.FieldType)
  8126. }
  8127. if m.addsex != nil {
  8128. fields = append(fields, contact.FieldSex)
  8129. }
  8130. if m.adddontseeit != nil {
  8131. fields = append(fields, contact.FieldDontseeit)
  8132. }
  8133. if m.adddontseeme != nil {
  8134. fields = append(fields, contact.FieldDontseeme)
  8135. }
  8136. if m.addorganization_id != nil {
  8137. fields = append(fields, contact.FieldOrganizationID)
  8138. }
  8139. return fields
  8140. }
  8141. // AddedField returns the numeric value that was incremented/decremented on a field
  8142. // with the given name. The second boolean return value indicates that this field
  8143. // was not set, or was not defined in the schema.
  8144. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8145. switch name {
  8146. case contact.FieldStatus:
  8147. return m.AddedStatus()
  8148. case contact.FieldType:
  8149. return m.AddedType()
  8150. case contact.FieldSex:
  8151. return m.AddedSex()
  8152. case contact.FieldDontseeit:
  8153. return m.AddedDontseeit()
  8154. case contact.FieldDontseeme:
  8155. return m.AddedDontseeme()
  8156. case contact.FieldOrganizationID:
  8157. return m.AddedOrganizationID()
  8158. }
  8159. return nil, false
  8160. }
  8161. // AddField adds the value to the field with the given name. It returns an error if
  8162. // the field is not defined in the schema, or if the type mismatched the field
  8163. // type.
  8164. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8165. switch name {
  8166. case contact.FieldStatus:
  8167. v, ok := value.(int8)
  8168. if !ok {
  8169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8170. }
  8171. m.AddStatus(v)
  8172. return nil
  8173. case contact.FieldType:
  8174. v, ok := value.(int)
  8175. if !ok {
  8176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8177. }
  8178. m.AddType(v)
  8179. return nil
  8180. case contact.FieldSex:
  8181. v, ok := value.(int)
  8182. if !ok {
  8183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8184. }
  8185. m.AddSex(v)
  8186. return nil
  8187. case contact.FieldDontseeit:
  8188. v, ok := value.(int)
  8189. if !ok {
  8190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8191. }
  8192. m.AddDontseeit(v)
  8193. return nil
  8194. case contact.FieldDontseeme:
  8195. v, ok := value.(int)
  8196. if !ok {
  8197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8198. }
  8199. m.AddDontseeme(v)
  8200. return nil
  8201. case contact.FieldOrganizationID:
  8202. v, ok := value.(int64)
  8203. if !ok {
  8204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8205. }
  8206. m.AddOrganizationID(v)
  8207. return nil
  8208. }
  8209. return fmt.Errorf("unknown Contact numeric field %s", name)
  8210. }
  8211. // ClearedFields returns all nullable fields that were cleared during this
  8212. // mutation.
  8213. func (m *ContactMutation) ClearedFields() []string {
  8214. var fields []string
  8215. if m.FieldCleared(contact.FieldStatus) {
  8216. fields = append(fields, contact.FieldStatus)
  8217. }
  8218. if m.FieldCleared(contact.FieldDeletedAt) {
  8219. fields = append(fields, contact.FieldDeletedAt)
  8220. }
  8221. if m.FieldCleared(contact.FieldType) {
  8222. fields = append(fields, contact.FieldType)
  8223. }
  8224. if m.FieldCleared(contact.FieldOrganizationID) {
  8225. fields = append(fields, contact.FieldOrganizationID)
  8226. }
  8227. return fields
  8228. }
  8229. // FieldCleared returns a boolean indicating if a field with the given name was
  8230. // cleared in this mutation.
  8231. func (m *ContactMutation) FieldCleared(name string) bool {
  8232. _, ok := m.clearedFields[name]
  8233. return ok
  8234. }
  8235. // ClearField clears the value of the field with the given name. It returns an
  8236. // error if the field is not defined in the schema.
  8237. func (m *ContactMutation) ClearField(name string) error {
  8238. switch name {
  8239. case contact.FieldStatus:
  8240. m.ClearStatus()
  8241. return nil
  8242. case contact.FieldDeletedAt:
  8243. m.ClearDeletedAt()
  8244. return nil
  8245. case contact.FieldType:
  8246. m.ClearType()
  8247. return nil
  8248. case contact.FieldOrganizationID:
  8249. m.ClearOrganizationID()
  8250. return nil
  8251. }
  8252. return fmt.Errorf("unknown Contact nullable field %s", name)
  8253. }
  8254. // ResetField resets all changes in the mutation for the field with the given name.
  8255. // It returns an error if the field is not defined in the schema.
  8256. func (m *ContactMutation) ResetField(name string) error {
  8257. switch name {
  8258. case contact.FieldCreatedAt:
  8259. m.ResetCreatedAt()
  8260. return nil
  8261. case contact.FieldUpdatedAt:
  8262. m.ResetUpdatedAt()
  8263. return nil
  8264. case contact.FieldStatus:
  8265. m.ResetStatus()
  8266. return nil
  8267. case contact.FieldDeletedAt:
  8268. m.ResetDeletedAt()
  8269. return nil
  8270. case contact.FieldWxWxid:
  8271. m.ResetWxWxid()
  8272. return nil
  8273. case contact.FieldType:
  8274. m.ResetType()
  8275. return nil
  8276. case contact.FieldWxid:
  8277. m.ResetWxid()
  8278. return nil
  8279. case contact.FieldAccount:
  8280. m.ResetAccount()
  8281. return nil
  8282. case contact.FieldNickname:
  8283. m.ResetNickname()
  8284. return nil
  8285. case contact.FieldMarkname:
  8286. m.ResetMarkname()
  8287. return nil
  8288. case contact.FieldHeadimg:
  8289. m.ResetHeadimg()
  8290. return nil
  8291. case contact.FieldSex:
  8292. m.ResetSex()
  8293. return nil
  8294. case contact.FieldStarrole:
  8295. m.ResetStarrole()
  8296. return nil
  8297. case contact.FieldDontseeit:
  8298. m.ResetDontseeit()
  8299. return nil
  8300. case contact.FieldDontseeme:
  8301. m.ResetDontseeme()
  8302. return nil
  8303. case contact.FieldLag:
  8304. m.ResetLag()
  8305. return nil
  8306. case contact.FieldGid:
  8307. m.ResetGid()
  8308. return nil
  8309. case contact.FieldGname:
  8310. m.ResetGname()
  8311. return nil
  8312. case contact.FieldV3:
  8313. m.ResetV3()
  8314. return nil
  8315. case contact.FieldOrganizationID:
  8316. m.ResetOrganizationID()
  8317. return nil
  8318. }
  8319. return fmt.Errorf("unknown Contact field %s", name)
  8320. }
  8321. // AddedEdges returns all edge names that were set/added in this mutation.
  8322. func (m *ContactMutation) AddedEdges() []string {
  8323. edges := make([]string, 0, 2)
  8324. if m.contact_relationships != nil {
  8325. edges = append(edges, contact.EdgeContactRelationships)
  8326. }
  8327. if m.contact_messages != nil {
  8328. edges = append(edges, contact.EdgeContactMessages)
  8329. }
  8330. return edges
  8331. }
  8332. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8333. // name in this mutation.
  8334. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8335. switch name {
  8336. case contact.EdgeContactRelationships:
  8337. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8338. for id := range m.contact_relationships {
  8339. ids = append(ids, id)
  8340. }
  8341. return ids
  8342. case contact.EdgeContactMessages:
  8343. ids := make([]ent.Value, 0, len(m.contact_messages))
  8344. for id := range m.contact_messages {
  8345. ids = append(ids, id)
  8346. }
  8347. return ids
  8348. }
  8349. return nil
  8350. }
  8351. // RemovedEdges returns all edge names that were removed in this mutation.
  8352. func (m *ContactMutation) RemovedEdges() []string {
  8353. edges := make([]string, 0, 2)
  8354. if m.removedcontact_relationships != nil {
  8355. edges = append(edges, contact.EdgeContactRelationships)
  8356. }
  8357. if m.removedcontact_messages != nil {
  8358. edges = append(edges, contact.EdgeContactMessages)
  8359. }
  8360. return edges
  8361. }
  8362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8363. // the given name in this mutation.
  8364. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8365. switch name {
  8366. case contact.EdgeContactRelationships:
  8367. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8368. for id := range m.removedcontact_relationships {
  8369. ids = append(ids, id)
  8370. }
  8371. return ids
  8372. case contact.EdgeContactMessages:
  8373. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8374. for id := range m.removedcontact_messages {
  8375. ids = append(ids, id)
  8376. }
  8377. return ids
  8378. }
  8379. return nil
  8380. }
  8381. // ClearedEdges returns all edge names that were cleared in this mutation.
  8382. func (m *ContactMutation) ClearedEdges() []string {
  8383. edges := make([]string, 0, 2)
  8384. if m.clearedcontact_relationships {
  8385. edges = append(edges, contact.EdgeContactRelationships)
  8386. }
  8387. if m.clearedcontact_messages {
  8388. edges = append(edges, contact.EdgeContactMessages)
  8389. }
  8390. return edges
  8391. }
  8392. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8393. // was cleared in this mutation.
  8394. func (m *ContactMutation) EdgeCleared(name string) bool {
  8395. switch name {
  8396. case contact.EdgeContactRelationships:
  8397. return m.clearedcontact_relationships
  8398. case contact.EdgeContactMessages:
  8399. return m.clearedcontact_messages
  8400. }
  8401. return false
  8402. }
  8403. // ClearEdge clears the value of the edge with the given name. It returns an error
  8404. // if that edge is not defined in the schema.
  8405. func (m *ContactMutation) ClearEdge(name string) error {
  8406. switch name {
  8407. }
  8408. return fmt.Errorf("unknown Contact unique edge %s", name)
  8409. }
  8410. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8411. // It returns an error if the edge is not defined in the schema.
  8412. func (m *ContactMutation) ResetEdge(name string) error {
  8413. switch name {
  8414. case contact.EdgeContactRelationships:
  8415. m.ResetContactRelationships()
  8416. return nil
  8417. case contact.EdgeContactMessages:
  8418. m.ResetContactMessages()
  8419. return nil
  8420. }
  8421. return fmt.Errorf("unknown Contact edge %s", name)
  8422. }
  8423. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8424. type EmployeeMutation struct {
  8425. config
  8426. op Op
  8427. typ string
  8428. id *uint64
  8429. created_at *time.Time
  8430. updated_at *time.Time
  8431. deleted_at *time.Time
  8432. title *string
  8433. avatar *string
  8434. tags *string
  8435. hire_count *int
  8436. addhire_count *int
  8437. service_count *int
  8438. addservice_count *int
  8439. achievement_count *int
  8440. addachievement_count *int
  8441. intro *string
  8442. estimate *string
  8443. skill *string
  8444. ability_type *string
  8445. scene *string
  8446. switch_in *string
  8447. video_url *string
  8448. organization_id *uint64
  8449. addorganization_id *int64
  8450. category_id *uint64
  8451. addcategory_id *int64
  8452. api_base *string
  8453. api_key *string
  8454. ai_info *string
  8455. is_vip *int
  8456. addis_vip *int
  8457. clearedFields map[string]struct{}
  8458. em_work_experiences map[uint64]struct{}
  8459. removedem_work_experiences map[uint64]struct{}
  8460. clearedem_work_experiences bool
  8461. em_tutorial map[uint64]struct{}
  8462. removedem_tutorial map[uint64]struct{}
  8463. clearedem_tutorial bool
  8464. done bool
  8465. oldValue func(context.Context) (*Employee, error)
  8466. predicates []predicate.Employee
  8467. }
  8468. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8469. // employeeOption allows management of the mutation configuration using functional options.
  8470. type employeeOption func(*EmployeeMutation)
  8471. // newEmployeeMutation creates new mutation for the Employee entity.
  8472. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8473. m := &EmployeeMutation{
  8474. config: c,
  8475. op: op,
  8476. typ: TypeEmployee,
  8477. clearedFields: make(map[string]struct{}),
  8478. }
  8479. for _, opt := range opts {
  8480. opt(m)
  8481. }
  8482. return m
  8483. }
  8484. // withEmployeeID sets the ID field of the mutation.
  8485. func withEmployeeID(id uint64) employeeOption {
  8486. return func(m *EmployeeMutation) {
  8487. var (
  8488. err error
  8489. once sync.Once
  8490. value *Employee
  8491. )
  8492. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8493. once.Do(func() {
  8494. if m.done {
  8495. err = errors.New("querying old values post mutation is not allowed")
  8496. } else {
  8497. value, err = m.Client().Employee.Get(ctx, id)
  8498. }
  8499. })
  8500. return value, err
  8501. }
  8502. m.id = &id
  8503. }
  8504. }
  8505. // withEmployee sets the old Employee of the mutation.
  8506. func withEmployee(node *Employee) employeeOption {
  8507. return func(m *EmployeeMutation) {
  8508. m.oldValue = func(context.Context) (*Employee, error) {
  8509. return node, nil
  8510. }
  8511. m.id = &node.ID
  8512. }
  8513. }
  8514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8515. // executed in a transaction (ent.Tx), a transactional client is returned.
  8516. func (m EmployeeMutation) Client() *Client {
  8517. client := &Client{config: m.config}
  8518. client.init()
  8519. return client
  8520. }
  8521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8522. // it returns an error otherwise.
  8523. func (m EmployeeMutation) Tx() (*Tx, error) {
  8524. if _, ok := m.driver.(*txDriver); !ok {
  8525. return nil, errors.New("ent: mutation is not running in a transaction")
  8526. }
  8527. tx := &Tx{config: m.config}
  8528. tx.init()
  8529. return tx, nil
  8530. }
  8531. // SetID sets the value of the id field. Note that this
  8532. // operation is only accepted on creation of Employee entities.
  8533. func (m *EmployeeMutation) SetID(id uint64) {
  8534. m.id = &id
  8535. }
  8536. // ID returns the ID value in the mutation. Note that the ID is only available
  8537. // if it was provided to the builder or after it was returned from the database.
  8538. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8539. if m.id == nil {
  8540. return
  8541. }
  8542. return *m.id, true
  8543. }
  8544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8545. // That means, if the mutation is applied within a transaction with an isolation level such
  8546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8547. // or updated by the mutation.
  8548. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8549. switch {
  8550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8551. id, exists := m.ID()
  8552. if exists {
  8553. return []uint64{id}, nil
  8554. }
  8555. fallthrough
  8556. case m.op.Is(OpUpdate | OpDelete):
  8557. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8558. default:
  8559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8560. }
  8561. }
  8562. // SetCreatedAt sets the "created_at" field.
  8563. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8564. m.created_at = &t
  8565. }
  8566. // CreatedAt returns the value of the "created_at" field in the mutation.
  8567. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8568. v := m.created_at
  8569. if v == nil {
  8570. return
  8571. }
  8572. return *v, true
  8573. }
  8574. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8575. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8577. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8578. if !m.op.Is(OpUpdateOne) {
  8579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8580. }
  8581. if m.id == nil || m.oldValue == nil {
  8582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8583. }
  8584. oldValue, err := m.oldValue(ctx)
  8585. if err != nil {
  8586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8587. }
  8588. return oldValue.CreatedAt, nil
  8589. }
  8590. // ResetCreatedAt resets all changes to the "created_at" field.
  8591. func (m *EmployeeMutation) ResetCreatedAt() {
  8592. m.created_at = nil
  8593. }
  8594. // SetUpdatedAt sets the "updated_at" field.
  8595. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8596. m.updated_at = &t
  8597. }
  8598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8599. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8600. v := m.updated_at
  8601. if v == nil {
  8602. return
  8603. }
  8604. return *v, true
  8605. }
  8606. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8607. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8609. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8610. if !m.op.Is(OpUpdateOne) {
  8611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8612. }
  8613. if m.id == nil || m.oldValue == nil {
  8614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8615. }
  8616. oldValue, err := m.oldValue(ctx)
  8617. if err != nil {
  8618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8619. }
  8620. return oldValue.UpdatedAt, nil
  8621. }
  8622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8623. func (m *EmployeeMutation) ResetUpdatedAt() {
  8624. m.updated_at = nil
  8625. }
  8626. // SetDeletedAt sets the "deleted_at" field.
  8627. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8628. m.deleted_at = &t
  8629. }
  8630. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8631. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8632. v := m.deleted_at
  8633. if v == nil {
  8634. return
  8635. }
  8636. return *v, true
  8637. }
  8638. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8639. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8641. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8642. if !m.op.Is(OpUpdateOne) {
  8643. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8644. }
  8645. if m.id == nil || m.oldValue == nil {
  8646. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8647. }
  8648. oldValue, err := m.oldValue(ctx)
  8649. if err != nil {
  8650. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8651. }
  8652. return oldValue.DeletedAt, nil
  8653. }
  8654. // ClearDeletedAt clears the value of the "deleted_at" field.
  8655. func (m *EmployeeMutation) ClearDeletedAt() {
  8656. m.deleted_at = nil
  8657. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8658. }
  8659. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8660. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8661. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8662. return ok
  8663. }
  8664. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8665. func (m *EmployeeMutation) ResetDeletedAt() {
  8666. m.deleted_at = nil
  8667. delete(m.clearedFields, employee.FieldDeletedAt)
  8668. }
  8669. // SetTitle sets the "title" field.
  8670. func (m *EmployeeMutation) SetTitle(s string) {
  8671. m.title = &s
  8672. }
  8673. // Title returns the value of the "title" field in the mutation.
  8674. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8675. v := m.title
  8676. if v == nil {
  8677. return
  8678. }
  8679. return *v, true
  8680. }
  8681. // OldTitle returns the old "title" field's value of the Employee entity.
  8682. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8684. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8685. if !m.op.Is(OpUpdateOne) {
  8686. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8687. }
  8688. if m.id == nil || m.oldValue == nil {
  8689. return v, errors.New("OldTitle requires an ID field in the mutation")
  8690. }
  8691. oldValue, err := m.oldValue(ctx)
  8692. if err != nil {
  8693. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8694. }
  8695. return oldValue.Title, nil
  8696. }
  8697. // ResetTitle resets all changes to the "title" field.
  8698. func (m *EmployeeMutation) ResetTitle() {
  8699. m.title = nil
  8700. }
  8701. // SetAvatar sets the "avatar" field.
  8702. func (m *EmployeeMutation) SetAvatar(s string) {
  8703. m.avatar = &s
  8704. }
  8705. // Avatar returns the value of the "avatar" field in the mutation.
  8706. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8707. v := m.avatar
  8708. if v == nil {
  8709. return
  8710. }
  8711. return *v, true
  8712. }
  8713. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8714. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8716. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8717. if !m.op.Is(OpUpdateOne) {
  8718. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8719. }
  8720. if m.id == nil || m.oldValue == nil {
  8721. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8722. }
  8723. oldValue, err := m.oldValue(ctx)
  8724. if err != nil {
  8725. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8726. }
  8727. return oldValue.Avatar, nil
  8728. }
  8729. // ResetAvatar resets all changes to the "avatar" field.
  8730. func (m *EmployeeMutation) ResetAvatar() {
  8731. m.avatar = nil
  8732. }
  8733. // SetTags sets the "tags" field.
  8734. func (m *EmployeeMutation) SetTags(s string) {
  8735. m.tags = &s
  8736. }
  8737. // Tags returns the value of the "tags" field in the mutation.
  8738. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8739. v := m.tags
  8740. if v == nil {
  8741. return
  8742. }
  8743. return *v, true
  8744. }
  8745. // OldTags returns the old "tags" field's value of the Employee entity.
  8746. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8748. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8749. if !m.op.Is(OpUpdateOne) {
  8750. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8751. }
  8752. if m.id == nil || m.oldValue == nil {
  8753. return v, errors.New("OldTags requires an ID field in the mutation")
  8754. }
  8755. oldValue, err := m.oldValue(ctx)
  8756. if err != nil {
  8757. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8758. }
  8759. return oldValue.Tags, nil
  8760. }
  8761. // ResetTags resets all changes to the "tags" field.
  8762. func (m *EmployeeMutation) ResetTags() {
  8763. m.tags = nil
  8764. }
  8765. // SetHireCount sets the "hire_count" field.
  8766. func (m *EmployeeMutation) SetHireCount(i int) {
  8767. m.hire_count = &i
  8768. m.addhire_count = nil
  8769. }
  8770. // HireCount returns the value of the "hire_count" field in the mutation.
  8771. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8772. v := m.hire_count
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8779. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8791. }
  8792. return oldValue.HireCount, nil
  8793. }
  8794. // AddHireCount adds i to the "hire_count" field.
  8795. func (m *EmployeeMutation) AddHireCount(i int) {
  8796. if m.addhire_count != nil {
  8797. *m.addhire_count += i
  8798. } else {
  8799. m.addhire_count = &i
  8800. }
  8801. }
  8802. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8803. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8804. v := m.addhire_count
  8805. if v == nil {
  8806. return
  8807. }
  8808. return *v, true
  8809. }
  8810. // ResetHireCount resets all changes to the "hire_count" field.
  8811. func (m *EmployeeMutation) ResetHireCount() {
  8812. m.hire_count = nil
  8813. m.addhire_count = nil
  8814. }
  8815. // SetServiceCount sets the "service_count" field.
  8816. func (m *EmployeeMutation) SetServiceCount(i int) {
  8817. m.service_count = &i
  8818. m.addservice_count = nil
  8819. }
  8820. // ServiceCount returns the value of the "service_count" field in the mutation.
  8821. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8822. v := m.service_count
  8823. if v == nil {
  8824. return
  8825. }
  8826. return *v, true
  8827. }
  8828. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8829. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8831. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8832. if !m.op.Is(OpUpdateOne) {
  8833. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8834. }
  8835. if m.id == nil || m.oldValue == nil {
  8836. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8837. }
  8838. oldValue, err := m.oldValue(ctx)
  8839. if err != nil {
  8840. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8841. }
  8842. return oldValue.ServiceCount, nil
  8843. }
  8844. // AddServiceCount adds i to the "service_count" field.
  8845. func (m *EmployeeMutation) AddServiceCount(i int) {
  8846. if m.addservice_count != nil {
  8847. *m.addservice_count += i
  8848. } else {
  8849. m.addservice_count = &i
  8850. }
  8851. }
  8852. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8853. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8854. v := m.addservice_count
  8855. if v == nil {
  8856. return
  8857. }
  8858. return *v, true
  8859. }
  8860. // ResetServiceCount resets all changes to the "service_count" field.
  8861. func (m *EmployeeMutation) ResetServiceCount() {
  8862. m.service_count = nil
  8863. m.addservice_count = nil
  8864. }
  8865. // SetAchievementCount sets the "achievement_count" field.
  8866. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8867. m.achievement_count = &i
  8868. m.addachievement_count = nil
  8869. }
  8870. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8871. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8872. v := m.achievement_count
  8873. if v == nil {
  8874. return
  8875. }
  8876. return *v, true
  8877. }
  8878. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8879. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8881. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8882. if !m.op.Is(OpUpdateOne) {
  8883. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8884. }
  8885. if m.id == nil || m.oldValue == nil {
  8886. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8887. }
  8888. oldValue, err := m.oldValue(ctx)
  8889. if err != nil {
  8890. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8891. }
  8892. return oldValue.AchievementCount, nil
  8893. }
  8894. // AddAchievementCount adds i to the "achievement_count" field.
  8895. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8896. if m.addachievement_count != nil {
  8897. *m.addachievement_count += i
  8898. } else {
  8899. m.addachievement_count = &i
  8900. }
  8901. }
  8902. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8903. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8904. v := m.addachievement_count
  8905. if v == nil {
  8906. return
  8907. }
  8908. return *v, true
  8909. }
  8910. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8911. func (m *EmployeeMutation) ResetAchievementCount() {
  8912. m.achievement_count = nil
  8913. m.addachievement_count = nil
  8914. }
  8915. // SetIntro sets the "intro" field.
  8916. func (m *EmployeeMutation) SetIntro(s string) {
  8917. m.intro = &s
  8918. }
  8919. // Intro returns the value of the "intro" field in the mutation.
  8920. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  8921. v := m.intro
  8922. if v == nil {
  8923. return
  8924. }
  8925. return *v, true
  8926. }
  8927. // OldIntro returns the old "intro" field's value of the Employee entity.
  8928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8930. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  8931. if !m.op.Is(OpUpdateOne) {
  8932. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  8933. }
  8934. if m.id == nil || m.oldValue == nil {
  8935. return v, errors.New("OldIntro requires an ID field in the mutation")
  8936. }
  8937. oldValue, err := m.oldValue(ctx)
  8938. if err != nil {
  8939. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  8940. }
  8941. return oldValue.Intro, nil
  8942. }
  8943. // ResetIntro resets all changes to the "intro" field.
  8944. func (m *EmployeeMutation) ResetIntro() {
  8945. m.intro = nil
  8946. }
  8947. // SetEstimate sets the "estimate" field.
  8948. func (m *EmployeeMutation) SetEstimate(s string) {
  8949. m.estimate = &s
  8950. }
  8951. // Estimate returns the value of the "estimate" field in the mutation.
  8952. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  8953. v := m.estimate
  8954. if v == nil {
  8955. return
  8956. }
  8957. return *v, true
  8958. }
  8959. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  8960. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8962. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  8963. if !m.op.Is(OpUpdateOne) {
  8964. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  8965. }
  8966. if m.id == nil || m.oldValue == nil {
  8967. return v, errors.New("OldEstimate requires an ID field in the mutation")
  8968. }
  8969. oldValue, err := m.oldValue(ctx)
  8970. if err != nil {
  8971. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  8972. }
  8973. return oldValue.Estimate, nil
  8974. }
  8975. // ResetEstimate resets all changes to the "estimate" field.
  8976. func (m *EmployeeMutation) ResetEstimate() {
  8977. m.estimate = nil
  8978. }
  8979. // SetSkill sets the "skill" field.
  8980. func (m *EmployeeMutation) SetSkill(s string) {
  8981. m.skill = &s
  8982. }
  8983. // Skill returns the value of the "skill" field in the mutation.
  8984. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  8985. v := m.skill
  8986. if v == nil {
  8987. return
  8988. }
  8989. return *v, true
  8990. }
  8991. // OldSkill returns the old "skill" field's value of the Employee entity.
  8992. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8994. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  8995. if !m.op.Is(OpUpdateOne) {
  8996. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  8997. }
  8998. if m.id == nil || m.oldValue == nil {
  8999. return v, errors.New("OldSkill requires an ID field in the mutation")
  9000. }
  9001. oldValue, err := m.oldValue(ctx)
  9002. if err != nil {
  9003. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9004. }
  9005. return oldValue.Skill, nil
  9006. }
  9007. // ResetSkill resets all changes to the "skill" field.
  9008. func (m *EmployeeMutation) ResetSkill() {
  9009. m.skill = nil
  9010. }
  9011. // SetAbilityType sets the "ability_type" field.
  9012. func (m *EmployeeMutation) SetAbilityType(s string) {
  9013. m.ability_type = &s
  9014. }
  9015. // AbilityType returns the value of the "ability_type" field in the mutation.
  9016. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9017. v := m.ability_type
  9018. if v == nil {
  9019. return
  9020. }
  9021. return *v, true
  9022. }
  9023. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9026. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9027. if !m.op.Is(OpUpdateOne) {
  9028. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9029. }
  9030. if m.id == nil || m.oldValue == nil {
  9031. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9032. }
  9033. oldValue, err := m.oldValue(ctx)
  9034. if err != nil {
  9035. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9036. }
  9037. return oldValue.AbilityType, nil
  9038. }
  9039. // ResetAbilityType resets all changes to the "ability_type" field.
  9040. func (m *EmployeeMutation) ResetAbilityType() {
  9041. m.ability_type = nil
  9042. }
  9043. // SetScene sets the "scene" field.
  9044. func (m *EmployeeMutation) SetScene(s string) {
  9045. m.scene = &s
  9046. }
  9047. // Scene returns the value of the "scene" field in the mutation.
  9048. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9049. v := m.scene
  9050. if v == nil {
  9051. return
  9052. }
  9053. return *v, true
  9054. }
  9055. // OldScene returns the old "scene" field's value of the Employee entity.
  9056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9058. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9059. if !m.op.Is(OpUpdateOne) {
  9060. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9061. }
  9062. if m.id == nil || m.oldValue == nil {
  9063. return v, errors.New("OldScene requires an ID field in the mutation")
  9064. }
  9065. oldValue, err := m.oldValue(ctx)
  9066. if err != nil {
  9067. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9068. }
  9069. return oldValue.Scene, nil
  9070. }
  9071. // ResetScene resets all changes to the "scene" field.
  9072. func (m *EmployeeMutation) ResetScene() {
  9073. m.scene = nil
  9074. }
  9075. // SetSwitchIn sets the "switch_in" field.
  9076. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9077. m.switch_in = &s
  9078. }
  9079. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9080. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9081. v := m.switch_in
  9082. if v == nil {
  9083. return
  9084. }
  9085. return *v, true
  9086. }
  9087. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9088. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9090. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9091. if !m.op.Is(OpUpdateOne) {
  9092. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9093. }
  9094. if m.id == nil || m.oldValue == nil {
  9095. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9096. }
  9097. oldValue, err := m.oldValue(ctx)
  9098. if err != nil {
  9099. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9100. }
  9101. return oldValue.SwitchIn, nil
  9102. }
  9103. // ResetSwitchIn resets all changes to the "switch_in" field.
  9104. func (m *EmployeeMutation) ResetSwitchIn() {
  9105. m.switch_in = nil
  9106. }
  9107. // SetVideoURL sets the "video_url" field.
  9108. func (m *EmployeeMutation) SetVideoURL(s string) {
  9109. m.video_url = &s
  9110. }
  9111. // VideoURL returns the value of the "video_url" field in the mutation.
  9112. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9113. v := m.video_url
  9114. if v == nil {
  9115. return
  9116. }
  9117. return *v, true
  9118. }
  9119. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9120. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9122. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9123. if !m.op.Is(OpUpdateOne) {
  9124. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9125. }
  9126. if m.id == nil || m.oldValue == nil {
  9127. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9128. }
  9129. oldValue, err := m.oldValue(ctx)
  9130. if err != nil {
  9131. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9132. }
  9133. return oldValue.VideoURL, nil
  9134. }
  9135. // ResetVideoURL resets all changes to the "video_url" field.
  9136. func (m *EmployeeMutation) ResetVideoURL() {
  9137. m.video_url = nil
  9138. }
  9139. // SetOrganizationID sets the "organization_id" field.
  9140. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9141. m.organization_id = &u
  9142. m.addorganization_id = nil
  9143. }
  9144. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9145. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9146. v := m.organization_id
  9147. if v == nil {
  9148. return
  9149. }
  9150. return *v, true
  9151. }
  9152. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9153. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9155. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9156. if !m.op.Is(OpUpdateOne) {
  9157. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9158. }
  9159. if m.id == nil || m.oldValue == nil {
  9160. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9161. }
  9162. oldValue, err := m.oldValue(ctx)
  9163. if err != nil {
  9164. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9165. }
  9166. return oldValue.OrganizationID, nil
  9167. }
  9168. // AddOrganizationID adds u to the "organization_id" field.
  9169. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9170. if m.addorganization_id != nil {
  9171. *m.addorganization_id += u
  9172. } else {
  9173. m.addorganization_id = &u
  9174. }
  9175. }
  9176. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9177. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9178. v := m.addorganization_id
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // ResetOrganizationID resets all changes to the "organization_id" field.
  9185. func (m *EmployeeMutation) ResetOrganizationID() {
  9186. m.organization_id = nil
  9187. m.addorganization_id = nil
  9188. }
  9189. // SetCategoryID sets the "category_id" field.
  9190. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9191. m.category_id = &u
  9192. m.addcategory_id = nil
  9193. }
  9194. // CategoryID returns the value of the "category_id" field in the mutation.
  9195. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9196. v := m.category_id
  9197. if v == nil {
  9198. return
  9199. }
  9200. return *v, true
  9201. }
  9202. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9203. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9205. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9206. if !m.op.Is(OpUpdateOne) {
  9207. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9208. }
  9209. if m.id == nil || m.oldValue == nil {
  9210. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9211. }
  9212. oldValue, err := m.oldValue(ctx)
  9213. if err != nil {
  9214. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9215. }
  9216. return oldValue.CategoryID, nil
  9217. }
  9218. // AddCategoryID adds u to the "category_id" field.
  9219. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9220. if m.addcategory_id != nil {
  9221. *m.addcategory_id += u
  9222. } else {
  9223. m.addcategory_id = &u
  9224. }
  9225. }
  9226. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9227. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9228. v := m.addcategory_id
  9229. if v == nil {
  9230. return
  9231. }
  9232. return *v, true
  9233. }
  9234. // ResetCategoryID resets all changes to the "category_id" field.
  9235. func (m *EmployeeMutation) ResetCategoryID() {
  9236. m.category_id = nil
  9237. m.addcategory_id = nil
  9238. }
  9239. // SetAPIBase sets the "api_base" field.
  9240. func (m *EmployeeMutation) SetAPIBase(s string) {
  9241. m.api_base = &s
  9242. }
  9243. // APIBase returns the value of the "api_base" field in the mutation.
  9244. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9245. v := m.api_base
  9246. if v == nil {
  9247. return
  9248. }
  9249. return *v, true
  9250. }
  9251. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9252. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9254. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9255. if !m.op.Is(OpUpdateOne) {
  9256. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9257. }
  9258. if m.id == nil || m.oldValue == nil {
  9259. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9260. }
  9261. oldValue, err := m.oldValue(ctx)
  9262. if err != nil {
  9263. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9264. }
  9265. return oldValue.APIBase, nil
  9266. }
  9267. // ResetAPIBase resets all changes to the "api_base" field.
  9268. func (m *EmployeeMutation) ResetAPIBase() {
  9269. m.api_base = nil
  9270. }
  9271. // SetAPIKey sets the "api_key" field.
  9272. func (m *EmployeeMutation) SetAPIKey(s string) {
  9273. m.api_key = &s
  9274. }
  9275. // APIKey returns the value of the "api_key" field in the mutation.
  9276. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9277. v := m.api_key
  9278. if v == nil {
  9279. return
  9280. }
  9281. return *v, true
  9282. }
  9283. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9284. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9286. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9287. if !m.op.Is(OpUpdateOne) {
  9288. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9289. }
  9290. if m.id == nil || m.oldValue == nil {
  9291. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9292. }
  9293. oldValue, err := m.oldValue(ctx)
  9294. if err != nil {
  9295. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9296. }
  9297. return oldValue.APIKey, nil
  9298. }
  9299. // ResetAPIKey resets all changes to the "api_key" field.
  9300. func (m *EmployeeMutation) ResetAPIKey() {
  9301. m.api_key = nil
  9302. }
  9303. // SetAiInfo sets the "ai_info" field.
  9304. func (m *EmployeeMutation) SetAiInfo(s string) {
  9305. m.ai_info = &s
  9306. }
  9307. // AiInfo returns the value of the "ai_info" field in the mutation.
  9308. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9309. v := m.ai_info
  9310. if v == nil {
  9311. return
  9312. }
  9313. return *v, true
  9314. }
  9315. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9316. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9318. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9319. if !m.op.Is(OpUpdateOne) {
  9320. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9321. }
  9322. if m.id == nil || m.oldValue == nil {
  9323. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9324. }
  9325. oldValue, err := m.oldValue(ctx)
  9326. if err != nil {
  9327. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9328. }
  9329. return oldValue.AiInfo, nil
  9330. }
  9331. // ClearAiInfo clears the value of the "ai_info" field.
  9332. func (m *EmployeeMutation) ClearAiInfo() {
  9333. m.ai_info = nil
  9334. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9335. }
  9336. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9337. func (m *EmployeeMutation) AiInfoCleared() bool {
  9338. _, ok := m.clearedFields[employee.FieldAiInfo]
  9339. return ok
  9340. }
  9341. // ResetAiInfo resets all changes to the "ai_info" field.
  9342. func (m *EmployeeMutation) ResetAiInfo() {
  9343. m.ai_info = nil
  9344. delete(m.clearedFields, employee.FieldAiInfo)
  9345. }
  9346. // SetIsVip sets the "is_vip" field.
  9347. func (m *EmployeeMutation) SetIsVip(i int) {
  9348. m.is_vip = &i
  9349. m.addis_vip = nil
  9350. }
  9351. // IsVip returns the value of the "is_vip" field in the mutation.
  9352. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9353. v := m.is_vip
  9354. if v == nil {
  9355. return
  9356. }
  9357. return *v, true
  9358. }
  9359. // OldIsVip returns the old "is_vip" 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) OldIsVip(ctx context.Context) (v int, err error) {
  9363. if !m.op.Is(OpUpdateOne) {
  9364. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9365. }
  9366. if m.id == nil || m.oldValue == nil {
  9367. return v, errors.New("OldIsVip 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 OldIsVip: %w", err)
  9372. }
  9373. return oldValue.IsVip, nil
  9374. }
  9375. // AddIsVip adds i to the "is_vip" field.
  9376. func (m *EmployeeMutation) AddIsVip(i int) {
  9377. if m.addis_vip != nil {
  9378. *m.addis_vip += i
  9379. } else {
  9380. m.addis_vip = &i
  9381. }
  9382. }
  9383. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9384. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9385. v := m.addis_vip
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // ResetIsVip resets all changes to the "is_vip" field.
  9392. func (m *EmployeeMutation) ResetIsVip() {
  9393. m.is_vip = nil
  9394. m.addis_vip = nil
  9395. }
  9396. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9397. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9398. if m.em_work_experiences == nil {
  9399. m.em_work_experiences = make(map[uint64]struct{})
  9400. }
  9401. for i := range ids {
  9402. m.em_work_experiences[ids[i]] = struct{}{}
  9403. }
  9404. }
  9405. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9406. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9407. m.clearedem_work_experiences = true
  9408. }
  9409. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9410. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9411. return m.clearedem_work_experiences
  9412. }
  9413. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9414. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9415. if m.removedem_work_experiences == nil {
  9416. m.removedem_work_experiences = make(map[uint64]struct{})
  9417. }
  9418. for i := range ids {
  9419. delete(m.em_work_experiences, ids[i])
  9420. m.removedem_work_experiences[ids[i]] = struct{}{}
  9421. }
  9422. }
  9423. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9424. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9425. for id := range m.removedem_work_experiences {
  9426. ids = append(ids, id)
  9427. }
  9428. return
  9429. }
  9430. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9431. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9432. for id := range m.em_work_experiences {
  9433. ids = append(ids, id)
  9434. }
  9435. return
  9436. }
  9437. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9438. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9439. m.em_work_experiences = nil
  9440. m.clearedem_work_experiences = false
  9441. m.removedem_work_experiences = nil
  9442. }
  9443. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9444. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9445. if m.em_tutorial == nil {
  9446. m.em_tutorial = make(map[uint64]struct{})
  9447. }
  9448. for i := range ids {
  9449. m.em_tutorial[ids[i]] = struct{}{}
  9450. }
  9451. }
  9452. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9453. func (m *EmployeeMutation) ClearEmTutorial() {
  9454. m.clearedem_tutorial = true
  9455. }
  9456. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9457. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9458. return m.clearedem_tutorial
  9459. }
  9460. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9461. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9462. if m.removedem_tutorial == nil {
  9463. m.removedem_tutorial = make(map[uint64]struct{})
  9464. }
  9465. for i := range ids {
  9466. delete(m.em_tutorial, ids[i])
  9467. m.removedem_tutorial[ids[i]] = struct{}{}
  9468. }
  9469. }
  9470. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9471. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9472. for id := range m.removedem_tutorial {
  9473. ids = append(ids, id)
  9474. }
  9475. return
  9476. }
  9477. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9478. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9479. for id := range m.em_tutorial {
  9480. ids = append(ids, id)
  9481. }
  9482. return
  9483. }
  9484. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9485. func (m *EmployeeMutation) ResetEmTutorial() {
  9486. m.em_tutorial = nil
  9487. m.clearedem_tutorial = false
  9488. m.removedem_tutorial = nil
  9489. }
  9490. // Where appends a list predicates to the EmployeeMutation builder.
  9491. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9492. m.predicates = append(m.predicates, ps...)
  9493. }
  9494. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9495. // users can use type-assertion to append predicates that do not depend on any generated package.
  9496. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9497. p := make([]predicate.Employee, len(ps))
  9498. for i := range ps {
  9499. p[i] = ps[i]
  9500. }
  9501. m.Where(p...)
  9502. }
  9503. // Op returns the operation name.
  9504. func (m *EmployeeMutation) Op() Op {
  9505. return m.op
  9506. }
  9507. // SetOp allows setting the mutation operation.
  9508. func (m *EmployeeMutation) SetOp(op Op) {
  9509. m.op = op
  9510. }
  9511. // Type returns the node type of this mutation (Employee).
  9512. func (m *EmployeeMutation) Type() string {
  9513. return m.typ
  9514. }
  9515. // Fields returns all fields that were changed during this mutation. Note that in
  9516. // order to get all numeric fields that were incremented/decremented, call
  9517. // AddedFields().
  9518. func (m *EmployeeMutation) Fields() []string {
  9519. fields := make([]string, 0, 22)
  9520. if m.created_at != nil {
  9521. fields = append(fields, employee.FieldCreatedAt)
  9522. }
  9523. if m.updated_at != nil {
  9524. fields = append(fields, employee.FieldUpdatedAt)
  9525. }
  9526. if m.deleted_at != nil {
  9527. fields = append(fields, employee.FieldDeletedAt)
  9528. }
  9529. if m.title != nil {
  9530. fields = append(fields, employee.FieldTitle)
  9531. }
  9532. if m.avatar != nil {
  9533. fields = append(fields, employee.FieldAvatar)
  9534. }
  9535. if m.tags != nil {
  9536. fields = append(fields, employee.FieldTags)
  9537. }
  9538. if m.hire_count != nil {
  9539. fields = append(fields, employee.FieldHireCount)
  9540. }
  9541. if m.service_count != nil {
  9542. fields = append(fields, employee.FieldServiceCount)
  9543. }
  9544. if m.achievement_count != nil {
  9545. fields = append(fields, employee.FieldAchievementCount)
  9546. }
  9547. if m.intro != nil {
  9548. fields = append(fields, employee.FieldIntro)
  9549. }
  9550. if m.estimate != nil {
  9551. fields = append(fields, employee.FieldEstimate)
  9552. }
  9553. if m.skill != nil {
  9554. fields = append(fields, employee.FieldSkill)
  9555. }
  9556. if m.ability_type != nil {
  9557. fields = append(fields, employee.FieldAbilityType)
  9558. }
  9559. if m.scene != nil {
  9560. fields = append(fields, employee.FieldScene)
  9561. }
  9562. if m.switch_in != nil {
  9563. fields = append(fields, employee.FieldSwitchIn)
  9564. }
  9565. if m.video_url != nil {
  9566. fields = append(fields, employee.FieldVideoURL)
  9567. }
  9568. if m.organization_id != nil {
  9569. fields = append(fields, employee.FieldOrganizationID)
  9570. }
  9571. if m.category_id != nil {
  9572. fields = append(fields, employee.FieldCategoryID)
  9573. }
  9574. if m.api_base != nil {
  9575. fields = append(fields, employee.FieldAPIBase)
  9576. }
  9577. if m.api_key != nil {
  9578. fields = append(fields, employee.FieldAPIKey)
  9579. }
  9580. if m.ai_info != nil {
  9581. fields = append(fields, employee.FieldAiInfo)
  9582. }
  9583. if m.is_vip != nil {
  9584. fields = append(fields, employee.FieldIsVip)
  9585. }
  9586. return fields
  9587. }
  9588. // Field returns the value of a field with the given name. The second boolean
  9589. // return value indicates that this field was not set, or was not defined in the
  9590. // schema.
  9591. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9592. switch name {
  9593. case employee.FieldCreatedAt:
  9594. return m.CreatedAt()
  9595. case employee.FieldUpdatedAt:
  9596. return m.UpdatedAt()
  9597. case employee.FieldDeletedAt:
  9598. return m.DeletedAt()
  9599. case employee.FieldTitle:
  9600. return m.Title()
  9601. case employee.FieldAvatar:
  9602. return m.Avatar()
  9603. case employee.FieldTags:
  9604. return m.Tags()
  9605. case employee.FieldHireCount:
  9606. return m.HireCount()
  9607. case employee.FieldServiceCount:
  9608. return m.ServiceCount()
  9609. case employee.FieldAchievementCount:
  9610. return m.AchievementCount()
  9611. case employee.FieldIntro:
  9612. return m.Intro()
  9613. case employee.FieldEstimate:
  9614. return m.Estimate()
  9615. case employee.FieldSkill:
  9616. return m.Skill()
  9617. case employee.FieldAbilityType:
  9618. return m.AbilityType()
  9619. case employee.FieldScene:
  9620. return m.Scene()
  9621. case employee.FieldSwitchIn:
  9622. return m.SwitchIn()
  9623. case employee.FieldVideoURL:
  9624. return m.VideoURL()
  9625. case employee.FieldOrganizationID:
  9626. return m.OrganizationID()
  9627. case employee.FieldCategoryID:
  9628. return m.CategoryID()
  9629. case employee.FieldAPIBase:
  9630. return m.APIBase()
  9631. case employee.FieldAPIKey:
  9632. return m.APIKey()
  9633. case employee.FieldAiInfo:
  9634. return m.AiInfo()
  9635. case employee.FieldIsVip:
  9636. return m.IsVip()
  9637. }
  9638. return nil, false
  9639. }
  9640. // OldField returns the old value of the field from the database. An error is
  9641. // returned if the mutation operation is not UpdateOne, or the query to the
  9642. // database failed.
  9643. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9644. switch name {
  9645. case employee.FieldCreatedAt:
  9646. return m.OldCreatedAt(ctx)
  9647. case employee.FieldUpdatedAt:
  9648. return m.OldUpdatedAt(ctx)
  9649. case employee.FieldDeletedAt:
  9650. return m.OldDeletedAt(ctx)
  9651. case employee.FieldTitle:
  9652. return m.OldTitle(ctx)
  9653. case employee.FieldAvatar:
  9654. return m.OldAvatar(ctx)
  9655. case employee.FieldTags:
  9656. return m.OldTags(ctx)
  9657. case employee.FieldHireCount:
  9658. return m.OldHireCount(ctx)
  9659. case employee.FieldServiceCount:
  9660. return m.OldServiceCount(ctx)
  9661. case employee.FieldAchievementCount:
  9662. return m.OldAchievementCount(ctx)
  9663. case employee.FieldIntro:
  9664. return m.OldIntro(ctx)
  9665. case employee.FieldEstimate:
  9666. return m.OldEstimate(ctx)
  9667. case employee.FieldSkill:
  9668. return m.OldSkill(ctx)
  9669. case employee.FieldAbilityType:
  9670. return m.OldAbilityType(ctx)
  9671. case employee.FieldScene:
  9672. return m.OldScene(ctx)
  9673. case employee.FieldSwitchIn:
  9674. return m.OldSwitchIn(ctx)
  9675. case employee.FieldVideoURL:
  9676. return m.OldVideoURL(ctx)
  9677. case employee.FieldOrganizationID:
  9678. return m.OldOrganizationID(ctx)
  9679. case employee.FieldCategoryID:
  9680. return m.OldCategoryID(ctx)
  9681. case employee.FieldAPIBase:
  9682. return m.OldAPIBase(ctx)
  9683. case employee.FieldAPIKey:
  9684. return m.OldAPIKey(ctx)
  9685. case employee.FieldAiInfo:
  9686. return m.OldAiInfo(ctx)
  9687. case employee.FieldIsVip:
  9688. return m.OldIsVip(ctx)
  9689. }
  9690. return nil, fmt.Errorf("unknown Employee field %s", name)
  9691. }
  9692. // SetField sets the value of a field with the given name. It returns an error if
  9693. // the field is not defined in the schema, or if the type mismatched the field
  9694. // type.
  9695. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9696. switch name {
  9697. case employee.FieldCreatedAt:
  9698. v, ok := value.(time.Time)
  9699. if !ok {
  9700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9701. }
  9702. m.SetCreatedAt(v)
  9703. return nil
  9704. case employee.FieldUpdatedAt:
  9705. v, ok := value.(time.Time)
  9706. if !ok {
  9707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9708. }
  9709. m.SetUpdatedAt(v)
  9710. return nil
  9711. case employee.FieldDeletedAt:
  9712. v, ok := value.(time.Time)
  9713. if !ok {
  9714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9715. }
  9716. m.SetDeletedAt(v)
  9717. return nil
  9718. case employee.FieldTitle:
  9719. v, ok := value.(string)
  9720. if !ok {
  9721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9722. }
  9723. m.SetTitle(v)
  9724. return nil
  9725. case employee.FieldAvatar:
  9726. v, ok := value.(string)
  9727. if !ok {
  9728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9729. }
  9730. m.SetAvatar(v)
  9731. return nil
  9732. case employee.FieldTags:
  9733. v, ok := value.(string)
  9734. if !ok {
  9735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9736. }
  9737. m.SetTags(v)
  9738. return nil
  9739. case employee.FieldHireCount:
  9740. v, ok := value.(int)
  9741. if !ok {
  9742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9743. }
  9744. m.SetHireCount(v)
  9745. return nil
  9746. case employee.FieldServiceCount:
  9747. v, ok := value.(int)
  9748. if !ok {
  9749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9750. }
  9751. m.SetServiceCount(v)
  9752. return nil
  9753. case employee.FieldAchievementCount:
  9754. v, ok := value.(int)
  9755. if !ok {
  9756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9757. }
  9758. m.SetAchievementCount(v)
  9759. return nil
  9760. case employee.FieldIntro:
  9761. v, ok := value.(string)
  9762. if !ok {
  9763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9764. }
  9765. m.SetIntro(v)
  9766. return nil
  9767. case employee.FieldEstimate:
  9768. v, ok := value.(string)
  9769. if !ok {
  9770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9771. }
  9772. m.SetEstimate(v)
  9773. return nil
  9774. case employee.FieldSkill:
  9775. v, ok := value.(string)
  9776. if !ok {
  9777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9778. }
  9779. m.SetSkill(v)
  9780. return nil
  9781. case employee.FieldAbilityType:
  9782. v, ok := value.(string)
  9783. if !ok {
  9784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9785. }
  9786. m.SetAbilityType(v)
  9787. return nil
  9788. case employee.FieldScene:
  9789. v, ok := value.(string)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetScene(v)
  9794. return nil
  9795. case employee.FieldSwitchIn:
  9796. v, ok := value.(string)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetSwitchIn(v)
  9801. return nil
  9802. case employee.FieldVideoURL:
  9803. v, ok := value.(string)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetVideoURL(v)
  9808. return nil
  9809. case employee.FieldOrganizationID:
  9810. v, ok := value.(uint64)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetOrganizationID(v)
  9815. return nil
  9816. case employee.FieldCategoryID:
  9817. v, ok := value.(uint64)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetCategoryID(v)
  9822. return nil
  9823. case employee.FieldAPIBase:
  9824. v, ok := value.(string)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetAPIBase(v)
  9829. return nil
  9830. case employee.FieldAPIKey:
  9831. v, ok := value.(string)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetAPIKey(v)
  9836. return nil
  9837. case employee.FieldAiInfo:
  9838. v, ok := value.(string)
  9839. if !ok {
  9840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9841. }
  9842. m.SetAiInfo(v)
  9843. return nil
  9844. case employee.FieldIsVip:
  9845. v, ok := value.(int)
  9846. if !ok {
  9847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9848. }
  9849. m.SetIsVip(v)
  9850. return nil
  9851. }
  9852. return fmt.Errorf("unknown Employee field %s", name)
  9853. }
  9854. // AddedFields returns all numeric fields that were incremented/decremented during
  9855. // this mutation.
  9856. func (m *EmployeeMutation) AddedFields() []string {
  9857. var fields []string
  9858. if m.addhire_count != nil {
  9859. fields = append(fields, employee.FieldHireCount)
  9860. }
  9861. if m.addservice_count != nil {
  9862. fields = append(fields, employee.FieldServiceCount)
  9863. }
  9864. if m.addachievement_count != nil {
  9865. fields = append(fields, employee.FieldAchievementCount)
  9866. }
  9867. if m.addorganization_id != nil {
  9868. fields = append(fields, employee.FieldOrganizationID)
  9869. }
  9870. if m.addcategory_id != nil {
  9871. fields = append(fields, employee.FieldCategoryID)
  9872. }
  9873. if m.addis_vip != nil {
  9874. fields = append(fields, employee.FieldIsVip)
  9875. }
  9876. return fields
  9877. }
  9878. // AddedField returns the numeric value that was incremented/decremented on a field
  9879. // with the given name. The second boolean return value indicates that this field
  9880. // was not set, or was not defined in the schema.
  9881. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  9882. switch name {
  9883. case employee.FieldHireCount:
  9884. return m.AddedHireCount()
  9885. case employee.FieldServiceCount:
  9886. return m.AddedServiceCount()
  9887. case employee.FieldAchievementCount:
  9888. return m.AddedAchievementCount()
  9889. case employee.FieldOrganizationID:
  9890. return m.AddedOrganizationID()
  9891. case employee.FieldCategoryID:
  9892. return m.AddedCategoryID()
  9893. case employee.FieldIsVip:
  9894. return m.AddedIsVip()
  9895. }
  9896. return nil, false
  9897. }
  9898. // AddField adds the value to the field with the given name. It returns an error if
  9899. // the field is not defined in the schema, or if the type mismatched the field
  9900. // type.
  9901. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  9902. switch name {
  9903. case employee.FieldHireCount:
  9904. v, ok := value.(int)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.AddHireCount(v)
  9909. return nil
  9910. case employee.FieldServiceCount:
  9911. v, ok := value.(int)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.AddServiceCount(v)
  9916. return nil
  9917. case employee.FieldAchievementCount:
  9918. v, ok := value.(int)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.AddAchievementCount(v)
  9923. return nil
  9924. case employee.FieldOrganizationID:
  9925. v, ok := value.(int64)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.AddOrganizationID(v)
  9930. return nil
  9931. case employee.FieldCategoryID:
  9932. v, ok := value.(int64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.AddCategoryID(v)
  9937. return nil
  9938. case employee.FieldIsVip:
  9939. v, ok := value.(int)
  9940. if !ok {
  9941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9942. }
  9943. m.AddIsVip(v)
  9944. return nil
  9945. }
  9946. return fmt.Errorf("unknown Employee numeric field %s", name)
  9947. }
  9948. // ClearedFields returns all nullable fields that were cleared during this
  9949. // mutation.
  9950. func (m *EmployeeMutation) ClearedFields() []string {
  9951. var fields []string
  9952. if m.FieldCleared(employee.FieldDeletedAt) {
  9953. fields = append(fields, employee.FieldDeletedAt)
  9954. }
  9955. if m.FieldCleared(employee.FieldAiInfo) {
  9956. fields = append(fields, employee.FieldAiInfo)
  9957. }
  9958. return fields
  9959. }
  9960. // FieldCleared returns a boolean indicating if a field with the given name was
  9961. // cleared in this mutation.
  9962. func (m *EmployeeMutation) FieldCleared(name string) bool {
  9963. _, ok := m.clearedFields[name]
  9964. return ok
  9965. }
  9966. // ClearField clears the value of the field with the given name. It returns an
  9967. // error if the field is not defined in the schema.
  9968. func (m *EmployeeMutation) ClearField(name string) error {
  9969. switch name {
  9970. case employee.FieldDeletedAt:
  9971. m.ClearDeletedAt()
  9972. return nil
  9973. case employee.FieldAiInfo:
  9974. m.ClearAiInfo()
  9975. return nil
  9976. }
  9977. return fmt.Errorf("unknown Employee nullable field %s", name)
  9978. }
  9979. // ResetField resets all changes in the mutation for the field with the given name.
  9980. // It returns an error if the field is not defined in the schema.
  9981. func (m *EmployeeMutation) ResetField(name string) error {
  9982. switch name {
  9983. case employee.FieldCreatedAt:
  9984. m.ResetCreatedAt()
  9985. return nil
  9986. case employee.FieldUpdatedAt:
  9987. m.ResetUpdatedAt()
  9988. return nil
  9989. case employee.FieldDeletedAt:
  9990. m.ResetDeletedAt()
  9991. return nil
  9992. case employee.FieldTitle:
  9993. m.ResetTitle()
  9994. return nil
  9995. case employee.FieldAvatar:
  9996. m.ResetAvatar()
  9997. return nil
  9998. case employee.FieldTags:
  9999. m.ResetTags()
  10000. return nil
  10001. case employee.FieldHireCount:
  10002. m.ResetHireCount()
  10003. return nil
  10004. case employee.FieldServiceCount:
  10005. m.ResetServiceCount()
  10006. return nil
  10007. case employee.FieldAchievementCount:
  10008. m.ResetAchievementCount()
  10009. return nil
  10010. case employee.FieldIntro:
  10011. m.ResetIntro()
  10012. return nil
  10013. case employee.FieldEstimate:
  10014. m.ResetEstimate()
  10015. return nil
  10016. case employee.FieldSkill:
  10017. m.ResetSkill()
  10018. return nil
  10019. case employee.FieldAbilityType:
  10020. m.ResetAbilityType()
  10021. return nil
  10022. case employee.FieldScene:
  10023. m.ResetScene()
  10024. return nil
  10025. case employee.FieldSwitchIn:
  10026. m.ResetSwitchIn()
  10027. return nil
  10028. case employee.FieldVideoURL:
  10029. m.ResetVideoURL()
  10030. return nil
  10031. case employee.FieldOrganizationID:
  10032. m.ResetOrganizationID()
  10033. return nil
  10034. case employee.FieldCategoryID:
  10035. m.ResetCategoryID()
  10036. return nil
  10037. case employee.FieldAPIBase:
  10038. m.ResetAPIBase()
  10039. return nil
  10040. case employee.FieldAPIKey:
  10041. m.ResetAPIKey()
  10042. return nil
  10043. case employee.FieldAiInfo:
  10044. m.ResetAiInfo()
  10045. return nil
  10046. case employee.FieldIsVip:
  10047. m.ResetIsVip()
  10048. return nil
  10049. }
  10050. return fmt.Errorf("unknown Employee field %s", name)
  10051. }
  10052. // AddedEdges returns all edge names that were set/added in this mutation.
  10053. func (m *EmployeeMutation) AddedEdges() []string {
  10054. edges := make([]string, 0, 2)
  10055. if m.em_work_experiences != nil {
  10056. edges = append(edges, employee.EdgeEmWorkExperiences)
  10057. }
  10058. if m.em_tutorial != nil {
  10059. edges = append(edges, employee.EdgeEmTutorial)
  10060. }
  10061. return edges
  10062. }
  10063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10064. // name in this mutation.
  10065. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10066. switch name {
  10067. case employee.EdgeEmWorkExperiences:
  10068. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10069. for id := range m.em_work_experiences {
  10070. ids = append(ids, id)
  10071. }
  10072. return ids
  10073. case employee.EdgeEmTutorial:
  10074. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10075. for id := range m.em_tutorial {
  10076. ids = append(ids, id)
  10077. }
  10078. return ids
  10079. }
  10080. return nil
  10081. }
  10082. // RemovedEdges returns all edge names that were removed in this mutation.
  10083. func (m *EmployeeMutation) RemovedEdges() []string {
  10084. edges := make([]string, 0, 2)
  10085. if m.removedem_work_experiences != nil {
  10086. edges = append(edges, employee.EdgeEmWorkExperiences)
  10087. }
  10088. if m.removedem_tutorial != nil {
  10089. edges = append(edges, employee.EdgeEmTutorial)
  10090. }
  10091. return edges
  10092. }
  10093. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10094. // the given name in this mutation.
  10095. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10096. switch name {
  10097. case employee.EdgeEmWorkExperiences:
  10098. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10099. for id := range m.removedem_work_experiences {
  10100. ids = append(ids, id)
  10101. }
  10102. return ids
  10103. case employee.EdgeEmTutorial:
  10104. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10105. for id := range m.removedem_tutorial {
  10106. ids = append(ids, id)
  10107. }
  10108. return ids
  10109. }
  10110. return nil
  10111. }
  10112. // ClearedEdges returns all edge names that were cleared in this mutation.
  10113. func (m *EmployeeMutation) ClearedEdges() []string {
  10114. edges := make([]string, 0, 2)
  10115. if m.clearedem_work_experiences {
  10116. edges = append(edges, employee.EdgeEmWorkExperiences)
  10117. }
  10118. if m.clearedem_tutorial {
  10119. edges = append(edges, employee.EdgeEmTutorial)
  10120. }
  10121. return edges
  10122. }
  10123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10124. // was cleared in this mutation.
  10125. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10126. switch name {
  10127. case employee.EdgeEmWorkExperiences:
  10128. return m.clearedem_work_experiences
  10129. case employee.EdgeEmTutorial:
  10130. return m.clearedem_tutorial
  10131. }
  10132. return false
  10133. }
  10134. // ClearEdge clears the value of the edge with the given name. It returns an error
  10135. // if that edge is not defined in the schema.
  10136. func (m *EmployeeMutation) ClearEdge(name string) error {
  10137. switch name {
  10138. }
  10139. return fmt.Errorf("unknown Employee unique edge %s", name)
  10140. }
  10141. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10142. // It returns an error if the edge is not defined in the schema.
  10143. func (m *EmployeeMutation) ResetEdge(name string) error {
  10144. switch name {
  10145. case employee.EdgeEmWorkExperiences:
  10146. m.ResetEmWorkExperiences()
  10147. return nil
  10148. case employee.EdgeEmTutorial:
  10149. m.ResetEmTutorial()
  10150. return nil
  10151. }
  10152. return fmt.Errorf("unknown Employee edge %s", name)
  10153. }
  10154. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10155. type EmployeeConfigMutation struct {
  10156. config
  10157. op Op
  10158. typ string
  10159. id *uint64
  10160. created_at *time.Time
  10161. updated_at *time.Time
  10162. deleted_at *time.Time
  10163. stype *string
  10164. title *string
  10165. photo *string
  10166. organization_id *uint64
  10167. addorganization_id *int64
  10168. clearedFields map[string]struct{}
  10169. done bool
  10170. oldValue func(context.Context) (*EmployeeConfig, error)
  10171. predicates []predicate.EmployeeConfig
  10172. }
  10173. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10174. // employeeconfigOption allows management of the mutation configuration using functional options.
  10175. type employeeconfigOption func(*EmployeeConfigMutation)
  10176. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10177. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10178. m := &EmployeeConfigMutation{
  10179. config: c,
  10180. op: op,
  10181. typ: TypeEmployeeConfig,
  10182. clearedFields: make(map[string]struct{}),
  10183. }
  10184. for _, opt := range opts {
  10185. opt(m)
  10186. }
  10187. return m
  10188. }
  10189. // withEmployeeConfigID sets the ID field of the mutation.
  10190. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10191. return func(m *EmployeeConfigMutation) {
  10192. var (
  10193. err error
  10194. once sync.Once
  10195. value *EmployeeConfig
  10196. )
  10197. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10198. once.Do(func() {
  10199. if m.done {
  10200. err = errors.New("querying old values post mutation is not allowed")
  10201. } else {
  10202. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10203. }
  10204. })
  10205. return value, err
  10206. }
  10207. m.id = &id
  10208. }
  10209. }
  10210. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10211. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10212. return func(m *EmployeeConfigMutation) {
  10213. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10214. return node, nil
  10215. }
  10216. m.id = &node.ID
  10217. }
  10218. }
  10219. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10220. // executed in a transaction (ent.Tx), a transactional client is returned.
  10221. func (m EmployeeConfigMutation) Client() *Client {
  10222. client := &Client{config: m.config}
  10223. client.init()
  10224. return client
  10225. }
  10226. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10227. // it returns an error otherwise.
  10228. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10229. if _, ok := m.driver.(*txDriver); !ok {
  10230. return nil, errors.New("ent: mutation is not running in a transaction")
  10231. }
  10232. tx := &Tx{config: m.config}
  10233. tx.init()
  10234. return tx, nil
  10235. }
  10236. // SetID sets the value of the id field. Note that this
  10237. // operation is only accepted on creation of EmployeeConfig entities.
  10238. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10239. m.id = &id
  10240. }
  10241. // ID returns the ID value in the mutation. Note that the ID is only available
  10242. // if it was provided to the builder or after it was returned from the database.
  10243. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10244. if m.id == nil {
  10245. return
  10246. }
  10247. return *m.id, true
  10248. }
  10249. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10250. // That means, if the mutation is applied within a transaction with an isolation level such
  10251. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10252. // or updated by the mutation.
  10253. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10254. switch {
  10255. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10256. id, exists := m.ID()
  10257. if exists {
  10258. return []uint64{id}, nil
  10259. }
  10260. fallthrough
  10261. case m.op.Is(OpUpdate | OpDelete):
  10262. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10263. default:
  10264. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10265. }
  10266. }
  10267. // SetCreatedAt sets the "created_at" field.
  10268. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10269. m.created_at = &t
  10270. }
  10271. // CreatedAt returns the value of the "created_at" field in the mutation.
  10272. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10273. v := m.created_at
  10274. if v == nil {
  10275. return
  10276. }
  10277. return *v, true
  10278. }
  10279. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10280. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10282. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10283. if !m.op.Is(OpUpdateOne) {
  10284. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10285. }
  10286. if m.id == nil || m.oldValue == nil {
  10287. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10288. }
  10289. oldValue, err := m.oldValue(ctx)
  10290. if err != nil {
  10291. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10292. }
  10293. return oldValue.CreatedAt, nil
  10294. }
  10295. // ResetCreatedAt resets all changes to the "created_at" field.
  10296. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10297. m.created_at = nil
  10298. }
  10299. // SetUpdatedAt sets the "updated_at" field.
  10300. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10301. m.updated_at = &t
  10302. }
  10303. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10304. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10305. v := m.updated_at
  10306. if v == nil {
  10307. return
  10308. }
  10309. return *v, true
  10310. }
  10311. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10312. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10314. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10315. if !m.op.Is(OpUpdateOne) {
  10316. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10317. }
  10318. if m.id == nil || m.oldValue == nil {
  10319. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10320. }
  10321. oldValue, err := m.oldValue(ctx)
  10322. if err != nil {
  10323. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10324. }
  10325. return oldValue.UpdatedAt, nil
  10326. }
  10327. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10328. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10329. m.updated_at = nil
  10330. }
  10331. // SetDeletedAt sets the "deleted_at" field.
  10332. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10333. m.deleted_at = &t
  10334. }
  10335. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10336. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10337. v := m.deleted_at
  10338. if v == nil {
  10339. return
  10340. }
  10341. return *v, true
  10342. }
  10343. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10344. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10346. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10347. if !m.op.Is(OpUpdateOne) {
  10348. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10349. }
  10350. if m.id == nil || m.oldValue == nil {
  10351. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10352. }
  10353. oldValue, err := m.oldValue(ctx)
  10354. if err != nil {
  10355. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10356. }
  10357. return oldValue.DeletedAt, nil
  10358. }
  10359. // ClearDeletedAt clears the value of the "deleted_at" field.
  10360. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10361. m.deleted_at = nil
  10362. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10363. }
  10364. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10365. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10366. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10367. return ok
  10368. }
  10369. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10370. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10371. m.deleted_at = nil
  10372. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10373. }
  10374. // SetStype sets the "stype" field.
  10375. func (m *EmployeeConfigMutation) SetStype(s string) {
  10376. m.stype = &s
  10377. }
  10378. // Stype returns the value of the "stype" field in the mutation.
  10379. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10380. v := m.stype
  10381. if v == nil {
  10382. return
  10383. }
  10384. return *v, true
  10385. }
  10386. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10387. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10389. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10390. if !m.op.Is(OpUpdateOne) {
  10391. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10392. }
  10393. if m.id == nil || m.oldValue == nil {
  10394. return v, errors.New("OldStype requires an ID field in the mutation")
  10395. }
  10396. oldValue, err := m.oldValue(ctx)
  10397. if err != nil {
  10398. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10399. }
  10400. return oldValue.Stype, nil
  10401. }
  10402. // ResetStype resets all changes to the "stype" field.
  10403. func (m *EmployeeConfigMutation) ResetStype() {
  10404. m.stype = nil
  10405. }
  10406. // SetTitle sets the "title" field.
  10407. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10408. m.title = &s
  10409. }
  10410. // Title returns the value of the "title" field in the mutation.
  10411. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10412. v := m.title
  10413. if v == nil {
  10414. return
  10415. }
  10416. return *v, true
  10417. }
  10418. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10419. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10421. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10422. if !m.op.Is(OpUpdateOne) {
  10423. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10424. }
  10425. if m.id == nil || m.oldValue == nil {
  10426. return v, errors.New("OldTitle requires an ID field in the mutation")
  10427. }
  10428. oldValue, err := m.oldValue(ctx)
  10429. if err != nil {
  10430. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10431. }
  10432. return oldValue.Title, nil
  10433. }
  10434. // ResetTitle resets all changes to the "title" field.
  10435. func (m *EmployeeConfigMutation) ResetTitle() {
  10436. m.title = nil
  10437. }
  10438. // SetPhoto sets the "photo" field.
  10439. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10440. m.photo = &s
  10441. }
  10442. // Photo returns the value of the "photo" field in the mutation.
  10443. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10444. v := m.photo
  10445. if v == nil {
  10446. return
  10447. }
  10448. return *v, true
  10449. }
  10450. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10451. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10453. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10454. if !m.op.Is(OpUpdateOne) {
  10455. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10456. }
  10457. if m.id == nil || m.oldValue == nil {
  10458. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10459. }
  10460. oldValue, err := m.oldValue(ctx)
  10461. if err != nil {
  10462. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10463. }
  10464. return oldValue.Photo, nil
  10465. }
  10466. // ResetPhoto resets all changes to the "photo" field.
  10467. func (m *EmployeeConfigMutation) ResetPhoto() {
  10468. m.photo = nil
  10469. }
  10470. // SetOrganizationID sets the "organization_id" field.
  10471. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10472. m.organization_id = &u
  10473. m.addorganization_id = nil
  10474. }
  10475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10476. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10477. v := m.organization_id
  10478. if v == nil {
  10479. return
  10480. }
  10481. return *v, true
  10482. }
  10483. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10484. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10486. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10487. if !m.op.Is(OpUpdateOne) {
  10488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10489. }
  10490. if m.id == nil || m.oldValue == nil {
  10491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10492. }
  10493. oldValue, err := m.oldValue(ctx)
  10494. if err != nil {
  10495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10496. }
  10497. return oldValue.OrganizationID, nil
  10498. }
  10499. // AddOrganizationID adds u to the "organization_id" field.
  10500. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10501. if m.addorganization_id != nil {
  10502. *m.addorganization_id += u
  10503. } else {
  10504. m.addorganization_id = &u
  10505. }
  10506. }
  10507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10508. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10509. v := m.addorganization_id
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // ClearOrganizationID clears the value of the "organization_id" field.
  10516. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10517. m.organization_id = nil
  10518. m.addorganization_id = nil
  10519. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10520. }
  10521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10522. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10523. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10524. return ok
  10525. }
  10526. // ResetOrganizationID resets all changes to the "organization_id" field.
  10527. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10528. m.organization_id = nil
  10529. m.addorganization_id = nil
  10530. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10531. }
  10532. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10533. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10534. m.predicates = append(m.predicates, ps...)
  10535. }
  10536. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10537. // users can use type-assertion to append predicates that do not depend on any generated package.
  10538. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10539. p := make([]predicate.EmployeeConfig, len(ps))
  10540. for i := range ps {
  10541. p[i] = ps[i]
  10542. }
  10543. m.Where(p...)
  10544. }
  10545. // Op returns the operation name.
  10546. func (m *EmployeeConfigMutation) Op() Op {
  10547. return m.op
  10548. }
  10549. // SetOp allows setting the mutation operation.
  10550. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10551. m.op = op
  10552. }
  10553. // Type returns the node type of this mutation (EmployeeConfig).
  10554. func (m *EmployeeConfigMutation) Type() string {
  10555. return m.typ
  10556. }
  10557. // Fields returns all fields that were changed during this mutation. Note that in
  10558. // order to get all numeric fields that were incremented/decremented, call
  10559. // AddedFields().
  10560. func (m *EmployeeConfigMutation) Fields() []string {
  10561. fields := make([]string, 0, 7)
  10562. if m.created_at != nil {
  10563. fields = append(fields, employeeconfig.FieldCreatedAt)
  10564. }
  10565. if m.updated_at != nil {
  10566. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10567. }
  10568. if m.deleted_at != nil {
  10569. fields = append(fields, employeeconfig.FieldDeletedAt)
  10570. }
  10571. if m.stype != nil {
  10572. fields = append(fields, employeeconfig.FieldStype)
  10573. }
  10574. if m.title != nil {
  10575. fields = append(fields, employeeconfig.FieldTitle)
  10576. }
  10577. if m.photo != nil {
  10578. fields = append(fields, employeeconfig.FieldPhoto)
  10579. }
  10580. if m.organization_id != nil {
  10581. fields = append(fields, employeeconfig.FieldOrganizationID)
  10582. }
  10583. return fields
  10584. }
  10585. // Field returns the value of a field with the given name. The second boolean
  10586. // return value indicates that this field was not set, or was not defined in the
  10587. // schema.
  10588. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10589. switch name {
  10590. case employeeconfig.FieldCreatedAt:
  10591. return m.CreatedAt()
  10592. case employeeconfig.FieldUpdatedAt:
  10593. return m.UpdatedAt()
  10594. case employeeconfig.FieldDeletedAt:
  10595. return m.DeletedAt()
  10596. case employeeconfig.FieldStype:
  10597. return m.Stype()
  10598. case employeeconfig.FieldTitle:
  10599. return m.Title()
  10600. case employeeconfig.FieldPhoto:
  10601. return m.Photo()
  10602. case employeeconfig.FieldOrganizationID:
  10603. return m.OrganizationID()
  10604. }
  10605. return nil, false
  10606. }
  10607. // OldField returns the old value of the field from the database. An error is
  10608. // returned if the mutation operation is not UpdateOne, or the query to the
  10609. // database failed.
  10610. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10611. switch name {
  10612. case employeeconfig.FieldCreatedAt:
  10613. return m.OldCreatedAt(ctx)
  10614. case employeeconfig.FieldUpdatedAt:
  10615. return m.OldUpdatedAt(ctx)
  10616. case employeeconfig.FieldDeletedAt:
  10617. return m.OldDeletedAt(ctx)
  10618. case employeeconfig.FieldStype:
  10619. return m.OldStype(ctx)
  10620. case employeeconfig.FieldTitle:
  10621. return m.OldTitle(ctx)
  10622. case employeeconfig.FieldPhoto:
  10623. return m.OldPhoto(ctx)
  10624. case employeeconfig.FieldOrganizationID:
  10625. return m.OldOrganizationID(ctx)
  10626. }
  10627. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10628. }
  10629. // SetField sets the value of a field with the given name. It returns an error if
  10630. // the field is not defined in the schema, or if the type mismatched the field
  10631. // type.
  10632. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10633. switch name {
  10634. case employeeconfig.FieldCreatedAt:
  10635. v, ok := value.(time.Time)
  10636. if !ok {
  10637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10638. }
  10639. m.SetCreatedAt(v)
  10640. return nil
  10641. case employeeconfig.FieldUpdatedAt:
  10642. v, ok := value.(time.Time)
  10643. if !ok {
  10644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10645. }
  10646. m.SetUpdatedAt(v)
  10647. return nil
  10648. case employeeconfig.FieldDeletedAt:
  10649. v, ok := value.(time.Time)
  10650. if !ok {
  10651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10652. }
  10653. m.SetDeletedAt(v)
  10654. return nil
  10655. case employeeconfig.FieldStype:
  10656. v, ok := value.(string)
  10657. if !ok {
  10658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10659. }
  10660. m.SetStype(v)
  10661. return nil
  10662. case employeeconfig.FieldTitle:
  10663. v, ok := value.(string)
  10664. if !ok {
  10665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10666. }
  10667. m.SetTitle(v)
  10668. return nil
  10669. case employeeconfig.FieldPhoto:
  10670. v, ok := value.(string)
  10671. if !ok {
  10672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10673. }
  10674. m.SetPhoto(v)
  10675. return nil
  10676. case employeeconfig.FieldOrganizationID:
  10677. v, ok := value.(uint64)
  10678. if !ok {
  10679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10680. }
  10681. m.SetOrganizationID(v)
  10682. return nil
  10683. }
  10684. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10685. }
  10686. // AddedFields returns all numeric fields that were incremented/decremented during
  10687. // this mutation.
  10688. func (m *EmployeeConfigMutation) AddedFields() []string {
  10689. var fields []string
  10690. if m.addorganization_id != nil {
  10691. fields = append(fields, employeeconfig.FieldOrganizationID)
  10692. }
  10693. return fields
  10694. }
  10695. // AddedField returns the numeric value that was incremented/decremented on a field
  10696. // with the given name. The second boolean return value indicates that this field
  10697. // was not set, or was not defined in the schema.
  10698. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10699. switch name {
  10700. case employeeconfig.FieldOrganizationID:
  10701. return m.AddedOrganizationID()
  10702. }
  10703. return nil, false
  10704. }
  10705. // AddField adds the value to the 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) AddField(name string, value ent.Value) error {
  10709. switch name {
  10710. case employeeconfig.FieldOrganizationID:
  10711. v, ok := value.(int64)
  10712. if !ok {
  10713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10714. }
  10715. m.AddOrganizationID(v)
  10716. return nil
  10717. }
  10718. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10719. }
  10720. // ClearedFields returns all nullable fields that were cleared during this
  10721. // mutation.
  10722. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10723. var fields []string
  10724. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10725. fields = append(fields, employeeconfig.FieldDeletedAt)
  10726. }
  10727. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10728. fields = append(fields, employeeconfig.FieldOrganizationID)
  10729. }
  10730. return fields
  10731. }
  10732. // FieldCleared returns a boolean indicating if a field with the given name was
  10733. // cleared in this mutation.
  10734. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10735. _, ok := m.clearedFields[name]
  10736. return ok
  10737. }
  10738. // ClearField clears the value of the field with the given name. It returns an
  10739. // error if the field is not defined in the schema.
  10740. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10741. switch name {
  10742. case employeeconfig.FieldDeletedAt:
  10743. m.ClearDeletedAt()
  10744. return nil
  10745. case employeeconfig.FieldOrganizationID:
  10746. m.ClearOrganizationID()
  10747. return nil
  10748. }
  10749. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10750. }
  10751. // ResetField resets all changes in the mutation for the field with the given name.
  10752. // It returns an error if the field is not defined in the schema.
  10753. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10754. switch name {
  10755. case employeeconfig.FieldCreatedAt:
  10756. m.ResetCreatedAt()
  10757. return nil
  10758. case employeeconfig.FieldUpdatedAt:
  10759. m.ResetUpdatedAt()
  10760. return nil
  10761. case employeeconfig.FieldDeletedAt:
  10762. m.ResetDeletedAt()
  10763. return nil
  10764. case employeeconfig.FieldStype:
  10765. m.ResetStype()
  10766. return nil
  10767. case employeeconfig.FieldTitle:
  10768. m.ResetTitle()
  10769. return nil
  10770. case employeeconfig.FieldPhoto:
  10771. m.ResetPhoto()
  10772. return nil
  10773. case employeeconfig.FieldOrganizationID:
  10774. m.ResetOrganizationID()
  10775. return nil
  10776. }
  10777. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10778. }
  10779. // AddedEdges returns all edge names that were set/added in this mutation.
  10780. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10781. edges := make([]string, 0, 0)
  10782. return edges
  10783. }
  10784. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10785. // name in this mutation.
  10786. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10787. return nil
  10788. }
  10789. // RemovedEdges returns all edge names that were removed in this mutation.
  10790. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10791. edges := make([]string, 0, 0)
  10792. return edges
  10793. }
  10794. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10795. // the given name in this mutation.
  10796. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10797. return nil
  10798. }
  10799. // ClearedEdges returns all edge names that were cleared in this mutation.
  10800. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10801. edges := make([]string, 0, 0)
  10802. return edges
  10803. }
  10804. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10805. // was cleared in this mutation.
  10806. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10807. return false
  10808. }
  10809. // ClearEdge clears the value of the edge with the given name. It returns an error
  10810. // if that edge is not defined in the schema.
  10811. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10812. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10813. }
  10814. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10815. // It returns an error if the edge is not defined in the schema.
  10816. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10817. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10818. }
  10819. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10820. type LabelMutation struct {
  10821. config
  10822. op Op
  10823. typ string
  10824. id *uint64
  10825. created_at *time.Time
  10826. updated_at *time.Time
  10827. status *uint8
  10828. addstatus *int8
  10829. _type *int
  10830. add_type *int
  10831. name *string
  10832. from *int
  10833. addfrom *int
  10834. mode *int
  10835. addmode *int
  10836. conditions *string
  10837. organization_id *uint64
  10838. addorganization_id *int64
  10839. clearedFields map[string]struct{}
  10840. label_relationships map[uint64]struct{}
  10841. removedlabel_relationships map[uint64]struct{}
  10842. clearedlabel_relationships bool
  10843. done bool
  10844. oldValue func(context.Context) (*Label, error)
  10845. predicates []predicate.Label
  10846. }
  10847. var _ ent.Mutation = (*LabelMutation)(nil)
  10848. // labelOption allows management of the mutation configuration using functional options.
  10849. type labelOption func(*LabelMutation)
  10850. // newLabelMutation creates new mutation for the Label entity.
  10851. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10852. m := &LabelMutation{
  10853. config: c,
  10854. op: op,
  10855. typ: TypeLabel,
  10856. clearedFields: make(map[string]struct{}),
  10857. }
  10858. for _, opt := range opts {
  10859. opt(m)
  10860. }
  10861. return m
  10862. }
  10863. // withLabelID sets the ID field of the mutation.
  10864. func withLabelID(id uint64) labelOption {
  10865. return func(m *LabelMutation) {
  10866. var (
  10867. err error
  10868. once sync.Once
  10869. value *Label
  10870. )
  10871. m.oldValue = func(ctx context.Context) (*Label, error) {
  10872. once.Do(func() {
  10873. if m.done {
  10874. err = errors.New("querying old values post mutation is not allowed")
  10875. } else {
  10876. value, err = m.Client().Label.Get(ctx, id)
  10877. }
  10878. })
  10879. return value, err
  10880. }
  10881. m.id = &id
  10882. }
  10883. }
  10884. // withLabel sets the old Label of the mutation.
  10885. func withLabel(node *Label) labelOption {
  10886. return func(m *LabelMutation) {
  10887. m.oldValue = func(context.Context) (*Label, error) {
  10888. return node, nil
  10889. }
  10890. m.id = &node.ID
  10891. }
  10892. }
  10893. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10894. // executed in a transaction (ent.Tx), a transactional client is returned.
  10895. func (m LabelMutation) Client() *Client {
  10896. client := &Client{config: m.config}
  10897. client.init()
  10898. return client
  10899. }
  10900. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10901. // it returns an error otherwise.
  10902. func (m LabelMutation) Tx() (*Tx, error) {
  10903. if _, ok := m.driver.(*txDriver); !ok {
  10904. return nil, errors.New("ent: mutation is not running in a transaction")
  10905. }
  10906. tx := &Tx{config: m.config}
  10907. tx.init()
  10908. return tx, nil
  10909. }
  10910. // SetID sets the value of the id field. Note that this
  10911. // operation is only accepted on creation of Label entities.
  10912. func (m *LabelMutation) SetID(id uint64) {
  10913. m.id = &id
  10914. }
  10915. // ID returns the ID value in the mutation. Note that the ID is only available
  10916. // if it was provided to the builder or after it was returned from the database.
  10917. func (m *LabelMutation) ID() (id uint64, exists bool) {
  10918. if m.id == nil {
  10919. return
  10920. }
  10921. return *m.id, true
  10922. }
  10923. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10924. // That means, if the mutation is applied within a transaction with an isolation level such
  10925. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10926. // or updated by the mutation.
  10927. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  10928. switch {
  10929. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10930. id, exists := m.ID()
  10931. if exists {
  10932. return []uint64{id}, nil
  10933. }
  10934. fallthrough
  10935. case m.op.Is(OpUpdate | OpDelete):
  10936. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  10937. default:
  10938. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10939. }
  10940. }
  10941. // SetCreatedAt sets the "created_at" field.
  10942. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  10943. m.created_at = &t
  10944. }
  10945. // CreatedAt returns the value of the "created_at" field in the mutation.
  10946. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  10947. v := m.created_at
  10948. if v == nil {
  10949. return
  10950. }
  10951. return *v, true
  10952. }
  10953. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  10954. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10956. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10957. if !m.op.Is(OpUpdateOne) {
  10958. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10959. }
  10960. if m.id == nil || m.oldValue == nil {
  10961. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10962. }
  10963. oldValue, err := m.oldValue(ctx)
  10964. if err != nil {
  10965. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10966. }
  10967. return oldValue.CreatedAt, nil
  10968. }
  10969. // ResetCreatedAt resets all changes to the "created_at" field.
  10970. func (m *LabelMutation) ResetCreatedAt() {
  10971. m.created_at = nil
  10972. }
  10973. // SetUpdatedAt sets the "updated_at" field.
  10974. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  10975. m.updated_at = &t
  10976. }
  10977. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10978. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  10979. v := m.updated_at
  10980. if v == nil {
  10981. return
  10982. }
  10983. return *v, true
  10984. }
  10985. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  10986. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10988. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10989. if !m.op.Is(OpUpdateOne) {
  10990. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10991. }
  10992. if m.id == nil || m.oldValue == nil {
  10993. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10994. }
  10995. oldValue, err := m.oldValue(ctx)
  10996. if err != nil {
  10997. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10998. }
  10999. return oldValue.UpdatedAt, nil
  11000. }
  11001. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11002. func (m *LabelMutation) ResetUpdatedAt() {
  11003. m.updated_at = nil
  11004. }
  11005. // SetStatus sets the "status" field.
  11006. func (m *LabelMutation) SetStatus(u uint8) {
  11007. m.status = &u
  11008. m.addstatus = nil
  11009. }
  11010. // Status returns the value of the "status" field in the mutation.
  11011. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11012. v := m.status
  11013. if v == nil {
  11014. return
  11015. }
  11016. return *v, true
  11017. }
  11018. // OldStatus returns the old "status" field's value of the Label entity.
  11019. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11021. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11022. if !m.op.Is(OpUpdateOne) {
  11023. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11024. }
  11025. if m.id == nil || m.oldValue == nil {
  11026. return v, errors.New("OldStatus requires an ID field in the mutation")
  11027. }
  11028. oldValue, err := m.oldValue(ctx)
  11029. if err != nil {
  11030. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11031. }
  11032. return oldValue.Status, nil
  11033. }
  11034. // AddStatus adds u to the "status" field.
  11035. func (m *LabelMutation) AddStatus(u int8) {
  11036. if m.addstatus != nil {
  11037. *m.addstatus += u
  11038. } else {
  11039. m.addstatus = &u
  11040. }
  11041. }
  11042. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11043. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11044. v := m.addstatus
  11045. if v == nil {
  11046. return
  11047. }
  11048. return *v, true
  11049. }
  11050. // ClearStatus clears the value of the "status" field.
  11051. func (m *LabelMutation) ClearStatus() {
  11052. m.status = nil
  11053. m.addstatus = nil
  11054. m.clearedFields[label.FieldStatus] = struct{}{}
  11055. }
  11056. // StatusCleared returns if the "status" field was cleared in this mutation.
  11057. func (m *LabelMutation) StatusCleared() bool {
  11058. _, ok := m.clearedFields[label.FieldStatus]
  11059. return ok
  11060. }
  11061. // ResetStatus resets all changes to the "status" field.
  11062. func (m *LabelMutation) ResetStatus() {
  11063. m.status = nil
  11064. m.addstatus = nil
  11065. delete(m.clearedFields, label.FieldStatus)
  11066. }
  11067. // SetType sets the "type" field.
  11068. func (m *LabelMutation) SetType(i int) {
  11069. m._type = &i
  11070. m.add_type = nil
  11071. }
  11072. // GetType returns the value of the "type" field in the mutation.
  11073. func (m *LabelMutation) GetType() (r int, exists bool) {
  11074. v := m._type
  11075. if v == nil {
  11076. return
  11077. }
  11078. return *v, true
  11079. }
  11080. // OldType returns the old "type" field's value of the Label entity.
  11081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11083. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11084. if !m.op.Is(OpUpdateOne) {
  11085. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11086. }
  11087. if m.id == nil || m.oldValue == nil {
  11088. return v, errors.New("OldType requires an ID field in the mutation")
  11089. }
  11090. oldValue, err := m.oldValue(ctx)
  11091. if err != nil {
  11092. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11093. }
  11094. return oldValue.Type, nil
  11095. }
  11096. // AddType adds i to the "type" field.
  11097. func (m *LabelMutation) AddType(i int) {
  11098. if m.add_type != nil {
  11099. *m.add_type += i
  11100. } else {
  11101. m.add_type = &i
  11102. }
  11103. }
  11104. // AddedType returns the value that was added to the "type" field in this mutation.
  11105. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11106. v := m.add_type
  11107. if v == nil {
  11108. return
  11109. }
  11110. return *v, true
  11111. }
  11112. // ResetType resets all changes to the "type" field.
  11113. func (m *LabelMutation) ResetType() {
  11114. m._type = nil
  11115. m.add_type = nil
  11116. }
  11117. // SetName sets the "name" field.
  11118. func (m *LabelMutation) SetName(s string) {
  11119. m.name = &s
  11120. }
  11121. // Name returns the value of the "name" field in the mutation.
  11122. func (m *LabelMutation) Name() (r string, exists bool) {
  11123. v := m.name
  11124. if v == nil {
  11125. return
  11126. }
  11127. return *v, true
  11128. }
  11129. // OldName returns the old "name" field's value of the Label entity.
  11130. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11132. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11133. if !m.op.Is(OpUpdateOne) {
  11134. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11135. }
  11136. if m.id == nil || m.oldValue == nil {
  11137. return v, errors.New("OldName requires an ID field in the mutation")
  11138. }
  11139. oldValue, err := m.oldValue(ctx)
  11140. if err != nil {
  11141. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11142. }
  11143. return oldValue.Name, nil
  11144. }
  11145. // ResetName resets all changes to the "name" field.
  11146. func (m *LabelMutation) ResetName() {
  11147. m.name = nil
  11148. }
  11149. // SetFrom sets the "from" field.
  11150. func (m *LabelMutation) SetFrom(i int) {
  11151. m.from = &i
  11152. m.addfrom = nil
  11153. }
  11154. // From returns the value of the "from" field in the mutation.
  11155. func (m *LabelMutation) From() (r int, exists bool) {
  11156. v := m.from
  11157. if v == nil {
  11158. return
  11159. }
  11160. return *v, true
  11161. }
  11162. // OldFrom returns the old "from" field's value of the Label entity.
  11163. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11165. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11166. if !m.op.Is(OpUpdateOne) {
  11167. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11168. }
  11169. if m.id == nil || m.oldValue == nil {
  11170. return v, errors.New("OldFrom requires an ID field in the mutation")
  11171. }
  11172. oldValue, err := m.oldValue(ctx)
  11173. if err != nil {
  11174. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11175. }
  11176. return oldValue.From, nil
  11177. }
  11178. // AddFrom adds i to the "from" field.
  11179. func (m *LabelMutation) AddFrom(i int) {
  11180. if m.addfrom != nil {
  11181. *m.addfrom += i
  11182. } else {
  11183. m.addfrom = &i
  11184. }
  11185. }
  11186. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11187. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11188. v := m.addfrom
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // ResetFrom resets all changes to the "from" field.
  11195. func (m *LabelMutation) ResetFrom() {
  11196. m.from = nil
  11197. m.addfrom = nil
  11198. }
  11199. // SetMode sets the "mode" field.
  11200. func (m *LabelMutation) SetMode(i int) {
  11201. m.mode = &i
  11202. m.addmode = nil
  11203. }
  11204. // Mode returns the value of the "mode" field in the mutation.
  11205. func (m *LabelMutation) Mode() (r int, exists bool) {
  11206. v := m.mode
  11207. if v == nil {
  11208. return
  11209. }
  11210. return *v, true
  11211. }
  11212. // OldMode returns the old "mode" field's value of the Label entity.
  11213. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11215. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11216. if !m.op.Is(OpUpdateOne) {
  11217. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11218. }
  11219. if m.id == nil || m.oldValue == nil {
  11220. return v, errors.New("OldMode requires an ID field in the mutation")
  11221. }
  11222. oldValue, err := m.oldValue(ctx)
  11223. if err != nil {
  11224. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11225. }
  11226. return oldValue.Mode, nil
  11227. }
  11228. // AddMode adds i to the "mode" field.
  11229. func (m *LabelMutation) AddMode(i int) {
  11230. if m.addmode != nil {
  11231. *m.addmode += i
  11232. } else {
  11233. m.addmode = &i
  11234. }
  11235. }
  11236. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11237. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11238. v := m.addmode
  11239. if v == nil {
  11240. return
  11241. }
  11242. return *v, true
  11243. }
  11244. // ResetMode resets all changes to the "mode" field.
  11245. func (m *LabelMutation) ResetMode() {
  11246. m.mode = nil
  11247. m.addmode = nil
  11248. }
  11249. // SetConditions sets the "conditions" field.
  11250. func (m *LabelMutation) SetConditions(s string) {
  11251. m.conditions = &s
  11252. }
  11253. // Conditions returns the value of the "conditions" field in the mutation.
  11254. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11255. v := m.conditions
  11256. if v == nil {
  11257. return
  11258. }
  11259. return *v, true
  11260. }
  11261. // OldConditions returns the old "conditions" field's value of the Label entity.
  11262. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11264. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11265. if !m.op.Is(OpUpdateOne) {
  11266. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11267. }
  11268. if m.id == nil || m.oldValue == nil {
  11269. return v, errors.New("OldConditions requires an ID field in the mutation")
  11270. }
  11271. oldValue, err := m.oldValue(ctx)
  11272. if err != nil {
  11273. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11274. }
  11275. return oldValue.Conditions, nil
  11276. }
  11277. // ClearConditions clears the value of the "conditions" field.
  11278. func (m *LabelMutation) ClearConditions() {
  11279. m.conditions = nil
  11280. m.clearedFields[label.FieldConditions] = struct{}{}
  11281. }
  11282. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11283. func (m *LabelMutation) ConditionsCleared() bool {
  11284. _, ok := m.clearedFields[label.FieldConditions]
  11285. return ok
  11286. }
  11287. // ResetConditions resets all changes to the "conditions" field.
  11288. func (m *LabelMutation) ResetConditions() {
  11289. m.conditions = nil
  11290. delete(m.clearedFields, label.FieldConditions)
  11291. }
  11292. // SetOrganizationID sets the "organization_id" field.
  11293. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11294. m.organization_id = &u
  11295. m.addorganization_id = nil
  11296. }
  11297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11298. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11299. v := m.organization_id
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11306. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11318. }
  11319. return oldValue.OrganizationID, nil
  11320. }
  11321. // AddOrganizationID adds u to the "organization_id" field.
  11322. func (m *LabelMutation) AddOrganizationID(u int64) {
  11323. if m.addorganization_id != nil {
  11324. *m.addorganization_id += u
  11325. } else {
  11326. m.addorganization_id = &u
  11327. }
  11328. }
  11329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11330. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11331. v := m.addorganization_id
  11332. if v == nil {
  11333. return
  11334. }
  11335. return *v, true
  11336. }
  11337. // ClearOrganizationID clears the value of the "organization_id" field.
  11338. func (m *LabelMutation) ClearOrganizationID() {
  11339. m.organization_id = nil
  11340. m.addorganization_id = nil
  11341. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11342. }
  11343. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11344. func (m *LabelMutation) OrganizationIDCleared() bool {
  11345. _, ok := m.clearedFields[label.FieldOrganizationID]
  11346. return ok
  11347. }
  11348. // ResetOrganizationID resets all changes to the "organization_id" field.
  11349. func (m *LabelMutation) ResetOrganizationID() {
  11350. m.organization_id = nil
  11351. m.addorganization_id = nil
  11352. delete(m.clearedFields, label.FieldOrganizationID)
  11353. }
  11354. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11355. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11356. if m.label_relationships == nil {
  11357. m.label_relationships = make(map[uint64]struct{})
  11358. }
  11359. for i := range ids {
  11360. m.label_relationships[ids[i]] = struct{}{}
  11361. }
  11362. }
  11363. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11364. func (m *LabelMutation) ClearLabelRelationships() {
  11365. m.clearedlabel_relationships = true
  11366. }
  11367. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11368. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11369. return m.clearedlabel_relationships
  11370. }
  11371. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11372. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11373. if m.removedlabel_relationships == nil {
  11374. m.removedlabel_relationships = make(map[uint64]struct{})
  11375. }
  11376. for i := range ids {
  11377. delete(m.label_relationships, ids[i])
  11378. m.removedlabel_relationships[ids[i]] = struct{}{}
  11379. }
  11380. }
  11381. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11382. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11383. for id := range m.removedlabel_relationships {
  11384. ids = append(ids, id)
  11385. }
  11386. return
  11387. }
  11388. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11389. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11390. for id := range m.label_relationships {
  11391. ids = append(ids, id)
  11392. }
  11393. return
  11394. }
  11395. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11396. func (m *LabelMutation) ResetLabelRelationships() {
  11397. m.label_relationships = nil
  11398. m.clearedlabel_relationships = false
  11399. m.removedlabel_relationships = nil
  11400. }
  11401. // Where appends a list predicates to the LabelMutation builder.
  11402. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11403. m.predicates = append(m.predicates, ps...)
  11404. }
  11405. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11406. // users can use type-assertion to append predicates that do not depend on any generated package.
  11407. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11408. p := make([]predicate.Label, len(ps))
  11409. for i := range ps {
  11410. p[i] = ps[i]
  11411. }
  11412. m.Where(p...)
  11413. }
  11414. // Op returns the operation name.
  11415. func (m *LabelMutation) Op() Op {
  11416. return m.op
  11417. }
  11418. // SetOp allows setting the mutation operation.
  11419. func (m *LabelMutation) SetOp(op Op) {
  11420. m.op = op
  11421. }
  11422. // Type returns the node type of this mutation (Label).
  11423. func (m *LabelMutation) Type() string {
  11424. return m.typ
  11425. }
  11426. // Fields returns all fields that were changed during this mutation. Note that in
  11427. // order to get all numeric fields that were incremented/decremented, call
  11428. // AddedFields().
  11429. func (m *LabelMutation) Fields() []string {
  11430. fields := make([]string, 0, 9)
  11431. if m.created_at != nil {
  11432. fields = append(fields, label.FieldCreatedAt)
  11433. }
  11434. if m.updated_at != nil {
  11435. fields = append(fields, label.FieldUpdatedAt)
  11436. }
  11437. if m.status != nil {
  11438. fields = append(fields, label.FieldStatus)
  11439. }
  11440. if m._type != nil {
  11441. fields = append(fields, label.FieldType)
  11442. }
  11443. if m.name != nil {
  11444. fields = append(fields, label.FieldName)
  11445. }
  11446. if m.from != nil {
  11447. fields = append(fields, label.FieldFrom)
  11448. }
  11449. if m.mode != nil {
  11450. fields = append(fields, label.FieldMode)
  11451. }
  11452. if m.conditions != nil {
  11453. fields = append(fields, label.FieldConditions)
  11454. }
  11455. if m.organization_id != nil {
  11456. fields = append(fields, label.FieldOrganizationID)
  11457. }
  11458. return fields
  11459. }
  11460. // Field returns the value of a field with the given name. The second boolean
  11461. // return value indicates that this field was not set, or was not defined in the
  11462. // schema.
  11463. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11464. switch name {
  11465. case label.FieldCreatedAt:
  11466. return m.CreatedAt()
  11467. case label.FieldUpdatedAt:
  11468. return m.UpdatedAt()
  11469. case label.FieldStatus:
  11470. return m.Status()
  11471. case label.FieldType:
  11472. return m.GetType()
  11473. case label.FieldName:
  11474. return m.Name()
  11475. case label.FieldFrom:
  11476. return m.From()
  11477. case label.FieldMode:
  11478. return m.Mode()
  11479. case label.FieldConditions:
  11480. return m.Conditions()
  11481. case label.FieldOrganizationID:
  11482. return m.OrganizationID()
  11483. }
  11484. return nil, false
  11485. }
  11486. // OldField returns the old value of the field from the database. An error is
  11487. // returned if the mutation operation is not UpdateOne, or the query to the
  11488. // database failed.
  11489. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11490. switch name {
  11491. case label.FieldCreatedAt:
  11492. return m.OldCreatedAt(ctx)
  11493. case label.FieldUpdatedAt:
  11494. return m.OldUpdatedAt(ctx)
  11495. case label.FieldStatus:
  11496. return m.OldStatus(ctx)
  11497. case label.FieldType:
  11498. return m.OldType(ctx)
  11499. case label.FieldName:
  11500. return m.OldName(ctx)
  11501. case label.FieldFrom:
  11502. return m.OldFrom(ctx)
  11503. case label.FieldMode:
  11504. return m.OldMode(ctx)
  11505. case label.FieldConditions:
  11506. return m.OldConditions(ctx)
  11507. case label.FieldOrganizationID:
  11508. return m.OldOrganizationID(ctx)
  11509. }
  11510. return nil, fmt.Errorf("unknown Label field %s", name)
  11511. }
  11512. // SetField sets the value of a field with the given name. It returns an error if
  11513. // the field is not defined in the schema, or if the type mismatched the field
  11514. // type.
  11515. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11516. switch name {
  11517. case label.FieldCreatedAt:
  11518. v, ok := value.(time.Time)
  11519. if !ok {
  11520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11521. }
  11522. m.SetCreatedAt(v)
  11523. return nil
  11524. case label.FieldUpdatedAt:
  11525. v, ok := value.(time.Time)
  11526. if !ok {
  11527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11528. }
  11529. m.SetUpdatedAt(v)
  11530. return nil
  11531. case label.FieldStatus:
  11532. v, ok := value.(uint8)
  11533. if !ok {
  11534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11535. }
  11536. m.SetStatus(v)
  11537. return nil
  11538. case label.FieldType:
  11539. v, ok := value.(int)
  11540. if !ok {
  11541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11542. }
  11543. m.SetType(v)
  11544. return nil
  11545. case label.FieldName:
  11546. v, ok := value.(string)
  11547. if !ok {
  11548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11549. }
  11550. m.SetName(v)
  11551. return nil
  11552. case label.FieldFrom:
  11553. v, ok := value.(int)
  11554. if !ok {
  11555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11556. }
  11557. m.SetFrom(v)
  11558. return nil
  11559. case label.FieldMode:
  11560. v, ok := value.(int)
  11561. if !ok {
  11562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11563. }
  11564. m.SetMode(v)
  11565. return nil
  11566. case label.FieldConditions:
  11567. v, ok := value.(string)
  11568. if !ok {
  11569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11570. }
  11571. m.SetConditions(v)
  11572. return nil
  11573. case label.FieldOrganizationID:
  11574. v, ok := value.(uint64)
  11575. if !ok {
  11576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11577. }
  11578. m.SetOrganizationID(v)
  11579. return nil
  11580. }
  11581. return fmt.Errorf("unknown Label field %s", name)
  11582. }
  11583. // AddedFields returns all numeric fields that were incremented/decremented during
  11584. // this mutation.
  11585. func (m *LabelMutation) AddedFields() []string {
  11586. var fields []string
  11587. if m.addstatus != nil {
  11588. fields = append(fields, label.FieldStatus)
  11589. }
  11590. if m.add_type != nil {
  11591. fields = append(fields, label.FieldType)
  11592. }
  11593. if m.addfrom != nil {
  11594. fields = append(fields, label.FieldFrom)
  11595. }
  11596. if m.addmode != nil {
  11597. fields = append(fields, label.FieldMode)
  11598. }
  11599. if m.addorganization_id != nil {
  11600. fields = append(fields, label.FieldOrganizationID)
  11601. }
  11602. return fields
  11603. }
  11604. // AddedField returns the numeric value that was incremented/decremented on a field
  11605. // with the given name. The second boolean return value indicates that this field
  11606. // was not set, or was not defined in the schema.
  11607. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11608. switch name {
  11609. case label.FieldStatus:
  11610. return m.AddedStatus()
  11611. case label.FieldType:
  11612. return m.AddedType()
  11613. case label.FieldFrom:
  11614. return m.AddedFrom()
  11615. case label.FieldMode:
  11616. return m.AddedMode()
  11617. case label.FieldOrganizationID:
  11618. return m.AddedOrganizationID()
  11619. }
  11620. return nil, false
  11621. }
  11622. // AddField adds the value to the field with the given name. It returns an error if
  11623. // the field is not defined in the schema, or if the type mismatched the field
  11624. // type.
  11625. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11626. switch name {
  11627. case label.FieldStatus:
  11628. v, ok := value.(int8)
  11629. if !ok {
  11630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11631. }
  11632. m.AddStatus(v)
  11633. return nil
  11634. case label.FieldType:
  11635. v, ok := value.(int)
  11636. if !ok {
  11637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11638. }
  11639. m.AddType(v)
  11640. return nil
  11641. case label.FieldFrom:
  11642. v, ok := value.(int)
  11643. if !ok {
  11644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11645. }
  11646. m.AddFrom(v)
  11647. return nil
  11648. case label.FieldMode:
  11649. v, ok := value.(int)
  11650. if !ok {
  11651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11652. }
  11653. m.AddMode(v)
  11654. return nil
  11655. case label.FieldOrganizationID:
  11656. v, ok := value.(int64)
  11657. if !ok {
  11658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11659. }
  11660. m.AddOrganizationID(v)
  11661. return nil
  11662. }
  11663. return fmt.Errorf("unknown Label numeric field %s", name)
  11664. }
  11665. // ClearedFields returns all nullable fields that were cleared during this
  11666. // mutation.
  11667. func (m *LabelMutation) ClearedFields() []string {
  11668. var fields []string
  11669. if m.FieldCleared(label.FieldStatus) {
  11670. fields = append(fields, label.FieldStatus)
  11671. }
  11672. if m.FieldCleared(label.FieldConditions) {
  11673. fields = append(fields, label.FieldConditions)
  11674. }
  11675. if m.FieldCleared(label.FieldOrganizationID) {
  11676. fields = append(fields, label.FieldOrganizationID)
  11677. }
  11678. return fields
  11679. }
  11680. // FieldCleared returns a boolean indicating if a field with the given name was
  11681. // cleared in this mutation.
  11682. func (m *LabelMutation) FieldCleared(name string) bool {
  11683. _, ok := m.clearedFields[name]
  11684. return ok
  11685. }
  11686. // ClearField clears the value of the field with the given name. It returns an
  11687. // error if the field is not defined in the schema.
  11688. func (m *LabelMutation) ClearField(name string) error {
  11689. switch name {
  11690. case label.FieldStatus:
  11691. m.ClearStatus()
  11692. return nil
  11693. case label.FieldConditions:
  11694. m.ClearConditions()
  11695. return nil
  11696. case label.FieldOrganizationID:
  11697. m.ClearOrganizationID()
  11698. return nil
  11699. }
  11700. return fmt.Errorf("unknown Label nullable field %s", name)
  11701. }
  11702. // ResetField resets all changes in the mutation for the field with the given name.
  11703. // It returns an error if the field is not defined in the schema.
  11704. func (m *LabelMutation) ResetField(name string) error {
  11705. switch name {
  11706. case label.FieldCreatedAt:
  11707. m.ResetCreatedAt()
  11708. return nil
  11709. case label.FieldUpdatedAt:
  11710. m.ResetUpdatedAt()
  11711. return nil
  11712. case label.FieldStatus:
  11713. m.ResetStatus()
  11714. return nil
  11715. case label.FieldType:
  11716. m.ResetType()
  11717. return nil
  11718. case label.FieldName:
  11719. m.ResetName()
  11720. return nil
  11721. case label.FieldFrom:
  11722. m.ResetFrom()
  11723. return nil
  11724. case label.FieldMode:
  11725. m.ResetMode()
  11726. return nil
  11727. case label.FieldConditions:
  11728. m.ResetConditions()
  11729. return nil
  11730. case label.FieldOrganizationID:
  11731. m.ResetOrganizationID()
  11732. return nil
  11733. }
  11734. return fmt.Errorf("unknown Label field %s", name)
  11735. }
  11736. // AddedEdges returns all edge names that were set/added in this mutation.
  11737. func (m *LabelMutation) AddedEdges() []string {
  11738. edges := make([]string, 0, 1)
  11739. if m.label_relationships != nil {
  11740. edges = append(edges, label.EdgeLabelRelationships)
  11741. }
  11742. return edges
  11743. }
  11744. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11745. // name in this mutation.
  11746. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11747. switch name {
  11748. case label.EdgeLabelRelationships:
  11749. ids := make([]ent.Value, 0, len(m.label_relationships))
  11750. for id := range m.label_relationships {
  11751. ids = append(ids, id)
  11752. }
  11753. return ids
  11754. }
  11755. return nil
  11756. }
  11757. // RemovedEdges returns all edge names that were removed in this mutation.
  11758. func (m *LabelMutation) RemovedEdges() []string {
  11759. edges := make([]string, 0, 1)
  11760. if m.removedlabel_relationships != nil {
  11761. edges = append(edges, label.EdgeLabelRelationships)
  11762. }
  11763. return edges
  11764. }
  11765. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11766. // the given name in this mutation.
  11767. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11768. switch name {
  11769. case label.EdgeLabelRelationships:
  11770. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11771. for id := range m.removedlabel_relationships {
  11772. ids = append(ids, id)
  11773. }
  11774. return ids
  11775. }
  11776. return nil
  11777. }
  11778. // ClearedEdges returns all edge names that were cleared in this mutation.
  11779. func (m *LabelMutation) ClearedEdges() []string {
  11780. edges := make([]string, 0, 1)
  11781. if m.clearedlabel_relationships {
  11782. edges = append(edges, label.EdgeLabelRelationships)
  11783. }
  11784. return edges
  11785. }
  11786. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11787. // was cleared in this mutation.
  11788. func (m *LabelMutation) EdgeCleared(name string) bool {
  11789. switch name {
  11790. case label.EdgeLabelRelationships:
  11791. return m.clearedlabel_relationships
  11792. }
  11793. return false
  11794. }
  11795. // ClearEdge clears the value of the edge with the given name. It returns an error
  11796. // if that edge is not defined in the schema.
  11797. func (m *LabelMutation) ClearEdge(name string) error {
  11798. switch name {
  11799. }
  11800. return fmt.Errorf("unknown Label unique edge %s", name)
  11801. }
  11802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11803. // It returns an error if the edge is not defined in the schema.
  11804. func (m *LabelMutation) ResetEdge(name string) error {
  11805. switch name {
  11806. case label.EdgeLabelRelationships:
  11807. m.ResetLabelRelationships()
  11808. return nil
  11809. }
  11810. return fmt.Errorf("unknown Label edge %s", name)
  11811. }
  11812. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11813. type LabelRelationshipMutation struct {
  11814. config
  11815. op Op
  11816. typ string
  11817. id *uint64
  11818. created_at *time.Time
  11819. updated_at *time.Time
  11820. status *uint8
  11821. addstatus *int8
  11822. deleted_at *time.Time
  11823. organization_id *uint64
  11824. addorganization_id *int64
  11825. clearedFields map[string]struct{}
  11826. contacts *uint64
  11827. clearedcontacts bool
  11828. labels *uint64
  11829. clearedlabels bool
  11830. done bool
  11831. oldValue func(context.Context) (*LabelRelationship, error)
  11832. predicates []predicate.LabelRelationship
  11833. }
  11834. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11835. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11836. type labelrelationshipOption func(*LabelRelationshipMutation)
  11837. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11838. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11839. m := &LabelRelationshipMutation{
  11840. config: c,
  11841. op: op,
  11842. typ: TypeLabelRelationship,
  11843. clearedFields: make(map[string]struct{}),
  11844. }
  11845. for _, opt := range opts {
  11846. opt(m)
  11847. }
  11848. return m
  11849. }
  11850. // withLabelRelationshipID sets the ID field of the mutation.
  11851. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11852. return func(m *LabelRelationshipMutation) {
  11853. var (
  11854. err error
  11855. once sync.Once
  11856. value *LabelRelationship
  11857. )
  11858. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11859. once.Do(func() {
  11860. if m.done {
  11861. err = errors.New("querying old values post mutation is not allowed")
  11862. } else {
  11863. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11864. }
  11865. })
  11866. return value, err
  11867. }
  11868. m.id = &id
  11869. }
  11870. }
  11871. // withLabelRelationship sets the old LabelRelationship of the mutation.
  11872. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  11873. return func(m *LabelRelationshipMutation) {
  11874. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  11875. return node, nil
  11876. }
  11877. m.id = &node.ID
  11878. }
  11879. }
  11880. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11881. // executed in a transaction (ent.Tx), a transactional client is returned.
  11882. func (m LabelRelationshipMutation) Client() *Client {
  11883. client := &Client{config: m.config}
  11884. client.init()
  11885. return client
  11886. }
  11887. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11888. // it returns an error otherwise.
  11889. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  11890. if _, ok := m.driver.(*txDriver); !ok {
  11891. return nil, errors.New("ent: mutation is not running in a transaction")
  11892. }
  11893. tx := &Tx{config: m.config}
  11894. tx.init()
  11895. return tx, nil
  11896. }
  11897. // SetID sets the value of the id field. Note that this
  11898. // operation is only accepted on creation of LabelRelationship entities.
  11899. func (m *LabelRelationshipMutation) SetID(id uint64) {
  11900. m.id = &id
  11901. }
  11902. // ID returns the ID value in the mutation. Note that the ID is only available
  11903. // if it was provided to the builder or after it was returned from the database.
  11904. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  11905. if m.id == nil {
  11906. return
  11907. }
  11908. return *m.id, true
  11909. }
  11910. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11911. // That means, if the mutation is applied within a transaction with an isolation level such
  11912. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11913. // or updated by the mutation.
  11914. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  11915. switch {
  11916. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11917. id, exists := m.ID()
  11918. if exists {
  11919. return []uint64{id}, nil
  11920. }
  11921. fallthrough
  11922. case m.op.Is(OpUpdate | OpDelete):
  11923. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  11924. default:
  11925. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11926. }
  11927. }
  11928. // SetCreatedAt sets the "created_at" field.
  11929. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  11930. m.created_at = &t
  11931. }
  11932. // CreatedAt returns the value of the "created_at" field in the mutation.
  11933. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  11934. v := m.created_at
  11935. if v == nil {
  11936. return
  11937. }
  11938. return *v, true
  11939. }
  11940. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  11941. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11943. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11944. if !m.op.Is(OpUpdateOne) {
  11945. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11946. }
  11947. if m.id == nil || m.oldValue == nil {
  11948. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11949. }
  11950. oldValue, err := m.oldValue(ctx)
  11951. if err != nil {
  11952. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11953. }
  11954. return oldValue.CreatedAt, nil
  11955. }
  11956. // ResetCreatedAt resets all changes to the "created_at" field.
  11957. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  11958. m.created_at = nil
  11959. }
  11960. // SetUpdatedAt sets the "updated_at" field.
  11961. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  11962. m.updated_at = &t
  11963. }
  11964. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11965. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  11966. v := m.updated_at
  11967. if v == nil {
  11968. return
  11969. }
  11970. return *v, true
  11971. }
  11972. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  11973. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11975. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11976. if !m.op.Is(OpUpdateOne) {
  11977. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11978. }
  11979. if m.id == nil || m.oldValue == nil {
  11980. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11981. }
  11982. oldValue, err := m.oldValue(ctx)
  11983. if err != nil {
  11984. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11985. }
  11986. return oldValue.UpdatedAt, nil
  11987. }
  11988. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11989. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  11990. m.updated_at = nil
  11991. }
  11992. // SetStatus sets the "status" field.
  11993. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  11994. m.status = &u
  11995. m.addstatus = nil
  11996. }
  11997. // Status returns the value of the "status" field in the mutation.
  11998. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  11999. v := m.status
  12000. if v == nil {
  12001. return
  12002. }
  12003. return *v, true
  12004. }
  12005. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12006. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12008. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12009. if !m.op.Is(OpUpdateOne) {
  12010. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12011. }
  12012. if m.id == nil || m.oldValue == nil {
  12013. return v, errors.New("OldStatus requires an ID field in the mutation")
  12014. }
  12015. oldValue, err := m.oldValue(ctx)
  12016. if err != nil {
  12017. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12018. }
  12019. return oldValue.Status, nil
  12020. }
  12021. // AddStatus adds u to the "status" field.
  12022. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12023. if m.addstatus != nil {
  12024. *m.addstatus += u
  12025. } else {
  12026. m.addstatus = &u
  12027. }
  12028. }
  12029. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12030. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12031. v := m.addstatus
  12032. if v == nil {
  12033. return
  12034. }
  12035. return *v, true
  12036. }
  12037. // ClearStatus clears the value of the "status" field.
  12038. func (m *LabelRelationshipMutation) ClearStatus() {
  12039. m.status = nil
  12040. m.addstatus = nil
  12041. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12042. }
  12043. // StatusCleared returns if the "status" field was cleared in this mutation.
  12044. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12045. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12046. return ok
  12047. }
  12048. // ResetStatus resets all changes to the "status" field.
  12049. func (m *LabelRelationshipMutation) ResetStatus() {
  12050. m.status = nil
  12051. m.addstatus = nil
  12052. delete(m.clearedFields, labelrelationship.FieldStatus)
  12053. }
  12054. // SetDeletedAt sets the "deleted_at" field.
  12055. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12056. m.deleted_at = &t
  12057. }
  12058. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12059. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12060. v := m.deleted_at
  12061. if v == nil {
  12062. return
  12063. }
  12064. return *v, true
  12065. }
  12066. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12067. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12069. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12070. if !m.op.Is(OpUpdateOne) {
  12071. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12072. }
  12073. if m.id == nil || m.oldValue == nil {
  12074. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12075. }
  12076. oldValue, err := m.oldValue(ctx)
  12077. if err != nil {
  12078. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12079. }
  12080. return oldValue.DeletedAt, nil
  12081. }
  12082. // ClearDeletedAt clears the value of the "deleted_at" field.
  12083. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12084. m.deleted_at = nil
  12085. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12086. }
  12087. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12088. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12089. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12090. return ok
  12091. }
  12092. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12093. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12094. m.deleted_at = nil
  12095. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12096. }
  12097. // SetLabelID sets the "label_id" field.
  12098. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12099. m.labels = &u
  12100. }
  12101. // LabelID returns the value of the "label_id" field in the mutation.
  12102. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12103. v := m.labels
  12104. if v == nil {
  12105. return
  12106. }
  12107. return *v, true
  12108. }
  12109. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12110. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12112. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12113. if !m.op.Is(OpUpdateOne) {
  12114. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12115. }
  12116. if m.id == nil || m.oldValue == nil {
  12117. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12118. }
  12119. oldValue, err := m.oldValue(ctx)
  12120. if err != nil {
  12121. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12122. }
  12123. return oldValue.LabelID, nil
  12124. }
  12125. // ResetLabelID resets all changes to the "label_id" field.
  12126. func (m *LabelRelationshipMutation) ResetLabelID() {
  12127. m.labels = nil
  12128. }
  12129. // SetContactID sets the "contact_id" field.
  12130. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12131. m.contacts = &u
  12132. }
  12133. // ContactID returns the value of the "contact_id" field in the mutation.
  12134. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12135. v := m.contacts
  12136. if v == nil {
  12137. return
  12138. }
  12139. return *v, true
  12140. }
  12141. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12142. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12144. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12145. if !m.op.Is(OpUpdateOne) {
  12146. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12147. }
  12148. if m.id == nil || m.oldValue == nil {
  12149. return v, errors.New("OldContactID requires an ID field in the mutation")
  12150. }
  12151. oldValue, err := m.oldValue(ctx)
  12152. if err != nil {
  12153. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12154. }
  12155. return oldValue.ContactID, nil
  12156. }
  12157. // ResetContactID resets all changes to the "contact_id" field.
  12158. func (m *LabelRelationshipMutation) ResetContactID() {
  12159. m.contacts = nil
  12160. }
  12161. // SetOrganizationID sets the "organization_id" field.
  12162. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12163. m.organization_id = &u
  12164. m.addorganization_id = nil
  12165. }
  12166. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12167. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12168. v := m.organization_id
  12169. if v == nil {
  12170. return
  12171. }
  12172. return *v, true
  12173. }
  12174. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12175. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12177. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12178. if !m.op.Is(OpUpdateOne) {
  12179. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12180. }
  12181. if m.id == nil || m.oldValue == nil {
  12182. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12183. }
  12184. oldValue, err := m.oldValue(ctx)
  12185. if err != nil {
  12186. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12187. }
  12188. return oldValue.OrganizationID, nil
  12189. }
  12190. // AddOrganizationID adds u to the "organization_id" field.
  12191. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12192. if m.addorganization_id != nil {
  12193. *m.addorganization_id += u
  12194. } else {
  12195. m.addorganization_id = &u
  12196. }
  12197. }
  12198. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12199. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12200. v := m.addorganization_id
  12201. if v == nil {
  12202. return
  12203. }
  12204. return *v, true
  12205. }
  12206. // ClearOrganizationID clears the value of the "organization_id" field.
  12207. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12208. m.organization_id = nil
  12209. m.addorganization_id = nil
  12210. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12211. }
  12212. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12213. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12214. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12215. return ok
  12216. }
  12217. // ResetOrganizationID resets all changes to the "organization_id" field.
  12218. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12219. m.organization_id = nil
  12220. m.addorganization_id = nil
  12221. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12222. }
  12223. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12224. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12225. m.contacts = &id
  12226. }
  12227. // ClearContacts clears the "contacts" edge to the Contact entity.
  12228. func (m *LabelRelationshipMutation) ClearContacts() {
  12229. m.clearedcontacts = true
  12230. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12231. }
  12232. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12233. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12234. return m.clearedcontacts
  12235. }
  12236. // ContactsID returns the "contacts" edge ID in the mutation.
  12237. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12238. if m.contacts != nil {
  12239. return *m.contacts, true
  12240. }
  12241. return
  12242. }
  12243. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12244. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12245. // ContactsID instead. It exists only for internal usage by the builders.
  12246. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12247. if id := m.contacts; id != nil {
  12248. ids = append(ids, *id)
  12249. }
  12250. return
  12251. }
  12252. // ResetContacts resets all changes to the "contacts" edge.
  12253. func (m *LabelRelationshipMutation) ResetContacts() {
  12254. m.contacts = nil
  12255. m.clearedcontacts = false
  12256. }
  12257. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12258. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12259. m.labels = &id
  12260. }
  12261. // ClearLabels clears the "labels" edge to the Label entity.
  12262. func (m *LabelRelationshipMutation) ClearLabels() {
  12263. m.clearedlabels = true
  12264. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12265. }
  12266. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12267. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12268. return m.clearedlabels
  12269. }
  12270. // LabelsID returns the "labels" edge ID in the mutation.
  12271. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12272. if m.labels != nil {
  12273. return *m.labels, true
  12274. }
  12275. return
  12276. }
  12277. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12278. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12279. // LabelsID instead. It exists only for internal usage by the builders.
  12280. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12281. if id := m.labels; id != nil {
  12282. ids = append(ids, *id)
  12283. }
  12284. return
  12285. }
  12286. // ResetLabels resets all changes to the "labels" edge.
  12287. func (m *LabelRelationshipMutation) ResetLabels() {
  12288. m.labels = nil
  12289. m.clearedlabels = false
  12290. }
  12291. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12292. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12293. m.predicates = append(m.predicates, ps...)
  12294. }
  12295. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12296. // users can use type-assertion to append predicates that do not depend on any generated package.
  12297. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12298. p := make([]predicate.LabelRelationship, len(ps))
  12299. for i := range ps {
  12300. p[i] = ps[i]
  12301. }
  12302. m.Where(p...)
  12303. }
  12304. // Op returns the operation name.
  12305. func (m *LabelRelationshipMutation) Op() Op {
  12306. return m.op
  12307. }
  12308. // SetOp allows setting the mutation operation.
  12309. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12310. m.op = op
  12311. }
  12312. // Type returns the node type of this mutation (LabelRelationship).
  12313. func (m *LabelRelationshipMutation) Type() string {
  12314. return m.typ
  12315. }
  12316. // Fields returns all fields that were changed during this mutation. Note that in
  12317. // order to get all numeric fields that were incremented/decremented, call
  12318. // AddedFields().
  12319. func (m *LabelRelationshipMutation) Fields() []string {
  12320. fields := make([]string, 0, 7)
  12321. if m.created_at != nil {
  12322. fields = append(fields, labelrelationship.FieldCreatedAt)
  12323. }
  12324. if m.updated_at != nil {
  12325. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12326. }
  12327. if m.status != nil {
  12328. fields = append(fields, labelrelationship.FieldStatus)
  12329. }
  12330. if m.deleted_at != nil {
  12331. fields = append(fields, labelrelationship.FieldDeletedAt)
  12332. }
  12333. if m.labels != nil {
  12334. fields = append(fields, labelrelationship.FieldLabelID)
  12335. }
  12336. if m.contacts != nil {
  12337. fields = append(fields, labelrelationship.FieldContactID)
  12338. }
  12339. if m.organization_id != nil {
  12340. fields = append(fields, labelrelationship.FieldOrganizationID)
  12341. }
  12342. return fields
  12343. }
  12344. // Field returns the value of a field with the given name. The second boolean
  12345. // return value indicates that this field was not set, or was not defined in the
  12346. // schema.
  12347. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12348. switch name {
  12349. case labelrelationship.FieldCreatedAt:
  12350. return m.CreatedAt()
  12351. case labelrelationship.FieldUpdatedAt:
  12352. return m.UpdatedAt()
  12353. case labelrelationship.FieldStatus:
  12354. return m.Status()
  12355. case labelrelationship.FieldDeletedAt:
  12356. return m.DeletedAt()
  12357. case labelrelationship.FieldLabelID:
  12358. return m.LabelID()
  12359. case labelrelationship.FieldContactID:
  12360. return m.ContactID()
  12361. case labelrelationship.FieldOrganizationID:
  12362. return m.OrganizationID()
  12363. }
  12364. return nil, false
  12365. }
  12366. // OldField returns the old value of the field from the database. An error is
  12367. // returned if the mutation operation is not UpdateOne, or the query to the
  12368. // database failed.
  12369. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12370. switch name {
  12371. case labelrelationship.FieldCreatedAt:
  12372. return m.OldCreatedAt(ctx)
  12373. case labelrelationship.FieldUpdatedAt:
  12374. return m.OldUpdatedAt(ctx)
  12375. case labelrelationship.FieldStatus:
  12376. return m.OldStatus(ctx)
  12377. case labelrelationship.FieldDeletedAt:
  12378. return m.OldDeletedAt(ctx)
  12379. case labelrelationship.FieldLabelID:
  12380. return m.OldLabelID(ctx)
  12381. case labelrelationship.FieldContactID:
  12382. return m.OldContactID(ctx)
  12383. case labelrelationship.FieldOrganizationID:
  12384. return m.OldOrganizationID(ctx)
  12385. }
  12386. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12387. }
  12388. // SetField sets the value of a field with the given name. It returns an error if
  12389. // the field is not defined in the schema, or if the type mismatched the field
  12390. // type.
  12391. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12392. switch name {
  12393. case labelrelationship.FieldCreatedAt:
  12394. v, ok := value.(time.Time)
  12395. if !ok {
  12396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12397. }
  12398. m.SetCreatedAt(v)
  12399. return nil
  12400. case labelrelationship.FieldUpdatedAt:
  12401. v, ok := value.(time.Time)
  12402. if !ok {
  12403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12404. }
  12405. m.SetUpdatedAt(v)
  12406. return nil
  12407. case labelrelationship.FieldStatus:
  12408. v, ok := value.(uint8)
  12409. if !ok {
  12410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12411. }
  12412. m.SetStatus(v)
  12413. return nil
  12414. case labelrelationship.FieldDeletedAt:
  12415. v, ok := value.(time.Time)
  12416. if !ok {
  12417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12418. }
  12419. m.SetDeletedAt(v)
  12420. return nil
  12421. case labelrelationship.FieldLabelID:
  12422. v, ok := value.(uint64)
  12423. if !ok {
  12424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12425. }
  12426. m.SetLabelID(v)
  12427. return nil
  12428. case labelrelationship.FieldContactID:
  12429. v, ok := value.(uint64)
  12430. if !ok {
  12431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12432. }
  12433. m.SetContactID(v)
  12434. return nil
  12435. case labelrelationship.FieldOrganizationID:
  12436. v, ok := value.(uint64)
  12437. if !ok {
  12438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12439. }
  12440. m.SetOrganizationID(v)
  12441. return nil
  12442. }
  12443. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12444. }
  12445. // AddedFields returns all numeric fields that were incremented/decremented during
  12446. // this mutation.
  12447. func (m *LabelRelationshipMutation) AddedFields() []string {
  12448. var fields []string
  12449. if m.addstatus != nil {
  12450. fields = append(fields, labelrelationship.FieldStatus)
  12451. }
  12452. if m.addorganization_id != nil {
  12453. fields = append(fields, labelrelationship.FieldOrganizationID)
  12454. }
  12455. return fields
  12456. }
  12457. // AddedField returns the numeric value that was incremented/decremented on a field
  12458. // with the given name. The second boolean return value indicates that this field
  12459. // was not set, or was not defined in the schema.
  12460. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12461. switch name {
  12462. case labelrelationship.FieldStatus:
  12463. return m.AddedStatus()
  12464. case labelrelationship.FieldOrganizationID:
  12465. return m.AddedOrganizationID()
  12466. }
  12467. return nil, false
  12468. }
  12469. // AddField adds the value to the field with the given name. It returns an error if
  12470. // the field is not defined in the schema, or if the type mismatched the field
  12471. // type.
  12472. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12473. switch name {
  12474. case labelrelationship.FieldStatus:
  12475. v, ok := value.(int8)
  12476. if !ok {
  12477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12478. }
  12479. m.AddStatus(v)
  12480. return nil
  12481. case labelrelationship.FieldOrganizationID:
  12482. v, ok := value.(int64)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.AddOrganizationID(v)
  12487. return nil
  12488. }
  12489. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12490. }
  12491. // ClearedFields returns all nullable fields that were cleared during this
  12492. // mutation.
  12493. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12494. var fields []string
  12495. if m.FieldCleared(labelrelationship.FieldStatus) {
  12496. fields = append(fields, labelrelationship.FieldStatus)
  12497. }
  12498. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12499. fields = append(fields, labelrelationship.FieldDeletedAt)
  12500. }
  12501. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12502. fields = append(fields, labelrelationship.FieldOrganizationID)
  12503. }
  12504. return fields
  12505. }
  12506. // FieldCleared returns a boolean indicating if a field with the given name was
  12507. // cleared in this mutation.
  12508. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12509. _, ok := m.clearedFields[name]
  12510. return ok
  12511. }
  12512. // ClearField clears the value of the field with the given name. It returns an
  12513. // error if the field is not defined in the schema.
  12514. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12515. switch name {
  12516. case labelrelationship.FieldStatus:
  12517. m.ClearStatus()
  12518. return nil
  12519. case labelrelationship.FieldDeletedAt:
  12520. m.ClearDeletedAt()
  12521. return nil
  12522. case labelrelationship.FieldOrganizationID:
  12523. m.ClearOrganizationID()
  12524. return nil
  12525. }
  12526. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12527. }
  12528. // ResetField resets all changes in the mutation for the field with the given name.
  12529. // It returns an error if the field is not defined in the schema.
  12530. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12531. switch name {
  12532. case labelrelationship.FieldCreatedAt:
  12533. m.ResetCreatedAt()
  12534. return nil
  12535. case labelrelationship.FieldUpdatedAt:
  12536. m.ResetUpdatedAt()
  12537. return nil
  12538. case labelrelationship.FieldStatus:
  12539. m.ResetStatus()
  12540. return nil
  12541. case labelrelationship.FieldDeletedAt:
  12542. m.ResetDeletedAt()
  12543. return nil
  12544. case labelrelationship.FieldLabelID:
  12545. m.ResetLabelID()
  12546. return nil
  12547. case labelrelationship.FieldContactID:
  12548. m.ResetContactID()
  12549. return nil
  12550. case labelrelationship.FieldOrganizationID:
  12551. m.ResetOrganizationID()
  12552. return nil
  12553. }
  12554. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12555. }
  12556. // AddedEdges returns all edge names that were set/added in this mutation.
  12557. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12558. edges := make([]string, 0, 2)
  12559. if m.contacts != nil {
  12560. edges = append(edges, labelrelationship.EdgeContacts)
  12561. }
  12562. if m.labels != nil {
  12563. edges = append(edges, labelrelationship.EdgeLabels)
  12564. }
  12565. return edges
  12566. }
  12567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12568. // name in this mutation.
  12569. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12570. switch name {
  12571. case labelrelationship.EdgeContacts:
  12572. if id := m.contacts; id != nil {
  12573. return []ent.Value{*id}
  12574. }
  12575. case labelrelationship.EdgeLabels:
  12576. if id := m.labels; id != nil {
  12577. return []ent.Value{*id}
  12578. }
  12579. }
  12580. return nil
  12581. }
  12582. // RemovedEdges returns all edge names that were removed in this mutation.
  12583. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12584. edges := make([]string, 0, 2)
  12585. return edges
  12586. }
  12587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12588. // the given name in this mutation.
  12589. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12590. return nil
  12591. }
  12592. // ClearedEdges returns all edge names that were cleared in this mutation.
  12593. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12594. edges := make([]string, 0, 2)
  12595. if m.clearedcontacts {
  12596. edges = append(edges, labelrelationship.EdgeContacts)
  12597. }
  12598. if m.clearedlabels {
  12599. edges = append(edges, labelrelationship.EdgeLabels)
  12600. }
  12601. return edges
  12602. }
  12603. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12604. // was cleared in this mutation.
  12605. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12606. switch name {
  12607. case labelrelationship.EdgeContacts:
  12608. return m.clearedcontacts
  12609. case labelrelationship.EdgeLabels:
  12610. return m.clearedlabels
  12611. }
  12612. return false
  12613. }
  12614. // ClearEdge clears the value of the edge with the given name. It returns an error
  12615. // if that edge is not defined in the schema.
  12616. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12617. switch name {
  12618. case labelrelationship.EdgeContacts:
  12619. m.ClearContacts()
  12620. return nil
  12621. case labelrelationship.EdgeLabels:
  12622. m.ClearLabels()
  12623. return nil
  12624. }
  12625. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12626. }
  12627. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12628. // It returns an error if the edge is not defined in the schema.
  12629. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12630. switch name {
  12631. case labelrelationship.EdgeContacts:
  12632. m.ResetContacts()
  12633. return nil
  12634. case labelrelationship.EdgeLabels:
  12635. m.ResetLabels()
  12636. return nil
  12637. }
  12638. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12639. }
  12640. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12641. type MessageMutation struct {
  12642. config
  12643. op Op
  12644. typ string
  12645. id *int
  12646. wx_wxid *string
  12647. wxid *string
  12648. content *string
  12649. clearedFields map[string]struct{}
  12650. done bool
  12651. oldValue func(context.Context) (*Message, error)
  12652. predicates []predicate.Message
  12653. }
  12654. var _ ent.Mutation = (*MessageMutation)(nil)
  12655. // messageOption allows management of the mutation configuration using functional options.
  12656. type messageOption func(*MessageMutation)
  12657. // newMessageMutation creates new mutation for the Message entity.
  12658. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12659. m := &MessageMutation{
  12660. config: c,
  12661. op: op,
  12662. typ: TypeMessage,
  12663. clearedFields: make(map[string]struct{}),
  12664. }
  12665. for _, opt := range opts {
  12666. opt(m)
  12667. }
  12668. return m
  12669. }
  12670. // withMessageID sets the ID field of the mutation.
  12671. func withMessageID(id int) messageOption {
  12672. return func(m *MessageMutation) {
  12673. var (
  12674. err error
  12675. once sync.Once
  12676. value *Message
  12677. )
  12678. m.oldValue = func(ctx context.Context) (*Message, error) {
  12679. once.Do(func() {
  12680. if m.done {
  12681. err = errors.New("querying old values post mutation is not allowed")
  12682. } else {
  12683. value, err = m.Client().Message.Get(ctx, id)
  12684. }
  12685. })
  12686. return value, err
  12687. }
  12688. m.id = &id
  12689. }
  12690. }
  12691. // withMessage sets the old Message of the mutation.
  12692. func withMessage(node *Message) messageOption {
  12693. return func(m *MessageMutation) {
  12694. m.oldValue = func(context.Context) (*Message, error) {
  12695. return node, nil
  12696. }
  12697. m.id = &node.ID
  12698. }
  12699. }
  12700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12701. // executed in a transaction (ent.Tx), a transactional client is returned.
  12702. func (m MessageMutation) Client() *Client {
  12703. client := &Client{config: m.config}
  12704. client.init()
  12705. return client
  12706. }
  12707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12708. // it returns an error otherwise.
  12709. func (m MessageMutation) Tx() (*Tx, error) {
  12710. if _, ok := m.driver.(*txDriver); !ok {
  12711. return nil, errors.New("ent: mutation is not running in a transaction")
  12712. }
  12713. tx := &Tx{config: m.config}
  12714. tx.init()
  12715. return tx, nil
  12716. }
  12717. // ID returns the ID value in the mutation. Note that the ID is only available
  12718. // if it was provided to the builder or after it was returned from the database.
  12719. func (m *MessageMutation) ID() (id int, exists bool) {
  12720. if m.id == nil {
  12721. return
  12722. }
  12723. return *m.id, true
  12724. }
  12725. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12726. // That means, if the mutation is applied within a transaction with an isolation level such
  12727. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12728. // or updated by the mutation.
  12729. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12730. switch {
  12731. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12732. id, exists := m.ID()
  12733. if exists {
  12734. return []int{id}, nil
  12735. }
  12736. fallthrough
  12737. case m.op.Is(OpUpdate | OpDelete):
  12738. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12739. default:
  12740. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12741. }
  12742. }
  12743. // SetWxWxid sets the "wx_wxid" field.
  12744. func (m *MessageMutation) SetWxWxid(s string) {
  12745. m.wx_wxid = &s
  12746. }
  12747. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12748. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12749. v := m.wx_wxid
  12750. if v == nil {
  12751. return
  12752. }
  12753. return *v, true
  12754. }
  12755. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12756. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12758. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12759. if !m.op.Is(OpUpdateOne) {
  12760. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12761. }
  12762. if m.id == nil || m.oldValue == nil {
  12763. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12764. }
  12765. oldValue, err := m.oldValue(ctx)
  12766. if err != nil {
  12767. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12768. }
  12769. return oldValue.WxWxid, nil
  12770. }
  12771. // ClearWxWxid clears the value of the "wx_wxid" field.
  12772. func (m *MessageMutation) ClearWxWxid() {
  12773. m.wx_wxid = nil
  12774. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12775. }
  12776. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12777. func (m *MessageMutation) WxWxidCleared() bool {
  12778. _, ok := m.clearedFields[message.FieldWxWxid]
  12779. return ok
  12780. }
  12781. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12782. func (m *MessageMutation) ResetWxWxid() {
  12783. m.wx_wxid = nil
  12784. delete(m.clearedFields, message.FieldWxWxid)
  12785. }
  12786. // SetWxid sets the "wxid" field.
  12787. func (m *MessageMutation) SetWxid(s string) {
  12788. m.wxid = &s
  12789. }
  12790. // Wxid returns the value of the "wxid" field in the mutation.
  12791. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12792. v := m.wxid
  12793. if v == nil {
  12794. return
  12795. }
  12796. return *v, true
  12797. }
  12798. // OldWxid returns the old "wxid" field's value of the Message entity.
  12799. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12801. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12802. if !m.op.Is(OpUpdateOne) {
  12803. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12804. }
  12805. if m.id == nil || m.oldValue == nil {
  12806. return v, errors.New("OldWxid requires an ID field in the mutation")
  12807. }
  12808. oldValue, err := m.oldValue(ctx)
  12809. if err != nil {
  12810. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12811. }
  12812. return oldValue.Wxid, nil
  12813. }
  12814. // ResetWxid resets all changes to the "wxid" field.
  12815. func (m *MessageMutation) ResetWxid() {
  12816. m.wxid = nil
  12817. }
  12818. // SetContent sets the "content" field.
  12819. func (m *MessageMutation) SetContent(s string) {
  12820. m.content = &s
  12821. }
  12822. // Content returns the value of the "content" field in the mutation.
  12823. func (m *MessageMutation) Content() (r string, exists bool) {
  12824. v := m.content
  12825. if v == nil {
  12826. return
  12827. }
  12828. return *v, true
  12829. }
  12830. // OldContent returns the old "content" field's value of the Message entity.
  12831. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12833. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12834. if !m.op.Is(OpUpdateOne) {
  12835. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12836. }
  12837. if m.id == nil || m.oldValue == nil {
  12838. return v, errors.New("OldContent requires an ID field in the mutation")
  12839. }
  12840. oldValue, err := m.oldValue(ctx)
  12841. if err != nil {
  12842. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12843. }
  12844. return oldValue.Content, nil
  12845. }
  12846. // ResetContent resets all changes to the "content" field.
  12847. func (m *MessageMutation) ResetContent() {
  12848. m.content = nil
  12849. }
  12850. // Where appends a list predicates to the MessageMutation builder.
  12851. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12852. m.predicates = append(m.predicates, ps...)
  12853. }
  12854. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12855. // users can use type-assertion to append predicates that do not depend on any generated package.
  12856. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12857. p := make([]predicate.Message, len(ps))
  12858. for i := range ps {
  12859. p[i] = ps[i]
  12860. }
  12861. m.Where(p...)
  12862. }
  12863. // Op returns the operation name.
  12864. func (m *MessageMutation) Op() Op {
  12865. return m.op
  12866. }
  12867. // SetOp allows setting the mutation operation.
  12868. func (m *MessageMutation) SetOp(op Op) {
  12869. m.op = op
  12870. }
  12871. // Type returns the node type of this mutation (Message).
  12872. func (m *MessageMutation) Type() string {
  12873. return m.typ
  12874. }
  12875. // Fields returns all fields that were changed during this mutation. Note that in
  12876. // order to get all numeric fields that were incremented/decremented, call
  12877. // AddedFields().
  12878. func (m *MessageMutation) Fields() []string {
  12879. fields := make([]string, 0, 3)
  12880. if m.wx_wxid != nil {
  12881. fields = append(fields, message.FieldWxWxid)
  12882. }
  12883. if m.wxid != nil {
  12884. fields = append(fields, message.FieldWxid)
  12885. }
  12886. if m.content != nil {
  12887. fields = append(fields, message.FieldContent)
  12888. }
  12889. return fields
  12890. }
  12891. // Field returns the value of a field with the given name. The second boolean
  12892. // return value indicates that this field was not set, or was not defined in the
  12893. // schema.
  12894. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  12895. switch name {
  12896. case message.FieldWxWxid:
  12897. return m.WxWxid()
  12898. case message.FieldWxid:
  12899. return m.Wxid()
  12900. case message.FieldContent:
  12901. return m.Content()
  12902. }
  12903. return nil, false
  12904. }
  12905. // OldField returns the old value of the field from the database. An error is
  12906. // returned if the mutation operation is not UpdateOne, or the query to the
  12907. // database failed.
  12908. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12909. switch name {
  12910. case message.FieldWxWxid:
  12911. return m.OldWxWxid(ctx)
  12912. case message.FieldWxid:
  12913. return m.OldWxid(ctx)
  12914. case message.FieldContent:
  12915. return m.OldContent(ctx)
  12916. }
  12917. return nil, fmt.Errorf("unknown Message field %s", name)
  12918. }
  12919. // SetField sets the value of a field with the given name. It returns an error if
  12920. // the field is not defined in the schema, or if the type mismatched the field
  12921. // type.
  12922. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  12923. switch name {
  12924. case message.FieldWxWxid:
  12925. v, ok := value.(string)
  12926. if !ok {
  12927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12928. }
  12929. m.SetWxWxid(v)
  12930. return nil
  12931. case message.FieldWxid:
  12932. v, ok := value.(string)
  12933. if !ok {
  12934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12935. }
  12936. m.SetWxid(v)
  12937. return nil
  12938. case message.FieldContent:
  12939. v, ok := value.(string)
  12940. if !ok {
  12941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12942. }
  12943. m.SetContent(v)
  12944. return nil
  12945. }
  12946. return fmt.Errorf("unknown Message field %s", name)
  12947. }
  12948. // AddedFields returns all numeric fields that were incremented/decremented during
  12949. // this mutation.
  12950. func (m *MessageMutation) AddedFields() []string {
  12951. return nil
  12952. }
  12953. // AddedField returns the numeric value that was incremented/decremented on a field
  12954. // with the given name. The second boolean return value indicates that this field
  12955. // was not set, or was not defined in the schema.
  12956. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  12957. return nil, false
  12958. }
  12959. // AddField adds the value to the field with the given name. It returns an error if
  12960. // the field is not defined in the schema, or if the type mismatched the field
  12961. // type.
  12962. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  12963. switch name {
  12964. }
  12965. return fmt.Errorf("unknown Message numeric field %s", name)
  12966. }
  12967. // ClearedFields returns all nullable fields that were cleared during this
  12968. // mutation.
  12969. func (m *MessageMutation) ClearedFields() []string {
  12970. var fields []string
  12971. if m.FieldCleared(message.FieldWxWxid) {
  12972. fields = append(fields, message.FieldWxWxid)
  12973. }
  12974. return fields
  12975. }
  12976. // FieldCleared returns a boolean indicating if a field with the given name was
  12977. // cleared in this mutation.
  12978. func (m *MessageMutation) FieldCleared(name string) bool {
  12979. _, ok := m.clearedFields[name]
  12980. return ok
  12981. }
  12982. // ClearField clears the value of the field with the given name. It returns an
  12983. // error if the field is not defined in the schema.
  12984. func (m *MessageMutation) ClearField(name string) error {
  12985. switch name {
  12986. case message.FieldWxWxid:
  12987. m.ClearWxWxid()
  12988. return nil
  12989. }
  12990. return fmt.Errorf("unknown Message nullable field %s", name)
  12991. }
  12992. // ResetField resets all changes in the mutation for the field with the given name.
  12993. // It returns an error if the field is not defined in the schema.
  12994. func (m *MessageMutation) ResetField(name string) error {
  12995. switch name {
  12996. case message.FieldWxWxid:
  12997. m.ResetWxWxid()
  12998. return nil
  12999. case message.FieldWxid:
  13000. m.ResetWxid()
  13001. return nil
  13002. case message.FieldContent:
  13003. m.ResetContent()
  13004. return nil
  13005. }
  13006. return fmt.Errorf("unknown Message field %s", name)
  13007. }
  13008. // AddedEdges returns all edge names that were set/added in this mutation.
  13009. func (m *MessageMutation) AddedEdges() []string {
  13010. edges := make([]string, 0, 0)
  13011. return edges
  13012. }
  13013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13014. // name in this mutation.
  13015. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13016. return nil
  13017. }
  13018. // RemovedEdges returns all edge names that were removed in this mutation.
  13019. func (m *MessageMutation) RemovedEdges() []string {
  13020. edges := make([]string, 0, 0)
  13021. return edges
  13022. }
  13023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13024. // the given name in this mutation.
  13025. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13026. return nil
  13027. }
  13028. // ClearedEdges returns all edge names that were cleared in this mutation.
  13029. func (m *MessageMutation) ClearedEdges() []string {
  13030. edges := make([]string, 0, 0)
  13031. return edges
  13032. }
  13033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13034. // was cleared in this mutation.
  13035. func (m *MessageMutation) EdgeCleared(name string) bool {
  13036. return false
  13037. }
  13038. // ClearEdge clears the value of the edge with the given name. It returns an error
  13039. // if that edge is not defined in the schema.
  13040. func (m *MessageMutation) ClearEdge(name string) error {
  13041. return fmt.Errorf("unknown Message unique edge %s", name)
  13042. }
  13043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13044. // It returns an error if the edge is not defined in the schema.
  13045. func (m *MessageMutation) ResetEdge(name string) error {
  13046. return fmt.Errorf("unknown Message edge %s", name)
  13047. }
  13048. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13049. type MessageRecordsMutation struct {
  13050. config
  13051. op Op
  13052. typ string
  13053. id *uint64
  13054. created_at *time.Time
  13055. updated_at *time.Time
  13056. status *uint8
  13057. addstatus *int8
  13058. bot_wxid *string
  13059. contact_type *int
  13060. addcontact_type *int
  13061. contact_wxid *string
  13062. content_type *int
  13063. addcontent_type *int
  13064. content *string
  13065. meta *custom_types.Meta
  13066. error_detail *string
  13067. send_time *time.Time
  13068. source_type *int
  13069. addsource_type *int
  13070. organization_id *uint64
  13071. addorganization_id *int64
  13072. clearedFields map[string]struct{}
  13073. sop_stage *uint64
  13074. clearedsop_stage bool
  13075. sop_node *uint64
  13076. clearedsop_node bool
  13077. message_contact *uint64
  13078. clearedmessage_contact bool
  13079. done bool
  13080. oldValue func(context.Context) (*MessageRecords, error)
  13081. predicates []predicate.MessageRecords
  13082. }
  13083. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13084. // messagerecordsOption allows management of the mutation configuration using functional options.
  13085. type messagerecordsOption func(*MessageRecordsMutation)
  13086. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13087. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13088. m := &MessageRecordsMutation{
  13089. config: c,
  13090. op: op,
  13091. typ: TypeMessageRecords,
  13092. clearedFields: make(map[string]struct{}),
  13093. }
  13094. for _, opt := range opts {
  13095. opt(m)
  13096. }
  13097. return m
  13098. }
  13099. // withMessageRecordsID sets the ID field of the mutation.
  13100. func withMessageRecordsID(id uint64) messagerecordsOption {
  13101. return func(m *MessageRecordsMutation) {
  13102. var (
  13103. err error
  13104. once sync.Once
  13105. value *MessageRecords
  13106. )
  13107. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13108. once.Do(func() {
  13109. if m.done {
  13110. err = errors.New("querying old values post mutation is not allowed")
  13111. } else {
  13112. value, err = m.Client().MessageRecords.Get(ctx, id)
  13113. }
  13114. })
  13115. return value, err
  13116. }
  13117. m.id = &id
  13118. }
  13119. }
  13120. // withMessageRecords sets the old MessageRecords of the mutation.
  13121. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13122. return func(m *MessageRecordsMutation) {
  13123. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13124. return node, nil
  13125. }
  13126. m.id = &node.ID
  13127. }
  13128. }
  13129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13130. // executed in a transaction (ent.Tx), a transactional client is returned.
  13131. func (m MessageRecordsMutation) Client() *Client {
  13132. client := &Client{config: m.config}
  13133. client.init()
  13134. return client
  13135. }
  13136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13137. // it returns an error otherwise.
  13138. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13139. if _, ok := m.driver.(*txDriver); !ok {
  13140. return nil, errors.New("ent: mutation is not running in a transaction")
  13141. }
  13142. tx := &Tx{config: m.config}
  13143. tx.init()
  13144. return tx, nil
  13145. }
  13146. // SetID sets the value of the id field. Note that this
  13147. // operation is only accepted on creation of MessageRecords entities.
  13148. func (m *MessageRecordsMutation) SetID(id uint64) {
  13149. m.id = &id
  13150. }
  13151. // ID returns the ID value in the mutation. Note that the ID is only available
  13152. // if it was provided to the builder or after it was returned from the database.
  13153. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13154. if m.id == nil {
  13155. return
  13156. }
  13157. return *m.id, true
  13158. }
  13159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13160. // That means, if the mutation is applied within a transaction with an isolation level such
  13161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13162. // or updated by the mutation.
  13163. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13164. switch {
  13165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13166. id, exists := m.ID()
  13167. if exists {
  13168. return []uint64{id}, nil
  13169. }
  13170. fallthrough
  13171. case m.op.Is(OpUpdate | OpDelete):
  13172. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13173. default:
  13174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13175. }
  13176. }
  13177. // SetCreatedAt sets the "created_at" field.
  13178. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13179. m.created_at = &t
  13180. }
  13181. // CreatedAt returns the value of the "created_at" field in the mutation.
  13182. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13183. v := m.created_at
  13184. if v == nil {
  13185. return
  13186. }
  13187. return *v, true
  13188. }
  13189. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13190. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13192. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13193. if !m.op.Is(OpUpdateOne) {
  13194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13195. }
  13196. if m.id == nil || m.oldValue == nil {
  13197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13198. }
  13199. oldValue, err := m.oldValue(ctx)
  13200. if err != nil {
  13201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13202. }
  13203. return oldValue.CreatedAt, nil
  13204. }
  13205. // ResetCreatedAt resets all changes to the "created_at" field.
  13206. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13207. m.created_at = nil
  13208. }
  13209. // SetUpdatedAt sets the "updated_at" field.
  13210. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13211. m.updated_at = &t
  13212. }
  13213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13214. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13215. v := m.updated_at
  13216. if v == nil {
  13217. return
  13218. }
  13219. return *v, true
  13220. }
  13221. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13224. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13225. if !m.op.Is(OpUpdateOne) {
  13226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13227. }
  13228. if m.id == nil || m.oldValue == nil {
  13229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13230. }
  13231. oldValue, err := m.oldValue(ctx)
  13232. if err != nil {
  13233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13234. }
  13235. return oldValue.UpdatedAt, nil
  13236. }
  13237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13238. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13239. m.updated_at = nil
  13240. }
  13241. // SetStatus sets the "status" field.
  13242. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13243. m.status = &u
  13244. m.addstatus = nil
  13245. }
  13246. // Status returns the value of the "status" field in the mutation.
  13247. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13248. v := m.status
  13249. if v == nil {
  13250. return
  13251. }
  13252. return *v, true
  13253. }
  13254. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13257. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13258. if !m.op.Is(OpUpdateOne) {
  13259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13260. }
  13261. if m.id == nil || m.oldValue == nil {
  13262. return v, errors.New("OldStatus requires an ID field in the mutation")
  13263. }
  13264. oldValue, err := m.oldValue(ctx)
  13265. if err != nil {
  13266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13267. }
  13268. return oldValue.Status, nil
  13269. }
  13270. // AddStatus adds u to the "status" field.
  13271. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13272. if m.addstatus != nil {
  13273. *m.addstatus += u
  13274. } else {
  13275. m.addstatus = &u
  13276. }
  13277. }
  13278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13279. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13280. v := m.addstatus
  13281. if v == nil {
  13282. return
  13283. }
  13284. return *v, true
  13285. }
  13286. // ClearStatus clears the value of the "status" field.
  13287. func (m *MessageRecordsMutation) ClearStatus() {
  13288. m.status = nil
  13289. m.addstatus = nil
  13290. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13291. }
  13292. // StatusCleared returns if the "status" field was cleared in this mutation.
  13293. func (m *MessageRecordsMutation) StatusCleared() bool {
  13294. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13295. return ok
  13296. }
  13297. // ResetStatus resets all changes to the "status" field.
  13298. func (m *MessageRecordsMutation) ResetStatus() {
  13299. m.status = nil
  13300. m.addstatus = nil
  13301. delete(m.clearedFields, messagerecords.FieldStatus)
  13302. }
  13303. // SetBotWxid sets the "bot_wxid" field.
  13304. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13305. m.bot_wxid = &s
  13306. }
  13307. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13308. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13309. v := m.bot_wxid
  13310. if v == nil {
  13311. return
  13312. }
  13313. return *v, true
  13314. }
  13315. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13316. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13318. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13319. if !m.op.Is(OpUpdateOne) {
  13320. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13321. }
  13322. if m.id == nil || m.oldValue == nil {
  13323. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13324. }
  13325. oldValue, err := m.oldValue(ctx)
  13326. if err != nil {
  13327. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13328. }
  13329. return oldValue.BotWxid, nil
  13330. }
  13331. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13332. func (m *MessageRecordsMutation) ResetBotWxid() {
  13333. m.bot_wxid = nil
  13334. }
  13335. // SetContactID sets the "contact_id" field.
  13336. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13337. m.message_contact = &u
  13338. }
  13339. // ContactID returns the value of the "contact_id" field in the mutation.
  13340. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13341. v := m.message_contact
  13342. if v == nil {
  13343. return
  13344. }
  13345. return *v, true
  13346. }
  13347. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13348. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13350. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13351. if !m.op.Is(OpUpdateOne) {
  13352. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13353. }
  13354. if m.id == nil || m.oldValue == nil {
  13355. return v, errors.New("OldContactID requires an ID field in the mutation")
  13356. }
  13357. oldValue, err := m.oldValue(ctx)
  13358. if err != nil {
  13359. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13360. }
  13361. return oldValue.ContactID, nil
  13362. }
  13363. // ClearContactID clears the value of the "contact_id" field.
  13364. func (m *MessageRecordsMutation) ClearContactID() {
  13365. m.message_contact = nil
  13366. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13367. }
  13368. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13369. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13370. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13371. return ok
  13372. }
  13373. // ResetContactID resets all changes to the "contact_id" field.
  13374. func (m *MessageRecordsMutation) ResetContactID() {
  13375. m.message_contact = nil
  13376. delete(m.clearedFields, messagerecords.FieldContactID)
  13377. }
  13378. // SetContactType sets the "contact_type" field.
  13379. func (m *MessageRecordsMutation) SetContactType(i int) {
  13380. m.contact_type = &i
  13381. m.addcontact_type = nil
  13382. }
  13383. // ContactType returns the value of the "contact_type" field in the mutation.
  13384. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13385. v := m.contact_type
  13386. if v == nil {
  13387. return
  13388. }
  13389. return *v, true
  13390. }
  13391. // OldContactType returns the old "contact_type" 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) OldContactType(ctx context.Context) (v int, err error) {
  13395. if !m.op.Is(OpUpdateOne) {
  13396. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13397. }
  13398. if m.id == nil || m.oldValue == nil {
  13399. return v, errors.New("OldContactType 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 OldContactType: %w", err)
  13404. }
  13405. return oldValue.ContactType, nil
  13406. }
  13407. // AddContactType adds i to the "contact_type" field.
  13408. func (m *MessageRecordsMutation) AddContactType(i int) {
  13409. if m.addcontact_type != nil {
  13410. *m.addcontact_type += i
  13411. } else {
  13412. m.addcontact_type = &i
  13413. }
  13414. }
  13415. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13416. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13417. v := m.addcontact_type
  13418. if v == nil {
  13419. return
  13420. }
  13421. return *v, true
  13422. }
  13423. // ResetContactType resets all changes to the "contact_type" field.
  13424. func (m *MessageRecordsMutation) ResetContactType() {
  13425. m.contact_type = nil
  13426. m.addcontact_type = nil
  13427. }
  13428. // SetContactWxid sets the "contact_wxid" field.
  13429. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13430. m.contact_wxid = &s
  13431. }
  13432. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13433. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13434. v := m.contact_wxid
  13435. if v == nil {
  13436. return
  13437. }
  13438. return *v, true
  13439. }
  13440. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13441. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13443. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13444. if !m.op.Is(OpUpdateOne) {
  13445. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13446. }
  13447. if m.id == nil || m.oldValue == nil {
  13448. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13449. }
  13450. oldValue, err := m.oldValue(ctx)
  13451. if err != nil {
  13452. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13453. }
  13454. return oldValue.ContactWxid, nil
  13455. }
  13456. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13457. func (m *MessageRecordsMutation) ResetContactWxid() {
  13458. m.contact_wxid = nil
  13459. }
  13460. // SetContentType sets the "content_type" field.
  13461. func (m *MessageRecordsMutation) SetContentType(i int) {
  13462. m.content_type = &i
  13463. m.addcontent_type = nil
  13464. }
  13465. // ContentType returns the value of the "content_type" field in the mutation.
  13466. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13467. v := m.content_type
  13468. if v == nil {
  13469. return
  13470. }
  13471. return *v, true
  13472. }
  13473. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13474. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13476. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13477. if !m.op.Is(OpUpdateOne) {
  13478. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13479. }
  13480. if m.id == nil || m.oldValue == nil {
  13481. return v, errors.New("OldContentType requires an ID field in the mutation")
  13482. }
  13483. oldValue, err := m.oldValue(ctx)
  13484. if err != nil {
  13485. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13486. }
  13487. return oldValue.ContentType, nil
  13488. }
  13489. // AddContentType adds i to the "content_type" field.
  13490. func (m *MessageRecordsMutation) AddContentType(i int) {
  13491. if m.addcontent_type != nil {
  13492. *m.addcontent_type += i
  13493. } else {
  13494. m.addcontent_type = &i
  13495. }
  13496. }
  13497. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13498. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13499. v := m.addcontent_type
  13500. if v == nil {
  13501. return
  13502. }
  13503. return *v, true
  13504. }
  13505. // ResetContentType resets all changes to the "content_type" field.
  13506. func (m *MessageRecordsMutation) ResetContentType() {
  13507. m.content_type = nil
  13508. m.addcontent_type = nil
  13509. }
  13510. // SetContent sets the "content" field.
  13511. func (m *MessageRecordsMutation) SetContent(s string) {
  13512. m.content = &s
  13513. }
  13514. // Content returns the value of the "content" field in the mutation.
  13515. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13516. v := m.content
  13517. if v == nil {
  13518. return
  13519. }
  13520. return *v, true
  13521. }
  13522. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13523. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13525. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13526. if !m.op.Is(OpUpdateOne) {
  13527. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13528. }
  13529. if m.id == nil || m.oldValue == nil {
  13530. return v, errors.New("OldContent requires an ID field in the mutation")
  13531. }
  13532. oldValue, err := m.oldValue(ctx)
  13533. if err != nil {
  13534. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13535. }
  13536. return oldValue.Content, nil
  13537. }
  13538. // ResetContent resets all changes to the "content" field.
  13539. func (m *MessageRecordsMutation) ResetContent() {
  13540. m.content = nil
  13541. }
  13542. // SetMeta sets the "meta" field.
  13543. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13544. m.meta = &ct
  13545. }
  13546. // Meta returns the value of the "meta" field in the mutation.
  13547. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13548. v := m.meta
  13549. if v == nil {
  13550. return
  13551. }
  13552. return *v, true
  13553. }
  13554. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13555. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13557. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13558. if !m.op.Is(OpUpdateOne) {
  13559. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13560. }
  13561. if m.id == nil || m.oldValue == nil {
  13562. return v, errors.New("OldMeta requires an ID field in the mutation")
  13563. }
  13564. oldValue, err := m.oldValue(ctx)
  13565. if err != nil {
  13566. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13567. }
  13568. return oldValue.Meta, nil
  13569. }
  13570. // ClearMeta clears the value of the "meta" field.
  13571. func (m *MessageRecordsMutation) ClearMeta() {
  13572. m.meta = nil
  13573. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13574. }
  13575. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13576. func (m *MessageRecordsMutation) MetaCleared() bool {
  13577. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13578. return ok
  13579. }
  13580. // ResetMeta resets all changes to the "meta" field.
  13581. func (m *MessageRecordsMutation) ResetMeta() {
  13582. m.meta = nil
  13583. delete(m.clearedFields, messagerecords.FieldMeta)
  13584. }
  13585. // SetErrorDetail sets the "error_detail" field.
  13586. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13587. m.error_detail = &s
  13588. }
  13589. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13590. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13591. v := m.error_detail
  13592. if v == nil {
  13593. return
  13594. }
  13595. return *v, true
  13596. }
  13597. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13598. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13600. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13601. if !m.op.Is(OpUpdateOne) {
  13602. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13603. }
  13604. if m.id == nil || m.oldValue == nil {
  13605. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13606. }
  13607. oldValue, err := m.oldValue(ctx)
  13608. if err != nil {
  13609. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13610. }
  13611. return oldValue.ErrorDetail, nil
  13612. }
  13613. // ResetErrorDetail resets all changes to the "error_detail" field.
  13614. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13615. m.error_detail = nil
  13616. }
  13617. // SetSendTime sets the "send_time" field.
  13618. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13619. m.send_time = &t
  13620. }
  13621. // SendTime returns the value of the "send_time" field in the mutation.
  13622. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13623. v := m.send_time
  13624. if v == nil {
  13625. return
  13626. }
  13627. return *v, true
  13628. }
  13629. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13630. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13632. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13633. if !m.op.Is(OpUpdateOne) {
  13634. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13635. }
  13636. if m.id == nil || m.oldValue == nil {
  13637. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13638. }
  13639. oldValue, err := m.oldValue(ctx)
  13640. if err != nil {
  13641. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13642. }
  13643. return oldValue.SendTime, nil
  13644. }
  13645. // ClearSendTime clears the value of the "send_time" field.
  13646. func (m *MessageRecordsMutation) ClearSendTime() {
  13647. m.send_time = nil
  13648. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13649. }
  13650. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13651. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13652. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13653. return ok
  13654. }
  13655. // ResetSendTime resets all changes to the "send_time" field.
  13656. func (m *MessageRecordsMutation) ResetSendTime() {
  13657. m.send_time = nil
  13658. delete(m.clearedFields, messagerecords.FieldSendTime)
  13659. }
  13660. // SetSourceType sets the "source_type" field.
  13661. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13662. m.source_type = &i
  13663. m.addsource_type = nil
  13664. }
  13665. // SourceType returns the value of the "source_type" field in the mutation.
  13666. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13667. v := m.source_type
  13668. if v == nil {
  13669. return
  13670. }
  13671. return *v, true
  13672. }
  13673. // OldSourceType returns the old "source_type" 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) OldSourceType(ctx context.Context) (v int, err error) {
  13677. if !m.op.Is(OpUpdateOne) {
  13678. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13679. }
  13680. if m.id == nil || m.oldValue == nil {
  13681. return v, errors.New("OldSourceType 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 OldSourceType: %w", err)
  13686. }
  13687. return oldValue.SourceType, nil
  13688. }
  13689. // AddSourceType adds i to the "source_type" field.
  13690. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13691. if m.addsource_type != nil {
  13692. *m.addsource_type += i
  13693. } else {
  13694. m.addsource_type = &i
  13695. }
  13696. }
  13697. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13698. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13699. v := m.addsource_type
  13700. if v == nil {
  13701. return
  13702. }
  13703. return *v, true
  13704. }
  13705. // ResetSourceType resets all changes to the "source_type" field.
  13706. func (m *MessageRecordsMutation) ResetSourceType() {
  13707. m.source_type = nil
  13708. m.addsource_type = nil
  13709. }
  13710. // SetSourceID sets the "source_id" field.
  13711. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13712. m.sop_stage = &u
  13713. }
  13714. // SourceID returns the value of the "source_id" field in the mutation.
  13715. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13716. v := m.sop_stage
  13717. if v == nil {
  13718. return
  13719. }
  13720. return *v, true
  13721. }
  13722. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13723. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13725. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13726. if !m.op.Is(OpUpdateOne) {
  13727. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13728. }
  13729. if m.id == nil || m.oldValue == nil {
  13730. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13731. }
  13732. oldValue, err := m.oldValue(ctx)
  13733. if err != nil {
  13734. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13735. }
  13736. return oldValue.SourceID, nil
  13737. }
  13738. // ClearSourceID clears the value of the "source_id" field.
  13739. func (m *MessageRecordsMutation) ClearSourceID() {
  13740. m.sop_stage = nil
  13741. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13742. }
  13743. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13744. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13745. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13746. return ok
  13747. }
  13748. // ResetSourceID resets all changes to the "source_id" field.
  13749. func (m *MessageRecordsMutation) ResetSourceID() {
  13750. m.sop_stage = nil
  13751. delete(m.clearedFields, messagerecords.FieldSourceID)
  13752. }
  13753. // SetSubSourceID sets the "sub_source_id" field.
  13754. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13755. m.sop_node = &u
  13756. }
  13757. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13758. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13759. v := m.sop_node
  13760. if v == nil {
  13761. return
  13762. }
  13763. return *v, true
  13764. }
  13765. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13766. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13768. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13769. if !m.op.Is(OpUpdateOne) {
  13770. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13771. }
  13772. if m.id == nil || m.oldValue == nil {
  13773. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13774. }
  13775. oldValue, err := m.oldValue(ctx)
  13776. if err != nil {
  13777. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13778. }
  13779. return oldValue.SubSourceID, nil
  13780. }
  13781. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13782. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13783. m.sop_node = nil
  13784. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13785. }
  13786. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13787. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13788. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13789. return ok
  13790. }
  13791. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13792. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13793. m.sop_node = nil
  13794. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13795. }
  13796. // SetOrganizationID sets the "organization_id" field.
  13797. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13798. m.organization_id = &u
  13799. m.addorganization_id = nil
  13800. }
  13801. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13802. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13803. v := m.organization_id
  13804. if v == nil {
  13805. return
  13806. }
  13807. return *v, true
  13808. }
  13809. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13810. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13812. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13813. if !m.op.Is(OpUpdateOne) {
  13814. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13815. }
  13816. if m.id == nil || m.oldValue == nil {
  13817. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13818. }
  13819. oldValue, err := m.oldValue(ctx)
  13820. if err != nil {
  13821. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13822. }
  13823. return oldValue.OrganizationID, nil
  13824. }
  13825. // AddOrganizationID adds u to the "organization_id" field.
  13826. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13827. if m.addorganization_id != nil {
  13828. *m.addorganization_id += u
  13829. } else {
  13830. m.addorganization_id = &u
  13831. }
  13832. }
  13833. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13834. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13835. v := m.addorganization_id
  13836. if v == nil {
  13837. return
  13838. }
  13839. return *v, true
  13840. }
  13841. // ClearOrganizationID clears the value of the "organization_id" field.
  13842. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13843. m.organization_id = nil
  13844. m.addorganization_id = nil
  13845. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13846. }
  13847. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13848. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13849. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13850. return ok
  13851. }
  13852. // ResetOrganizationID resets all changes to the "organization_id" field.
  13853. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13854. m.organization_id = nil
  13855. m.addorganization_id = nil
  13856. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13857. }
  13858. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13859. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13860. m.sop_stage = &id
  13861. }
  13862. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13863. func (m *MessageRecordsMutation) ClearSopStage() {
  13864. m.clearedsop_stage = true
  13865. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13866. }
  13867. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13868. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13869. return m.SourceIDCleared() || m.clearedsop_stage
  13870. }
  13871. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13872. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  13873. if m.sop_stage != nil {
  13874. return *m.sop_stage, true
  13875. }
  13876. return
  13877. }
  13878. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13879. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13880. // SopStageID instead. It exists only for internal usage by the builders.
  13881. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  13882. if id := m.sop_stage; id != nil {
  13883. ids = append(ids, *id)
  13884. }
  13885. return
  13886. }
  13887. // ResetSopStage resets all changes to the "sop_stage" edge.
  13888. func (m *MessageRecordsMutation) ResetSopStage() {
  13889. m.sop_stage = nil
  13890. m.clearedsop_stage = false
  13891. }
  13892. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  13893. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  13894. m.sop_node = &id
  13895. }
  13896. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  13897. func (m *MessageRecordsMutation) ClearSopNode() {
  13898. m.clearedsop_node = true
  13899. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13900. }
  13901. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  13902. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  13903. return m.SubSourceIDCleared() || m.clearedsop_node
  13904. }
  13905. // SopNodeID returns the "sop_node" edge ID in the mutation.
  13906. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  13907. if m.sop_node != nil {
  13908. return *m.sop_node, true
  13909. }
  13910. return
  13911. }
  13912. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  13913. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13914. // SopNodeID instead. It exists only for internal usage by the builders.
  13915. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  13916. if id := m.sop_node; id != nil {
  13917. ids = append(ids, *id)
  13918. }
  13919. return
  13920. }
  13921. // ResetSopNode resets all changes to the "sop_node" edge.
  13922. func (m *MessageRecordsMutation) ResetSopNode() {
  13923. m.sop_node = nil
  13924. m.clearedsop_node = false
  13925. }
  13926. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  13927. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  13928. m.message_contact = &id
  13929. }
  13930. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  13931. func (m *MessageRecordsMutation) ClearMessageContact() {
  13932. m.clearedmessage_contact = true
  13933. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13934. }
  13935. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  13936. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  13937. return m.ContactIDCleared() || m.clearedmessage_contact
  13938. }
  13939. // MessageContactID returns the "message_contact" edge ID in the mutation.
  13940. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  13941. if m.message_contact != nil {
  13942. return *m.message_contact, true
  13943. }
  13944. return
  13945. }
  13946. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  13947. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13948. // MessageContactID instead. It exists only for internal usage by the builders.
  13949. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  13950. if id := m.message_contact; id != nil {
  13951. ids = append(ids, *id)
  13952. }
  13953. return
  13954. }
  13955. // ResetMessageContact resets all changes to the "message_contact" edge.
  13956. func (m *MessageRecordsMutation) ResetMessageContact() {
  13957. m.message_contact = nil
  13958. m.clearedmessage_contact = false
  13959. }
  13960. // Where appends a list predicates to the MessageRecordsMutation builder.
  13961. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  13962. m.predicates = append(m.predicates, ps...)
  13963. }
  13964. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  13965. // users can use type-assertion to append predicates that do not depend on any generated package.
  13966. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  13967. p := make([]predicate.MessageRecords, len(ps))
  13968. for i := range ps {
  13969. p[i] = ps[i]
  13970. }
  13971. m.Where(p...)
  13972. }
  13973. // Op returns the operation name.
  13974. func (m *MessageRecordsMutation) Op() Op {
  13975. return m.op
  13976. }
  13977. // SetOp allows setting the mutation operation.
  13978. func (m *MessageRecordsMutation) SetOp(op Op) {
  13979. m.op = op
  13980. }
  13981. // Type returns the node type of this mutation (MessageRecords).
  13982. func (m *MessageRecordsMutation) Type() string {
  13983. return m.typ
  13984. }
  13985. // Fields returns all fields that were changed during this mutation. Note that in
  13986. // order to get all numeric fields that were incremented/decremented, call
  13987. // AddedFields().
  13988. func (m *MessageRecordsMutation) Fields() []string {
  13989. fields := make([]string, 0, 16)
  13990. if m.created_at != nil {
  13991. fields = append(fields, messagerecords.FieldCreatedAt)
  13992. }
  13993. if m.updated_at != nil {
  13994. fields = append(fields, messagerecords.FieldUpdatedAt)
  13995. }
  13996. if m.status != nil {
  13997. fields = append(fields, messagerecords.FieldStatus)
  13998. }
  13999. if m.bot_wxid != nil {
  14000. fields = append(fields, messagerecords.FieldBotWxid)
  14001. }
  14002. if m.message_contact != nil {
  14003. fields = append(fields, messagerecords.FieldContactID)
  14004. }
  14005. if m.contact_type != nil {
  14006. fields = append(fields, messagerecords.FieldContactType)
  14007. }
  14008. if m.contact_wxid != nil {
  14009. fields = append(fields, messagerecords.FieldContactWxid)
  14010. }
  14011. if m.content_type != nil {
  14012. fields = append(fields, messagerecords.FieldContentType)
  14013. }
  14014. if m.content != nil {
  14015. fields = append(fields, messagerecords.FieldContent)
  14016. }
  14017. if m.meta != nil {
  14018. fields = append(fields, messagerecords.FieldMeta)
  14019. }
  14020. if m.error_detail != nil {
  14021. fields = append(fields, messagerecords.FieldErrorDetail)
  14022. }
  14023. if m.send_time != nil {
  14024. fields = append(fields, messagerecords.FieldSendTime)
  14025. }
  14026. if m.source_type != nil {
  14027. fields = append(fields, messagerecords.FieldSourceType)
  14028. }
  14029. if m.sop_stage != nil {
  14030. fields = append(fields, messagerecords.FieldSourceID)
  14031. }
  14032. if m.sop_node != nil {
  14033. fields = append(fields, messagerecords.FieldSubSourceID)
  14034. }
  14035. if m.organization_id != nil {
  14036. fields = append(fields, messagerecords.FieldOrganizationID)
  14037. }
  14038. return fields
  14039. }
  14040. // Field returns the value of a field with the given name. The second boolean
  14041. // return value indicates that this field was not set, or was not defined in the
  14042. // schema.
  14043. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14044. switch name {
  14045. case messagerecords.FieldCreatedAt:
  14046. return m.CreatedAt()
  14047. case messagerecords.FieldUpdatedAt:
  14048. return m.UpdatedAt()
  14049. case messagerecords.FieldStatus:
  14050. return m.Status()
  14051. case messagerecords.FieldBotWxid:
  14052. return m.BotWxid()
  14053. case messagerecords.FieldContactID:
  14054. return m.ContactID()
  14055. case messagerecords.FieldContactType:
  14056. return m.ContactType()
  14057. case messagerecords.FieldContactWxid:
  14058. return m.ContactWxid()
  14059. case messagerecords.FieldContentType:
  14060. return m.ContentType()
  14061. case messagerecords.FieldContent:
  14062. return m.Content()
  14063. case messagerecords.FieldMeta:
  14064. return m.Meta()
  14065. case messagerecords.FieldErrorDetail:
  14066. return m.ErrorDetail()
  14067. case messagerecords.FieldSendTime:
  14068. return m.SendTime()
  14069. case messagerecords.FieldSourceType:
  14070. return m.SourceType()
  14071. case messagerecords.FieldSourceID:
  14072. return m.SourceID()
  14073. case messagerecords.FieldSubSourceID:
  14074. return m.SubSourceID()
  14075. case messagerecords.FieldOrganizationID:
  14076. return m.OrganizationID()
  14077. }
  14078. return nil, false
  14079. }
  14080. // OldField returns the old value of the field from the database. An error is
  14081. // returned if the mutation operation is not UpdateOne, or the query to the
  14082. // database failed.
  14083. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14084. switch name {
  14085. case messagerecords.FieldCreatedAt:
  14086. return m.OldCreatedAt(ctx)
  14087. case messagerecords.FieldUpdatedAt:
  14088. return m.OldUpdatedAt(ctx)
  14089. case messagerecords.FieldStatus:
  14090. return m.OldStatus(ctx)
  14091. case messagerecords.FieldBotWxid:
  14092. return m.OldBotWxid(ctx)
  14093. case messagerecords.FieldContactID:
  14094. return m.OldContactID(ctx)
  14095. case messagerecords.FieldContactType:
  14096. return m.OldContactType(ctx)
  14097. case messagerecords.FieldContactWxid:
  14098. return m.OldContactWxid(ctx)
  14099. case messagerecords.FieldContentType:
  14100. return m.OldContentType(ctx)
  14101. case messagerecords.FieldContent:
  14102. return m.OldContent(ctx)
  14103. case messagerecords.FieldMeta:
  14104. return m.OldMeta(ctx)
  14105. case messagerecords.FieldErrorDetail:
  14106. return m.OldErrorDetail(ctx)
  14107. case messagerecords.FieldSendTime:
  14108. return m.OldSendTime(ctx)
  14109. case messagerecords.FieldSourceType:
  14110. return m.OldSourceType(ctx)
  14111. case messagerecords.FieldSourceID:
  14112. return m.OldSourceID(ctx)
  14113. case messagerecords.FieldSubSourceID:
  14114. return m.OldSubSourceID(ctx)
  14115. case messagerecords.FieldOrganizationID:
  14116. return m.OldOrganizationID(ctx)
  14117. }
  14118. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14119. }
  14120. // SetField sets the value of a field with the given name. It returns an error if
  14121. // the field is not defined in the schema, or if the type mismatched the field
  14122. // type.
  14123. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14124. switch name {
  14125. case messagerecords.FieldCreatedAt:
  14126. v, ok := value.(time.Time)
  14127. if !ok {
  14128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14129. }
  14130. m.SetCreatedAt(v)
  14131. return nil
  14132. case messagerecords.FieldUpdatedAt:
  14133. v, ok := value.(time.Time)
  14134. if !ok {
  14135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14136. }
  14137. m.SetUpdatedAt(v)
  14138. return nil
  14139. case messagerecords.FieldStatus:
  14140. v, ok := value.(uint8)
  14141. if !ok {
  14142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14143. }
  14144. m.SetStatus(v)
  14145. return nil
  14146. case messagerecords.FieldBotWxid:
  14147. v, ok := value.(string)
  14148. if !ok {
  14149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14150. }
  14151. m.SetBotWxid(v)
  14152. return nil
  14153. case messagerecords.FieldContactID:
  14154. v, ok := value.(uint64)
  14155. if !ok {
  14156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14157. }
  14158. m.SetContactID(v)
  14159. return nil
  14160. case messagerecords.FieldContactType:
  14161. v, ok := value.(int)
  14162. if !ok {
  14163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14164. }
  14165. m.SetContactType(v)
  14166. return nil
  14167. case messagerecords.FieldContactWxid:
  14168. v, ok := value.(string)
  14169. if !ok {
  14170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14171. }
  14172. m.SetContactWxid(v)
  14173. return nil
  14174. case messagerecords.FieldContentType:
  14175. v, ok := value.(int)
  14176. if !ok {
  14177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14178. }
  14179. m.SetContentType(v)
  14180. return nil
  14181. case messagerecords.FieldContent:
  14182. v, ok := value.(string)
  14183. if !ok {
  14184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14185. }
  14186. m.SetContent(v)
  14187. return nil
  14188. case messagerecords.FieldMeta:
  14189. v, ok := value.(custom_types.Meta)
  14190. if !ok {
  14191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14192. }
  14193. m.SetMeta(v)
  14194. return nil
  14195. case messagerecords.FieldErrorDetail:
  14196. v, ok := value.(string)
  14197. if !ok {
  14198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14199. }
  14200. m.SetErrorDetail(v)
  14201. return nil
  14202. case messagerecords.FieldSendTime:
  14203. v, ok := value.(time.Time)
  14204. if !ok {
  14205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14206. }
  14207. m.SetSendTime(v)
  14208. return nil
  14209. case messagerecords.FieldSourceType:
  14210. v, ok := value.(int)
  14211. if !ok {
  14212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14213. }
  14214. m.SetSourceType(v)
  14215. return nil
  14216. case messagerecords.FieldSourceID:
  14217. v, ok := value.(uint64)
  14218. if !ok {
  14219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14220. }
  14221. m.SetSourceID(v)
  14222. return nil
  14223. case messagerecords.FieldSubSourceID:
  14224. v, ok := value.(uint64)
  14225. if !ok {
  14226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14227. }
  14228. m.SetSubSourceID(v)
  14229. return nil
  14230. case messagerecords.FieldOrganizationID:
  14231. v, ok := value.(uint64)
  14232. if !ok {
  14233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14234. }
  14235. m.SetOrganizationID(v)
  14236. return nil
  14237. }
  14238. return fmt.Errorf("unknown MessageRecords field %s", name)
  14239. }
  14240. // AddedFields returns all numeric fields that were incremented/decremented during
  14241. // this mutation.
  14242. func (m *MessageRecordsMutation) AddedFields() []string {
  14243. var fields []string
  14244. if m.addstatus != nil {
  14245. fields = append(fields, messagerecords.FieldStatus)
  14246. }
  14247. if m.addcontact_type != nil {
  14248. fields = append(fields, messagerecords.FieldContactType)
  14249. }
  14250. if m.addcontent_type != nil {
  14251. fields = append(fields, messagerecords.FieldContentType)
  14252. }
  14253. if m.addsource_type != nil {
  14254. fields = append(fields, messagerecords.FieldSourceType)
  14255. }
  14256. if m.addorganization_id != nil {
  14257. fields = append(fields, messagerecords.FieldOrganizationID)
  14258. }
  14259. return fields
  14260. }
  14261. // AddedField returns the numeric value that was incremented/decremented on a field
  14262. // with the given name. The second boolean return value indicates that this field
  14263. // was not set, or was not defined in the schema.
  14264. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14265. switch name {
  14266. case messagerecords.FieldStatus:
  14267. return m.AddedStatus()
  14268. case messagerecords.FieldContactType:
  14269. return m.AddedContactType()
  14270. case messagerecords.FieldContentType:
  14271. return m.AddedContentType()
  14272. case messagerecords.FieldSourceType:
  14273. return m.AddedSourceType()
  14274. case messagerecords.FieldOrganizationID:
  14275. return m.AddedOrganizationID()
  14276. }
  14277. return nil, false
  14278. }
  14279. // AddField adds the value to the field with the given name. It returns an error if
  14280. // the field is not defined in the schema, or if the type mismatched the field
  14281. // type.
  14282. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14283. switch name {
  14284. case messagerecords.FieldStatus:
  14285. v, ok := value.(int8)
  14286. if !ok {
  14287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14288. }
  14289. m.AddStatus(v)
  14290. return nil
  14291. case messagerecords.FieldContactType:
  14292. v, ok := value.(int)
  14293. if !ok {
  14294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14295. }
  14296. m.AddContactType(v)
  14297. return nil
  14298. case messagerecords.FieldContentType:
  14299. v, ok := value.(int)
  14300. if !ok {
  14301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14302. }
  14303. m.AddContentType(v)
  14304. return nil
  14305. case messagerecords.FieldSourceType:
  14306. v, ok := value.(int)
  14307. if !ok {
  14308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14309. }
  14310. m.AddSourceType(v)
  14311. return nil
  14312. case messagerecords.FieldOrganizationID:
  14313. v, ok := value.(int64)
  14314. if !ok {
  14315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14316. }
  14317. m.AddOrganizationID(v)
  14318. return nil
  14319. }
  14320. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14321. }
  14322. // ClearedFields returns all nullable fields that were cleared during this
  14323. // mutation.
  14324. func (m *MessageRecordsMutation) ClearedFields() []string {
  14325. var fields []string
  14326. if m.FieldCleared(messagerecords.FieldStatus) {
  14327. fields = append(fields, messagerecords.FieldStatus)
  14328. }
  14329. if m.FieldCleared(messagerecords.FieldContactID) {
  14330. fields = append(fields, messagerecords.FieldContactID)
  14331. }
  14332. if m.FieldCleared(messagerecords.FieldMeta) {
  14333. fields = append(fields, messagerecords.FieldMeta)
  14334. }
  14335. if m.FieldCleared(messagerecords.FieldSendTime) {
  14336. fields = append(fields, messagerecords.FieldSendTime)
  14337. }
  14338. if m.FieldCleared(messagerecords.FieldSourceID) {
  14339. fields = append(fields, messagerecords.FieldSourceID)
  14340. }
  14341. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14342. fields = append(fields, messagerecords.FieldSubSourceID)
  14343. }
  14344. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14345. fields = append(fields, messagerecords.FieldOrganizationID)
  14346. }
  14347. return fields
  14348. }
  14349. // FieldCleared returns a boolean indicating if a field with the given name was
  14350. // cleared in this mutation.
  14351. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14352. _, ok := m.clearedFields[name]
  14353. return ok
  14354. }
  14355. // ClearField clears the value of the field with the given name. It returns an
  14356. // error if the field is not defined in the schema.
  14357. func (m *MessageRecordsMutation) ClearField(name string) error {
  14358. switch name {
  14359. case messagerecords.FieldStatus:
  14360. m.ClearStatus()
  14361. return nil
  14362. case messagerecords.FieldContactID:
  14363. m.ClearContactID()
  14364. return nil
  14365. case messagerecords.FieldMeta:
  14366. m.ClearMeta()
  14367. return nil
  14368. case messagerecords.FieldSendTime:
  14369. m.ClearSendTime()
  14370. return nil
  14371. case messagerecords.FieldSourceID:
  14372. m.ClearSourceID()
  14373. return nil
  14374. case messagerecords.FieldSubSourceID:
  14375. m.ClearSubSourceID()
  14376. return nil
  14377. case messagerecords.FieldOrganizationID:
  14378. m.ClearOrganizationID()
  14379. return nil
  14380. }
  14381. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14382. }
  14383. // ResetField resets all changes in the mutation for the field with the given name.
  14384. // It returns an error if the field is not defined in the schema.
  14385. func (m *MessageRecordsMutation) ResetField(name string) error {
  14386. switch name {
  14387. case messagerecords.FieldCreatedAt:
  14388. m.ResetCreatedAt()
  14389. return nil
  14390. case messagerecords.FieldUpdatedAt:
  14391. m.ResetUpdatedAt()
  14392. return nil
  14393. case messagerecords.FieldStatus:
  14394. m.ResetStatus()
  14395. return nil
  14396. case messagerecords.FieldBotWxid:
  14397. m.ResetBotWxid()
  14398. return nil
  14399. case messagerecords.FieldContactID:
  14400. m.ResetContactID()
  14401. return nil
  14402. case messagerecords.FieldContactType:
  14403. m.ResetContactType()
  14404. return nil
  14405. case messagerecords.FieldContactWxid:
  14406. m.ResetContactWxid()
  14407. return nil
  14408. case messagerecords.FieldContentType:
  14409. m.ResetContentType()
  14410. return nil
  14411. case messagerecords.FieldContent:
  14412. m.ResetContent()
  14413. return nil
  14414. case messagerecords.FieldMeta:
  14415. m.ResetMeta()
  14416. return nil
  14417. case messagerecords.FieldErrorDetail:
  14418. m.ResetErrorDetail()
  14419. return nil
  14420. case messagerecords.FieldSendTime:
  14421. m.ResetSendTime()
  14422. return nil
  14423. case messagerecords.FieldSourceType:
  14424. m.ResetSourceType()
  14425. return nil
  14426. case messagerecords.FieldSourceID:
  14427. m.ResetSourceID()
  14428. return nil
  14429. case messagerecords.FieldSubSourceID:
  14430. m.ResetSubSourceID()
  14431. return nil
  14432. case messagerecords.FieldOrganizationID:
  14433. m.ResetOrganizationID()
  14434. return nil
  14435. }
  14436. return fmt.Errorf("unknown MessageRecords field %s", name)
  14437. }
  14438. // AddedEdges returns all edge names that were set/added in this mutation.
  14439. func (m *MessageRecordsMutation) AddedEdges() []string {
  14440. edges := make([]string, 0, 3)
  14441. if m.sop_stage != nil {
  14442. edges = append(edges, messagerecords.EdgeSopStage)
  14443. }
  14444. if m.sop_node != nil {
  14445. edges = append(edges, messagerecords.EdgeSopNode)
  14446. }
  14447. if m.message_contact != nil {
  14448. edges = append(edges, messagerecords.EdgeMessageContact)
  14449. }
  14450. return edges
  14451. }
  14452. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14453. // name in this mutation.
  14454. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14455. switch name {
  14456. case messagerecords.EdgeSopStage:
  14457. if id := m.sop_stage; id != nil {
  14458. return []ent.Value{*id}
  14459. }
  14460. case messagerecords.EdgeSopNode:
  14461. if id := m.sop_node; id != nil {
  14462. return []ent.Value{*id}
  14463. }
  14464. case messagerecords.EdgeMessageContact:
  14465. if id := m.message_contact; id != nil {
  14466. return []ent.Value{*id}
  14467. }
  14468. }
  14469. return nil
  14470. }
  14471. // RemovedEdges returns all edge names that were removed in this mutation.
  14472. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14473. edges := make([]string, 0, 3)
  14474. return edges
  14475. }
  14476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14477. // the given name in this mutation.
  14478. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14479. return nil
  14480. }
  14481. // ClearedEdges returns all edge names that were cleared in this mutation.
  14482. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14483. edges := make([]string, 0, 3)
  14484. if m.clearedsop_stage {
  14485. edges = append(edges, messagerecords.EdgeSopStage)
  14486. }
  14487. if m.clearedsop_node {
  14488. edges = append(edges, messagerecords.EdgeSopNode)
  14489. }
  14490. if m.clearedmessage_contact {
  14491. edges = append(edges, messagerecords.EdgeMessageContact)
  14492. }
  14493. return edges
  14494. }
  14495. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14496. // was cleared in this mutation.
  14497. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14498. switch name {
  14499. case messagerecords.EdgeSopStage:
  14500. return m.clearedsop_stage
  14501. case messagerecords.EdgeSopNode:
  14502. return m.clearedsop_node
  14503. case messagerecords.EdgeMessageContact:
  14504. return m.clearedmessage_contact
  14505. }
  14506. return false
  14507. }
  14508. // ClearEdge clears the value of the edge with the given name. It returns an error
  14509. // if that edge is not defined in the schema.
  14510. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14511. switch name {
  14512. case messagerecords.EdgeSopStage:
  14513. m.ClearSopStage()
  14514. return nil
  14515. case messagerecords.EdgeSopNode:
  14516. m.ClearSopNode()
  14517. return nil
  14518. case messagerecords.EdgeMessageContact:
  14519. m.ClearMessageContact()
  14520. return nil
  14521. }
  14522. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14523. }
  14524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14525. // It returns an error if the edge is not defined in the schema.
  14526. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14527. switch name {
  14528. case messagerecords.EdgeSopStage:
  14529. m.ResetSopStage()
  14530. return nil
  14531. case messagerecords.EdgeSopNode:
  14532. m.ResetSopNode()
  14533. return nil
  14534. case messagerecords.EdgeMessageContact:
  14535. m.ResetMessageContact()
  14536. return nil
  14537. }
  14538. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14539. }
  14540. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14541. type MsgMutation struct {
  14542. config
  14543. op Op
  14544. typ string
  14545. id *uint64
  14546. created_at *time.Time
  14547. updated_at *time.Time
  14548. deleted_at *time.Time
  14549. status *uint8
  14550. addstatus *int8
  14551. fromwxid *string
  14552. toid *string
  14553. msgtype *int32
  14554. addmsgtype *int32
  14555. msg *string
  14556. batch_no *string
  14557. clearedFields map[string]struct{}
  14558. done bool
  14559. oldValue func(context.Context) (*Msg, error)
  14560. predicates []predicate.Msg
  14561. }
  14562. var _ ent.Mutation = (*MsgMutation)(nil)
  14563. // msgOption allows management of the mutation configuration using functional options.
  14564. type msgOption func(*MsgMutation)
  14565. // newMsgMutation creates new mutation for the Msg entity.
  14566. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14567. m := &MsgMutation{
  14568. config: c,
  14569. op: op,
  14570. typ: TypeMsg,
  14571. clearedFields: make(map[string]struct{}),
  14572. }
  14573. for _, opt := range opts {
  14574. opt(m)
  14575. }
  14576. return m
  14577. }
  14578. // withMsgID sets the ID field of the mutation.
  14579. func withMsgID(id uint64) msgOption {
  14580. return func(m *MsgMutation) {
  14581. var (
  14582. err error
  14583. once sync.Once
  14584. value *Msg
  14585. )
  14586. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14587. once.Do(func() {
  14588. if m.done {
  14589. err = errors.New("querying old values post mutation is not allowed")
  14590. } else {
  14591. value, err = m.Client().Msg.Get(ctx, id)
  14592. }
  14593. })
  14594. return value, err
  14595. }
  14596. m.id = &id
  14597. }
  14598. }
  14599. // withMsg sets the old Msg of the mutation.
  14600. func withMsg(node *Msg) msgOption {
  14601. return func(m *MsgMutation) {
  14602. m.oldValue = func(context.Context) (*Msg, error) {
  14603. return node, nil
  14604. }
  14605. m.id = &node.ID
  14606. }
  14607. }
  14608. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14609. // executed in a transaction (ent.Tx), a transactional client is returned.
  14610. func (m MsgMutation) Client() *Client {
  14611. client := &Client{config: m.config}
  14612. client.init()
  14613. return client
  14614. }
  14615. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14616. // it returns an error otherwise.
  14617. func (m MsgMutation) Tx() (*Tx, error) {
  14618. if _, ok := m.driver.(*txDriver); !ok {
  14619. return nil, errors.New("ent: mutation is not running in a transaction")
  14620. }
  14621. tx := &Tx{config: m.config}
  14622. tx.init()
  14623. return tx, nil
  14624. }
  14625. // SetID sets the value of the id field. Note that this
  14626. // operation is only accepted on creation of Msg entities.
  14627. func (m *MsgMutation) SetID(id uint64) {
  14628. m.id = &id
  14629. }
  14630. // ID returns the ID value in the mutation. Note that the ID is only available
  14631. // if it was provided to the builder or after it was returned from the database.
  14632. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14633. if m.id == nil {
  14634. return
  14635. }
  14636. return *m.id, true
  14637. }
  14638. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14639. // That means, if the mutation is applied within a transaction with an isolation level such
  14640. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14641. // or updated by the mutation.
  14642. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14643. switch {
  14644. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14645. id, exists := m.ID()
  14646. if exists {
  14647. return []uint64{id}, nil
  14648. }
  14649. fallthrough
  14650. case m.op.Is(OpUpdate | OpDelete):
  14651. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14652. default:
  14653. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14654. }
  14655. }
  14656. // SetCreatedAt sets the "created_at" field.
  14657. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14658. m.created_at = &t
  14659. }
  14660. // CreatedAt returns the value of the "created_at" field in the mutation.
  14661. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14662. v := m.created_at
  14663. if v == nil {
  14664. return
  14665. }
  14666. return *v, true
  14667. }
  14668. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14669. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14671. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14672. if !m.op.Is(OpUpdateOne) {
  14673. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14674. }
  14675. if m.id == nil || m.oldValue == nil {
  14676. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14677. }
  14678. oldValue, err := m.oldValue(ctx)
  14679. if err != nil {
  14680. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14681. }
  14682. return oldValue.CreatedAt, nil
  14683. }
  14684. // ResetCreatedAt resets all changes to the "created_at" field.
  14685. func (m *MsgMutation) ResetCreatedAt() {
  14686. m.created_at = nil
  14687. }
  14688. // SetUpdatedAt sets the "updated_at" field.
  14689. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14690. m.updated_at = &t
  14691. }
  14692. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14693. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14694. v := m.updated_at
  14695. if v == nil {
  14696. return
  14697. }
  14698. return *v, true
  14699. }
  14700. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14701. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14703. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14704. if !m.op.Is(OpUpdateOne) {
  14705. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14706. }
  14707. if m.id == nil || m.oldValue == nil {
  14708. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14709. }
  14710. oldValue, err := m.oldValue(ctx)
  14711. if err != nil {
  14712. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14713. }
  14714. return oldValue.UpdatedAt, nil
  14715. }
  14716. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14717. func (m *MsgMutation) ResetUpdatedAt() {
  14718. m.updated_at = nil
  14719. }
  14720. // SetDeletedAt sets the "deleted_at" field.
  14721. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14722. m.deleted_at = &t
  14723. }
  14724. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14725. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14726. v := m.deleted_at
  14727. if v == nil {
  14728. return
  14729. }
  14730. return *v, true
  14731. }
  14732. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14733. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14735. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14736. if !m.op.Is(OpUpdateOne) {
  14737. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14738. }
  14739. if m.id == nil || m.oldValue == nil {
  14740. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14741. }
  14742. oldValue, err := m.oldValue(ctx)
  14743. if err != nil {
  14744. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14745. }
  14746. return oldValue.DeletedAt, nil
  14747. }
  14748. // ClearDeletedAt clears the value of the "deleted_at" field.
  14749. func (m *MsgMutation) ClearDeletedAt() {
  14750. m.deleted_at = nil
  14751. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14752. }
  14753. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14754. func (m *MsgMutation) DeletedAtCleared() bool {
  14755. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14756. return ok
  14757. }
  14758. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14759. func (m *MsgMutation) ResetDeletedAt() {
  14760. m.deleted_at = nil
  14761. delete(m.clearedFields, msg.FieldDeletedAt)
  14762. }
  14763. // SetStatus sets the "status" field.
  14764. func (m *MsgMutation) SetStatus(u uint8) {
  14765. m.status = &u
  14766. m.addstatus = nil
  14767. }
  14768. // Status returns the value of the "status" field in the mutation.
  14769. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14770. v := m.status
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  14780. if !m.op.Is(OpUpdateOne) {
  14781. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14782. }
  14783. if m.id == nil || m.oldValue == nil {
  14784. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  14789. }
  14790. return oldValue.Status, nil
  14791. }
  14792. // AddStatus adds u to the "status" field.
  14793. func (m *MsgMutation) AddStatus(u int8) {
  14794. if m.addstatus != nil {
  14795. *m.addstatus += u
  14796. } else {
  14797. m.addstatus = &u
  14798. }
  14799. }
  14800. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14801. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14802. v := m.addstatus
  14803. if v == nil {
  14804. return
  14805. }
  14806. return *v, true
  14807. }
  14808. // ClearStatus clears the value of the "status" field.
  14809. func (m *MsgMutation) ClearStatus() {
  14810. m.status = nil
  14811. m.addstatus = nil
  14812. m.clearedFields[msg.FieldStatus] = struct{}{}
  14813. }
  14814. // StatusCleared returns if the "status" field was cleared in this mutation.
  14815. func (m *MsgMutation) StatusCleared() bool {
  14816. _, ok := m.clearedFields[msg.FieldStatus]
  14817. return ok
  14818. }
  14819. // ResetStatus resets all changes to the "status" field.
  14820. func (m *MsgMutation) ResetStatus() {
  14821. m.status = nil
  14822. m.addstatus = nil
  14823. delete(m.clearedFields, msg.FieldStatus)
  14824. }
  14825. // SetFromwxid sets the "fromwxid" field.
  14826. func (m *MsgMutation) SetFromwxid(s string) {
  14827. m.fromwxid = &s
  14828. }
  14829. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14830. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14831. v := m.fromwxid
  14832. if v == nil {
  14833. return
  14834. }
  14835. return *v, true
  14836. }
  14837. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14838. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14840. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14841. if !m.op.Is(OpUpdateOne) {
  14842. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14843. }
  14844. if m.id == nil || m.oldValue == nil {
  14845. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14846. }
  14847. oldValue, err := m.oldValue(ctx)
  14848. if err != nil {
  14849. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14850. }
  14851. return oldValue.Fromwxid, nil
  14852. }
  14853. // ClearFromwxid clears the value of the "fromwxid" field.
  14854. func (m *MsgMutation) ClearFromwxid() {
  14855. m.fromwxid = nil
  14856. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14857. }
  14858. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14859. func (m *MsgMutation) FromwxidCleared() bool {
  14860. _, ok := m.clearedFields[msg.FieldFromwxid]
  14861. return ok
  14862. }
  14863. // ResetFromwxid resets all changes to the "fromwxid" field.
  14864. func (m *MsgMutation) ResetFromwxid() {
  14865. m.fromwxid = nil
  14866. delete(m.clearedFields, msg.FieldFromwxid)
  14867. }
  14868. // SetToid sets the "toid" field.
  14869. func (m *MsgMutation) SetToid(s string) {
  14870. m.toid = &s
  14871. }
  14872. // Toid returns the value of the "toid" field in the mutation.
  14873. func (m *MsgMutation) Toid() (r string, exists bool) {
  14874. v := m.toid
  14875. if v == nil {
  14876. return
  14877. }
  14878. return *v, true
  14879. }
  14880. // OldToid returns the old "toid" field's value of the Msg entity.
  14881. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14883. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  14884. if !m.op.Is(OpUpdateOne) {
  14885. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  14886. }
  14887. if m.id == nil || m.oldValue == nil {
  14888. return v, errors.New("OldToid requires an ID field in the mutation")
  14889. }
  14890. oldValue, err := m.oldValue(ctx)
  14891. if err != nil {
  14892. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  14893. }
  14894. return oldValue.Toid, nil
  14895. }
  14896. // ClearToid clears the value of the "toid" field.
  14897. func (m *MsgMutation) ClearToid() {
  14898. m.toid = nil
  14899. m.clearedFields[msg.FieldToid] = struct{}{}
  14900. }
  14901. // ToidCleared returns if the "toid" field was cleared in this mutation.
  14902. func (m *MsgMutation) ToidCleared() bool {
  14903. _, ok := m.clearedFields[msg.FieldToid]
  14904. return ok
  14905. }
  14906. // ResetToid resets all changes to the "toid" field.
  14907. func (m *MsgMutation) ResetToid() {
  14908. m.toid = nil
  14909. delete(m.clearedFields, msg.FieldToid)
  14910. }
  14911. // SetMsgtype sets the "msgtype" field.
  14912. func (m *MsgMutation) SetMsgtype(i int32) {
  14913. m.msgtype = &i
  14914. m.addmsgtype = nil
  14915. }
  14916. // Msgtype returns the value of the "msgtype" field in the mutation.
  14917. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  14918. v := m.msgtype
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  14925. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  14937. }
  14938. return oldValue.Msgtype, nil
  14939. }
  14940. // AddMsgtype adds i to the "msgtype" field.
  14941. func (m *MsgMutation) AddMsgtype(i int32) {
  14942. if m.addmsgtype != nil {
  14943. *m.addmsgtype += i
  14944. } else {
  14945. m.addmsgtype = &i
  14946. }
  14947. }
  14948. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  14949. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  14950. v := m.addmsgtype
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearMsgtype clears the value of the "msgtype" field.
  14957. func (m *MsgMutation) ClearMsgtype() {
  14958. m.msgtype = nil
  14959. m.addmsgtype = nil
  14960. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  14961. }
  14962. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  14963. func (m *MsgMutation) MsgtypeCleared() bool {
  14964. _, ok := m.clearedFields[msg.FieldMsgtype]
  14965. return ok
  14966. }
  14967. // ResetMsgtype resets all changes to the "msgtype" field.
  14968. func (m *MsgMutation) ResetMsgtype() {
  14969. m.msgtype = nil
  14970. m.addmsgtype = nil
  14971. delete(m.clearedFields, msg.FieldMsgtype)
  14972. }
  14973. // SetMsg sets the "msg" field.
  14974. func (m *MsgMutation) SetMsg(s string) {
  14975. m.msg = &s
  14976. }
  14977. // Msg returns the value of the "msg" field in the mutation.
  14978. func (m *MsgMutation) Msg() (r string, exists bool) {
  14979. v := m.msg
  14980. if v == nil {
  14981. return
  14982. }
  14983. return *v, true
  14984. }
  14985. // OldMsg returns the old "msg" field's value of the Msg entity.
  14986. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14988. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  14989. if !m.op.Is(OpUpdateOne) {
  14990. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  14991. }
  14992. if m.id == nil || m.oldValue == nil {
  14993. return v, errors.New("OldMsg requires an ID field in the mutation")
  14994. }
  14995. oldValue, err := m.oldValue(ctx)
  14996. if err != nil {
  14997. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  14998. }
  14999. return oldValue.Msg, nil
  15000. }
  15001. // ClearMsg clears the value of the "msg" field.
  15002. func (m *MsgMutation) ClearMsg() {
  15003. m.msg = nil
  15004. m.clearedFields[msg.FieldMsg] = struct{}{}
  15005. }
  15006. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15007. func (m *MsgMutation) MsgCleared() bool {
  15008. _, ok := m.clearedFields[msg.FieldMsg]
  15009. return ok
  15010. }
  15011. // ResetMsg resets all changes to the "msg" field.
  15012. func (m *MsgMutation) ResetMsg() {
  15013. m.msg = nil
  15014. delete(m.clearedFields, msg.FieldMsg)
  15015. }
  15016. // SetBatchNo sets the "batch_no" field.
  15017. func (m *MsgMutation) SetBatchNo(s string) {
  15018. m.batch_no = &s
  15019. }
  15020. // BatchNo returns the value of the "batch_no" field in the mutation.
  15021. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15022. v := m.batch_no
  15023. if v == nil {
  15024. return
  15025. }
  15026. return *v, true
  15027. }
  15028. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15029. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15031. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15032. if !m.op.Is(OpUpdateOne) {
  15033. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15034. }
  15035. if m.id == nil || m.oldValue == nil {
  15036. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15037. }
  15038. oldValue, err := m.oldValue(ctx)
  15039. if err != nil {
  15040. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15041. }
  15042. return oldValue.BatchNo, nil
  15043. }
  15044. // ClearBatchNo clears the value of the "batch_no" field.
  15045. func (m *MsgMutation) ClearBatchNo() {
  15046. m.batch_no = nil
  15047. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15048. }
  15049. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15050. func (m *MsgMutation) BatchNoCleared() bool {
  15051. _, ok := m.clearedFields[msg.FieldBatchNo]
  15052. return ok
  15053. }
  15054. // ResetBatchNo resets all changes to the "batch_no" field.
  15055. func (m *MsgMutation) ResetBatchNo() {
  15056. m.batch_no = nil
  15057. delete(m.clearedFields, msg.FieldBatchNo)
  15058. }
  15059. // Where appends a list predicates to the MsgMutation builder.
  15060. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15061. m.predicates = append(m.predicates, ps...)
  15062. }
  15063. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15064. // users can use type-assertion to append predicates that do not depend on any generated package.
  15065. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15066. p := make([]predicate.Msg, len(ps))
  15067. for i := range ps {
  15068. p[i] = ps[i]
  15069. }
  15070. m.Where(p...)
  15071. }
  15072. // Op returns the operation name.
  15073. func (m *MsgMutation) Op() Op {
  15074. return m.op
  15075. }
  15076. // SetOp allows setting the mutation operation.
  15077. func (m *MsgMutation) SetOp(op Op) {
  15078. m.op = op
  15079. }
  15080. // Type returns the node type of this mutation (Msg).
  15081. func (m *MsgMutation) Type() string {
  15082. return m.typ
  15083. }
  15084. // Fields returns all fields that were changed during this mutation. Note that in
  15085. // order to get all numeric fields that were incremented/decremented, call
  15086. // AddedFields().
  15087. func (m *MsgMutation) Fields() []string {
  15088. fields := make([]string, 0, 9)
  15089. if m.created_at != nil {
  15090. fields = append(fields, msg.FieldCreatedAt)
  15091. }
  15092. if m.updated_at != nil {
  15093. fields = append(fields, msg.FieldUpdatedAt)
  15094. }
  15095. if m.deleted_at != nil {
  15096. fields = append(fields, msg.FieldDeletedAt)
  15097. }
  15098. if m.status != nil {
  15099. fields = append(fields, msg.FieldStatus)
  15100. }
  15101. if m.fromwxid != nil {
  15102. fields = append(fields, msg.FieldFromwxid)
  15103. }
  15104. if m.toid != nil {
  15105. fields = append(fields, msg.FieldToid)
  15106. }
  15107. if m.msgtype != nil {
  15108. fields = append(fields, msg.FieldMsgtype)
  15109. }
  15110. if m.msg != nil {
  15111. fields = append(fields, msg.FieldMsg)
  15112. }
  15113. if m.batch_no != nil {
  15114. fields = append(fields, msg.FieldBatchNo)
  15115. }
  15116. return fields
  15117. }
  15118. // Field returns the value of a field with the given name. The second boolean
  15119. // return value indicates that this field was not set, or was not defined in the
  15120. // schema.
  15121. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15122. switch name {
  15123. case msg.FieldCreatedAt:
  15124. return m.CreatedAt()
  15125. case msg.FieldUpdatedAt:
  15126. return m.UpdatedAt()
  15127. case msg.FieldDeletedAt:
  15128. return m.DeletedAt()
  15129. case msg.FieldStatus:
  15130. return m.Status()
  15131. case msg.FieldFromwxid:
  15132. return m.Fromwxid()
  15133. case msg.FieldToid:
  15134. return m.Toid()
  15135. case msg.FieldMsgtype:
  15136. return m.Msgtype()
  15137. case msg.FieldMsg:
  15138. return m.Msg()
  15139. case msg.FieldBatchNo:
  15140. return m.BatchNo()
  15141. }
  15142. return nil, false
  15143. }
  15144. // OldField returns the old value of the field from the database. An error is
  15145. // returned if the mutation operation is not UpdateOne, or the query to the
  15146. // database failed.
  15147. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15148. switch name {
  15149. case msg.FieldCreatedAt:
  15150. return m.OldCreatedAt(ctx)
  15151. case msg.FieldUpdatedAt:
  15152. return m.OldUpdatedAt(ctx)
  15153. case msg.FieldDeletedAt:
  15154. return m.OldDeletedAt(ctx)
  15155. case msg.FieldStatus:
  15156. return m.OldStatus(ctx)
  15157. case msg.FieldFromwxid:
  15158. return m.OldFromwxid(ctx)
  15159. case msg.FieldToid:
  15160. return m.OldToid(ctx)
  15161. case msg.FieldMsgtype:
  15162. return m.OldMsgtype(ctx)
  15163. case msg.FieldMsg:
  15164. return m.OldMsg(ctx)
  15165. case msg.FieldBatchNo:
  15166. return m.OldBatchNo(ctx)
  15167. }
  15168. return nil, fmt.Errorf("unknown Msg field %s", name)
  15169. }
  15170. // SetField sets the value of a field with the given name. It returns an error if
  15171. // the field is not defined in the schema, or if the type mismatched the field
  15172. // type.
  15173. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15174. switch name {
  15175. case msg.FieldCreatedAt:
  15176. v, ok := value.(time.Time)
  15177. if !ok {
  15178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15179. }
  15180. m.SetCreatedAt(v)
  15181. return nil
  15182. case msg.FieldUpdatedAt:
  15183. v, ok := value.(time.Time)
  15184. if !ok {
  15185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15186. }
  15187. m.SetUpdatedAt(v)
  15188. return nil
  15189. case msg.FieldDeletedAt:
  15190. v, ok := value.(time.Time)
  15191. if !ok {
  15192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15193. }
  15194. m.SetDeletedAt(v)
  15195. return nil
  15196. case msg.FieldStatus:
  15197. v, ok := value.(uint8)
  15198. if !ok {
  15199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15200. }
  15201. m.SetStatus(v)
  15202. return nil
  15203. case msg.FieldFromwxid:
  15204. v, ok := value.(string)
  15205. if !ok {
  15206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15207. }
  15208. m.SetFromwxid(v)
  15209. return nil
  15210. case msg.FieldToid:
  15211. v, ok := value.(string)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.SetToid(v)
  15216. return nil
  15217. case msg.FieldMsgtype:
  15218. v, ok := value.(int32)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.SetMsgtype(v)
  15223. return nil
  15224. case msg.FieldMsg:
  15225. v, ok := value.(string)
  15226. if !ok {
  15227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15228. }
  15229. m.SetMsg(v)
  15230. return nil
  15231. case msg.FieldBatchNo:
  15232. v, ok := value.(string)
  15233. if !ok {
  15234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15235. }
  15236. m.SetBatchNo(v)
  15237. return nil
  15238. }
  15239. return fmt.Errorf("unknown Msg field %s", name)
  15240. }
  15241. // AddedFields returns all numeric fields that were incremented/decremented during
  15242. // this mutation.
  15243. func (m *MsgMutation) AddedFields() []string {
  15244. var fields []string
  15245. if m.addstatus != nil {
  15246. fields = append(fields, msg.FieldStatus)
  15247. }
  15248. if m.addmsgtype != nil {
  15249. fields = append(fields, msg.FieldMsgtype)
  15250. }
  15251. return fields
  15252. }
  15253. // AddedField returns the numeric value that was incremented/decremented on a field
  15254. // with the given name. The second boolean return value indicates that this field
  15255. // was not set, or was not defined in the schema.
  15256. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15257. switch name {
  15258. case msg.FieldStatus:
  15259. return m.AddedStatus()
  15260. case msg.FieldMsgtype:
  15261. return m.AddedMsgtype()
  15262. }
  15263. return nil, false
  15264. }
  15265. // AddField adds the value to the field with the given name. It returns an error if
  15266. // the field is not defined in the schema, or if the type mismatched the field
  15267. // type.
  15268. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15269. switch name {
  15270. case msg.FieldStatus:
  15271. v, ok := value.(int8)
  15272. if !ok {
  15273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15274. }
  15275. m.AddStatus(v)
  15276. return nil
  15277. case msg.FieldMsgtype:
  15278. v, ok := value.(int32)
  15279. if !ok {
  15280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15281. }
  15282. m.AddMsgtype(v)
  15283. return nil
  15284. }
  15285. return fmt.Errorf("unknown Msg numeric field %s", name)
  15286. }
  15287. // ClearedFields returns all nullable fields that were cleared during this
  15288. // mutation.
  15289. func (m *MsgMutation) ClearedFields() []string {
  15290. var fields []string
  15291. if m.FieldCleared(msg.FieldDeletedAt) {
  15292. fields = append(fields, msg.FieldDeletedAt)
  15293. }
  15294. if m.FieldCleared(msg.FieldStatus) {
  15295. fields = append(fields, msg.FieldStatus)
  15296. }
  15297. if m.FieldCleared(msg.FieldFromwxid) {
  15298. fields = append(fields, msg.FieldFromwxid)
  15299. }
  15300. if m.FieldCleared(msg.FieldToid) {
  15301. fields = append(fields, msg.FieldToid)
  15302. }
  15303. if m.FieldCleared(msg.FieldMsgtype) {
  15304. fields = append(fields, msg.FieldMsgtype)
  15305. }
  15306. if m.FieldCleared(msg.FieldMsg) {
  15307. fields = append(fields, msg.FieldMsg)
  15308. }
  15309. if m.FieldCleared(msg.FieldBatchNo) {
  15310. fields = append(fields, msg.FieldBatchNo)
  15311. }
  15312. return fields
  15313. }
  15314. // FieldCleared returns a boolean indicating if a field with the given name was
  15315. // cleared in this mutation.
  15316. func (m *MsgMutation) FieldCleared(name string) bool {
  15317. _, ok := m.clearedFields[name]
  15318. return ok
  15319. }
  15320. // ClearField clears the value of the field with the given name. It returns an
  15321. // error if the field is not defined in the schema.
  15322. func (m *MsgMutation) ClearField(name string) error {
  15323. switch name {
  15324. case msg.FieldDeletedAt:
  15325. m.ClearDeletedAt()
  15326. return nil
  15327. case msg.FieldStatus:
  15328. m.ClearStatus()
  15329. return nil
  15330. case msg.FieldFromwxid:
  15331. m.ClearFromwxid()
  15332. return nil
  15333. case msg.FieldToid:
  15334. m.ClearToid()
  15335. return nil
  15336. case msg.FieldMsgtype:
  15337. m.ClearMsgtype()
  15338. return nil
  15339. case msg.FieldMsg:
  15340. m.ClearMsg()
  15341. return nil
  15342. case msg.FieldBatchNo:
  15343. m.ClearBatchNo()
  15344. return nil
  15345. }
  15346. return fmt.Errorf("unknown Msg nullable field %s", name)
  15347. }
  15348. // ResetField resets all changes in the mutation for the field with the given name.
  15349. // It returns an error if the field is not defined in the schema.
  15350. func (m *MsgMutation) ResetField(name string) error {
  15351. switch name {
  15352. case msg.FieldCreatedAt:
  15353. m.ResetCreatedAt()
  15354. return nil
  15355. case msg.FieldUpdatedAt:
  15356. m.ResetUpdatedAt()
  15357. return nil
  15358. case msg.FieldDeletedAt:
  15359. m.ResetDeletedAt()
  15360. return nil
  15361. case msg.FieldStatus:
  15362. m.ResetStatus()
  15363. return nil
  15364. case msg.FieldFromwxid:
  15365. m.ResetFromwxid()
  15366. return nil
  15367. case msg.FieldToid:
  15368. m.ResetToid()
  15369. return nil
  15370. case msg.FieldMsgtype:
  15371. m.ResetMsgtype()
  15372. return nil
  15373. case msg.FieldMsg:
  15374. m.ResetMsg()
  15375. return nil
  15376. case msg.FieldBatchNo:
  15377. m.ResetBatchNo()
  15378. return nil
  15379. }
  15380. return fmt.Errorf("unknown Msg field %s", name)
  15381. }
  15382. // AddedEdges returns all edge names that were set/added in this mutation.
  15383. func (m *MsgMutation) AddedEdges() []string {
  15384. edges := make([]string, 0, 0)
  15385. return edges
  15386. }
  15387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15388. // name in this mutation.
  15389. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15390. return nil
  15391. }
  15392. // RemovedEdges returns all edge names that were removed in this mutation.
  15393. func (m *MsgMutation) RemovedEdges() []string {
  15394. edges := make([]string, 0, 0)
  15395. return edges
  15396. }
  15397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15398. // the given name in this mutation.
  15399. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15400. return nil
  15401. }
  15402. // ClearedEdges returns all edge names that were cleared in this mutation.
  15403. func (m *MsgMutation) ClearedEdges() []string {
  15404. edges := make([]string, 0, 0)
  15405. return edges
  15406. }
  15407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15408. // was cleared in this mutation.
  15409. func (m *MsgMutation) EdgeCleared(name string) bool {
  15410. return false
  15411. }
  15412. // ClearEdge clears the value of the edge with the given name. It returns an error
  15413. // if that edge is not defined in the schema.
  15414. func (m *MsgMutation) ClearEdge(name string) error {
  15415. return fmt.Errorf("unknown Msg unique edge %s", name)
  15416. }
  15417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15418. // It returns an error if the edge is not defined in the schema.
  15419. func (m *MsgMutation) ResetEdge(name string) error {
  15420. return fmt.Errorf("unknown Msg edge %s", name)
  15421. }
  15422. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15423. type ServerMutation struct {
  15424. config
  15425. op Op
  15426. typ string
  15427. id *uint64
  15428. created_at *time.Time
  15429. updated_at *time.Time
  15430. status *uint8
  15431. addstatus *int8
  15432. deleted_at *time.Time
  15433. name *string
  15434. public_ip *string
  15435. private_ip *string
  15436. admin_port *string
  15437. clearedFields map[string]struct{}
  15438. wxs map[uint64]struct{}
  15439. removedwxs map[uint64]struct{}
  15440. clearedwxs bool
  15441. done bool
  15442. oldValue func(context.Context) (*Server, error)
  15443. predicates []predicate.Server
  15444. }
  15445. var _ ent.Mutation = (*ServerMutation)(nil)
  15446. // serverOption allows management of the mutation configuration using functional options.
  15447. type serverOption func(*ServerMutation)
  15448. // newServerMutation creates new mutation for the Server entity.
  15449. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15450. m := &ServerMutation{
  15451. config: c,
  15452. op: op,
  15453. typ: TypeServer,
  15454. clearedFields: make(map[string]struct{}),
  15455. }
  15456. for _, opt := range opts {
  15457. opt(m)
  15458. }
  15459. return m
  15460. }
  15461. // withServerID sets the ID field of the mutation.
  15462. func withServerID(id uint64) serverOption {
  15463. return func(m *ServerMutation) {
  15464. var (
  15465. err error
  15466. once sync.Once
  15467. value *Server
  15468. )
  15469. m.oldValue = func(ctx context.Context) (*Server, error) {
  15470. once.Do(func() {
  15471. if m.done {
  15472. err = errors.New("querying old values post mutation is not allowed")
  15473. } else {
  15474. value, err = m.Client().Server.Get(ctx, id)
  15475. }
  15476. })
  15477. return value, err
  15478. }
  15479. m.id = &id
  15480. }
  15481. }
  15482. // withServer sets the old Server of the mutation.
  15483. func withServer(node *Server) serverOption {
  15484. return func(m *ServerMutation) {
  15485. m.oldValue = func(context.Context) (*Server, error) {
  15486. return node, nil
  15487. }
  15488. m.id = &node.ID
  15489. }
  15490. }
  15491. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15492. // executed in a transaction (ent.Tx), a transactional client is returned.
  15493. func (m ServerMutation) Client() *Client {
  15494. client := &Client{config: m.config}
  15495. client.init()
  15496. return client
  15497. }
  15498. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15499. // it returns an error otherwise.
  15500. func (m ServerMutation) Tx() (*Tx, error) {
  15501. if _, ok := m.driver.(*txDriver); !ok {
  15502. return nil, errors.New("ent: mutation is not running in a transaction")
  15503. }
  15504. tx := &Tx{config: m.config}
  15505. tx.init()
  15506. return tx, nil
  15507. }
  15508. // SetID sets the value of the id field. Note that this
  15509. // operation is only accepted on creation of Server entities.
  15510. func (m *ServerMutation) SetID(id uint64) {
  15511. m.id = &id
  15512. }
  15513. // ID returns the ID value in the mutation. Note that the ID is only available
  15514. // if it was provided to the builder or after it was returned from the database.
  15515. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15516. if m.id == nil {
  15517. return
  15518. }
  15519. return *m.id, true
  15520. }
  15521. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15522. // That means, if the mutation is applied within a transaction with an isolation level such
  15523. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15524. // or updated by the mutation.
  15525. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15526. switch {
  15527. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15528. id, exists := m.ID()
  15529. if exists {
  15530. return []uint64{id}, nil
  15531. }
  15532. fallthrough
  15533. case m.op.Is(OpUpdate | OpDelete):
  15534. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15535. default:
  15536. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15537. }
  15538. }
  15539. // SetCreatedAt sets the "created_at" field.
  15540. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15541. m.created_at = &t
  15542. }
  15543. // CreatedAt returns the value of the "created_at" field in the mutation.
  15544. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15545. v := m.created_at
  15546. if v == nil {
  15547. return
  15548. }
  15549. return *v, true
  15550. }
  15551. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15552. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15554. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15555. if !m.op.Is(OpUpdateOne) {
  15556. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15557. }
  15558. if m.id == nil || m.oldValue == nil {
  15559. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15560. }
  15561. oldValue, err := m.oldValue(ctx)
  15562. if err != nil {
  15563. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15564. }
  15565. return oldValue.CreatedAt, nil
  15566. }
  15567. // ResetCreatedAt resets all changes to the "created_at" field.
  15568. func (m *ServerMutation) ResetCreatedAt() {
  15569. m.created_at = nil
  15570. }
  15571. // SetUpdatedAt sets the "updated_at" field.
  15572. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15573. m.updated_at = &t
  15574. }
  15575. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15576. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15577. v := m.updated_at
  15578. if v == nil {
  15579. return
  15580. }
  15581. return *v, true
  15582. }
  15583. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15584. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15586. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15587. if !m.op.Is(OpUpdateOne) {
  15588. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15589. }
  15590. if m.id == nil || m.oldValue == nil {
  15591. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15592. }
  15593. oldValue, err := m.oldValue(ctx)
  15594. if err != nil {
  15595. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15596. }
  15597. return oldValue.UpdatedAt, nil
  15598. }
  15599. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15600. func (m *ServerMutation) ResetUpdatedAt() {
  15601. m.updated_at = nil
  15602. }
  15603. // SetStatus sets the "status" field.
  15604. func (m *ServerMutation) SetStatus(u uint8) {
  15605. m.status = &u
  15606. m.addstatus = nil
  15607. }
  15608. // Status returns the value of the "status" field in the mutation.
  15609. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15610. v := m.status
  15611. if v == nil {
  15612. return
  15613. }
  15614. return *v, true
  15615. }
  15616. // OldStatus returns the old "status" field's value of the Server entity.
  15617. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15619. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15620. if !m.op.Is(OpUpdateOne) {
  15621. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15622. }
  15623. if m.id == nil || m.oldValue == nil {
  15624. return v, errors.New("OldStatus requires an ID field in the mutation")
  15625. }
  15626. oldValue, err := m.oldValue(ctx)
  15627. if err != nil {
  15628. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15629. }
  15630. return oldValue.Status, nil
  15631. }
  15632. // AddStatus adds u to the "status" field.
  15633. func (m *ServerMutation) AddStatus(u int8) {
  15634. if m.addstatus != nil {
  15635. *m.addstatus += u
  15636. } else {
  15637. m.addstatus = &u
  15638. }
  15639. }
  15640. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15641. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15642. v := m.addstatus
  15643. if v == nil {
  15644. return
  15645. }
  15646. return *v, true
  15647. }
  15648. // ClearStatus clears the value of the "status" field.
  15649. func (m *ServerMutation) ClearStatus() {
  15650. m.status = nil
  15651. m.addstatus = nil
  15652. m.clearedFields[server.FieldStatus] = struct{}{}
  15653. }
  15654. // StatusCleared returns if the "status" field was cleared in this mutation.
  15655. func (m *ServerMutation) StatusCleared() bool {
  15656. _, ok := m.clearedFields[server.FieldStatus]
  15657. return ok
  15658. }
  15659. // ResetStatus resets all changes to the "status" field.
  15660. func (m *ServerMutation) ResetStatus() {
  15661. m.status = nil
  15662. m.addstatus = nil
  15663. delete(m.clearedFields, server.FieldStatus)
  15664. }
  15665. // SetDeletedAt sets the "deleted_at" field.
  15666. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15667. m.deleted_at = &t
  15668. }
  15669. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15670. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15671. v := m.deleted_at
  15672. if v == nil {
  15673. return
  15674. }
  15675. return *v, true
  15676. }
  15677. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15678. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15680. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15681. if !m.op.Is(OpUpdateOne) {
  15682. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15683. }
  15684. if m.id == nil || m.oldValue == nil {
  15685. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15686. }
  15687. oldValue, err := m.oldValue(ctx)
  15688. if err != nil {
  15689. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15690. }
  15691. return oldValue.DeletedAt, nil
  15692. }
  15693. // ClearDeletedAt clears the value of the "deleted_at" field.
  15694. func (m *ServerMutation) ClearDeletedAt() {
  15695. m.deleted_at = nil
  15696. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15697. }
  15698. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15699. func (m *ServerMutation) DeletedAtCleared() bool {
  15700. _, ok := m.clearedFields[server.FieldDeletedAt]
  15701. return ok
  15702. }
  15703. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15704. func (m *ServerMutation) ResetDeletedAt() {
  15705. m.deleted_at = nil
  15706. delete(m.clearedFields, server.FieldDeletedAt)
  15707. }
  15708. // SetName sets the "name" field.
  15709. func (m *ServerMutation) SetName(s string) {
  15710. m.name = &s
  15711. }
  15712. // Name returns the value of the "name" field in the mutation.
  15713. func (m *ServerMutation) Name() (r string, exists bool) {
  15714. v := m.name
  15715. if v == nil {
  15716. return
  15717. }
  15718. return *v, true
  15719. }
  15720. // OldName returns the old "name" field's value of the Server entity.
  15721. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15723. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15724. if !m.op.Is(OpUpdateOne) {
  15725. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15726. }
  15727. if m.id == nil || m.oldValue == nil {
  15728. return v, errors.New("OldName requires an ID field in the mutation")
  15729. }
  15730. oldValue, err := m.oldValue(ctx)
  15731. if err != nil {
  15732. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15733. }
  15734. return oldValue.Name, nil
  15735. }
  15736. // ResetName resets all changes to the "name" field.
  15737. func (m *ServerMutation) ResetName() {
  15738. m.name = nil
  15739. }
  15740. // SetPublicIP sets the "public_ip" field.
  15741. func (m *ServerMutation) SetPublicIP(s string) {
  15742. m.public_ip = &s
  15743. }
  15744. // PublicIP returns the value of the "public_ip" field in the mutation.
  15745. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15746. v := m.public_ip
  15747. if v == nil {
  15748. return
  15749. }
  15750. return *v, true
  15751. }
  15752. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15753. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15755. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15756. if !m.op.Is(OpUpdateOne) {
  15757. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15758. }
  15759. if m.id == nil || m.oldValue == nil {
  15760. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15761. }
  15762. oldValue, err := m.oldValue(ctx)
  15763. if err != nil {
  15764. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15765. }
  15766. return oldValue.PublicIP, nil
  15767. }
  15768. // ResetPublicIP resets all changes to the "public_ip" field.
  15769. func (m *ServerMutation) ResetPublicIP() {
  15770. m.public_ip = nil
  15771. }
  15772. // SetPrivateIP sets the "private_ip" field.
  15773. func (m *ServerMutation) SetPrivateIP(s string) {
  15774. m.private_ip = &s
  15775. }
  15776. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15777. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15778. v := m.private_ip
  15779. if v == nil {
  15780. return
  15781. }
  15782. return *v, true
  15783. }
  15784. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15785. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15787. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15788. if !m.op.Is(OpUpdateOne) {
  15789. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15790. }
  15791. if m.id == nil || m.oldValue == nil {
  15792. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15793. }
  15794. oldValue, err := m.oldValue(ctx)
  15795. if err != nil {
  15796. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15797. }
  15798. return oldValue.PrivateIP, nil
  15799. }
  15800. // ResetPrivateIP resets all changes to the "private_ip" field.
  15801. func (m *ServerMutation) ResetPrivateIP() {
  15802. m.private_ip = nil
  15803. }
  15804. // SetAdminPort sets the "admin_port" field.
  15805. func (m *ServerMutation) SetAdminPort(s string) {
  15806. m.admin_port = &s
  15807. }
  15808. // AdminPort returns the value of the "admin_port" field in the mutation.
  15809. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15810. v := m.admin_port
  15811. if v == nil {
  15812. return
  15813. }
  15814. return *v, true
  15815. }
  15816. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15817. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15819. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15820. if !m.op.Is(OpUpdateOne) {
  15821. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15822. }
  15823. if m.id == nil || m.oldValue == nil {
  15824. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15825. }
  15826. oldValue, err := m.oldValue(ctx)
  15827. if err != nil {
  15828. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15829. }
  15830. return oldValue.AdminPort, nil
  15831. }
  15832. // ResetAdminPort resets all changes to the "admin_port" field.
  15833. func (m *ServerMutation) ResetAdminPort() {
  15834. m.admin_port = nil
  15835. }
  15836. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15837. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15838. if m.wxs == nil {
  15839. m.wxs = make(map[uint64]struct{})
  15840. }
  15841. for i := range ids {
  15842. m.wxs[ids[i]] = struct{}{}
  15843. }
  15844. }
  15845. // ClearWxs clears the "wxs" edge to the Wx entity.
  15846. func (m *ServerMutation) ClearWxs() {
  15847. m.clearedwxs = true
  15848. }
  15849. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15850. func (m *ServerMutation) WxsCleared() bool {
  15851. return m.clearedwxs
  15852. }
  15853. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15854. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15855. if m.removedwxs == nil {
  15856. m.removedwxs = make(map[uint64]struct{})
  15857. }
  15858. for i := range ids {
  15859. delete(m.wxs, ids[i])
  15860. m.removedwxs[ids[i]] = struct{}{}
  15861. }
  15862. }
  15863. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15864. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15865. for id := range m.removedwxs {
  15866. ids = append(ids, id)
  15867. }
  15868. return
  15869. }
  15870. // WxsIDs returns the "wxs" edge IDs in the mutation.
  15871. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  15872. for id := range m.wxs {
  15873. ids = append(ids, id)
  15874. }
  15875. return
  15876. }
  15877. // ResetWxs resets all changes to the "wxs" edge.
  15878. func (m *ServerMutation) ResetWxs() {
  15879. m.wxs = nil
  15880. m.clearedwxs = false
  15881. m.removedwxs = nil
  15882. }
  15883. // Where appends a list predicates to the ServerMutation builder.
  15884. func (m *ServerMutation) Where(ps ...predicate.Server) {
  15885. m.predicates = append(m.predicates, ps...)
  15886. }
  15887. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  15888. // users can use type-assertion to append predicates that do not depend on any generated package.
  15889. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  15890. p := make([]predicate.Server, len(ps))
  15891. for i := range ps {
  15892. p[i] = ps[i]
  15893. }
  15894. m.Where(p...)
  15895. }
  15896. // Op returns the operation name.
  15897. func (m *ServerMutation) Op() Op {
  15898. return m.op
  15899. }
  15900. // SetOp allows setting the mutation operation.
  15901. func (m *ServerMutation) SetOp(op Op) {
  15902. m.op = op
  15903. }
  15904. // Type returns the node type of this mutation (Server).
  15905. func (m *ServerMutation) Type() string {
  15906. return m.typ
  15907. }
  15908. // Fields returns all fields that were changed during this mutation. Note that in
  15909. // order to get all numeric fields that were incremented/decremented, call
  15910. // AddedFields().
  15911. func (m *ServerMutation) Fields() []string {
  15912. fields := make([]string, 0, 8)
  15913. if m.created_at != nil {
  15914. fields = append(fields, server.FieldCreatedAt)
  15915. }
  15916. if m.updated_at != nil {
  15917. fields = append(fields, server.FieldUpdatedAt)
  15918. }
  15919. if m.status != nil {
  15920. fields = append(fields, server.FieldStatus)
  15921. }
  15922. if m.deleted_at != nil {
  15923. fields = append(fields, server.FieldDeletedAt)
  15924. }
  15925. if m.name != nil {
  15926. fields = append(fields, server.FieldName)
  15927. }
  15928. if m.public_ip != nil {
  15929. fields = append(fields, server.FieldPublicIP)
  15930. }
  15931. if m.private_ip != nil {
  15932. fields = append(fields, server.FieldPrivateIP)
  15933. }
  15934. if m.admin_port != nil {
  15935. fields = append(fields, server.FieldAdminPort)
  15936. }
  15937. return fields
  15938. }
  15939. // Field returns the value of a field with the given name. The second boolean
  15940. // return value indicates that this field was not set, or was not defined in the
  15941. // schema.
  15942. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  15943. switch name {
  15944. case server.FieldCreatedAt:
  15945. return m.CreatedAt()
  15946. case server.FieldUpdatedAt:
  15947. return m.UpdatedAt()
  15948. case server.FieldStatus:
  15949. return m.Status()
  15950. case server.FieldDeletedAt:
  15951. return m.DeletedAt()
  15952. case server.FieldName:
  15953. return m.Name()
  15954. case server.FieldPublicIP:
  15955. return m.PublicIP()
  15956. case server.FieldPrivateIP:
  15957. return m.PrivateIP()
  15958. case server.FieldAdminPort:
  15959. return m.AdminPort()
  15960. }
  15961. return nil, false
  15962. }
  15963. // OldField returns the old value of the field from the database. An error is
  15964. // returned if the mutation operation is not UpdateOne, or the query to the
  15965. // database failed.
  15966. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15967. switch name {
  15968. case server.FieldCreatedAt:
  15969. return m.OldCreatedAt(ctx)
  15970. case server.FieldUpdatedAt:
  15971. return m.OldUpdatedAt(ctx)
  15972. case server.FieldStatus:
  15973. return m.OldStatus(ctx)
  15974. case server.FieldDeletedAt:
  15975. return m.OldDeletedAt(ctx)
  15976. case server.FieldName:
  15977. return m.OldName(ctx)
  15978. case server.FieldPublicIP:
  15979. return m.OldPublicIP(ctx)
  15980. case server.FieldPrivateIP:
  15981. return m.OldPrivateIP(ctx)
  15982. case server.FieldAdminPort:
  15983. return m.OldAdminPort(ctx)
  15984. }
  15985. return nil, fmt.Errorf("unknown Server field %s", name)
  15986. }
  15987. // SetField sets the value of a field with the given name. It returns an error if
  15988. // the field is not defined in the schema, or if the type mismatched the field
  15989. // type.
  15990. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  15991. switch name {
  15992. case server.FieldCreatedAt:
  15993. v, ok := value.(time.Time)
  15994. if !ok {
  15995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15996. }
  15997. m.SetCreatedAt(v)
  15998. return nil
  15999. case server.FieldUpdatedAt:
  16000. v, ok := value.(time.Time)
  16001. if !ok {
  16002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16003. }
  16004. m.SetUpdatedAt(v)
  16005. return nil
  16006. case server.FieldStatus:
  16007. v, ok := value.(uint8)
  16008. if !ok {
  16009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16010. }
  16011. m.SetStatus(v)
  16012. return nil
  16013. case server.FieldDeletedAt:
  16014. v, ok := value.(time.Time)
  16015. if !ok {
  16016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16017. }
  16018. m.SetDeletedAt(v)
  16019. return nil
  16020. case server.FieldName:
  16021. v, ok := value.(string)
  16022. if !ok {
  16023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16024. }
  16025. m.SetName(v)
  16026. return nil
  16027. case server.FieldPublicIP:
  16028. v, ok := value.(string)
  16029. if !ok {
  16030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16031. }
  16032. m.SetPublicIP(v)
  16033. return nil
  16034. case server.FieldPrivateIP:
  16035. v, ok := value.(string)
  16036. if !ok {
  16037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16038. }
  16039. m.SetPrivateIP(v)
  16040. return nil
  16041. case server.FieldAdminPort:
  16042. v, ok := value.(string)
  16043. if !ok {
  16044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16045. }
  16046. m.SetAdminPort(v)
  16047. return nil
  16048. }
  16049. return fmt.Errorf("unknown Server field %s", name)
  16050. }
  16051. // AddedFields returns all numeric fields that were incremented/decremented during
  16052. // this mutation.
  16053. func (m *ServerMutation) AddedFields() []string {
  16054. var fields []string
  16055. if m.addstatus != nil {
  16056. fields = append(fields, server.FieldStatus)
  16057. }
  16058. return fields
  16059. }
  16060. // AddedField returns the numeric value that was incremented/decremented on a field
  16061. // with the given name. The second boolean return value indicates that this field
  16062. // was not set, or was not defined in the schema.
  16063. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16064. switch name {
  16065. case server.FieldStatus:
  16066. return m.AddedStatus()
  16067. }
  16068. return nil, false
  16069. }
  16070. // AddField adds the value to the field with the given name. It returns an error if
  16071. // the field is not defined in the schema, or if the type mismatched the field
  16072. // type.
  16073. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16074. switch name {
  16075. case server.FieldStatus:
  16076. v, ok := value.(int8)
  16077. if !ok {
  16078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16079. }
  16080. m.AddStatus(v)
  16081. return nil
  16082. }
  16083. return fmt.Errorf("unknown Server numeric field %s", name)
  16084. }
  16085. // ClearedFields returns all nullable fields that were cleared during this
  16086. // mutation.
  16087. func (m *ServerMutation) ClearedFields() []string {
  16088. var fields []string
  16089. if m.FieldCleared(server.FieldStatus) {
  16090. fields = append(fields, server.FieldStatus)
  16091. }
  16092. if m.FieldCleared(server.FieldDeletedAt) {
  16093. fields = append(fields, server.FieldDeletedAt)
  16094. }
  16095. return fields
  16096. }
  16097. // FieldCleared returns a boolean indicating if a field with the given name was
  16098. // cleared in this mutation.
  16099. func (m *ServerMutation) FieldCleared(name string) bool {
  16100. _, ok := m.clearedFields[name]
  16101. return ok
  16102. }
  16103. // ClearField clears the value of the field with the given name. It returns an
  16104. // error if the field is not defined in the schema.
  16105. func (m *ServerMutation) ClearField(name string) error {
  16106. switch name {
  16107. case server.FieldStatus:
  16108. m.ClearStatus()
  16109. return nil
  16110. case server.FieldDeletedAt:
  16111. m.ClearDeletedAt()
  16112. return nil
  16113. }
  16114. return fmt.Errorf("unknown Server nullable field %s", name)
  16115. }
  16116. // ResetField resets all changes in the mutation for the field with the given name.
  16117. // It returns an error if the field is not defined in the schema.
  16118. func (m *ServerMutation) ResetField(name string) error {
  16119. switch name {
  16120. case server.FieldCreatedAt:
  16121. m.ResetCreatedAt()
  16122. return nil
  16123. case server.FieldUpdatedAt:
  16124. m.ResetUpdatedAt()
  16125. return nil
  16126. case server.FieldStatus:
  16127. m.ResetStatus()
  16128. return nil
  16129. case server.FieldDeletedAt:
  16130. m.ResetDeletedAt()
  16131. return nil
  16132. case server.FieldName:
  16133. m.ResetName()
  16134. return nil
  16135. case server.FieldPublicIP:
  16136. m.ResetPublicIP()
  16137. return nil
  16138. case server.FieldPrivateIP:
  16139. m.ResetPrivateIP()
  16140. return nil
  16141. case server.FieldAdminPort:
  16142. m.ResetAdminPort()
  16143. return nil
  16144. }
  16145. return fmt.Errorf("unknown Server field %s", name)
  16146. }
  16147. // AddedEdges returns all edge names that were set/added in this mutation.
  16148. func (m *ServerMutation) AddedEdges() []string {
  16149. edges := make([]string, 0, 1)
  16150. if m.wxs != nil {
  16151. edges = append(edges, server.EdgeWxs)
  16152. }
  16153. return edges
  16154. }
  16155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16156. // name in this mutation.
  16157. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16158. switch name {
  16159. case server.EdgeWxs:
  16160. ids := make([]ent.Value, 0, len(m.wxs))
  16161. for id := range m.wxs {
  16162. ids = append(ids, id)
  16163. }
  16164. return ids
  16165. }
  16166. return nil
  16167. }
  16168. // RemovedEdges returns all edge names that were removed in this mutation.
  16169. func (m *ServerMutation) RemovedEdges() []string {
  16170. edges := make([]string, 0, 1)
  16171. if m.removedwxs != nil {
  16172. edges = append(edges, server.EdgeWxs)
  16173. }
  16174. return edges
  16175. }
  16176. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16177. // the given name in this mutation.
  16178. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16179. switch name {
  16180. case server.EdgeWxs:
  16181. ids := make([]ent.Value, 0, len(m.removedwxs))
  16182. for id := range m.removedwxs {
  16183. ids = append(ids, id)
  16184. }
  16185. return ids
  16186. }
  16187. return nil
  16188. }
  16189. // ClearedEdges returns all edge names that were cleared in this mutation.
  16190. func (m *ServerMutation) ClearedEdges() []string {
  16191. edges := make([]string, 0, 1)
  16192. if m.clearedwxs {
  16193. edges = append(edges, server.EdgeWxs)
  16194. }
  16195. return edges
  16196. }
  16197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16198. // was cleared in this mutation.
  16199. func (m *ServerMutation) EdgeCleared(name string) bool {
  16200. switch name {
  16201. case server.EdgeWxs:
  16202. return m.clearedwxs
  16203. }
  16204. return false
  16205. }
  16206. // ClearEdge clears the value of the edge with the given name. It returns an error
  16207. // if that edge is not defined in the schema.
  16208. func (m *ServerMutation) ClearEdge(name string) error {
  16209. switch name {
  16210. }
  16211. return fmt.Errorf("unknown Server unique edge %s", name)
  16212. }
  16213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16214. // It returns an error if the edge is not defined in the schema.
  16215. func (m *ServerMutation) ResetEdge(name string) error {
  16216. switch name {
  16217. case server.EdgeWxs:
  16218. m.ResetWxs()
  16219. return nil
  16220. }
  16221. return fmt.Errorf("unknown Server edge %s", name)
  16222. }
  16223. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16224. type SopNodeMutation struct {
  16225. config
  16226. op Op
  16227. typ string
  16228. id *uint64
  16229. created_at *time.Time
  16230. updated_at *time.Time
  16231. status *uint8
  16232. addstatus *int8
  16233. deleted_at *time.Time
  16234. parent_id *uint64
  16235. addparent_id *int64
  16236. name *string
  16237. condition_type *int
  16238. addcondition_type *int
  16239. condition_list *[]string
  16240. appendcondition_list []string
  16241. no_reply_condition *uint64
  16242. addno_reply_condition *int64
  16243. no_reply_unit *string
  16244. action_message *[]custom_types.Action
  16245. appendaction_message []custom_types.Action
  16246. action_label_add *[]uint64
  16247. appendaction_label_add []uint64
  16248. action_label_del *[]uint64
  16249. appendaction_label_del []uint64
  16250. action_forward **custom_types.ActionForward
  16251. clearedFields map[string]struct{}
  16252. sop_stage *uint64
  16253. clearedsop_stage bool
  16254. node_messages map[uint64]struct{}
  16255. removednode_messages map[uint64]struct{}
  16256. clearednode_messages bool
  16257. done bool
  16258. oldValue func(context.Context) (*SopNode, error)
  16259. predicates []predicate.SopNode
  16260. }
  16261. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16262. // sopnodeOption allows management of the mutation configuration using functional options.
  16263. type sopnodeOption func(*SopNodeMutation)
  16264. // newSopNodeMutation creates new mutation for the SopNode entity.
  16265. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16266. m := &SopNodeMutation{
  16267. config: c,
  16268. op: op,
  16269. typ: TypeSopNode,
  16270. clearedFields: make(map[string]struct{}),
  16271. }
  16272. for _, opt := range opts {
  16273. opt(m)
  16274. }
  16275. return m
  16276. }
  16277. // withSopNodeID sets the ID field of the mutation.
  16278. func withSopNodeID(id uint64) sopnodeOption {
  16279. return func(m *SopNodeMutation) {
  16280. var (
  16281. err error
  16282. once sync.Once
  16283. value *SopNode
  16284. )
  16285. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16286. once.Do(func() {
  16287. if m.done {
  16288. err = errors.New("querying old values post mutation is not allowed")
  16289. } else {
  16290. value, err = m.Client().SopNode.Get(ctx, id)
  16291. }
  16292. })
  16293. return value, err
  16294. }
  16295. m.id = &id
  16296. }
  16297. }
  16298. // withSopNode sets the old SopNode of the mutation.
  16299. func withSopNode(node *SopNode) sopnodeOption {
  16300. return func(m *SopNodeMutation) {
  16301. m.oldValue = func(context.Context) (*SopNode, error) {
  16302. return node, nil
  16303. }
  16304. m.id = &node.ID
  16305. }
  16306. }
  16307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16308. // executed in a transaction (ent.Tx), a transactional client is returned.
  16309. func (m SopNodeMutation) Client() *Client {
  16310. client := &Client{config: m.config}
  16311. client.init()
  16312. return client
  16313. }
  16314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16315. // it returns an error otherwise.
  16316. func (m SopNodeMutation) Tx() (*Tx, error) {
  16317. if _, ok := m.driver.(*txDriver); !ok {
  16318. return nil, errors.New("ent: mutation is not running in a transaction")
  16319. }
  16320. tx := &Tx{config: m.config}
  16321. tx.init()
  16322. return tx, nil
  16323. }
  16324. // SetID sets the value of the id field. Note that this
  16325. // operation is only accepted on creation of SopNode entities.
  16326. func (m *SopNodeMutation) SetID(id uint64) {
  16327. m.id = &id
  16328. }
  16329. // ID returns the ID value in the mutation. Note that the ID is only available
  16330. // if it was provided to the builder or after it was returned from the database.
  16331. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16332. if m.id == nil {
  16333. return
  16334. }
  16335. return *m.id, true
  16336. }
  16337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16338. // That means, if the mutation is applied within a transaction with an isolation level such
  16339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16340. // or updated by the mutation.
  16341. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16342. switch {
  16343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16344. id, exists := m.ID()
  16345. if exists {
  16346. return []uint64{id}, nil
  16347. }
  16348. fallthrough
  16349. case m.op.Is(OpUpdate | OpDelete):
  16350. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16351. default:
  16352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16353. }
  16354. }
  16355. // SetCreatedAt sets the "created_at" field.
  16356. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16357. m.created_at = &t
  16358. }
  16359. // CreatedAt returns the value of the "created_at" field in the mutation.
  16360. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16361. v := m.created_at
  16362. if v == nil {
  16363. return
  16364. }
  16365. return *v, true
  16366. }
  16367. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16368. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16370. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16371. if !m.op.Is(OpUpdateOne) {
  16372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16373. }
  16374. if m.id == nil || m.oldValue == nil {
  16375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16376. }
  16377. oldValue, err := m.oldValue(ctx)
  16378. if err != nil {
  16379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16380. }
  16381. return oldValue.CreatedAt, nil
  16382. }
  16383. // ResetCreatedAt resets all changes to the "created_at" field.
  16384. func (m *SopNodeMutation) ResetCreatedAt() {
  16385. m.created_at = nil
  16386. }
  16387. // SetUpdatedAt sets the "updated_at" field.
  16388. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16389. m.updated_at = &t
  16390. }
  16391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16392. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16393. v := m.updated_at
  16394. if v == nil {
  16395. return
  16396. }
  16397. return *v, true
  16398. }
  16399. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16400. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16402. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16403. if !m.op.Is(OpUpdateOne) {
  16404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16405. }
  16406. if m.id == nil || m.oldValue == nil {
  16407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16408. }
  16409. oldValue, err := m.oldValue(ctx)
  16410. if err != nil {
  16411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16412. }
  16413. return oldValue.UpdatedAt, nil
  16414. }
  16415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16416. func (m *SopNodeMutation) ResetUpdatedAt() {
  16417. m.updated_at = nil
  16418. }
  16419. // SetStatus sets the "status" field.
  16420. func (m *SopNodeMutation) SetStatus(u uint8) {
  16421. m.status = &u
  16422. m.addstatus = nil
  16423. }
  16424. // Status returns the value of the "status" field in the mutation.
  16425. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16426. v := m.status
  16427. if v == nil {
  16428. return
  16429. }
  16430. return *v, true
  16431. }
  16432. // OldStatus returns the old "status" field's value of the SopNode entity.
  16433. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16435. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16436. if !m.op.Is(OpUpdateOne) {
  16437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16438. }
  16439. if m.id == nil || m.oldValue == nil {
  16440. return v, errors.New("OldStatus requires an ID field in the mutation")
  16441. }
  16442. oldValue, err := m.oldValue(ctx)
  16443. if err != nil {
  16444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16445. }
  16446. return oldValue.Status, nil
  16447. }
  16448. // AddStatus adds u to the "status" field.
  16449. func (m *SopNodeMutation) AddStatus(u int8) {
  16450. if m.addstatus != nil {
  16451. *m.addstatus += u
  16452. } else {
  16453. m.addstatus = &u
  16454. }
  16455. }
  16456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16457. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16458. v := m.addstatus
  16459. if v == nil {
  16460. return
  16461. }
  16462. return *v, true
  16463. }
  16464. // ClearStatus clears the value of the "status" field.
  16465. func (m *SopNodeMutation) ClearStatus() {
  16466. m.status = nil
  16467. m.addstatus = nil
  16468. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16469. }
  16470. // StatusCleared returns if the "status" field was cleared in this mutation.
  16471. func (m *SopNodeMutation) StatusCleared() bool {
  16472. _, ok := m.clearedFields[sopnode.FieldStatus]
  16473. return ok
  16474. }
  16475. // ResetStatus resets all changes to the "status" field.
  16476. func (m *SopNodeMutation) ResetStatus() {
  16477. m.status = nil
  16478. m.addstatus = nil
  16479. delete(m.clearedFields, sopnode.FieldStatus)
  16480. }
  16481. // SetDeletedAt sets the "deleted_at" field.
  16482. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16483. m.deleted_at = &t
  16484. }
  16485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16486. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16487. v := m.deleted_at
  16488. if v == nil {
  16489. return
  16490. }
  16491. return *v, true
  16492. }
  16493. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16496. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16497. if !m.op.Is(OpUpdateOne) {
  16498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16499. }
  16500. if m.id == nil || m.oldValue == nil {
  16501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16502. }
  16503. oldValue, err := m.oldValue(ctx)
  16504. if err != nil {
  16505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16506. }
  16507. return oldValue.DeletedAt, nil
  16508. }
  16509. // ClearDeletedAt clears the value of the "deleted_at" field.
  16510. func (m *SopNodeMutation) ClearDeletedAt() {
  16511. m.deleted_at = nil
  16512. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16513. }
  16514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16515. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16516. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16517. return ok
  16518. }
  16519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16520. func (m *SopNodeMutation) ResetDeletedAt() {
  16521. m.deleted_at = nil
  16522. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16523. }
  16524. // SetStageID sets the "stage_id" field.
  16525. func (m *SopNodeMutation) SetStageID(u uint64) {
  16526. m.sop_stage = &u
  16527. }
  16528. // StageID returns the value of the "stage_id" field in the mutation.
  16529. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16530. v := m.sop_stage
  16531. if v == nil {
  16532. return
  16533. }
  16534. return *v, true
  16535. }
  16536. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16537. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16539. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16540. if !m.op.Is(OpUpdateOne) {
  16541. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16542. }
  16543. if m.id == nil || m.oldValue == nil {
  16544. return v, errors.New("OldStageID requires an ID field in the mutation")
  16545. }
  16546. oldValue, err := m.oldValue(ctx)
  16547. if err != nil {
  16548. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16549. }
  16550. return oldValue.StageID, nil
  16551. }
  16552. // ResetStageID resets all changes to the "stage_id" field.
  16553. func (m *SopNodeMutation) ResetStageID() {
  16554. m.sop_stage = nil
  16555. }
  16556. // SetParentID sets the "parent_id" field.
  16557. func (m *SopNodeMutation) SetParentID(u uint64) {
  16558. m.parent_id = &u
  16559. m.addparent_id = nil
  16560. }
  16561. // ParentID returns the value of the "parent_id" field in the mutation.
  16562. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16563. v := m.parent_id
  16564. if v == nil {
  16565. return
  16566. }
  16567. return *v, true
  16568. }
  16569. // OldParentID returns the old "parent_id" 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) OldParentID(ctx context.Context) (v uint64, err error) {
  16573. if !m.op.Is(OpUpdateOne) {
  16574. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16575. }
  16576. if m.id == nil || m.oldValue == nil {
  16577. return v, errors.New("OldParentID 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 OldParentID: %w", err)
  16582. }
  16583. return oldValue.ParentID, nil
  16584. }
  16585. // AddParentID adds u to the "parent_id" field.
  16586. func (m *SopNodeMutation) AddParentID(u int64) {
  16587. if m.addparent_id != nil {
  16588. *m.addparent_id += u
  16589. } else {
  16590. m.addparent_id = &u
  16591. }
  16592. }
  16593. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16594. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16595. v := m.addparent_id
  16596. if v == nil {
  16597. return
  16598. }
  16599. return *v, true
  16600. }
  16601. // ResetParentID resets all changes to the "parent_id" field.
  16602. func (m *SopNodeMutation) ResetParentID() {
  16603. m.parent_id = nil
  16604. m.addparent_id = nil
  16605. }
  16606. // SetName sets the "name" field.
  16607. func (m *SopNodeMutation) SetName(s string) {
  16608. m.name = &s
  16609. }
  16610. // Name returns the value of the "name" field in the mutation.
  16611. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16612. v := m.name
  16613. if v == nil {
  16614. return
  16615. }
  16616. return *v, true
  16617. }
  16618. // OldName returns the old "name" field's value of the SopNode entity.
  16619. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16621. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16622. if !m.op.Is(OpUpdateOne) {
  16623. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16624. }
  16625. if m.id == nil || m.oldValue == nil {
  16626. return v, errors.New("OldName requires an ID field in the mutation")
  16627. }
  16628. oldValue, err := m.oldValue(ctx)
  16629. if err != nil {
  16630. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16631. }
  16632. return oldValue.Name, nil
  16633. }
  16634. // ResetName resets all changes to the "name" field.
  16635. func (m *SopNodeMutation) ResetName() {
  16636. m.name = nil
  16637. }
  16638. // SetConditionType sets the "condition_type" field.
  16639. func (m *SopNodeMutation) SetConditionType(i int) {
  16640. m.condition_type = &i
  16641. m.addcondition_type = nil
  16642. }
  16643. // ConditionType returns the value of the "condition_type" field in the mutation.
  16644. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16645. v := m.condition_type
  16646. if v == nil {
  16647. return
  16648. }
  16649. return *v, true
  16650. }
  16651. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16652. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16654. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16655. if !m.op.Is(OpUpdateOne) {
  16656. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16657. }
  16658. if m.id == nil || m.oldValue == nil {
  16659. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16660. }
  16661. oldValue, err := m.oldValue(ctx)
  16662. if err != nil {
  16663. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16664. }
  16665. return oldValue.ConditionType, nil
  16666. }
  16667. // AddConditionType adds i to the "condition_type" field.
  16668. func (m *SopNodeMutation) AddConditionType(i int) {
  16669. if m.addcondition_type != nil {
  16670. *m.addcondition_type += i
  16671. } else {
  16672. m.addcondition_type = &i
  16673. }
  16674. }
  16675. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16676. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16677. v := m.addcondition_type
  16678. if v == nil {
  16679. return
  16680. }
  16681. return *v, true
  16682. }
  16683. // ResetConditionType resets all changes to the "condition_type" field.
  16684. func (m *SopNodeMutation) ResetConditionType() {
  16685. m.condition_type = nil
  16686. m.addcondition_type = nil
  16687. }
  16688. // SetConditionList sets the "condition_list" field.
  16689. func (m *SopNodeMutation) SetConditionList(s []string) {
  16690. m.condition_list = &s
  16691. m.appendcondition_list = nil
  16692. }
  16693. // ConditionList returns the value of the "condition_list" field in the mutation.
  16694. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16695. v := m.condition_list
  16696. if v == nil {
  16697. return
  16698. }
  16699. return *v, true
  16700. }
  16701. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16702. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16704. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16705. if !m.op.Is(OpUpdateOne) {
  16706. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16707. }
  16708. if m.id == nil || m.oldValue == nil {
  16709. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16710. }
  16711. oldValue, err := m.oldValue(ctx)
  16712. if err != nil {
  16713. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16714. }
  16715. return oldValue.ConditionList, nil
  16716. }
  16717. // AppendConditionList adds s to the "condition_list" field.
  16718. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16719. m.appendcondition_list = append(m.appendcondition_list, s...)
  16720. }
  16721. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16722. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16723. if len(m.appendcondition_list) == 0 {
  16724. return nil, false
  16725. }
  16726. return m.appendcondition_list, true
  16727. }
  16728. // ClearConditionList clears the value of the "condition_list" field.
  16729. func (m *SopNodeMutation) ClearConditionList() {
  16730. m.condition_list = nil
  16731. m.appendcondition_list = nil
  16732. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16733. }
  16734. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16735. func (m *SopNodeMutation) ConditionListCleared() bool {
  16736. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16737. return ok
  16738. }
  16739. // ResetConditionList resets all changes to the "condition_list" field.
  16740. func (m *SopNodeMutation) ResetConditionList() {
  16741. m.condition_list = nil
  16742. m.appendcondition_list = nil
  16743. delete(m.clearedFields, sopnode.FieldConditionList)
  16744. }
  16745. // SetNoReplyCondition sets the "no_reply_condition" field.
  16746. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16747. m.no_reply_condition = &u
  16748. m.addno_reply_condition = nil
  16749. }
  16750. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16751. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16752. v := m.no_reply_condition
  16753. if v == nil {
  16754. return
  16755. }
  16756. return *v, true
  16757. }
  16758. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16759. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16761. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16762. if !m.op.Is(OpUpdateOne) {
  16763. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16764. }
  16765. if m.id == nil || m.oldValue == nil {
  16766. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16767. }
  16768. oldValue, err := m.oldValue(ctx)
  16769. if err != nil {
  16770. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16771. }
  16772. return oldValue.NoReplyCondition, nil
  16773. }
  16774. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16775. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16776. if m.addno_reply_condition != nil {
  16777. *m.addno_reply_condition += u
  16778. } else {
  16779. m.addno_reply_condition = &u
  16780. }
  16781. }
  16782. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16783. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16784. v := m.addno_reply_condition
  16785. if v == nil {
  16786. return
  16787. }
  16788. return *v, true
  16789. }
  16790. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16791. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16792. m.no_reply_condition = nil
  16793. m.addno_reply_condition = nil
  16794. }
  16795. // SetNoReplyUnit sets the "no_reply_unit" field.
  16796. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16797. m.no_reply_unit = &s
  16798. }
  16799. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16800. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16801. v := m.no_reply_unit
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16808. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16820. }
  16821. return oldValue.NoReplyUnit, nil
  16822. }
  16823. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16824. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16825. m.no_reply_unit = nil
  16826. }
  16827. // SetActionMessage sets the "action_message" field.
  16828. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16829. m.action_message = &ct
  16830. m.appendaction_message = nil
  16831. }
  16832. // ActionMessage returns the value of the "action_message" field in the mutation.
  16833. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16834. v := m.action_message
  16835. if v == nil {
  16836. return
  16837. }
  16838. return *v, true
  16839. }
  16840. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16843. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16844. if !m.op.Is(OpUpdateOne) {
  16845. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16846. }
  16847. if m.id == nil || m.oldValue == nil {
  16848. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16849. }
  16850. oldValue, err := m.oldValue(ctx)
  16851. if err != nil {
  16852. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16853. }
  16854. return oldValue.ActionMessage, nil
  16855. }
  16856. // AppendActionMessage adds ct to the "action_message" field.
  16857. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16858. m.appendaction_message = append(m.appendaction_message, ct...)
  16859. }
  16860. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16861. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16862. if len(m.appendaction_message) == 0 {
  16863. return nil, false
  16864. }
  16865. return m.appendaction_message, true
  16866. }
  16867. // ClearActionMessage clears the value of the "action_message" field.
  16868. func (m *SopNodeMutation) ClearActionMessage() {
  16869. m.action_message = nil
  16870. m.appendaction_message = nil
  16871. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  16872. }
  16873. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  16874. func (m *SopNodeMutation) ActionMessageCleared() bool {
  16875. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  16876. return ok
  16877. }
  16878. // ResetActionMessage resets all changes to the "action_message" field.
  16879. func (m *SopNodeMutation) ResetActionMessage() {
  16880. m.action_message = nil
  16881. m.appendaction_message = nil
  16882. delete(m.clearedFields, sopnode.FieldActionMessage)
  16883. }
  16884. // SetActionLabelAdd sets the "action_label_add" field.
  16885. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  16886. m.action_label_add = &u
  16887. m.appendaction_label_add = nil
  16888. }
  16889. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16890. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16891. v := m.action_label_add
  16892. if v == nil {
  16893. return
  16894. }
  16895. return *v, true
  16896. }
  16897. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  16898. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16900. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16901. if !m.op.Is(OpUpdateOne) {
  16902. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16903. }
  16904. if m.id == nil || m.oldValue == nil {
  16905. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16906. }
  16907. oldValue, err := m.oldValue(ctx)
  16908. if err != nil {
  16909. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16910. }
  16911. return oldValue.ActionLabelAdd, nil
  16912. }
  16913. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16914. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  16915. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16916. }
  16917. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16918. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16919. if len(m.appendaction_label_add) == 0 {
  16920. return nil, false
  16921. }
  16922. return m.appendaction_label_add, true
  16923. }
  16924. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16925. func (m *SopNodeMutation) ClearActionLabelAdd() {
  16926. m.action_label_add = nil
  16927. m.appendaction_label_add = nil
  16928. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  16929. }
  16930. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16931. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  16932. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  16933. return ok
  16934. }
  16935. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16936. func (m *SopNodeMutation) ResetActionLabelAdd() {
  16937. m.action_label_add = nil
  16938. m.appendaction_label_add = nil
  16939. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  16940. }
  16941. // SetActionLabelDel sets the "action_label_del" field.
  16942. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  16943. m.action_label_del = &u
  16944. m.appendaction_label_del = nil
  16945. }
  16946. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16947. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  16948. v := m.action_label_del
  16949. if v == nil {
  16950. return
  16951. }
  16952. return *v, true
  16953. }
  16954. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  16955. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16957. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16958. if !m.op.Is(OpUpdateOne) {
  16959. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16960. }
  16961. if m.id == nil || m.oldValue == nil {
  16962. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16963. }
  16964. oldValue, err := m.oldValue(ctx)
  16965. if err != nil {
  16966. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16967. }
  16968. return oldValue.ActionLabelDel, nil
  16969. }
  16970. // AppendActionLabelDel adds u to the "action_label_del" field.
  16971. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  16972. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16973. }
  16974. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16975. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16976. if len(m.appendaction_label_del) == 0 {
  16977. return nil, false
  16978. }
  16979. return m.appendaction_label_del, true
  16980. }
  16981. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16982. func (m *SopNodeMutation) ClearActionLabelDel() {
  16983. m.action_label_del = nil
  16984. m.appendaction_label_del = nil
  16985. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  16986. }
  16987. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16988. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  16989. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  16990. return ok
  16991. }
  16992. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16993. func (m *SopNodeMutation) ResetActionLabelDel() {
  16994. m.action_label_del = nil
  16995. m.appendaction_label_del = nil
  16996. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  16997. }
  16998. // SetActionForward sets the "action_forward" field.
  16999. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17000. m.action_forward = &ctf
  17001. }
  17002. // ActionForward returns the value of the "action_forward" field in the mutation.
  17003. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17004. v := m.action_forward
  17005. if v == nil {
  17006. return
  17007. }
  17008. return *v, true
  17009. }
  17010. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17011. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17013. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17014. if !m.op.Is(OpUpdateOne) {
  17015. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17016. }
  17017. if m.id == nil || m.oldValue == nil {
  17018. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17019. }
  17020. oldValue, err := m.oldValue(ctx)
  17021. if err != nil {
  17022. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17023. }
  17024. return oldValue.ActionForward, nil
  17025. }
  17026. // ClearActionForward clears the value of the "action_forward" field.
  17027. func (m *SopNodeMutation) ClearActionForward() {
  17028. m.action_forward = nil
  17029. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17030. }
  17031. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17032. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17033. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17034. return ok
  17035. }
  17036. // ResetActionForward resets all changes to the "action_forward" field.
  17037. func (m *SopNodeMutation) ResetActionForward() {
  17038. m.action_forward = nil
  17039. delete(m.clearedFields, sopnode.FieldActionForward)
  17040. }
  17041. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17042. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17043. m.sop_stage = &id
  17044. }
  17045. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17046. func (m *SopNodeMutation) ClearSopStage() {
  17047. m.clearedsop_stage = true
  17048. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17049. }
  17050. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17051. func (m *SopNodeMutation) SopStageCleared() bool {
  17052. return m.clearedsop_stage
  17053. }
  17054. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17055. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17056. if m.sop_stage != nil {
  17057. return *m.sop_stage, true
  17058. }
  17059. return
  17060. }
  17061. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17062. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17063. // SopStageID instead. It exists only for internal usage by the builders.
  17064. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17065. if id := m.sop_stage; id != nil {
  17066. ids = append(ids, *id)
  17067. }
  17068. return
  17069. }
  17070. // ResetSopStage resets all changes to the "sop_stage" edge.
  17071. func (m *SopNodeMutation) ResetSopStage() {
  17072. m.sop_stage = nil
  17073. m.clearedsop_stage = false
  17074. }
  17075. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17076. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17077. if m.node_messages == nil {
  17078. m.node_messages = make(map[uint64]struct{})
  17079. }
  17080. for i := range ids {
  17081. m.node_messages[ids[i]] = struct{}{}
  17082. }
  17083. }
  17084. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17085. func (m *SopNodeMutation) ClearNodeMessages() {
  17086. m.clearednode_messages = true
  17087. }
  17088. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17089. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17090. return m.clearednode_messages
  17091. }
  17092. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17093. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17094. if m.removednode_messages == nil {
  17095. m.removednode_messages = make(map[uint64]struct{})
  17096. }
  17097. for i := range ids {
  17098. delete(m.node_messages, ids[i])
  17099. m.removednode_messages[ids[i]] = struct{}{}
  17100. }
  17101. }
  17102. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17103. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17104. for id := range m.removednode_messages {
  17105. ids = append(ids, id)
  17106. }
  17107. return
  17108. }
  17109. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17110. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17111. for id := range m.node_messages {
  17112. ids = append(ids, id)
  17113. }
  17114. return
  17115. }
  17116. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17117. func (m *SopNodeMutation) ResetNodeMessages() {
  17118. m.node_messages = nil
  17119. m.clearednode_messages = false
  17120. m.removednode_messages = nil
  17121. }
  17122. // Where appends a list predicates to the SopNodeMutation builder.
  17123. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17124. m.predicates = append(m.predicates, ps...)
  17125. }
  17126. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17127. // users can use type-assertion to append predicates that do not depend on any generated package.
  17128. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17129. p := make([]predicate.SopNode, len(ps))
  17130. for i := range ps {
  17131. p[i] = ps[i]
  17132. }
  17133. m.Where(p...)
  17134. }
  17135. // Op returns the operation name.
  17136. func (m *SopNodeMutation) Op() Op {
  17137. return m.op
  17138. }
  17139. // SetOp allows setting the mutation operation.
  17140. func (m *SopNodeMutation) SetOp(op Op) {
  17141. m.op = op
  17142. }
  17143. // Type returns the node type of this mutation (SopNode).
  17144. func (m *SopNodeMutation) Type() string {
  17145. return m.typ
  17146. }
  17147. // Fields returns all fields that were changed during this mutation. Note that in
  17148. // order to get all numeric fields that were incremented/decremented, call
  17149. // AddedFields().
  17150. func (m *SopNodeMutation) Fields() []string {
  17151. fields := make([]string, 0, 15)
  17152. if m.created_at != nil {
  17153. fields = append(fields, sopnode.FieldCreatedAt)
  17154. }
  17155. if m.updated_at != nil {
  17156. fields = append(fields, sopnode.FieldUpdatedAt)
  17157. }
  17158. if m.status != nil {
  17159. fields = append(fields, sopnode.FieldStatus)
  17160. }
  17161. if m.deleted_at != nil {
  17162. fields = append(fields, sopnode.FieldDeletedAt)
  17163. }
  17164. if m.sop_stage != nil {
  17165. fields = append(fields, sopnode.FieldStageID)
  17166. }
  17167. if m.parent_id != nil {
  17168. fields = append(fields, sopnode.FieldParentID)
  17169. }
  17170. if m.name != nil {
  17171. fields = append(fields, sopnode.FieldName)
  17172. }
  17173. if m.condition_type != nil {
  17174. fields = append(fields, sopnode.FieldConditionType)
  17175. }
  17176. if m.condition_list != nil {
  17177. fields = append(fields, sopnode.FieldConditionList)
  17178. }
  17179. if m.no_reply_condition != nil {
  17180. fields = append(fields, sopnode.FieldNoReplyCondition)
  17181. }
  17182. if m.no_reply_unit != nil {
  17183. fields = append(fields, sopnode.FieldNoReplyUnit)
  17184. }
  17185. if m.action_message != nil {
  17186. fields = append(fields, sopnode.FieldActionMessage)
  17187. }
  17188. if m.action_label_add != nil {
  17189. fields = append(fields, sopnode.FieldActionLabelAdd)
  17190. }
  17191. if m.action_label_del != nil {
  17192. fields = append(fields, sopnode.FieldActionLabelDel)
  17193. }
  17194. if m.action_forward != nil {
  17195. fields = append(fields, sopnode.FieldActionForward)
  17196. }
  17197. return fields
  17198. }
  17199. // Field returns the value of a field with the given name. The second boolean
  17200. // return value indicates that this field was not set, or was not defined in the
  17201. // schema.
  17202. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17203. switch name {
  17204. case sopnode.FieldCreatedAt:
  17205. return m.CreatedAt()
  17206. case sopnode.FieldUpdatedAt:
  17207. return m.UpdatedAt()
  17208. case sopnode.FieldStatus:
  17209. return m.Status()
  17210. case sopnode.FieldDeletedAt:
  17211. return m.DeletedAt()
  17212. case sopnode.FieldStageID:
  17213. return m.StageID()
  17214. case sopnode.FieldParentID:
  17215. return m.ParentID()
  17216. case sopnode.FieldName:
  17217. return m.Name()
  17218. case sopnode.FieldConditionType:
  17219. return m.ConditionType()
  17220. case sopnode.FieldConditionList:
  17221. return m.ConditionList()
  17222. case sopnode.FieldNoReplyCondition:
  17223. return m.NoReplyCondition()
  17224. case sopnode.FieldNoReplyUnit:
  17225. return m.NoReplyUnit()
  17226. case sopnode.FieldActionMessage:
  17227. return m.ActionMessage()
  17228. case sopnode.FieldActionLabelAdd:
  17229. return m.ActionLabelAdd()
  17230. case sopnode.FieldActionLabelDel:
  17231. return m.ActionLabelDel()
  17232. case sopnode.FieldActionForward:
  17233. return m.ActionForward()
  17234. }
  17235. return nil, false
  17236. }
  17237. // OldField returns the old value of the field from the database. An error is
  17238. // returned if the mutation operation is not UpdateOne, or the query to the
  17239. // database failed.
  17240. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17241. switch name {
  17242. case sopnode.FieldCreatedAt:
  17243. return m.OldCreatedAt(ctx)
  17244. case sopnode.FieldUpdatedAt:
  17245. return m.OldUpdatedAt(ctx)
  17246. case sopnode.FieldStatus:
  17247. return m.OldStatus(ctx)
  17248. case sopnode.FieldDeletedAt:
  17249. return m.OldDeletedAt(ctx)
  17250. case sopnode.FieldStageID:
  17251. return m.OldStageID(ctx)
  17252. case sopnode.FieldParentID:
  17253. return m.OldParentID(ctx)
  17254. case sopnode.FieldName:
  17255. return m.OldName(ctx)
  17256. case sopnode.FieldConditionType:
  17257. return m.OldConditionType(ctx)
  17258. case sopnode.FieldConditionList:
  17259. return m.OldConditionList(ctx)
  17260. case sopnode.FieldNoReplyCondition:
  17261. return m.OldNoReplyCondition(ctx)
  17262. case sopnode.FieldNoReplyUnit:
  17263. return m.OldNoReplyUnit(ctx)
  17264. case sopnode.FieldActionMessage:
  17265. return m.OldActionMessage(ctx)
  17266. case sopnode.FieldActionLabelAdd:
  17267. return m.OldActionLabelAdd(ctx)
  17268. case sopnode.FieldActionLabelDel:
  17269. return m.OldActionLabelDel(ctx)
  17270. case sopnode.FieldActionForward:
  17271. return m.OldActionForward(ctx)
  17272. }
  17273. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17274. }
  17275. // SetField sets the value of a field with the given name. It returns an error if
  17276. // the field is not defined in the schema, or if the type mismatched the field
  17277. // type.
  17278. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17279. switch name {
  17280. case sopnode.FieldCreatedAt:
  17281. v, ok := value.(time.Time)
  17282. if !ok {
  17283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17284. }
  17285. m.SetCreatedAt(v)
  17286. return nil
  17287. case sopnode.FieldUpdatedAt:
  17288. v, ok := value.(time.Time)
  17289. if !ok {
  17290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17291. }
  17292. m.SetUpdatedAt(v)
  17293. return nil
  17294. case sopnode.FieldStatus:
  17295. v, ok := value.(uint8)
  17296. if !ok {
  17297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17298. }
  17299. m.SetStatus(v)
  17300. return nil
  17301. case sopnode.FieldDeletedAt:
  17302. v, ok := value.(time.Time)
  17303. if !ok {
  17304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17305. }
  17306. m.SetDeletedAt(v)
  17307. return nil
  17308. case sopnode.FieldStageID:
  17309. v, ok := value.(uint64)
  17310. if !ok {
  17311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17312. }
  17313. m.SetStageID(v)
  17314. return nil
  17315. case sopnode.FieldParentID:
  17316. v, ok := value.(uint64)
  17317. if !ok {
  17318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17319. }
  17320. m.SetParentID(v)
  17321. return nil
  17322. case sopnode.FieldName:
  17323. v, ok := value.(string)
  17324. if !ok {
  17325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17326. }
  17327. m.SetName(v)
  17328. return nil
  17329. case sopnode.FieldConditionType:
  17330. v, ok := value.(int)
  17331. if !ok {
  17332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17333. }
  17334. m.SetConditionType(v)
  17335. return nil
  17336. case sopnode.FieldConditionList:
  17337. v, ok := value.([]string)
  17338. if !ok {
  17339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17340. }
  17341. m.SetConditionList(v)
  17342. return nil
  17343. case sopnode.FieldNoReplyCondition:
  17344. v, ok := value.(uint64)
  17345. if !ok {
  17346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17347. }
  17348. m.SetNoReplyCondition(v)
  17349. return nil
  17350. case sopnode.FieldNoReplyUnit:
  17351. v, ok := value.(string)
  17352. if !ok {
  17353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17354. }
  17355. m.SetNoReplyUnit(v)
  17356. return nil
  17357. case sopnode.FieldActionMessage:
  17358. v, ok := value.([]custom_types.Action)
  17359. if !ok {
  17360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17361. }
  17362. m.SetActionMessage(v)
  17363. return nil
  17364. case sopnode.FieldActionLabelAdd:
  17365. v, ok := value.([]uint64)
  17366. if !ok {
  17367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17368. }
  17369. m.SetActionLabelAdd(v)
  17370. return nil
  17371. case sopnode.FieldActionLabelDel:
  17372. v, ok := value.([]uint64)
  17373. if !ok {
  17374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17375. }
  17376. m.SetActionLabelDel(v)
  17377. return nil
  17378. case sopnode.FieldActionForward:
  17379. v, ok := value.(*custom_types.ActionForward)
  17380. if !ok {
  17381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17382. }
  17383. m.SetActionForward(v)
  17384. return nil
  17385. }
  17386. return fmt.Errorf("unknown SopNode field %s", name)
  17387. }
  17388. // AddedFields returns all numeric fields that were incremented/decremented during
  17389. // this mutation.
  17390. func (m *SopNodeMutation) AddedFields() []string {
  17391. var fields []string
  17392. if m.addstatus != nil {
  17393. fields = append(fields, sopnode.FieldStatus)
  17394. }
  17395. if m.addparent_id != nil {
  17396. fields = append(fields, sopnode.FieldParentID)
  17397. }
  17398. if m.addcondition_type != nil {
  17399. fields = append(fields, sopnode.FieldConditionType)
  17400. }
  17401. if m.addno_reply_condition != nil {
  17402. fields = append(fields, sopnode.FieldNoReplyCondition)
  17403. }
  17404. return fields
  17405. }
  17406. // AddedField returns the numeric value that was incremented/decremented on a field
  17407. // with the given name. The second boolean return value indicates that this field
  17408. // was not set, or was not defined in the schema.
  17409. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17410. switch name {
  17411. case sopnode.FieldStatus:
  17412. return m.AddedStatus()
  17413. case sopnode.FieldParentID:
  17414. return m.AddedParentID()
  17415. case sopnode.FieldConditionType:
  17416. return m.AddedConditionType()
  17417. case sopnode.FieldNoReplyCondition:
  17418. return m.AddedNoReplyCondition()
  17419. }
  17420. return nil, false
  17421. }
  17422. // AddField adds the value to the field with the given name. It returns an error if
  17423. // the field is not defined in the schema, or if the type mismatched the field
  17424. // type.
  17425. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17426. switch name {
  17427. case sopnode.FieldStatus:
  17428. v, ok := value.(int8)
  17429. if !ok {
  17430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17431. }
  17432. m.AddStatus(v)
  17433. return nil
  17434. case sopnode.FieldParentID:
  17435. v, ok := value.(int64)
  17436. if !ok {
  17437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17438. }
  17439. m.AddParentID(v)
  17440. return nil
  17441. case sopnode.FieldConditionType:
  17442. v, ok := value.(int)
  17443. if !ok {
  17444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17445. }
  17446. m.AddConditionType(v)
  17447. return nil
  17448. case sopnode.FieldNoReplyCondition:
  17449. v, ok := value.(int64)
  17450. if !ok {
  17451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17452. }
  17453. m.AddNoReplyCondition(v)
  17454. return nil
  17455. }
  17456. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17457. }
  17458. // ClearedFields returns all nullable fields that were cleared during this
  17459. // mutation.
  17460. func (m *SopNodeMutation) ClearedFields() []string {
  17461. var fields []string
  17462. if m.FieldCleared(sopnode.FieldStatus) {
  17463. fields = append(fields, sopnode.FieldStatus)
  17464. }
  17465. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17466. fields = append(fields, sopnode.FieldDeletedAt)
  17467. }
  17468. if m.FieldCleared(sopnode.FieldConditionList) {
  17469. fields = append(fields, sopnode.FieldConditionList)
  17470. }
  17471. if m.FieldCleared(sopnode.FieldActionMessage) {
  17472. fields = append(fields, sopnode.FieldActionMessage)
  17473. }
  17474. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17475. fields = append(fields, sopnode.FieldActionLabelAdd)
  17476. }
  17477. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17478. fields = append(fields, sopnode.FieldActionLabelDel)
  17479. }
  17480. if m.FieldCleared(sopnode.FieldActionForward) {
  17481. fields = append(fields, sopnode.FieldActionForward)
  17482. }
  17483. return fields
  17484. }
  17485. // FieldCleared returns a boolean indicating if a field with the given name was
  17486. // cleared in this mutation.
  17487. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17488. _, ok := m.clearedFields[name]
  17489. return ok
  17490. }
  17491. // ClearField clears the value of the field with the given name. It returns an
  17492. // error if the field is not defined in the schema.
  17493. func (m *SopNodeMutation) ClearField(name string) error {
  17494. switch name {
  17495. case sopnode.FieldStatus:
  17496. m.ClearStatus()
  17497. return nil
  17498. case sopnode.FieldDeletedAt:
  17499. m.ClearDeletedAt()
  17500. return nil
  17501. case sopnode.FieldConditionList:
  17502. m.ClearConditionList()
  17503. return nil
  17504. case sopnode.FieldActionMessage:
  17505. m.ClearActionMessage()
  17506. return nil
  17507. case sopnode.FieldActionLabelAdd:
  17508. m.ClearActionLabelAdd()
  17509. return nil
  17510. case sopnode.FieldActionLabelDel:
  17511. m.ClearActionLabelDel()
  17512. return nil
  17513. case sopnode.FieldActionForward:
  17514. m.ClearActionForward()
  17515. return nil
  17516. }
  17517. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17518. }
  17519. // ResetField resets all changes in the mutation for the field with the given name.
  17520. // It returns an error if the field is not defined in the schema.
  17521. func (m *SopNodeMutation) ResetField(name string) error {
  17522. switch name {
  17523. case sopnode.FieldCreatedAt:
  17524. m.ResetCreatedAt()
  17525. return nil
  17526. case sopnode.FieldUpdatedAt:
  17527. m.ResetUpdatedAt()
  17528. return nil
  17529. case sopnode.FieldStatus:
  17530. m.ResetStatus()
  17531. return nil
  17532. case sopnode.FieldDeletedAt:
  17533. m.ResetDeletedAt()
  17534. return nil
  17535. case sopnode.FieldStageID:
  17536. m.ResetStageID()
  17537. return nil
  17538. case sopnode.FieldParentID:
  17539. m.ResetParentID()
  17540. return nil
  17541. case sopnode.FieldName:
  17542. m.ResetName()
  17543. return nil
  17544. case sopnode.FieldConditionType:
  17545. m.ResetConditionType()
  17546. return nil
  17547. case sopnode.FieldConditionList:
  17548. m.ResetConditionList()
  17549. return nil
  17550. case sopnode.FieldNoReplyCondition:
  17551. m.ResetNoReplyCondition()
  17552. return nil
  17553. case sopnode.FieldNoReplyUnit:
  17554. m.ResetNoReplyUnit()
  17555. return nil
  17556. case sopnode.FieldActionMessage:
  17557. m.ResetActionMessage()
  17558. return nil
  17559. case sopnode.FieldActionLabelAdd:
  17560. m.ResetActionLabelAdd()
  17561. return nil
  17562. case sopnode.FieldActionLabelDel:
  17563. m.ResetActionLabelDel()
  17564. return nil
  17565. case sopnode.FieldActionForward:
  17566. m.ResetActionForward()
  17567. return nil
  17568. }
  17569. return fmt.Errorf("unknown SopNode field %s", name)
  17570. }
  17571. // AddedEdges returns all edge names that were set/added in this mutation.
  17572. func (m *SopNodeMutation) AddedEdges() []string {
  17573. edges := make([]string, 0, 2)
  17574. if m.sop_stage != nil {
  17575. edges = append(edges, sopnode.EdgeSopStage)
  17576. }
  17577. if m.node_messages != nil {
  17578. edges = append(edges, sopnode.EdgeNodeMessages)
  17579. }
  17580. return edges
  17581. }
  17582. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17583. // name in this mutation.
  17584. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17585. switch name {
  17586. case sopnode.EdgeSopStage:
  17587. if id := m.sop_stage; id != nil {
  17588. return []ent.Value{*id}
  17589. }
  17590. case sopnode.EdgeNodeMessages:
  17591. ids := make([]ent.Value, 0, len(m.node_messages))
  17592. for id := range m.node_messages {
  17593. ids = append(ids, id)
  17594. }
  17595. return ids
  17596. }
  17597. return nil
  17598. }
  17599. // RemovedEdges returns all edge names that were removed in this mutation.
  17600. func (m *SopNodeMutation) RemovedEdges() []string {
  17601. edges := make([]string, 0, 2)
  17602. if m.removednode_messages != nil {
  17603. edges = append(edges, sopnode.EdgeNodeMessages)
  17604. }
  17605. return edges
  17606. }
  17607. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17608. // the given name in this mutation.
  17609. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17610. switch name {
  17611. case sopnode.EdgeNodeMessages:
  17612. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17613. for id := range m.removednode_messages {
  17614. ids = append(ids, id)
  17615. }
  17616. return ids
  17617. }
  17618. return nil
  17619. }
  17620. // ClearedEdges returns all edge names that were cleared in this mutation.
  17621. func (m *SopNodeMutation) ClearedEdges() []string {
  17622. edges := make([]string, 0, 2)
  17623. if m.clearedsop_stage {
  17624. edges = append(edges, sopnode.EdgeSopStage)
  17625. }
  17626. if m.clearednode_messages {
  17627. edges = append(edges, sopnode.EdgeNodeMessages)
  17628. }
  17629. return edges
  17630. }
  17631. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17632. // was cleared in this mutation.
  17633. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17634. switch name {
  17635. case sopnode.EdgeSopStage:
  17636. return m.clearedsop_stage
  17637. case sopnode.EdgeNodeMessages:
  17638. return m.clearednode_messages
  17639. }
  17640. return false
  17641. }
  17642. // ClearEdge clears the value of the edge with the given name. It returns an error
  17643. // if that edge is not defined in the schema.
  17644. func (m *SopNodeMutation) ClearEdge(name string) error {
  17645. switch name {
  17646. case sopnode.EdgeSopStage:
  17647. m.ClearSopStage()
  17648. return nil
  17649. }
  17650. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17651. }
  17652. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17653. // It returns an error if the edge is not defined in the schema.
  17654. func (m *SopNodeMutation) ResetEdge(name string) error {
  17655. switch name {
  17656. case sopnode.EdgeSopStage:
  17657. m.ResetSopStage()
  17658. return nil
  17659. case sopnode.EdgeNodeMessages:
  17660. m.ResetNodeMessages()
  17661. return nil
  17662. }
  17663. return fmt.Errorf("unknown SopNode edge %s", name)
  17664. }
  17665. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17666. type SopStageMutation struct {
  17667. config
  17668. op Op
  17669. typ string
  17670. id *uint64
  17671. created_at *time.Time
  17672. updated_at *time.Time
  17673. status *uint8
  17674. addstatus *int8
  17675. deleted_at *time.Time
  17676. name *string
  17677. condition_type *int
  17678. addcondition_type *int
  17679. condition_operator *int
  17680. addcondition_operator *int
  17681. condition_list *[]custom_types.Condition
  17682. appendcondition_list []custom_types.Condition
  17683. action_message *[]custom_types.Action
  17684. appendaction_message []custom_types.Action
  17685. action_label_add *[]uint64
  17686. appendaction_label_add []uint64
  17687. action_label_del *[]uint64
  17688. appendaction_label_del []uint64
  17689. action_forward **custom_types.ActionForward
  17690. index_sort *int
  17691. addindex_sort *int
  17692. clearedFields map[string]struct{}
  17693. sop_task *uint64
  17694. clearedsop_task bool
  17695. stage_nodes map[uint64]struct{}
  17696. removedstage_nodes map[uint64]struct{}
  17697. clearedstage_nodes bool
  17698. stage_messages map[uint64]struct{}
  17699. removedstage_messages map[uint64]struct{}
  17700. clearedstage_messages bool
  17701. done bool
  17702. oldValue func(context.Context) (*SopStage, error)
  17703. predicates []predicate.SopStage
  17704. }
  17705. var _ ent.Mutation = (*SopStageMutation)(nil)
  17706. // sopstageOption allows management of the mutation configuration using functional options.
  17707. type sopstageOption func(*SopStageMutation)
  17708. // newSopStageMutation creates new mutation for the SopStage entity.
  17709. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17710. m := &SopStageMutation{
  17711. config: c,
  17712. op: op,
  17713. typ: TypeSopStage,
  17714. clearedFields: make(map[string]struct{}),
  17715. }
  17716. for _, opt := range opts {
  17717. opt(m)
  17718. }
  17719. return m
  17720. }
  17721. // withSopStageID sets the ID field of the mutation.
  17722. func withSopStageID(id uint64) sopstageOption {
  17723. return func(m *SopStageMutation) {
  17724. var (
  17725. err error
  17726. once sync.Once
  17727. value *SopStage
  17728. )
  17729. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17730. once.Do(func() {
  17731. if m.done {
  17732. err = errors.New("querying old values post mutation is not allowed")
  17733. } else {
  17734. value, err = m.Client().SopStage.Get(ctx, id)
  17735. }
  17736. })
  17737. return value, err
  17738. }
  17739. m.id = &id
  17740. }
  17741. }
  17742. // withSopStage sets the old SopStage of the mutation.
  17743. func withSopStage(node *SopStage) sopstageOption {
  17744. return func(m *SopStageMutation) {
  17745. m.oldValue = func(context.Context) (*SopStage, error) {
  17746. return node, nil
  17747. }
  17748. m.id = &node.ID
  17749. }
  17750. }
  17751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17752. // executed in a transaction (ent.Tx), a transactional client is returned.
  17753. func (m SopStageMutation) Client() *Client {
  17754. client := &Client{config: m.config}
  17755. client.init()
  17756. return client
  17757. }
  17758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17759. // it returns an error otherwise.
  17760. func (m SopStageMutation) Tx() (*Tx, error) {
  17761. if _, ok := m.driver.(*txDriver); !ok {
  17762. return nil, errors.New("ent: mutation is not running in a transaction")
  17763. }
  17764. tx := &Tx{config: m.config}
  17765. tx.init()
  17766. return tx, nil
  17767. }
  17768. // SetID sets the value of the id field. Note that this
  17769. // operation is only accepted on creation of SopStage entities.
  17770. func (m *SopStageMutation) SetID(id uint64) {
  17771. m.id = &id
  17772. }
  17773. // ID returns the ID value in the mutation. Note that the ID is only available
  17774. // if it was provided to the builder or after it was returned from the database.
  17775. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17776. if m.id == nil {
  17777. return
  17778. }
  17779. return *m.id, true
  17780. }
  17781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17782. // That means, if the mutation is applied within a transaction with an isolation level such
  17783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17784. // or updated by the mutation.
  17785. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17786. switch {
  17787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17788. id, exists := m.ID()
  17789. if exists {
  17790. return []uint64{id}, nil
  17791. }
  17792. fallthrough
  17793. case m.op.Is(OpUpdate | OpDelete):
  17794. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17795. default:
  17796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17797. }
  17798. }
  17799. // SetCreatedAt sets the "created_at" field.
  17800. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17801. m.created_at = &t
  17802. }
  17803. // CreatedAt returns the value of the "created_at" field in the mutation.
  17804. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17805. v := m.created_at
  17806. if v == nil {
  17807. return
  17808. }
  17809. return *v, true
  17810. }
  17811. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17812. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17814. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17815. if !m.op.Is(OpUpdateOne) {
  17816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17817. }
  17818. if m.id == nil || m.oldValue == nil {
  17819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17820. }
  17821. oldValue, err := m.oldValue(ctx)
  17822. if err != nil {
  17823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17824. }
  17825. return oldValue.CreatedAt, nil
  17826. }
  17827. // ResetCreatedAt resets all changes to the "created_at" field.
  17828. func (m *SopStageMutation) ResetCreatedAt() {
  17829. m.created_at = nil
  17830. }
  17831. // SetUpdatedAt sets the "updated_at" field.
  17832. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17833. m.updated_at = &t
  17834. }
  17835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17836. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17837. v := m.updated_at
  17838. if v == nil {
  17839. return
  17840. }
  17841. return *v, true
  17842. }
  17843. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17844. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17846. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17847. if !m.op.Is(OpUpdateOne) {
  17848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17849. }
  17850. if m.id == nil || m.oldValue == nil {
  17851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17852. }
  17853. oldValue, err := m.oldValue(ctx)
  17854. if err != nil {
  17855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17856. }
  17857. return oldValue.UpdatedAt, nil
  17858. }
  17859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17860. func (m *SopStageMutation) ResetUpdatedAt() {
  17861. m.updated_at = nil
  17862. }
  17863. // SetStatus sets the "status" field.
  17864. func (m *SopStageMutation) SetStatus(u uint8) {
  17865. m.status = &u
  17866. m.addstatus = nil
  17867. }
  17868. // Status returns the value of the "status" field in the mutation.
  17869. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  17870. v := m.status
  17871. if v == nil {
  17872. return
  17873. }
  17874. return *v, true
  17875. }
  17876. // OldStatus returns the old "status" field's value of the SopStage entity.
  17877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17879. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17880. if !m.op.Is(OpUpdateOne) {
  17881. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17882. }
  17883. if m.id == nil || m.oldValue == nil {
  17884. return v, errors.New("OldStatus requires an ID field in the mutation")
  17885. }
  17886. oldValue, err := m.oldValue(ctx)
  17887. if err != nil {
  17888. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17889. }
  17890. return oldValue.Status, nil
  17891. }
  17892. // AddStatus adds u to the "status" field.
  17893. func (m *SopStageMutation) AddStatus(u int8) {
  17894. if m.addstatus != nil {
  17895. *m.addstatus += u
  17896. } else {
  17897. m.addstatus = &u
  17898. }
  17899. }
  17900. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17901. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  17902. v := m.addstatus
  17903. if v == nil {
  17904. return
  17905. }
  17906. return *v, true
  17907. }
  17908. // ClearStatus clears the value of the "status" field.
  17909. func (m *SopStageMutation) ClearStatus() {
  17910. m.status = nil
  17911. m.addstatus = nil
  17912. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  17913. }
  17914. // StatusCleared returns if the "status" field was cleared in this mutation.
  17915. func (m *SopStageMutation) StatusCleared() bool {
  17916. _, ok := m.clearedFields[sopstage.FieldStatus]
  17917. return ok
  17918. }
  17919. // ResetStatus resets all changes to the "status" field.
  17920. func (m *SopStageMutation) ResetStatus() {
  17921. m.status = nil
  17922. m.addstatus = nil
  17923. delete(m.clearedFields, sopstage.FieldStatus)
  17924. }
  17925. // SetDeletedAt sets the "deleted_at" field.
  17926. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  17927. m.deleted_at = &t
  17928. }
  17929. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17930. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  17931. v := m.deleted_at
  17932. if v == nil {
  17933. return
  17934. }
  17935. return *v, true
  17936. }
  17937. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  17938. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17940. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17941. if !m.op.Is(OpUpdateOne) {
  17942. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17943. }
  17944. if m.id == nil || m.oldValue == nil {
  17945. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17946. }
  17947. oldValue, err := m.oldValue(ctx)
  17948. if err != nil {
  17949. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17950. }
  17951. return oldValue.DeletedAt, nil
  17952. }
  17953. // ClearDeletedAt clears the value of the "deleted_at" field.
  17954. func (m *SopStageMutation) ClearDeletedAt() {
  17955. m.deleted_at = nil
  17956. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  17957. }
  17958. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17959. func (m *SopStageMutation) DeletedAtCleared() bool {
  17960. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  17961. return ok
  17962. }
  17963. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17964. func (m *SopStageMutation) ResetDeletedAt() {
  17965. m.deleted_at = nil
  17966. delete(m.clearedFields, sopstage.FieldDeletedAt)
  17967. }
  17968. // SetTaskID sets the "task_id" field.
  17969. func (m *SopStageMutation) SetTaskID(u uint64) {
  17970. m.sop_task = &u
  17971. }
  17972. // TaskID returns the value of the "task_id" field in the mutation.
  17973. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  17974. v := m.sop_task
  17975. if v == nil {
  17976. return
  17977. }
  17978. return *v, true
  17979. }
  17980. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  17981. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17983. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  17984. if !m.op.Is(OpUpdateOne) {
  17985. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  17986. }
  17987. if m.id == nil || m.oldValue == nil {
  17988. return v, errors.New("OldTaskID requires an ID field in the mutation")
  17989. }
  17990. oldValue, err := m.oldValue(ctx)
  17991. if err != nil {
  17992. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  17993. }
  17994. return oldValue.TaskID, nil
  17995. }
  17996. // ResetTaskID resets all changes to the "task_id" field.
  17997. func (m *SopStageMutation) ResetTaskID() {
  17998. m.sop_task = nil
  17999. }
  18000. // SetName sets the "name" field.
  18001. func (m *SopStageMutation) SetName(s string) {
  18002. m.name = &s
  18003. }
  18004. // Name returns the value of the "name" field in the mutation.
  18005. func (m *SopStageMutation) Name() (r string, exists bool) {
  18006. v := m.name
  18007. if v == nil {
  18008. return
  18009. }
  18010. return *v, true
  18011. }
  18012. // OldName returns the old "name" field's value of the SopStage entity.
  18013. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18015. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18016. if !m.op.Is(OpUpdateOne) {
  18017. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18018. }
  18019. if m.id == nil || m.oldValue == nil {
  18020. return v, errors.New("OldName requires an ID field in the mutation")
  18021. }
  18022. oldValue, err := m.oldValue(ctx)
  18023. if err != nil {
  18024. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18025. }
  18026. return oldValue.Name, nil
  18027. }
  18028. // ResetName resets all changes to the "name" field.
  18029. func (m *SopStageMutation) ResetName() {
  18030. m.name = nil
  18031. }
  18032. // SetConditionType sets the "condition_type" field.
  18033. func (m *SopStageMutation) SetConditionType(i int) {
  18034. m.condition_type = &i
  18035. m.addcondition_type = nil
  18036. }
  18037. // ConditionType returns the value of the "condition_type" field in the mutation.
  18038. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18039. v := m.condition_type
  18040. if v == nil {
  18041. return
  18042. }
  18043. return *v, true
  18044. }
  18045. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18048. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18049. if !m.op.Is(OpUpdateOne) {
  18050. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18051. }
  18052. if m.id == nil || m.oldValue == nil {
  18053. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18054. }
  18055. oldValue, err := m.oldValue(ctx)
  18056. if err != nil {
  18057. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18058. }
  18059. return oldValue.ConditionType, nil
  18060. }
  18061. // AddConditionType adds i to the "condition_type" field.
  18062. func (m *SopStageMutation) AddConditionType(i int) {
  18063. if m.addcondition_type != nil {
  18064. *m.addcondition_type += i
  18065. } else {
  18066. m.addcondition_type = &i
  18067. }
  18068. }
  18069. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18070. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18071. v := m.addcondition_type
  18072. if v == nil {
  18073. return
  18074. }
  18075. return *v, true
  18076. }
  18077. // ResetConditionType resets all changes to the "condition_type" field.
  18078. func (m *SopStageMutation) ResetConditionType() {
  18079. m.condition_type = nil
  18080. m.addcondition_type = nil
  18081. }
  18082. // SetConditionOperator sets the "condition_operator" field.
  18083. func (m *SopStageMutation) SetConditionOperator(i int) {
  18084. m.condition_operator = &i
  18085. m.addcondition_operator = nil
  18086. }
  18087. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18088. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18089. v := m.condition_operator
  18090. if v == nil {
  18091. return
  18092. }
  18093. return *v, true
  18094. }
  18095. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18096. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18098. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18099. if !m.op.Is(OpUpdateOne) {
  18100. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18101. }
  18102. if m.id == nil || m.oldValue == nil {
  18103. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18104. }
  18105. oldValue, err := m.oldValue(ctx)
  18106. if err != nil {
  18107. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18108. }
  18109. return oldValue.ConditionOperator, nil
  18110. }
  18111. // AddConditionOperator adds i to the "condition_operator" field.
  18112. func (m *SopStageMutation) AddConditionOperator(i int) {
  18113. if m.addcondition_operator != nil {
  18114. *m.addcondition_operator += i
  18115. } else {
  18116. m.addcondition_operator = &i
  18117. }
  18118. }
  18119. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18120. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18121. v := m.addcondition_operator
  18122. if v == nil {
  18123. return
  18124. }
  18125. return *v, true
  18126. }
  18127. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18128. func (m *SopStageMutation) ResetConditionOperator() {
  18129. m.condition_operator = nil
  18130. m.addcondition_operator = nil
  18131. }
  18132. // SetConditionList sets the "condition_list" field.
  18133. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18134. m.condition_list = &ct
  18135. m.appendcondition_list = nil
  18136. }
  18137. // ConditionList returns the value of the "condition_list" field in the mutation.
  18138. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18139. v := m.condition_list
  18140. if v == nil {
  18141. return
  18142. }
  18143. return *v, true
  18144. }
  18145. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18146. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18148. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18149. if !m.op.Is(OpUpdateOne) {
  18150. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18151. }
  18152. if m.id == nil || m.oldValue == nil {
  18153. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18154. }
  18155. oldValue, err := m.oldValue(ctx)
  18156. if err != nil {
  18157. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18158. }
  18159. return oldValue.ConditionList, nil
  18160. }
  18161. // AppendConditionList adds ct to the "condition_list" field.
  18162. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18163. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18164. }
  18165. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18166. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18167. if len(m.appendcondition_list) == 0 {
  18168. return nil, false
  18169. }
  18170. return m.appendcondition_list, true
  18171. }
  18172. // ResetConditionList resets all changes to the "condition_list" field.
  18173. func (m *SopStageMutation) ResetConditionList() {
  18174. m.condition_list = nil
  18175. m.appendcondition_list = nil
  18176. }
  18177. // SetActionMessage sets the "action_message" field.
  18178. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18179. m.action_message = &ct
  18180. m.appendaction_message = nil
  18181. }
  18182. // ActionMessage returns the value of the "action_message" field in the mutation.
  18183. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18184. v := m.action_message
  18185. if v == nil {
  18186. return
  18187. }
  18188. return *v, true
  18189. }
  18190. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18191. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18193. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18194. if !m.op.Is(OpUpdateOne) {
  18195. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18196. }
  18197. if m.id == nil || m.oldValue == nil {
  18198. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18199. }
  18200. oldValue, err := m.oldValue(ctx)
  18201. if err != nil {
  18202. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18203. }
  18204. return oldValue.ActionMessage, nil
  18205. }
  18206. // AppendActionMessage adds ct to the "action_message" field.
  18207. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18208. m.appendaction_message = append(m.appendaction_message, ct...)
  18209. }
  18210. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18211. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18212. if len(m.appendaction_message) == 0 {
  18213. return nil, false
  18214. }
  18215. return m.appendaction_message, true
  18216. }
  18217. // ClearActionMessage clears the value of the "action_message" field.
  18218. func (m *SopStageMutation) ClearActionMessage() {
  18219. m.action_message = nil
  18220. m.appendaction_message = nil
  18221. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18222. }
  18223. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18224. func (m *SopStageMutation) ActionMessageCleared() bool {
  18225. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18226. return ok
  18227. }
  18228. // ResetActionMessage resets all changes to the "action_message" field.
  18229. func (m *SopStageMutation) ResetActionMessage() {
  18230. m.action_message = nil
  18231. m.appendaction_message = nil
  18232. delete(m.clearedFields, sopstage.FieldActionMessage)
  18233. }
  18234. // SetActionLabelAdd sets the "action_label_add" field.
  18235. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18236. m.action_label_add = &u
  18237. m.appendaction_label_add = nil
  18238. }
  18239. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18240. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18241. v := m.action_label_add
  18242. if v == nil {
  18243. return
  18244. }
  18245. return *v, true
  18246. }
  18247. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18248. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18250. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18251. if !m.op.Is(OpUpdateOne) {
  18252. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18253. }
  18254. if m.id == nil || m.oldValue == nil {
  18255. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18256. }
  18257. oldValue, err := m.oldValue(ctx)
  18258. if err != nil {
  18259. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18260. }
  18261. return oldValue.ActionLabelAdd, nil
  18262. }
  18263. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18264. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18265. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18266. }
  18267. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18268. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18269. if len(m.appendaction_label_add) == 0 {
  18270. return nil, false
  18271. }
  18272. return m.appendaction_label_add, true
  18273. }
  18274. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18275. func (m *SopStageMutation) ClearActionLabelAdd() {
  18276. m.action_label_add = nil
  18277. m.appendaction_label_add = nil
  18278. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18279. }
  18280. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18281. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18282. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18283. return ok
  18284. }
  18285. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18286. func (m *SopStageMutation) ResetActionLabelAdd() {
  18287. m.action_label_add = nil
  18288. m.appendaction_label_add = nil
  18289. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18290. }
  18291. // SetActionLabelDel sets the "action_label_del" field.
  18292. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18293. m.action_label_del = &u
  18294. m.appendaction_label_del = nil
  18295. }
  18296. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18297. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18298. v := m.action_label_del
  18299. if v == nil {
  18300. return
  18301. }
  18302. return *v, true
  18303. }
  18304. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18305. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18307. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18308. if !m.op.Is(OpUpdateOne) {
  18309. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18310. }
  18311. if m.id == nil || m.oldValue == nil {
  18312. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18313. }
  18314. oldValue, err := m.oldValue(ctx)
  18315. if err != nil {
  18316. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18317. }
  18318. return oldValue.ActionLabelDel, nil
  18319. }
  18320. // AppendActionLabelDel adds u to the "action_label_del" field.
  18321. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18322. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18323. }
  18324. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18325. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18326. if len(m.appendaction_label_del) == 0 {
  18327. return nil, false
  18328. }
  18329. return m.appendaction_label_del, true
  18330. }
  18331. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18332. func (m *SopStageMutation) ClearActionLabelDel() {
  18333. m.action_label_del = nil
  18334. m.appendaction_label_del = nil
  18335. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18336. }
  18337. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18338. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18339. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18340. return ok
  18341. }
  18342. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18343. func (m *SopStageMutation) ResetActionLabelDel() {
  18344. m.action_label_del = nil
  18345. m.appendaction_label_del = nil
  18346. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18347. }
  18348. // SetActionForward sets the "action_forward" field.
  18349. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18350. m.action_forward = &ctf
  18351. }
  18352. // ActionForward returns the value of the "action_forward" field in the mutation.
  18353. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18354. v := m.action_forward
  18355. if v == nil {
  18356. return
  18357. }
  18358. return *v, true
  18359. }
  18360. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18363. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18364. if !m.op.Is(OpUpdateOne) {
  18365. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18366. }
  18367. if m.id == nil || m.oldValue == nil {
  18368. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18369. }
  18370. oldValue, err := m.oldValue(ctx)
  18371. if err != nil {
  18372. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18373. }
  18374. return oldValue.ActionForward, nil
  18375. }
  18376. // ClearActionForward clears the value of the "action_forward" field.
  18377. func (m *SopStageMutation) ClearActionForward() {
  18378. m.action_forward = nil
  18379. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18380. }
  18381. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18382. func (m *SopStageMutation) ActionForwardCleared() bool {
  18383. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18384. return ok
  18385. }
  18386. // ResetActionForward resets all changes to the "action_forward" field.
  18387. func (m *SopStageMutation) ResetActionForward() {
  18388. m.action_forward = nil
  18389. delete(m.clearedFields, sopstage.FieldActionForward)
  18390. }
  18391. // SetIndexSort sets the "index_sort" field.
  18392. func (m *SopStageMutation) SetIndexSort(i int) {
  18393. m.index_sort = &i
  18394. m.addindex_sort = nil
  18395. }
  18396. // IndexSort returns the value of the "index_sort" field in the mutation.
  18397. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18398. v := m.index_sort
  18399. if v == nil {
  18400. return
  18401. }
  18402. return *v, true
  18403. }
  18404. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18405. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18407. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18408. if !m.op.Is(OpUpdateOne) {
  18409. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18410. }
  18411. if m.id == nil || m.oldValue == nil {
  18412. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18413. }
  18414. oldValue, err := m.oldValue(ctx)
  18415. if err != nil {
  18416. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18417. }
  18418. return oldValue.IndexSort, nil
  18419. }
  18420. // AddIndexSort adds i to the "index_sort" field.
  18421. func (m *SopStageMutation) AddIndexSort(i int) {
  18422. if m.addindex_sort != nil {
  18423. *m.addindex_sort += i
  18424. } else {
  18425. m.addindex_sort = &i
  18426. }
  18427. }
  18428. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18429. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18430. v := m.addindex_sort
  18431. if v == nil {
  18432. return
  18433. }
  18434. return *v, true
  18435. }
  18436. // ClearIndexSort clears the value of the "index_sort" field.
  18437. func (m *SopStageMutation) ClearIndexSort() {
  18438. m.index_sort = nil
  18439. m.addindex_sort = nil
  18440. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18441. }
  18442. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18443. func (m *SopStageMutation) IndexSortCleared() bool {
  18444. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18445. return ok
  18446. }
  18447. // ResetIndexSort resets all changes to the "index_sort" field.
  18448. func (m *SopStageMutation) ResetIndexSort() {
  18449. m.index_sort = nil
  18450. m.addindex_sort = nil
  18451. delete(m.clearedFields, sopstage.FieldIndexSort)
  18452. }
  18453. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18454. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18455. m.sop_task = &id
  18456. }
  18457. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18458. func (m *SopStageMutation) ClearSopTask() {
  18459. m.clearedsop_task = true
  18460. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18461. }
  18462. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18463. func (m *SopStageMutation) SopTaskCleared() bool {
  18464. return m.clearedsop_task
  18465. }
  18466. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18467. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18468. if m.sop_task != nil {
  18469. return *m.sop_task, true
  18470. }
  18471. return
  18472. }
  18473. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18474. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18475. // SopTaskID instead. It exists only for internal usage by the builders.
  18476. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18477. if id := m.sop_task; id != nil {
  18478. ids = append(ids, *id)
  18479. }
  18480. return
  18481. }
  18482. // ResetSopTask resets all changes to the "sop_task" edge.
  18483. func (m *SopStageMutation) ResetSopTask() {
  18484. m.sop_task = nil
  18485. m.clearedsop_task = false
  18486. }
  18487. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18488. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18489. if m.stage_nodes == nil {
  18490. m.stage_nodes = make(map[uint64]struct{})
  18491. }
  18492. for i := range ids {
  18493. m.stage_nodes[ids[i]] = struct{}{}
  18494. }
  18495. }
  18496. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18497. func (m *SopStageMutation) ClearStageNodes() {
  18498. m.clearedstage_nodes = true
  18499. }
  18500. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18501. func (m *SopStageMutation) StageNodesCleared() bool {
  18502. return m.clearedstage_nodes
  18503. }
  18504. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18505. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18506. if m.removedstage_nodes == nil {
  18507. m.removedstage_nodes = make(map[uint64]struct{})
  18508. }
  18509. for i := range ids {
  18510. delete(m.stage_nodes, ids[i])
  18511. m.removedstage_nodes[ids[i]] = struct{}{}
  18512. }
  18513. }
  18514. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18515. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18516. for id := range m.removedstage_nodes {
  18517. ids = append(ids, id)
  18518. }
  18519. return
  18520. }
  18521. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18522. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18523. for id := range m.stage_nodes {
  18524. ids = append(ids, id)
  18525. }
  18526. return
  18527. }
  18528. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18529. func (m *SopStageMutation) ResetStageNodes() {
  18530. m.stage_nodes = nil
  18531. m.clearedstage_nodes = false
  18532. m.removedstage_nodes = nil
  18533. }
  18534. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18535. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18536. if m.stage_messages == nil {
  18537. m.stage_messages = make(map[uint64]struct{})
  18538. }
  18539. for i := range ids {
  18540. m.stage_messages[ids[i]] = struct{}{}
  18541. }
  18542. }
  18543. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18544. func (m *SopStageMutation) ClearStageMessages() {
  18545. m.clearedstage_messages = true
  18546. }
  18547. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18548. func (m *SopStageMutation) StageMessagesCleared() bool {
  18549. return m.clearedstage_messages
  18550. }
  18551. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18552. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18553. if m.removedstage_messages == nil {
  18554. m.removedstage_messages = make(map[uint64]struct{})
  18555. }
  18556. for i := range ids {
  18557. delete(m.stage_messages, ids[i])
  18558. m.removedstage_messages[ids[i]] = struct{}{}
  18559. }
  18560. }
  18561. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18562. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18563. for id := range m.removedstage_messages {
  18564. ids = append(ids, id)
  18565. }
  18566. return
  18567. }
  18568. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18569. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18570. for id := range m.stage_messages {
  18571. ids = append(ids, id)
  18572. }
  18573. return
  18574. }
  18575. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18576. func (m *SopStageMutation) ResetStageMessages() {
  18577. m.stage_messages = nil
  18578. m.clearedstage_messages = false
  18579. m.removedstage_messages = nil
  18580. }
  18581. // Where appends a list predicates to the SopStageMutation builder.
  18582. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18583. m.predicates = append(m.predicates, ps...)
  18584. }
  18585. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18586. // users can use type-assertion to append predicates that do not depend on any generated package.
  18587. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18588. p := make([]predicate.SopStage, len(ps))
  18589. for i := range ps {
  18590. p[i] = ps[i]
  18591. }
  18592. m.Where(p...)
  18593. }
  18594. // Op returns the operation name.
  18595. func (m *SopStageMutation) Op() Op {
  18596. return m.op
  18597. }
  18598. // SetOp allows setting the mutation operation.
  18599. func (m *SopStageMutation) SetOp(op Op) {
  18600. m.op = op
  18601. }
  18602. // Type returns the node type of this mutation (SopStage).
  18603. func (m *SopStageMutation) Type() string {
  18604. return m.typ
  18605. }
  18606. // Fields returns all fields that were changed during this mutation. Note that in
  18607. // order to get all numeric fields that were incremented/decremented, call
  18608. // AddedFields().
  18609. func (m *SopStageMutation) Fields() []string {
  18610. fields := make([]string, 0, 14)
  18611. if m.created_at != nil {
  18612. fields = append(fields, sopstage.FieldCreatedAt)
  18613. }
  18614. if m.updated_at != nil {
  18615. fields = append(fields, sopstage.FieldUpdatedAt)
  18616. }
  18617. if m.status != nil {
  18618. fields = append(fields, sopstage.FieldStatus)
  18619. }
  18620. if m.deleted_at != nil {
  18621. fields = append(fields, sopstage.FieldDeletedAt)
  18622. }
  18623. if m.sop_task != nil {
  18624. fields = append(fields, sopstage.FieldTaskID)
  18625. }
  18626. if m.name != nil {
  18627. fields = append(fields, sopstage.FieldName)
  18628. }
  18629. if m.condition_type != nil {
  18630. fields = append(fields, sopstage.FieldConditionType)
  18631. }
  18632. if m.condition_operator != nil {
  18633. fields = append(fields, sopstage.FieldConditionOperator)
  18634. }
  18635. if m.condition_list != nil {
  18636. fields = append(fields, sopstage.FieldConditionList)
  18637. }
  18638. if m.action_message != nil {
  18639. fields = append(fields, sopstage.FieldActionMessage)
  18640. }
  18641. if m.action_label_add != nil {
  18642. fields = append(fields, sopstage.FieldActionLabelAdd)
  18643. }
  18644. if m.action_label_del != nil {
  18645. fields = append(fields, sopstage.FieldActionLabelDel)
  18646. }
  18647. if m.action_forward != nil {
  18648. fields = append(fields, sopstage.FieldActionForward)
  18649. }
  18650. if m.index_sort != nil {
  18651. fields = append(fields, sopstage.FieldIndexSort)
  18652. }
  18653. return fields
  18654. }
  18655. // Field returns the value of a field with the given name. The second boolean
  18656. // return value indicates that this field was not set, or was not defined in the
  18657. // schema.
  18658. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18659. switch name {
  18660. case sopstage.FieldCreatedAt:
  18661. return m.CreatedAt()
  18662. case sopstage.FieldUpdatedAt:
  18663. return m.UpdatedAt()
  18664. case sopstage.FieldStatus:
  18665. return m.Status()
  18666. case sopstage.FieldDeletedAt:
  18667. return m.DeletedAt()
  18668. case sopstage.FieldTaskID:
  18669. return m.TaskID()
  18670. case sopstage.FieldName:
  18671. return m.Name()
  18672. case sopstage.FieldConditionType:
  18673. return m.ConditionType()
  18674. case sopstage.FieldConditionOperator:
  18675. return m.ConditionOperator()
  18676. case sopstage.FieldConditionList:
  18677. return m.ConditionList()
  18678. case sopstage.FieldActionMessage:
  18679. return m.ActionMessage()
  18680. case sopstage.FieldActionLabelAdd:
  18681. return m.ActionLabelAdd()
  18682. case sopstage.FieldActionLabelDel:
  18683. return m.ActionLabelDel()
  18684. case sopstage.FieldActionForward:
  18685. return m.ActionForward()
  18686. case sopstage.FieldIndexSort:
  18687. return m.IndexSort()
  18688. }
  18689. return nil, false
  18690. }
  18691. // OldField returns the old value of the field from the database. An error is
  18692. // returned if the mutation operation is not UpdateOne, or the query to the
  18693. // database failed.
  18694. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18695. switch name {
  18696. case sopstage.FieldCreatedAt:
  18697. return m.OldCreatedAt(ctx)
  18698. case sopstage.FieldUpdatedAt:
  18699. return m.OldUpdatedAt(ctx)
  18700. case sopstage.FieldStatus:
  18701. return m.OldStatus(ctx)
  18702. case sopstage.FieldDeletedAt:
  18703. return m.OldDeletedAt(ctx)
  18704. case sopstage.FieldTaskID:
  18705. return m.OldTaskID(ctx)
  18706. case sopstage.FieldName:
  18707. return m.OldName(ctx)
  18708. case sopstage.FieldConditionType:
  18709. return m.OldConditionType(ctx)
  18710. case sopstage.FieldConditionOperator:
  18711. return m.OldConditionOperator(ctx)
  18712. case sopstage.FieldConditionList:
  18713. return m.OldConditionList(ctx)
  18714. case sopstage.FieldActionMessage:
  18715. return m.OldActionMessage(ctx)
  18716. case sopstage.FieldActionLabelAdd:
  18717. return m.OldActionLabelAdd(ctx)
  18718. case sopstage.FieldActionLabelDel:
  18719. return m.OldActionLabelDel(ctx)
  18720. case sopstage.FieldActionForward:
  18721. return m.OldActionForward(ctx)
  18722. case sopstage.FieldIndexSort:
  18723. return m.OldIndexSort(ctx)
  18724. }
  18725. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18726. }
  18727. // SetField sets the value of a field with the given name. It returns an error if
  18728. // the field is not defined in the schema, or if the type mismatched the field
  18729. // type.
  18730. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18731. switch name {
  18732. case sopstage.FieldCreatedAt:
  18733. v, ok := value.(time.Time)
  18734. if !ok {
  18735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18736. }
  18737. m.SetCreatedAt(v)
  18738. return nil
  18739. case sopstage.FieldUpdatedAt:
  18740. v, ok := value.(time.Time)
  18741. if !ok {
  18742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18743. }
  18744. m.SetUpdatedAt(v)
  18745. return nil
  18746. case sopstage.FieldStatus:
  18747. v, ok := value.(uint8)
  18748. if !ok {
  18749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18750. }
  18751. m.SetStatus(v)
  18752. return nil
  18753. case sopstage.FieldDeletedAt:
  18754. v, ok := value.(time.Time)
  18755. if !ok {
  18756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18757. }
  18758. m.SetDeletedAt(v)
  18759. return nil
  18760. case sopstage.FieldTaskID:
  18761. v, ok := value.(uint64)
  18762. if !ok {
  18763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18764. }
  18765. m.SetTaskID(v)
  18766. return nil
  18767. case sopstage.FieldName:
  18768. v, ok := value.(string)
  18769. if !ok {
  18770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18771. }
  18772. m.SetName(v)
  18773. return nil
  18774. case sopstage.FieldConditionType:
  18775. v, ok := value.(int)
  18776. if !ok {
  18777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18778. }
  18779. m.SetConditionType(v)
  18780. return nil
  18781. case sopstage.FieldConditionOperator:
  18782. v, ok := value.(int)
  18783. if !ok {
  18784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18785. }
  18786. m.SetConditionOperator(v)
  18787. return nil
  18788. case sopstage.FieldConditionList:
  18789. v, ok := value.([]custom_types.Condition)
  18790. if !ok {
  18791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18792. }
  18793. m.SetConditionList(v)
  18794. return nil
  18795. case sopstage.FieldActionMessage:
  18796. v, ok := value.([]custom_types.Action)
  18797. if !ok {
  18798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18799. }
  18800. m.SetActionMessage(v)
  18801. return nil
  18802. case sopstage.FieldActionLabelAdd:
  18803. v, ok := value.([]uint64)
  18804. if !ok {
  18805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18806. }
  18807. m.SetActionLabelAdd(v)
  18808. return nil
  18809. case sopstage.FieldActionLabelDel:
  18810. v, ok := value.([]uint64)
  18811. if !ok {
  18812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18813. }
  18814. m.SetActionLabelDel(v)
  18815. return nil
  18816. case sopstage.FieldActionForward:
  18817. v, ok := value.(*custom_types.ActionForward)
  18818. if !ok {
  18819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18820. }
  18821. m.SetActionForward(v)
  18822. return nil
  18823. case sopstage.FieldIndexSort:
  18824. v, ok := value.(int)
  18825. if !ok {
  18826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18827. }
  18828. m.SetIndexSort(v)
  18829. return nil
  18830. }
  18831. return fmt.Errorf("unknown SopStage field %s", name)
  18832. }
  18833. // AddedFields returns all numeric fields that were incremented/decremented during
  18834. // this mutation.
  18835. func (m *SopStageMutation) AddedFields() []string {
  18836. var fields []string
  18837. if m.addstatus != nil {
  18838. fields = append(fields, sopstage.FieldStatus)
  18839. }
  18840. if m.addcondition_type != nil {
  18841. fields = append(fields, sopstage.FieldConditionType)
  18842. }
  18843. if m.addcondition_operator != nil {
  18844. fields = append(fields, sopstage.FieldConditionOperator)
  18845. }
  18846. if m.addindex_sort != nil {
  18847. fields = append(fields, sopstage.FieldIndexSort)
  18848. }
  18849. return fields
  18850. }
  18851. // AddedField returns the numeric value that was incremented/decremented on a field
  18852. // with the given name. The second boolean return value indicates that this field
  18853. // was not set, or was not defined in the schema.
  18854. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18855. switch name {
  18856. case sopstage.FieldStatus:
  18857. return m.AddedStatus()
  18858. case sopstage.FieldConditionType:
  18859. return m.AddedConditionType()
  18860. case sopstage.FieldConditionOperator:
  18861. return m.AddedConditionOperator()
  18862. case sopstage.FieldIndexSort:
  18863. return m.AddedIndexSort()
  18864. }
  18865. return nil, false
  18866. }
  18867. // AddField adds the value to the field with the given name. It returns an error if
  18868. // the field is not defined in the schema, or if the type mismatched the field
  18869. // type.
  18870. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  18871. switch name {
  18872. case sopstage.FieldStatus:
  18873. v, ok := value.(int8)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.AddStatus(v)
  18878. return nil
  18879. case sopstage.FieldConditionType:
  18880. v, ok := value.(int)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.AddConditionType(v)
  18885. return nil
  18886. case sopstage.FieldConditionOperator:
  18887. v, ok := value.(int)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.AddConditionOperator(v)
  18892. return nil
  18893. case sopstage.FieldIndexSort:
  18894. v, ok := value.(int)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.AddIndexSort(v)
  18899. return nil
  18900. }
  18901. return fmt.Errorf("unknown SopStage numeric field %s", name)
  18902. }
  18903. // ClearedFields returns all nullable fields that were cleared during this
  18904. // mutation.
  18905. func (m *SopStageMutation) ClearedFields() []string {
  18906. var fields []string
  18907. if m.FieldCleared(sopstage.FieldStatus) {
  18908. fields = append(fields, sopstage.FieldStatus)
  18909. }
  18910. if m.FieldCleared(sopstage.FieldDeletedAt) {
  18911. fields = append(fields, sopstage.FieldDeletedAt)
  18912. }
  18913. if m.FieldCleared(sopstage.FieldActionMessage) {
  18914. fields = append(fields, sopstage.FieldActionMessage)
  18915. }
  18916. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  18917. fields = append(fields, sopstage.FieldActionLabelAdd)
  18918. }
  18919. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  18920. fields = append(fields, sopstage.FieldActionLabelDel)
  18921. }
  18922. if m.FieldCleared(sopstage.FieldActionForward) {
  18923. fields = append(fields, sopstage.FieldActionForward)
  18924. }
  18925. if m.FieldCleared(sopstage.FieldIndexSort) {
  18926. fields = append(fields, sopstage.FieldIndexSort)
  18927. }
  18928. return fields
  18929. }
  18930. // FieldCleared returns a boolean indicating if a field with the given name was
  18931. // cleared in this mutation.
  18932. func (m *SopStageMutation) FieldCleared(name string) bool {
  18933. _, ok := m.clearedFields[name]
  18934. return ok
  18935. }
  18936. // ClearField clears the value of the field with the given name. It returns an
  18937. // error if the field is not defined in the schema.
  18938. func (m *SopStageMutation) ClearField(name string) error {
  18939. switch name {
  18940. case sopstage.FieldStatus:
  18941. m.ClearStatus()
  18942. return nil
  18943. case sopstage.FieldDeletedAt:
  18944. m.ClearDeletedAt()
  18945. return nil
  18946. case sopstage.FieldActionMessage:
  18947. m.ClearActionMessage()
  18948. return nil
  18949. case sopstage.FieldActionLabelAdd:
  18950. m.ClearActionLabelAdd()
  18951. return nil
  18952. case sopstage.FieldActionLabelDel:
  18953. m.ClearActionLabelDel()
  18954. return nil
  18955. case sopstage.FieldActionForward:
  18956. m.ClearActionForward()
  18957. return nil
  18958. case sopstage.FieldIndexSort:
  18959. m.ClearIndexSort()
  18960. return nil
  18961. }
  18962. return fmt.Errorf("unknown SopStage nullable field %s", name)
  18963. }
  18964. // ResetField resets all changes in the mutation for the field with the given name.
  18965. // It returns an error if the field is not defined in the schema.
  18966. func (m *SopStageMutation) ResetField(name string) error {
  18967. switch name {
  18968. case sopstage.FieldCreatedAt:
  18969. m.ResetCreatedAt()
  18970. return nil
  18971. case sopstage.FieldUpdatedAt:
  18972. m.ResetUpdatedAt()
  18973. return nil
  18974. case sopstage.FieldStatus:
  18975. m.ResetStatus()
  18976. return nil
  18977. case sopstage.FieldDeletedAt:
  18978. m.ResetDeletedAt()
  18979. return nil
  18980. case sopstage.FieldTaskID:
  18981. m.ResetTaskID()
  18982. return nil
  18983. case sopstage.FieldName:
  18984. m.ResetName()
  18985. return nil
  18986. case sopstage.FieldConditionType:
  18987. m.ResetConditionType()
  18988. return nil
  18989. case sopstage.FieldConditionOperator:
  18990. m.ResetConditionOperator()
  18991. return nil
  18992. case sopstage.FieldConditionList:
  18993. m.ResetConditionList()
  18994. return nil
  18995. case sopstage.FieldActionMessage:
  18996. m.ResetActionMessage()
  18997. return nil
  18998. case sopstage.FieldActionLabelAdd:
  18999. m.ResetActionLabelAdd()
  19000. return nil
  19001. case sopstage.FieldActionLabelDel:
  19002. m.ResetActionLabelDel()
  19003. return nil
  19004. case sopstage.FieldActionForward:
  19005. m.ResetActionForward()
  19006. return nil
  19007. case sopstage.FieldIndexSort:
  19008. m.ResetIndexSort()
  19009. return nil
  19010. }
  19011. return fmt.Errorf("unknown SopStage field %s", name)
  19012. }
  19013. // AddedEdges returns all edge names that were set/added in this mutation.
  19014. func (m *SopStageMutation) AddedEdges() []string {
  19015. edges := make([]string, 0, 3)
  19016. if m.sop_task != nil {
  19017. edges = append(edges, sopstage.EdgeSopTask)
  19018. }
  19019. if m.stage_nodes != nil {
  19020. edges = append(edges, sopstage.EdgeStageNodes)
  19021. }
  19022. if m.stage_messages != nil {
  19023. edges = append(edges, sopstage.EdgeStageMessages)
  19024. }
  19025. return edges
  19026. }
  19027. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19028. // name in this mutation.
  19029. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19030. switch name {
  19031. case sopstage.EdgeSopTask:
  19032. if id := m.sop_task; id != nil {
  19033. return []ent.Value{*id}
  19034. }
  19035. case sopstage.EdgeStageNodes:
  19036. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19037. for id := range m.stage_nodes {
  19038. ids = append(ids, id)
  19039. }
  19040. return ids
  19041. case sopstage.EdgeStageMessages:
  19042. ids := make([]ent.Value, 0, len(m.stage_messages))
  19043. for id := range m.stage_messages {
  19044. ids = append(ids, id)
  19045. }
  19046. return ids
  19047. }
  19048. return nil
  19049. }
  19050. // RemovedEdges returns all edge names that were removed in this mutation.
  19051. func (m *SopStageMutation) RemovedEdges() []string {
  19052. edges := make([]string, 0, 3)
  19053. if m.removedstage_nodes != nil {
  19054. edges = append(edges, sopstage.EdgeStageNodes)
  19055. }
  19056. if m.removedstage_messages != nil {
  19057. edges = append(edges, sopstage.EdgeStageMessages)
  19058. }
  19059. return edges
  19060. }
  19061. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19062. // the given name in this mutation.
  19063. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19064. switch name {
  19065. case sopstage.EdgeStageNodes:
  19066. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19067. for id := range m.removedstage_nodes {
  19068. ids = append(ids, id)
  19069. }
  19070. return ids
  19071. case sopstage.EdgeStageMessages:
  19072. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19073. for id := range m.removedstage_messages {
  19074. ids = append(ids, id)
  19075. }
  19076. return ids
  19077. }
  19078. return nil
  19079. }
  19080. // ClearedEdges returns all edge names that were cleared in this mutation.
  19081. func (m *SopStageMutation) ClearedEdges() []string {
  19082. edges := make([]string, 0, 3)
  19083. if m.clearedsop_task {
  19084. edges = append(edges, sopstage.EdgeSopTask)
  19085. }
  19086. if m.clearedstage_nodes {
  19087. edges = append(edges, sopstage.EdgeStageNodes)
  19088. }
  19089. if m.clearedstage_messages {
  19090. edges = append(edges, sopstage.EdgeStageMessages)
  19091. }
  19092. return edges
  19093. }
  19094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19095. // was cleared in this mutation.
  19096. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19097. switch name {
  19098. case sopstage.EdgeSopTask:
  19099. return m.clearedsop_task
  19100. case sopstage.EdgeStageNodes:
  19101. return m.clearedstage_nodes
  19102. case sopstage.EdgeStageMessages:
  19103. return m.clearedstage_messages
  19104. }
  19105. return false
  19106. }
  19107. // ClearEdge clears the value of the edge with the given name. It returns an error
  19108. // if that edge is not defined in the schema.
  19109. func (m *SopStageMutation) ClearEdge(name string) error {
  19110. switch name {
  19111. case sopstage.EdgeSopTask:
  19112. m.ClearSopTask()
  19113. return nil
  19114. }
  19115. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19116. }
  19117. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19118. // It returns an error if the edge is not defined in the schema.
  19119. func (m *SopStageMutation) ResetEdge(name string) error {
  19120. switch name {
  19121. case sopstage.EdgeSopTask:
  19122. m.ResetSopTask()
  19123. return nil
  19124. case sopstage.EdgeStageNodes:
  19125. m.ResetStageNodes()
  19126. return nil
  19127. case sopstage.EdgeStageMessages:
  19128. m.ResetStageMessages()
  19129. return nil
  19130. }
  19131. return fmt.Errorf("unknown SopStage edge %s", name)
  19132. }
  19133. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19134. type SopTaskMutation struct {
  19135. config
  19136. op Op
  19137. typ string
  19138. id *uint64
  19139. created_at *time.Time
  19140. updated_at *time.Time
  19141. status *uint8
  19142. addstatus *int8
  19143. deleted_at *time.Time
  19144. name *string
  19145. bot_wxid_list *[]string
  19146. appendbot_wxid_list []string
  19147. _type *int
  19148. add_type *int
  19149. plan_start_time *time.Time
  19150. plan_end_time *time.Time
  19151. creator_id *string
  19152. organization_id *uint64
  19153. addorganization_id *int64
  19154. clearedFields map[string]struct{}
  19155. task_stages map[uint64]struct{}
  19156. removedtask_stages map[uint64]struct{}
  19157. clearedtask_stages bool
  19158. done bool
  19159. oldValue func(context.Context) (*SopTask, error)
  19160. predicates []predicate.SopTask
  19161. }
  19162. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19163. // soptaskOption allows management of the mutation configuration using functional options.
  19164. type soptaskOption func(*SopTaskMutation)
  19165. // newSopTaskMutation creates new mutation for the SopTask entity.
  19166. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19167. m := &SopTaskMutation{
  19168. config: c,
  19169. op: op,
  19170. typ: TypeSopTask,
  19171. clearedFields: make(map[string]struct{}),
  19172. }
  19173. for _, opt := range opts {
  19174. opt(m)
  19175. }
  19176. return m
  19177. }
  19178. // withSopTaskID sets the ID field of the mutation.
  19179. func withSopTaskID(id uint64) soptaskOption {
  19180. return func(m *SopTaskMutation) {
  19181. var (
  19182. err error
  19183. once sync.Once
  19184. value *SopTask
  19185. )
  19186. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19187. once.Do(func() {
  19188. if m.done {
  19189. err = errors.New("querying old values post mutation is not allowed")
  19190. } else {
  19191. value, err = m.Client().SopTask.Get(ctx, id)
  19192. }
  19193. })
  19194. return value, err
  19195. }
  19196. m.id = &id
  19197. }
  19198. }
  19199. // withSopTask sets the old SopTask of the mutation.
  19200. func withSopTask(node *SopTask) soptaskOption {
  19201. return func(m *SopTaskMutation) {
  19202. m.oldValue = func(context.Context) (*SopTask, error) {
  19203. return node, nil
  19204. }
  19205. m.id = &node.ID
  19206. }
  19207. }
  19208. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19209. // executed in a transaction (ent.Tx), a transactional client is returned.
  19210. func (m SopTaskMutation) Client() *Client {
  19211. client := &Client{config: m.config}
  19212. client.init()
  19213. return client
  19214. }
  19215. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19216. // it returns an error otherwise.
  19217. func (m SopTaskMutation) Tx() (*Tx, error) {
  19218. if _, ok := m.driver.(*txDriver); !ok {
  19219. return nil, errors.New("ent: mutation is not running in a transaction")
  19220. }
  19221. tx := &Tx{config: m.config}
  19222. tx.init()
  19223. return tx, nil
  19224. }
  19225. // SetID sets the value of the id field. Note that this
  19226. // operation is only accepted on creation of SopTask entities.
  19227. func (m *SopTaskMutation) SetID(id uint64) {
  19228. m.id = &id
  19229. }
  19230. // ID returns the ID value in the mutation. Note that the ID is only available
  19231. // if it was provided to the builder or after it was returned from the database.
  19232. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19233. if m.id == nil {
  19234. return
  19235. }
  19236. return *m.id, true
  19237. }
  19238. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19239. // That means, if the mutation is applied within a transaction with an isolation level such
  19240. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19241. // or updated by the mutation.
  19242. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19243. switch {
  19244. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19245. id, exists := m.ID()
  19246. if exists {
  19247. return []uint64{id}, nil
  19248. }
  19249. fallthrough
  19250. case m.op.Is(OpUpdate | OpDelete):
  19251. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19252. default:
  19253. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19254. }
  19255. }
  19256. // SetCreatedAt sets the "created_at" field.
  19257. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19258. m.created_at = &t
  19259. }
  19260. // CreatedAt returns the value of the "created_at" field in the mutation.
  19261. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19262. v := m.created_at
  19263. if v == nil {
  19264. return
  19265. }
  19266. return *v, true
  19267. }
  19268. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19269. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19271. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19272. if !m.op.Is(OpUpdateOne) {
  19273. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19274. }
  19275. if m.id == nil || m.oldValue == nil {
  19276. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19277. }
  19278. oldValue, err := m.oldValue(ctx)
  19279. if err != nil {
  19280. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19281. }
  19282. return oldValue.CreatedAt, nil
  19283. }
  19284. // ResetCreatedAt resets all changes to the "created_at" field.
  19285. func (m *SopTaskMutation) ResetCreatedAt() {
  19286. m.created_at = nil
  19287. }
  19288. // SetUpdatedAt sets the "updated_at" field.
  19289. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19290. m.updated_at = &t
  19291. }
  19292. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19293. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19294. v := m.updated_at
  19295. if v == nil {
  19296. return
  19297. }
  19298. return *v, true
  19299. }
  19300. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19301. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19303. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19304. if !m.op.Is(OpUpdateOne) {
  19305. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19306. }
  19307. if m.id == nil || m.oldValue == nil {
  19308. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19309. }
  19310. oldValue, err := m.oldValue(ctx)
  19311. if err != nil {
  19312. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19313. }
  19314. return oldValue.UpdatedAt, nil
  19315. }
  19316. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19317. func (m *SopTaskMutation) ResetUpdatedAt() {
  19318. m.updated_at = nil
  19319. }
  19320. // SetStatus sets the "status" field.
  19321. func (m *SopTaskMutation) SetStatus(u uint8) {
  19322. m.status = &u
  19323. m.addstatus = nil
  19324. }
  19325. // Status returns the value of the "status" field in the mutation.
  19326. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19327. v := m.status
  19328. if v == nil {
  19329. return
  19330. }
  19331. return *v, true
  19332. }
  19333. // OldStatus returns the old "status" field's value of the SopTask entity.
  19334. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19336. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19337. if !m.op.Is(OpUpdateOne) {
  19338. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19339. }
  19340. if m.id == nil || m.oldValue == nil {
  19341. return v, errors.New("OldStatus requires an ID field in the mutation")
  19342. }
  19343. oldValue, err := m.oldValue(ctx)
  19344. if err != nil {
  19345. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19346. }
  19347. return oldValue.Status, nil
  19348. }
  19349. // AddStatus adds u to the "status" field.
  19350. func (m *SopTaskMutation) AddStatus(u int8) {
  19351. if m.addstatus != nil {
  19352. *m.addstatus += u
  19353. } else {
  19354. m.addstatus = &u
  19355. }
  19356. }
  19357. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19358. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19359. v := m.addstatus
  19360. if v == nil {
  19361. return
  19362. }
  19363. return *v, true
  19364. }
  19365. // ClearStatus clears the value of the "status" field.
  19366. func (m *SopTaskMutation) ClearStatus() {
  19367. m.status = nil
  19368. m.addstatus = nil
  19369. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19370. }
  19371. // StatusCleared returns if the "status" field was cleared in this mutation.
  19372. func (m *SopTaskMutation) StatusCleared() bool {
  19373. _, ok := m.clearedFields[soptask.FieldStatus]
  19374. return ok
  19375. }
  19376. // ResetStatus resets all changes to the "status" field.
  19377. func (m *SopTaskMutation) ResetStatus() {
  19378. m.status = nil
  19379. m.addstatus = nil
  19380. delete(m.clearedFields, soptask.FieldStatus)
  19381. }
  19382. // SetDeletedAt sets the "deleted_at" field.
  19383. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19384. m.deleted_at = &t
  19385. }
  19386. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19387. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19388. v := m.deleted_at
  19389. if v == nil {
  19390. return
  19391. }
  19392. return *v, true
  19393. }
  19394. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19395. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19397. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19398. if !m.op.Is(OpUpdateOne) {
  19399. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19400. }
  19401. if m.id == nil || m.oldValue == nil {
  19402. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19403. }
  19404. oldValue, err := m.oldValue(ctx)
  19405. if err != nil {
  19406. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19407. }
  19408. return oldValue.DeletedAt, nil
  19409. }
  19410. // ClearDeletedAt clears the value of the "deleted_at" field.
  19411. func (m *SopTaskMutation) ClearDeletedAt() {
  19412. m.deleted_at = nil
  19413. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19414. }
  19415. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19416. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19417. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19418. return ok
  19419. }
  19420. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19421. func (m *SopTaskMutation) ResetDeletedAt() {
  19422. m.deleted_at = nil
  19423. delete(m.clearedFields, soptask.FieldDeletedAt)
  19424. }
  19425. // SetName sets the "name" field.
  19426. func (m *SopTaskMutation) SetName(s string) {
  19427. m.name = &s
  19428. }
  19429. // Name returns the value of the "name" field in the mutation.
  19430. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19431. v := m.name
  19432. if v == nil {
  19433. return
  19434. }
  19435. return *v, true
  19436. }
  19437. // OldName returns the old "name" field's value of the SopTask entity.
  19438. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19440. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19441. if !m.op.Is(OpUpdateOne) {
  19442. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19443. }
  19444. if m.id == nil || m.oldValue == nil {
  19445. return v, errors.New("OldName requires an ID field in the mutation")
  19446. }
  19447. oldValue, err := m.oldValue(ctx)
  19448. if err != nil {
  19449. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19450. }
  19451. return oldValue.Name, nil
  19452. }
  19453. // ResetName resets all changes to the "name" field.
  19454. func (m *SopTaskMutation) ResetName() {
  19455. m.name = nil
  19456. }
  19457. // SetBotWxidList sets the "bot_wxid_list" field.
  19458. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19459. m.bot_wxid_list = &s
  19460. m.appendbot_wxid_list = nil
  19461. }
  19462. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19463. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19464. v := m.bot_wxid_list
  19465. if v == nil {
  19466. return
  19467. }
  19468. return *v, true
  19469. }
  19470. // OldBotWxidList returns the old "bot_wxid_list" 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) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19474. if !m.op.Is(OpUpdateOne) {
  19475. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19476. }
  19477. if m.id == nil || m.oldValue == nil {
  19478. return v, errors.New("OldBotWxidList 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 OldBotWxidList: %w", err)
  19483. }
  19484. return oldValue.BotWxidList, nil
  19485. }
  19486. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19487. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19488. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19489. }
  19490. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19491. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19492. if len(m.appendbot_wxid_list) == 0 {
  19493. return nil, false
  19494. }
  19495. return m.appendbot_wxid_list, true
  19496. }
  19497. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19498. func (m *SopTaskMutation) ClearBotWxidList() {
  19499. m.bot_wxid_list = nil
  19500. m.appendbot_wxid_list = nil
  19501. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19502. }
  19503. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19504. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19505. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19506. return ok
  19507. }
  19508. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19509. func (m *SopTaskMutation) ResetBotWxidList() {
  19510. m.bot_wxid_list = nil
  19511. m.appendbot_wxid_list = nil
  19512. delete(m.clearedFields, soptask.FieldBotWxidList)
  19513. }
  19514. // SetType sets the "type" field.
  19515. func (m *SopTaskMutation) SetType(i int) {
  19516. m._type = &i
  19517. m.add_type = nil
  19518. }
  19519. // GetType returns the value of the "type" field in the mutation.
  19520. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19521. v := m._type
  19522. if v == nil {
  19523. return
  19524. }
  19525. return *v, true
  19526. }
  19527. // OldType returns the old "type" field's value of the SopTask entity.
  19528. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19530. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19531. if !m.op.Is(OpUpdateOne) {
  19532. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19533. }
  19534. if m.id == nil || m.oldValue == nil {
  19535. return v, errors.New("OldType requires an ID field in the mutation")
  19536. }
  19537. oldValue, err := m.oldValue(ctx)
  19538. if err != nil {
  19539. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19540. }
  19541. return oldValue.Type, nil
  19542. }
  19543. // AddType adds i to the "type" field.
  19544. func (m *SopTaskMutation) AddType(i int) {
  19545. if m.add_type != nil {
  19546. *m.add_type += i
  19547. } else {
  19548. m.add_type = &i
  19549. }
  19550. }
  19551. // AddedType returns the value that was added to the "type" field in this mutation.
  19552. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19553. v := m.add_type
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // ResetType resets all changes to the "type" field.
  19560. func (m *SopTaskMutation) ResetType() {
  19561. m._type = nil
  19562. m.add_type = nil
  19563. }
  19564. // SetPlanStartTime sets the "plan_start_time" field.
  19565. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19566. m.plan_start_time = &t
  19567. }
  19568. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19569. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19570. v := m.plan_start_time
  19571. if v == nil {
  19572. return
  19573. }
  19574. return *v, true
  19575. }
  19576. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19577. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19579. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19580. if !m.op.Is(OpUpdateOne) {
  19581. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19582. }
  19583. if m.id == nil || m.oldValue == nil {
  19584. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19585. }
  19586. oldValue, err := m.oldValue(ctx)
  19587. if err != nil {
  19588. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19589. }
  19590. return oldValue.PlanStartTime, nil
  19591. }
  19592. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19593. func (m *SopTaskMutation) ClearPlanStartTime() {
  19594. m.plan_start_time = nil
  19595. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19596. }
  19597. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19598. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19599. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19600. return ok
  19601. }
  19602. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19603. func (m *SopTaskMutation) ResetPlanStartTime() {
  19604. m.plan_start_time = nil
  19605. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19606. }
  19607. // SetPlanEndTime sets the "plan_end_time" field.
  19608. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19609. m.plan_end_time = &t
  19610. }
  19611. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19612. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19613. v := m.plan_end_time
  19614. if v == nil {
  19615. return
  19616. }
  19617. return *v, true
  19618. }
  19619. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19620. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19622. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19623. if !m.op.Is(OpUpdateOne) {
  19624. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19625. }
  19626. if m.id == nil || m.oldValue == nil {
  19627. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19628. }
  19629. oldValue, err := m.oldValue(ctx)
  19630. if err != nil {
  19631. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19632. }
  19633. return oldValue.PlanEndTime, nil
  19634. }
  19635. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19636. func (m *SopTaskMutation) ClearPlanEndTime() {
  19637. m.plan_end_time = nil
  19638. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19639. }
  19640. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19641. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19642. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19643. return ok
  19644. }
  19645. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19646. func (m *SopTaskMutation) ResetPlanEndTime() {
  19647. m.plan_end_time = nil
  19648. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19649. }
  19650. // SetCreatorID sets the "creator_id" field.
  19651. func (m *SopTaskMutation) SetCreatorID(s string) {
  19652. m.creator_id = &s
  19653. }
  19654. // CreatorID returns the value of the "creator_id" field in the mutation.
  19655. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19656. v := m.creator_id
  19657. if v == nil {
  19658. return
  19659. }
  19660. return *v, true
  19661. }
  19662. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19663. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19665. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19666. if !m.op.Is(OpUpdateOne) {
  19667. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19668. }
  19669. if m.id == nil || m.oldValue == nil {
  19670. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19671. }
  19672. oldValue, err := m.oldValue(ctx)
  19673. if err != nil {
  19674. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19675. }
  19676. return oldValue.CreatorID, nil
  19677. }
  19678. // ClearCreatorID clears the value of the "creator_id" field.
  19679. func (m *SopTaskMutation) ClearCreatorID() {
  19680. m.creator_id = nil
  19681. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19682. }
  19683. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19684. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19685. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19686. return ok
  19687. }
  19688. // ResetCreatorID resets all changes to the "creator_id" field.
  19689. func (m *SopTaskMutation) ResetCreatorID() {
  19690. m.creator_id = nil
  19691. delete(m.clearedFields, soptask.FieldCreatorID)
  19692. }
  19693. // SetOrganizationID sets the "organization_id" field.
  19694. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19695. m.organization_id = &u
  19696. m.addorganization_id = nil
  19697. }
  19698. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19699. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19700. v := m.organization_id
  19701. if v == nil {
  19702. return
  19703. }
  19704. return *v, true
  19705. }
  19706. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19707. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19709. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19710. if !m.op.Is(OpUpdateOne) {
  19711. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19712. }
  19713. if m.id == nil || m.oldValue == nil {
  19714. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19715. }
  19716. oldValue, err := m.oldValue(ctx)
  19717. if err != nil {
  19718. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19719. }
  19720. return oldValue.OrganizationID, nil
  19721. }
  19722. // AddOrganizationID adds u to the "organization_id" field.
  19723. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19724. if m.addorganization_id != nil {
  19725. *m.addorganization_id += u
  19726. } else {
  19727. m.addorganization_id = &u
  19728. }
  19729. }
  19730. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19731. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19732. v := m.addorganization_id
  19733. if v == nil {
  19734. return
  19735. }
  19736. return *v, true
  19737. }
  19738. // ClearOrganizationID clears the value of the "organization_id" field.
  19739. func (m *SopTaskMutation) ClearOrganizationID() {
  19740. m.organization_id = nil
  19741. m.addorganization_id = nil
  19742. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19743. }
  19744. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19745. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19746. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19747. return ok
  19748. }
  19749. // ResetOrganizationID resets all changes to the "organization_id" field.
  19750. func (m *SopTaskMutation) ResetOrganizationID() {
  19751. m.organization_id = nil
  19752. m.addorganization_id = nil
  19753. delete(m.clearedFields, soptask.FieldOrganizationID)
  19754. }
  19755. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19756. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19757. if m.task_stages == nil {
  19758. m.task_stages = make(map[uint64]struct{})
  19759. }
  19760. for i := range ids {
  19761. m.task_stages[ids[i]] = struct{}{}
  19762. }
  19763. }
  19764. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19765. func (m *SopTaskMutation) ClearTaskStages() {
  19766. m.clearedtask_stages = true
  19767. }
  19768. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19769. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19770. return m.clearedtask_stages
  19771. }
  19772. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19773. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19774. if m.removedtask_stages == nil {
  19775. m.removedtask_stages = make(map[uint64]struct{})
  19776. }
  19777. for i := range ids {
  19778. delete(m.task_stages, ids[i])
  19779. m.removedtask_stages[ids[i]] = struct{}{}
  19780. }
  19781. }
  19782. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19783. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19784. for id := range m.removedtask_stages {
  19785. ids = append(ids, id)
  19786. }
  19787. return
  19788. }
  19789. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19790. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19791. for id := range m.task_stages {
  19792. ids = append(ids, id)
  19793. }
  19794. return
  19795. }
  19796. // ResetTaskStages resets all changes to the "task_stages" edge.
  19797. func (m *SopTaskMutation) ResetTaskStages() {
  19798. m.task_stages = nil
  19799. m.clearedtask_stages = false
  19800. m.removedtask_stages = nil
  19801. }
  19802. // Where appends a list predicates to the SopTaskMutation builder.
  19803. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19804. m.predicates = append(m.predicates, ps...)
  19805. }
  19806. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19807. // users can use type-assertion to append predicates that do not depend on any generated package.
  19808. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19809. p := make([]predicate.SopTask, len(ps))
  19810. for i := range ps {
  19811. p[i] = ps[i]
  19812. }
  19813. m.Where(p...)
  19814. }
  19815. // Op returns the operation name.
  19816. func (m *SopTaskMutation) Op() Op {
  19817. return m.op
  19818. }
  19819. // SetOp allows setting the mutation operation.
  19820. func (m *SopTaskMutation) SetOp(op Op) {
  19821. m.op = op
  19822. }
  19823. // Type returns the node type of this mutation (SopTask).
  19824. func (m *SopTaskMutation) Type() string {
  19825. return m.typ
  19826. }
  19827. // Fields returns all fields that were changed during this mutation. Note that in
  19828. // order to get all numeric fields that were incremented/decremented, call
  19829. // AddedFields().
  19830. func (m *SopTaskMutation) Fields() []string {
  19831. fields := make([]string, 0, 11)
  19832. if m.created_at != nil {
  19833. fields = append(fields, soptask.FieldCreatedAt)
  19834. }
  19835. if m.updated_at != nil {
  19836. fields = append(fields, soptask.FieldUpdatedAt)
  19837. }
  19838. if m.status != nil {
  19839. fields = append(fields, soptask.FieldStatus)
  19840. }
  19841. if m.deleted_at != nil {
  19842. fields = append(fields, soptask.FieldDeletedAt)
  19843. }
  19844. if m.name != nil {
  19845. fields = append(fields, soptask.FieldName)
  19846. }
  19847. if m.bot_wxid_list != nil {
  19848. fields = append(fields, soptask.FieldBotWxidList)
  19849. }
  19850. if m._type != nil {
  19851. fields = append(fields, soptask.FieldType)
  19852. }
  19853. if m.plan_start_time != nil {
  19854. fields = append(fields, soptask.FieldPlanStartTime)
  19855. }
  19856. if m.plan_end_time != nil {
  19857. fields = append(fields, soptask.FieldPlanEndTime)
  19858. }
  19859. if m.creator_id != nil {
  19860. fields = append(fields, soptask.FieldCreatorID)
  19861. }
  19862. if m.organization_id != nil {
  19863. fields = append(fields, soptask.FieldOrganizationID)
  19864. }
  19865. return fields
  19866. }
  19867. // Field returns the value of a field with the given name. The second boolean
  19868. // return value indicates that this field was not set, or was not defined in the
  19869. // schema.
  19870. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  19871. switch name {
  19872. case soptask.FieldCreatedAt:
  19873. return m.CreatedAt()
  19874. case soptask.FieldUpdatedAt:
  19875. return m.UpdatedAt()
  19876. case soptask.FieldStatus:
  19877. return m.Status()
  19878. case soptask.FieldDeletedAt:
  19879. return m.DeletedAt()
  19880. case soptask.FieldName:
  19881. return m.Name()
  19882. case soptask.FieldBotWxidList:
  19883. return m.BotWxidList()
  19884. case soptask.FieldType:
  19885. return m.GetType()
  19886. case soptask.FieldPlanStartTime:
  19887. return m.PlanStartTime()
  19888. case soptask.FieldPlanEndTime:
  19889. return m.PlanEndTime()
  19890. case soptask.FieldCreatorID:
  19891. return m.CreatorID()
  19892. case soptask.FieldOrganizationID:
  19893. return m.OrganizationID()
  19894. }
  19895. return nil, false
  19896. }
  19897. // OldField returns the old value of the field from the database. An error is
  19898. // returned if the mutation operation is not UpdateOne, or the query to the
  19899. // database failed.
  19900. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19901. switch name {
  19902. case soptask.FieldCreatedAt:
  19903. return m.OldCreatedAt(ctx)
  19904. case soptask.FieldUpdatedAt:
  19905. return m.OldUpdatedAt(ctx)
  19906. case soptask.FieldStatus:
  19907. return m.OldStatus(ctx)
  19908. case soptask.FieldDeletedAt:
  19909. return m.OldDeletedAt(ctx)
  19910. case soptask.FieldName:
  19911. return m.OldName(ctx)
  19912. case soptask.FieldBotWxidList:
  19913. return m.OldBotWxidList(ctx)
  19914. case soptask.FieldType:
  19915. return m.OldType(ctx)
  19916. case soptask.FieldPlanStartTime:
  19917. return m.OldPlanStartTime(ctx)
  19918. case soptask.FieldPlanEndTime:
  19919. return m.OldPlanEndTime(ctx)
  19920. case soptask.FieldCreatorID:
  19921. return m.OldCreatorID(ctx)
  19922. case soptask.FieldOrganizationID:
  19923. return m.OldOrganizationID(ctx)
  19924. }
  19925. return nil, fmt.Errorf("unknown SopTask field %s", name)
  19926. }
  19927. // SetField sets the value of a field with the given name. It returns an error if
  19928. // the field is not defined in the schema, or if the type mismatched the field
  19929. // type.
  19930. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  19931. switch name {
  19932. case soptask.FieldCreatedAt:
  19933. v, ok := value.(time.Time)
  19934. if !ok {
  19935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19936. }
  19937. m.SetCreatedAt(v)
  19938. return nil
  19939. case soptask.FieldUpdatedAt:
  19940. v, ok := value.(time.Time)
  19941. if !ok {
  19942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19943. }
  19944. m.SetUpdatedAt(v)
  19945. return nil
  19946. case soptask.FieldStatus:
  19947. v, ok := value.(uint8)
  19948. if !ok {
  19949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19950. }
  19951. m.SetStatus(v)
  19952. return nil
  19953. case soptask.FieldDeletedAt:
  19954. v, ok := value.(time.Time)
  19955. if !ok {
  19956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19957. }
  19958. m.SetDeletedAt(v)
  19959. return nil
  19960. case soptask.FieldName:
  19961. v, ok := value.(string)
  19962. if !ok {
  19963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19964. }
  19965. m.SetName(v)
  19966. return nil
  19967. case soptask.FieldBotWxidList:
  19968. v, ok := value.([]string)
  19969. if !ok {
  19970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19971. }
  19972. m.SetBotWxidList(v)
  19973. return nil
  19974. case soptask.FieldType:
  19975. v, ok := value.(int)
  19976. if !ok {
  19977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19978. }
  19979. m.SetType(v)
  19980. return nil
  19981. case soptask.FieldPlanStartTime:
  19982. v, ok := value.(time.Time)
  19983. if !ok {
  19984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19985. }
  19986. m.SetPlanStartTime(v)
  19987. return nil
  19988. case soptask.FieldPlanEndTime:
  19989. v, ok := value.(time.Time)
  19990. if !ok {
  19991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19992. }
  19993. m.SetPlanEndTime(v)
  19994. return nil
  19995. case soptask.FieldCreatorID:
  19996. v, ok := value.(string)
  19997. if !ok {
  19998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19999. }
  20000. m.SetCreatorID(v)
  20001. return nil
  20002. case soptask.FieldOrganizationID:
  20003. v, ok := value.(uint64)
  20004. if !ok {
  20005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20006. }
  20007. m.SetOrganizationID(v)
  20008. return nil
  20009. }
  20010. return fmt.Errorf("unknown SopTask field %s", name)
  20011. }
  20012. // AddedFields returns all numeric fields that were incremented/decremented during
  20013. // this mutation.
  20014. func (m *SopTaskMutation) AddedFields() []string {
  20015. var fields []string
  20016. if m.addstatus != nil {
  20017. fields = append(fields, soptask.FieldStatus)
  20018. }
  20019. if m.add_type != nil {
  20020. fields = append(fields, soptask.FieldType)
  20021. }
  20022. if m.addorganization_id != nil {
  20023. fields = append(fields, soptask.FieldOrganizationID)
  20024. }
  20025. return fields
  20026. }
  20027. // AddedField returns the numeric value that was incremented/decremented on a field
  20028. // with the given name. The second boolean return value indicates that this field
  20029. // was not set, or was not defined in the schema.
  20030. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20031. switch name {
  20032. case soptask.FieldStatus:
  20033. return m.AddedStatus()
  20034. case soptask.FieldType:
  20035. return m.AddedType()
  20036. case soptask.FieldOrganizationID:
  20037. return m.AddedOrganizationID()
  20038. }
  20039. return nil, false
  20040. }
  20041. // AddField adds the value to the field with the given name. It returns an error if
  20042. // the field is not defined in the schema, or if the type mismatched the field
  20043. // type.
  20044. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20045. switch name {
  20046. case soptask.FieldStatus:
  20047. v, ok := value.(int8)
  20048. if !ok {
  20049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20050. }
  20051. m.AddStatus(v)
  20052. return nil
  20053. case soptask.FieldType:
  20054. v, ok := value.(int)
  20055. if !ok {
  20056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20057. }
  20058. m.AddType(v)
  20059. return nil
  20060. case soptask.FieldOrganizationID:
  20061. v, ok := value.(int64)
  20062. if !ok {
  20063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20064. }
  20065. m.AddOrganizationID(v)
  20066. return nil
  20067. }
  20068. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20069. }
  20070. // ClearedFields returns all nullable fields that were cleared during this
  20071. // mutation.
  20072. func (m *SopTaskMutation) ClearedFields() []string {
  20073. var fields []string
  20074. if m.FieldCleared(soptask.FieldStatus) {
  20075. fields = append(fields, soptask.FieldStatus)
  20076. }
  20077. if m.FieldCleared(soptask.FieldDeletedAt) {
  20078. fields = append(fields, soptask.FieldDeletedAt)
  20079. }
  20080. if m.FieldCleared(soptask.FieldBotWxidList) {
  20081. fields = append(fields, soptask.FieldBotWxidList)
  20082. }
  20083. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20084. fields = append(fields, soptask.FieldPlanStartTime)
  20085. }
  20086. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20087. fields = append(fields, soptask.FieldPlanEndTime)
  20088. }
  20089. if m.FieldCleared(soptask.FieldCreatorID) {
  20090. fields = append(fields, soptask.FieldCreatorID)
  20091. }
  20092. if m.FieldCleared(soptask.FieldOrganizationID) {
  20093. fields = append(fields, soptask.FieldOrganizationID)
  20094. }
  20095. return fields
  20096. }
  20097. // FieldCleared returns a boolean indicating if a field with the given name was
  20098. // cleared in this mutation.
  20099. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20100. _, ok := m.clearedFields[name]
  20101. return ok
  20102. }
  20103. // ClearField clears the value of the field with the given name. It returns an
  20104. // error if the field is not defined in the schema.
  20105. func (m *SopTaskMutation) ClearField(name string) error {
  20106. switch name {
  20107. case soptask.FieldStatus:
  20108. m.ClearStatus()
  20109. return nil
  20110. case soptask.FieldDeletedAt:
  20111. m.ClearDeletedAt()
  20112. return nil
  20113. case soptask.FieldBotWxidList:
  20114. m.ClearBotWxidList()
  20115. return nil
  20116. case soptask.FieldPlanStartTime:
  20117. m.ClearPlanStartTime()
  20118. return nil
  20119. case soptask.FieldPlanEndTime:
  20120. m.ClearPlanEndTime()
  20121. return nil
  20122. case soptask.FieldCreatorID:
  20123. m.ClearCreatorID()
  20124. return nil
  20125. case soptask.FieldOrganizationID:
  20126. m.ClearOrganizationID()
  20127. return nil
  20128. }
  20129. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20130. }
  20131. // ResetField resets all changes in the mutation for the field with the given name.
  20132. // It returns an error if the field is not defined in the schema.
  20133. func (m *SopTaskMutation) ResetField(name string) error {
  20134. switch name {
  20135. case soptask.FieldCreatedAt:
  20136. m.ResetCreatedAt()
  20137. return nil
  20138. case soptask.FieldUpdatedAt:
  20139. m.ResetUpdatedAt()
  20140. return nil
  20141. case soptask.FieldStatus:
  20142. m.ResetStatus()
  20143. return nil
  20144. case soptask.FieldDeletedAt:
  20145. m.ResetDeletedAt()
  20146. return nil
  20147. case soptask.FieldName:
  20148. m.ResetName()
  20149. return nil
  20150. case soptask.FieldBotWxidList:
  20151. m.ResetBotWxidList()
  20152. return nil
  20153. case soptask.FieldType:
  20154. m.ResetType()
  20155. return nil
  20156. case soptask.FieldPlanStartTime:
  20157. m.ResetPlanStartTime()
  20158. return nil
  20159. case soptask.FieldPlanEndTime:
  20160. m.ResetPlanEndTime()
  20161. return nil
  20162. case soptask.FieldCreatorID:
  20163. m.ResetCreatorID()
  20164. return nil
  20165. case soptask.FieldOrganizationID:
  20166. m.ResetOrganizationID()
  20167. return nil
  20168. }
  20169. return fmt.Errorf("unknown SopTask field %s", name)
  20170. }
  20171. // AddedEdges returns all edge names that were set/added in this mutation.
  20172. func (m *SopTaskMutation) AddedEdges() []string {
  20173. edges := make([]string, 0, 1)
  20174. if m.task_stages != nil {
  20175. edges = append(edges, soptask.EdgeTaskStages)
  20176. }
  20177. return edges
  20178. }
  20179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20180. // name in this mutation.
  20181. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20182. switch name {
  20183. case soptask.EdgeTaskStages:
  20184. ids := make([]ent.Value, 0, len(m.task_stages))
  20185. for id := range m.task_stages {
  20186. ids = append(ids, id)
  20187. }
  20188. return ids
  20189. }
  20190. return nil
  20191. }
  20192. // RemovedEdges returns all edge names that were removed in this mutation.
  20193. func (m *SopTaskMutation) RemovedEdges() []string {
  20194. edges := make([]string, 0, 1)
  20195. if m.removedtask_stages != nil {
  20196. edges = append(edges, soptask.EdgeTaskStages)
  20197. }
  20198. return edges
  20199. }
  20200. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20201. // the given name in this mutation.
  20202. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20203. switch name {
  20204. case soptask.EdgeTaskStages:
  20205. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20206. for id := range m.removedtask_stages {
  20207. ids = append(ids, id)
  20208. }
  20209. return ids
  20210. }
  20211. return nil
  20212. }
  20213. // ClearedEdges returns all edge names that were cleared in this mutation.
  20214. func (m *SopTaskMutation) ClearedEdges() []string {
  20215. edges := make([]string, 0, 1)
  20216. if m.clearedtask_stages {
  20217. edges = append(edges, soptask.EdgeTaskStages)
  20218. }
  20219. return edges
  20220. }
  20221. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20222. // was cleared in this mutation.
  20223. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20224. switch name {
  20225. case soptask.EdgeTaskStages:
  20226. return m.clearedtask_stages
  20227. }
  20228. return false
  20229. }
  20230. // ClearEdge clears the value of the edge with the given name. It returns an error
  20231. // if that edge is not defined in the schema.
  20232. func (m *SopTaskMutation) ClearEdge(name string) error {
  20233. switch name {
  20234. }
  20235. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20236. }
  20237. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20238. // It returns an error if the edge is not defined in the schema.
  20239. func (m *SopTaskMutation) ResetEdge(name string) error {
  20240. switch name {
  20241. case soptask.EdgeTaskStages:
  20242. m.ResetTaskStages()
  20243. return nil
  20244. }
  20245. return fmt.Errorf("unknown SopTask edge %s", name)
  20246. }
  20247. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20248. type TokenMutation struct {
  20249. config
  20250. op Op
  20251. typ string
  20252. id *uint64
  20253. created_at *time.Time
  20254. updated_at *time.Time
  20255. deleted_at *time.Time
  20256. expire_at *time.Time
  20257. token *string
  20258. mac *string
  20259. organization_id *uint64
  20260. addorganization_id *int64
  20261. agent_id *uint64
  20262. addagent_id *int64
  20263. custom_agent_base *string
  20264. custom_agent_key *string
  20265. openai_base *string
  20266. openai_key *string
  20267. clearedFields map[string]struct{}
  20268. done bool
  20269. oldValue func(context.Context) (*Token, error)
  20270. predicates []predicate.Token
  20271. }
  20272. var _ ent.Mutation = (*TokenMutation)(nil)
  20273. // tokenOption allows management of the mutation configuration using functional options.
  20274. type tokenOption func(*TokenMutation)
  20275. // newTokenMutation creates new mutation for the Token entity.
  20276. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20277. m := &TokenMutation{
  20278. config: c,
  20279. op: op,
  20280. typ: TypeToken,
  20281. clearedFields: make(map[string]struct{}),
  20282. }
  20283. for _, opt := range opts {
  20284. opt(m)
  20285. }
  20286. return m
  20287. }
  20288. // withTokenID sets the ID field of the mutation.
  20289. func withTokenID(id uint64) tokenOption {
  20290. return func(m *TokenMutation) {
  20291. var (
  20292. err error
  20293. once sync.Once
  20294. value *Token
  20295. )
  20296. m.oldValue = func(ctx context.Context) (*Token, error) {
  20297. once.Do(func() {
  20298. if m.done {
  20299. err = errors.New("querying old values post mutation is not allowed")
  20300. } else {
  20301. value, err = m.Client().Token.Get(ctx, id)
  20302. }
  20303. })
  20304. return value, err
  20305. }
  20306. m.id = &id
  20307. }
  20308. }
  20309. // withToken sets the old Token of the mutation.
  20310. func withToken(node *Token) tokenOption {
  20311. return func(m *TokenMutation) {
  20312. m.oldValue = func(context.Context) (*Token, error) {
  20313. return node, nil
  20314. }
  20315. m.id = &node.ID
  20316. }
  20317. }
  20318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20319. // executed in a transaction (ent.Tx), a transactional client is returned.
  20320. func (m TokenMutation) Client() *Client {
  20321. client := &Client{config: m.config}
  20322. client.init()
  20323. return client
  20324. }
  20325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20326. // it returns an error otherwise.
  20327. func (m TokenMutation) Tx() (*Tx, error) {
  20328. if _, ok := m.driver.(*txDriver); !ok {
  20329. return nil, errors.New("ent: mutation is not running in a transaction")
  20330. }
  20331. tx := &Tx{config: m.config}
  20332. tx.init()
  20333. return tx, nil
  20334. }
  20335. // SetID sets the value of the id field. Note that this
  20336. // operation is only accepted on creation of Token entities.
  20337. func (m *TokenMutation) SetID(id uint64) {
  20338. m.id = &id
  20339. }
  20340. // ID returns the ID value in the mutation. Note that the ID is only available
  20341. // if it was provided to the builder or after it was returned from the database.
  20342. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20343. if m.id == nil {
  20344. return
  20345. }
  20346. return *m.id, true
  20347. }
  20348. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20349. // That means, if the mutation is applied within a transaction with an isolation level such
  20350. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20351. // or updated by the mutation.
  20352. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20353. switch {
  20354. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20355. id, exists := m.ID()
  20356. if exists {
  20357. return []uint64{id}, nil
  20358. }
  20359. fallthrough
  20360. case m.op.Is(OpUpdate | OpDelete):
  20361. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20362. default:
  20363. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20364. }
  20365. }
  20366. // SetCreatedAt sets the "created_at" field.
  20367. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20368. m.created_at = &t
  20369. }
  20370. // CreatedAt returns the value of the "created_at" field in the mutation.
  20371. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20372. v := m.created_at
  20373. if v == nil {
  20374. return
  20375. }
  20376. return *v, true
  20377. }
  20378. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20379. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20381. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20382. if !m.op.Is(OpUpdateOne) {
  20383. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20384. }
  20385. if m.id == nil || m.oldValue == nil {
  20386. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20387. }
  20388. oldValue, err := m.oldValue(ctx)
  20389. if err != nil {
  20390. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20391. }
  20392. return oldValue.CreatedAt, nil
  20393. }
  20394. // ResetCreatedAt resets all changes to the "created_at" field.
  20395. func (m *TokenMutation) ResetCreatedAt() {
  20396. m.created_at = nil
  20397. }
  20398. // SetUpdatedAt sets the "updated_at" field.
  20399. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20400. m.updated_at = &t
  20401. }
  20402. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20403. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20404. v := m.updated_at
  20405. if v == nil {
  20406. return
  20407. }
  20408. return *v, true
  20409. }
  20410. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20411. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20413. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20414. if !m.op.Is(OpUpdateOne) {
  20415. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20416. }
  20417. if m.id == nil || m.oldValue == nil {
  20418. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20419. }
  20420. oldValue, err := m.oldValue(ctx)
  20421. if err != nil {
  20422. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20423. }
  20424. return oldValue.UpdatedAt, nil
  20425. }
  20426. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20427. func (m *TokenMutation) ResetUpdatedAt() {
  20428. m.updated_at = nil
  20429. }
  20430. // SetDeletedAt sets the "deleted_at" field.
  20431. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20432. m.deleted_at = &t
  20433. }
  20434. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20435. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20436. v := m.deleted_at
  20437. if v == nil {
  20438. return
  20439. }
  20440. return *v, true
  20441. }
  20442. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20443. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20445. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20446. if !m.op.Is(OpUpdateOne) {
  20447. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20448. }
  20449. if m.id == nil || m.oldValue == nil {
  20450. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20451. }
  20452. oldValue, err := m.oldValue(ctx)
  20453. if err != nil {
  20454. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20455. }
  20456. return oldValue.DeletedAt, nil
  20457. }
  20458. // ClearDeletedAt clears the value of the "deleted_at" field.
  20459. func (m *TokenMutation) ClearDeletedAt() {
  20460. m.deleted_at = nil
  20461. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20462. }
  20463. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20464. func (m *TokenMutation) DeletedAtCleared() bool {
  20465. _, ok := m.clearedFields[token.FieldDeletedAt]
  20466. return ok
  20467. }
  20468. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20469. func (m *TokenMutation) ResetDeletedAt() {
  20470. m.deleted_at = nil
  20471. delete(m.clearedFields, token.FieldDeletedAt)
  20472. }
  20473. // SetExpireAt sets the "expire_at" field.
  20474. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20475. m.expire_at = &t
  20476. }
  20477. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20478. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20479. v := m.expire_at
  20480. if v == nil {
  20481. return
  20482. }
  20483. return *v, true
  20484. }
  20485. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20486. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20488. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20489. if !m.op.Is(OpUpdateOne) {
  20490. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20491. }
  20492. if m.id == nil || m.oldValue == nil {
  20493. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20494. }
  20495. oldValue, err := m.oldValue(ctx)
  20496. if err != nil {
  20497. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20498. }
  20499. return oldValue.ExpireAt, nil
  20500. }
  20501. // ClearExpireAt clears the value of the "expire_at" field.
  20502. func (m *TokenMutation) ClearExpireAt() {
  20503. m.expire_at = nil
  20504. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20505. }
  20506. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20507. func (m *TokenMutation) ExpireAtCleared() bool {
  20508. _, ok := m.clearedFields[token.FieldExpireAt]
  20509. return ok
  20510. }
  20511. // ResetExpireAt resets all changes to the "expire_at" field.
  20512. func (m *TokenMutation) ResetExpireAt() {
  20513. m.expire_at = nil
  20514. delete(m.clearedFields, token.FieldExpireAt)
  20515. }
  20516. // SetToken sets the "token" field.
  20517. func (m *TokenMutation) SetToken(s string) {
  20518. m.token = &s
  20519. }
  20520. // Token returns the value of the "token" field in the mutation.
  20521. func (m *TokenMutation) Token() (r string, exists bool) {
  20522. v := m.token
  20523. if v == nil {
  20524. return
  20525. }
  20526. return *v, true
  20527. }
  20528. // OldToken returns the old "token" field's value of the Token entity.
  20529. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20531. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20532. if !m.op.Is(OpUpdateOne) {
  20533. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20534. }
  20535. if m.id == nil || m.oldValue == nil {
  20536. return v, errors.New("OldToken requires an ID field in the mutation")
  20537. }
  20538. oldValue, err := m.oldValue(ctx)
  20539. if err != nil {
  20540. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20541. }
  20542. return oldValue.Token, nil
  20543. }
  20544. // ClearToken clears the value of the "token" field.
  20545. func (m *TokenMutation) ClearToken() {
  20546. m.token = nil
  20547. m.clearedFields[token.FieldToken] = struct{}{}
  20548. }
  20549. // TokenCleared returns if the "token" field was cleared in this mutation.
  20550. func (m *TokenMutation) TokenCleared() bool {
  20551. _, ok := m.clearedFields[token.FieldToken]
  20552. return ok
  20553. }
  20554. // ResetToken resets all changes to the "token" field.
  20555. func (m *TokenMutation) ResetToken() {
  20556. m.token = nil
  20557. delete(m.clearedFields, token.FieldToken)
  20558. }
  20559. // SetMAC sets the "mac" field.
  20560. func (m *TokenMutation) SetMAC(s string) {
  20561. m.mac = &s
  20562. }
  20563. // MAC returns the value of the "mac" field in the mutation.
  20564. func (m *TokenMutation) MAC() (r string, exists bool) {
  20565. v := m.mac
  20566. if v == nil {
  20567. return
  20568. }
  20569. return *v, true
  20570. }
  20571. // OldMAC returns the old "mac" field's value of the Token entity.
  20572. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20574. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20575. if !m.op.Is(OpUpdateOne) {
  20576. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20577. }
  20578. if m.id == nil || m.oldValue == nil {
  20579. return v, errors.New("OldMAC requires an ID field in the mutation")
  20580. }
  20581. oldValue, err := m.oldValue(ctx)
  20582. if err != nil {
  20583. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20584. }
  20585. return oldValue.MAC, nil
  20586. }
  20587. // ResetMAC resets all changes to the "mac" field.
  20588. func (m *TokenMutation) ResetMAC() {
  20589. m.mac = nil
  20590. }
  20591. // SetOrganizationID sets the "organization_id" field.
  20592. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20593. m.organization_id = &u
  20594. m.addorganization_id = nil
  20595. }
  20596. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20597. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20598. v := m.organization_id
  20599. if v == nil {
  20600. return
  20601. }
  20602. return *v, true
  20603. }
  20604. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20608. if !m.op.Is(OpUpdateOne) {
  20609. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20610. }
  20611. if m.id == nil || m.oldValue == nil {
  20612. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  20617. }
  20618. return oldValue.OrganizationID, nil
  20619. }
  20620. // AddOrganizationID adds u to the "organization_id" field.
  20621. func (m *TokenMutation) AddOrganizationID(u int64) {
  20622. if m.addorganization_id != nil {
  20623. *m.addorganization_id += u
  20624. } else {
  20625. m.addorganization_id = &u
  20626. }
  20627. }
  20628. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20629. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20630. v := m.addorganization_id
  20631. if v == nil {
  20632. return
  20633. }
  20634. return *v, true
  20635. }
  20636. // ResetOrganizationID resets all changes to the "organization_id" field.
  20637. func (m *TokenMutation) ResetOrganizationID() {
  20638. m.organization_id = nil
  20639. m.addorganization_id = nil
  20640. }
  20641. // SetAgentID sets the "agent_id" field.
  20642. func (m *TokenMutation) SetAgentID(u uint64) {
  20643. m.agent_id = &u
  20644. m.addagent_id = nil
  20645. }
  20646. // AgentID returns the value of the "agent_id" field in the mutation.
  20647. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20648. v := m.agent_id
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20655. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20657. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20658. if !m.op.Is(OpUpdateOne) {
  20659. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20660. }
  20661. if m.id == nil || m.oldValue == nil {
  20662. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20663. }
  20664. oldValue, err := m.oldValue(ctx)
  20665. if err != nil {
  20666. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20667. }
  20668. return oldValue.AgentID, nil
  20669. }
  20670. // AddAgentID adds u to the "agent_id" field.
  20671. func (m *TokenMutation) AddAgentID(u int64) {
  20672. if m.addagent_id != nil {
  20673. *m.addagent_id += u
  20674. } else {
  20675. m.addagent_id = &u
  20676. }
  20677. }
  20678. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  20679. func (m *TokenMutation) AddedAgentID() (r int64, exists bool) {
  20680. v := m.addagent_id
  20681. if v == nil {
  20682. return
  20683. }
  20684. return *v, true
  20685. }
  20686. // ResetAgentID resets all changes to the "agent_id" field.
  20687. func (m *TokenMutation) ResetAgentID() {
  20688. m.agent_id = nil
  20689. m.addagent_id = nil
  20690. }
  20691. // SetCustomAgentBase sets the "custom_agent_base" field.
  20692. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20693. m.custom_agent_base = &s
  20694. }
  20695. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20696. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20697. v := m.custom_agent_base
  20698. if v == nil {
  20699. return
  20700. }
  20701. return *v, true
  20702. }
  20703. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20704. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20706. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20707. if !m.op.Is(OpUpdateOne) {
  20708. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20709. }
  20710. if m.id == nil || m.oldValue == nil {
  20711. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20712. }
  20713. oldValue, err := m.oldValue(ctx)
  20714. if err != nil {
  20715. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20716. }
  20717. return oldValue.CustomAgentBase, nil
  20718. }
  20719. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20720. func (m *TokenMutation) ClearCustomAgentBase() {
  20721. m.custom_agent_base = nil
  20722. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20723. }
  20724. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20725. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20726. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20727. return ok
  20728. }
  20729. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20730. func (m *TokenMutation) ResetCustomAgentBase() {
  20731. m.custom_agent_base = nil
  20732. delete(m.clearedFields, token.FieldCustomAgentBase)
  20733. }
  20734. // SetCustomAgentKey sets the "custom_agent_key" field.
  20735. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20736. m.custom_agent_key = &s
  20737. }
  20738. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20739. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20740. v := m.custom_agent_key
  20741. if v == nil {
  20742. return
  20743. }
  20744. return *v, true
  20745. }
  20746. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20747. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20749. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20750. if !m.op.Is(OpUpdateOne) {
  20751. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20752. }
  20753. if m.id == nil || m.oldValue == nil {
  20754. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20755. }
  20756. oldValue, err := m.oldValue(ctx)
  20757. if err != nil {
  20758. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20759. }
  20760. return oldValue.CustomAgentKey, nil
  20761. }
  20762. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20763. func (m *TokenMutation) ClearCustomAgentKey() {
  20764. m.custom_agent_key = nil
  20765. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20766. }
  20767. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20768. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20769. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20770. return ok
  20771. }
  20772. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20773. func (m *TokenMutation) ResetCustomAgentKey() {
  20774. m.custom_agent_key = nil
  20775. delete(m.clearedFields, token.FieldCustomAgentKey)
  20776. }
  20777. // SetOpenaiBase sets the "openai_base" field.
  20778. func (m *TokenMutation) SetOpenaiBase(s string) {
  20779. m.openai_base = &s
  20780. }
  20781. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20782. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20783. v := m.openai_base
  20784. if v == nil {
  20785. return
  20786. }
  20787. return *v, true
  20788. }
  20789. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20790. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20792. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  20793. if !m.op.Is(OpUpdateOne) {
  20794. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  20795. }
  20796. if m.id == nil || m.oldValue == nil {
  20797. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  20798. }
  20799. oldValue, err := m.oldValue(ctx)
  20800. if err != nil {
  20801. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  20802. }
  20803. return oldValue.OpenaiBase, nil
  20804. }
  20805. // ClearOpenaiBase clears the value of the "openai_base" field.
  20806. func (m *TokenMutation) ClearOpenaiBase() {
  20807. m.openai_base = nil
  20808. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  20809. }
  20810. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  20811. func (m *TokenMutation) OpenaiBaseCleared() bool {
  20812. _, ok := m.clearedFields[token.FieldOpenaiBase]
  20813. return ok
  20814. }
  20815. // ResetOpenaiBase resets all changes to the "openai_base" field.
  20816. func (m *TokenMutation) ResetOpenaiBase() {
  20817. m.openai_base = nil
  20818. delete(m.clearedFields, token.FieldOpenaiBase)
  20819. }
  20820. // SetOpenaiKey sets the "openai_key" field.
  20821. func (m *TokenMutation) SetOpenaiKey(s string) {
  20822. m.openai_key = &s
  20823. }
  20824. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  20825. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  20826. v := m.openai_key
  20827. if v == nil {
  20828. return
  20829. }
  20830. return *v, true
  20831. }
  20832. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  20833. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20835. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  20836. if !m.op.Is(OpUpdateOne) {
  20837. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  20838. }
  20839. if m.id == nil || m.oldValue == nil {
  20840. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  20841. }
  20842. oldValue, err := m.oldValue(ctx)
  20843. if err != nil {
  20844. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  20845. }
  20846. return oldValue.OpenaiKey, nil
  20847. }
  20848. // ClearOpenaiKey clears the value of the "openai_key" field.
  20849. func (m *TokenMutation) ClearOpenaiKey() {
  20850. m.openai_key = nil
  20851. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  20852. }
  20853. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  20854. func (m *TokenMutation) OpenaiKeyCleared() bool {
  20855. _, ok := m.clearedFields[token.FieldOpenaiKey]
  20856. return ok
  20857. }
  20858. // ResetOpenaiKey resets all changes to the "openai_key" field.
  20859. func (m *TokenMutation) ResetOpenaiKey() {
  20860. m.openai_key = nil
  20861. delete(m.clearedFields, token.FieldOpenaiKey)
  20862. }
  20863. // Where appends a list predicates to the TokenMutation builder.
  20864. func (m *TokenMutation) Where(ps ...predicate.Token) {
  20865. m.predicates = append(m.predicates, ps...)
  20866. }
  20867. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  20868. // users can use type-assertion to append predicates that do not depend on any generated package.
  20869. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  20870. p := make([]predicate.Token, len(ps))
  20871. for i := range ps {
  20872. p[i] = ps[i]
  20873. }
  20874. m.Where(p...)
  20875. }
  20876. // Op returns the operation name.
  20877. func (m *TokenMutation) Op() Op {
  20878. return m.op
  20879. }
  20880. // SetOp allows setting the mutation operation.
  20881. func (m *TokenMutation) SetOp(op Op) {
  20882. m.op = op
  20883. }
  20884. // Type returns the node type of this mutation (Token).
  20885. func (m *TokenMutation) Type() string {
  20886. return m.typ
  20887. }
  20888. // Fields returns all fields that were changed during this mutation. Note that in
  20889. // order to get all numeric fields that were incremented/decremented, call
  20890. // AddedFields().
  20891. func (m *TokenMutation) Fields() []string {
  20892. fields := make([]string, 0, 12)
  20893. if m.created_at != nil {
  20894. fields = append(fields, token.FieldCreatedAt)
  20895. }
  20896. if m.updated_at != nil {
  20897. fields = append(fields, token.FieldUpdatedAt)
  20898. }
  20899. if m.deleted_at != nil {
  20900. fields = append(fields, token.FieldDeletedAt)
  20901. }
  20902. if m.expire_at != nil {
  20903. fields = append(fields, token.FieldExpireAt)
  20904. }
  20905. if m.token != nil {
  20906. fields = append(fields, token.FieldToken)
  20907. }
  20908. if m.mac != nil {
  20909. fields = append(fields, token.FieldMAC)
  20910. }
  20911. if m.organization_id != nil {
  20912. fields = append(fields, token.FieldOrganizationID)
  20913. }
  20914. if m.agent_id != nil {
  20915. fields = append(fields, token.FieldAgentID)
  20916. }
  20917. if m.custom_agent_base != nil {
  20918. fields = append(fields, token.FieldCustomAgentBase)
  20919. }
  20920. if m.custom_agent_key != nil {
  20921. fields = append(fields, token.FieldCustomAgentKey)
  20922. }
  20923. if m.openai_base != nil {
  20924. fields = append(fields, token.FieldOpenaiBase)
  20925. }
  20926. if m.openai_key != nil {
  20927. fields = append(fields, token.FieldOpenaiKey)
  20928. }
  20929. return fields
  20930. }
  20931. // Field returns the value of a field with the given name. The second boolean
  20932. // return value indicates that this field was not set, or was not defined in the
  20933. // schema.
  20934. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  20935. switch name {
  20936. case token.FieldCreatedAt:
  20937. return m.CreatedAt()
  20938. case token.FieldUpdatedAt:
  20939. return m.UpdatedAt()
  20940. case token.FieldDeletedAt:
  20941. return m.DeletedAt()
  20942. case token.FieldExpireAt:
  20943. return m.ExpireAt()
  20944. case token.FieldToken:
  20945. return m.Token()
  20946. case token.FieldMAC:
  20947. return m.MAC()
  20948. case token.FieldOrganizationID:
  20949. return m.OrganizationID()
  20950. case token.FieldAgentID:
  20951. return m.AgentID()
  20952. case token.FieldCustomAgentBase:
  20953. return m.CustomAgentBase()
  20954. case token.FieldCustomAgentKey:
  20955. return m.CustomAgentKey()
  20956. case token.FieldOpenaiBase:
  20957. return m.OpenaiBase()
  20958. case token.FieldOpenaiKey:
  20959. return m.OpenaiKey()
  20960. }
  20961. return nil, false
  20962. }
  20963. // OldField returns the old value of the field from the database. An error is
  20964. // returned if the mutation operation is not UpdateOne, or the query to the
  20965. // database failed.
  20966. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20967. switch name {
  20968. case token.FieldCreatedAt:
  20969. return m.OldCreatedAt(ctx)
  20970. case token.FieldUpdatedAt:
  20971. return m.OldUpdatedAt(ctx)
  20972. case token.FieldDeletedAt:
  20973. return m.OldDeletedAt(ctx)
  20974. case token.FieldExpireAt:
  20975. return m.OldExpireAt(ctx)
  20976. case token.FieldToken:
  20977. return m.OldToken(ctx)
  20978. case token.FieldMAC:
  20979. return m.OldMAC(ctx)
  20980. case token.FieldOrganizationID:
  20981. return m.OldOrganizationID(ctx)
  20982. case token.FieldAgentID:
  20983. return m.OldAgentID(ctx)
  20984. case token.FieldCustomAgentBase:
  20985. return m.OldCustomAgentBase(ctx)
  20986. case token.FieldCustomAgentKey:
  20987. return m.OldCustomAgentKey(ctx)
  20988. case token.FieldOpenaiBase:
  20989. return m.OldOpenaiBase(ctx)
  20990. case token.FieldOpenaiKey:
  20991. return m.OldOpenaiKey(ctx)
  20992. }
  20993. return nil, fmt.Errorf("unknown Token field %s", name)
  20994. }
  20995. // SetField sets the value of a field with the given name. It returns an error if
  20996. // the field is not defined in the schema, or if the type mismatched the field
  20997. // type.
  20998. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  20999. switch name {
  21000. case token.FieldCreatedAt:
  21001. v, ok := value.(time.Time)
  21002. if !ok {
  21003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21004. }
  21005. m.SetCreatedAt(v)
  21006. return nil
  21007. case token.FieldUpdatedAt:
  21008. v, ok := value.(time.Time)
  21009. if !ok {
  21010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21011. }
  21012. m.SetUpdatedAt(v)
  21013. return nil
  21014. case token.FieldDeletedAt:
  21015. v, ok := value.(time.Time)
  21016. if !ok {
  21017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21018. }
  21019. m.SetDeletedAt(v)
  21020. return nil
  21021. case token.FieldExpireAt:
  21022. v, ok := value.(time.Time)
  21023. if !ok {
  21024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21025. }
  21026. m.SetExpireAt(v)
  21027. return nil
  21028. case token.FieldToken:
  21029. v, ok := value.(string)
  21030. if !ok {
  21031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21032. }
  21033. m.SetToken(v)
  21034. return nil
  21035. case token.FieldMAC:
  21036. v, ok := value.(string)
  21037. if !ok {
  21038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21039. }
  21040. m.SetMAC(v)
  21041. return nil
  21042. case token.FieldOrganizationID:
  21043. v, ok := value.(uint64)
  21044. if !ok {
  21045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21046. }
  21047. m.SetOrganizationID(v)
  21048. return nil
  21049. case token.FieldAgentID:
  21050. v, ok := value.(uint64)
  21051. if !ok {
  21052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21053. }
  21054. m.SetAgentID(v)
  21055. return nil
  21056. case token.FieldCustomAgentBase:
  21057. v, ok := value.(string)
  21058. if !ok {
  21059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21060. }
  21061. m.SetCustomAgentBase(v)
  21062. return nil
  21063. case token.FieldCustomAgentKey:
  21064. v, ok := value.(string)
  21065. if !ok {
  21066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21067. }
  21068. m.SetCustomAgentKey(v)
  21069. return nil
  21070. case token.FieldOpenaiBase:
  21071. v, ok := value.(string)
  21072. if !ok {
  21073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21074. }
  21075. m.SetOpenaiBase(v)
  21076. return nil
  21077. case token.FieldOpenaiKey:
  21078. v, ok := value.(string)
  21079. if !ok {
  21080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21081. }
  21082. m.SetOpenaiKey(v)
  21083. return nil
  21084. }
  21085. return fmt.Errorf("unknown Token field %s", name)
  21086. }
  21087. // AddedFields returns all numeric fields that were incremented/decremented during
  21088. // this mutation.
  21089. func (m *TokenMutation) AddedFields() []string {
  21090. var fields []string
  21091. if m.addorganization_id != nil {
  21092. fields = append(fields, token.FieldOrganizationID)
  21093. }
  21094. if m.addagent_id != nil {
  21095. fields = append(fields, token.FieldAgentID)
  21096. }
  21097. return fields
  21098. }
  21099. // AddedField returns the numeric value that was incremented/decremented on a field
  21100. // with the given name. The second boolean return value indicates that this field
  21101. // was not set, or was not defined in the schema.
  21102. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21103. switch name {
  21104. case token.FieldOrganizationID:
  21105. return m.AddedOrganizationID()
  21106. case token.FieldAgentID:
  21107. return m.AddedAgentID()
  21108. }
  21109. return nil, false
  21110. }
  21111. // AddField adds the value to the field with the given name. It returns an error if
  21112. // the field is not defined in the schema, or if the type mismatched the field
  21113. // type.
  21114. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21115. switch name {
  21116. case token.FieldOrganizationID:
  21117. v, ok := value.(int64)
  21118. if !ok {
  21119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21120. }
  21121. m.AddOrganizationID(v)
  21122. return nil
  21123. case token.FieldAgentID:
  21124. v, ok := value.(int64)
  21125. if !ok {
  21126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21127. }
  21128. m.AddAgentID(v)
  21129. return nil
  21130. }
  21131. return fmt.Errorf("unknown Token numeric field %s", name)
  21132. }
  21133. // ClearedFields returns all nullable fields that were cleared during this
  21134. // mutation.
  21135. func (m *TokenMutation) ClearedFields() []string {
  21136. var fields []string
  21137. if m.FieldCleared(token.FieldDeletedAt) {
  21138. fields = append(fields, token.FieldDeletedAt)
  21139. }
  21140. if m.FieldCleared(token.FieldExpireAt) {
  21141. fields = append(fields, token.FieldExpireAt)
  21142. }
  21143. if m.FieldCleared(token.FieldToken) {
  21144. fields = append(fields, token.FieldToken)
  21145. }
  21146. if m.FieldCleared(token.FieldCustomAgentBase) {
  21147. fields = append(fields, token.FieldCustomAgentBase)
  21148. }
  21149. if m.FieldCleared(token.FieldCustomAgentKey) {
  21150. fields = append(fields, token.FieldCustomAgentKey)
  21151. }
  21152. if m.FieldCleared(token.FieldOpenaiBase) {
  21153. fields = append(fields, token.FieldOpenaiBase)
  21154. }
  21155. if m.FieldCleared(token.FieldOpenaiKey) {
  21156. fields = append(fields, token.FieldOpenaiKey)
  21157. }
  21158. return fields
  21159. }
  21160. // FieldCleared returns a boolean indicating if a field with the given name was
  21161. // cleared in this mutation.
  21162. func (m *TokenMutation) FieldCleared(name string) bool {
  21163. _, ok := m.clearedFields[name]
  21164. return ok
  21165. }
  21166. // ClearField clears the value of the field with the given name. It returns an
  21167. // error if the field is not defined in the schema.
  21168. func (m *TokenMutation) ClearField(name string) error {
  21169. switch name {
  21170. case token.FieldDeletedAt:
  21171. m.ClearDeletedAt()
  21172. return nil
  21173. case token.FieldExpireAt:
  21174. m.ClearExpireAt()
  21175. return nil
  21176. case token.FieldToken:
  21177. m.ClearToken()
  21178. return nil
  21179. case token.FieldCustomAgentBase:
  21180. m.ClearCustomAgentBase()
  21181. return nil
  21182. case token.FieldCustomAgentKey:
  21183. m.ClearCustomAgentKey()
  21184. return nil
  21185. case token.FieldOpenaiBase:
  21186. m.ClearOpenaiBase()
  21187. return nil
  21188. case token.FieldOpenaiKey:
  21189. m.ClearOpenaiKey()
  21190. return nil
  21191. }
  21192. return fmt.Errorf("unknown Token nullable field %s", name)
  21193. }
  21194. // ResetField resets all changes in the mutation for the field with the given name.
  21195. // It returns an error if the field is not defined in the schema.
  21196. func (m *TokenMutation) ResetField(name string) error {
  21197. switch name {
  21198. case token.FieldCreatedAt:
  21199. m.ResetCreatedAt()
  21200. return nil
  21201. case token.FieldUpdatedAt:
  21202. m.ResetUpdatedAt()
  21203. return nil
  21204. case token.FieldDeletedAt:
  21205. m.ResetDeletedAt()
  21206. return nil
  21207. case token.FieldExpireAt:
  21208. m.ResetExpireAt()
  21209. return nil
  21210. case token.FieldToken:
  21211. m.ResetToken()
  21212. return nil
  21213. case token.FieldMAC:
  21214. m.ResetMAC()
  21215. return nil
  21216. case token.FieldOrganizationID:
  21217. m.ResetOrganizationID()
  21218. return nil
  21219. case token.FieldAgentID:
  21220. m.ResetAgentID()
  21221. return nil
  21222. case token.FieldCustomAgentBase:
  21223. m.ResetCustomAgentBase()
  21224. return nil
  21225. case token.FieldCustomAgentKey:
  21226. m.ResetCustomAgentKey()
  21227. return nil
  21228. case token.FieldOpenaiBase:
  21229. m.ResetOpenaiBase()
  21230. return nil
  21231. case token.FieldOpenaiKey:
  21232. m.ResetOpenaiKey()
  21233. return nil
  21234. }
  21235. return fmt.Errorf("unknown Token field %s", name)
  21236. }
  21237. // AddedEdges returns all edge names that were set/added in this mutation.
  21238. func (m *TokenMutation) AddedEdges() []string {
  21239. edges := make([]string, 0, 0)
  21240. return edges
  21241. }
  21242. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21243. // name in this mutation.
  21244. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21245. return nil
  21246. }
  21247. // RemovedEdges returns all edge names that were removed in this mutation.
  21248. func (m *TokenMutation) RemovedEdges() []string {
  21249. edges := make([]string, 0, 0)
  21250. return edges
  21251. }
  21252. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21253. // the given name in this mutation.
  21254. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21255. return nil
  21256. }
  21257. // ClearedEdges returns all edge names that were cleared in this mutation.
  21258. func (m *TokenMutation) ClearedEdges() []string {
  21259. edges := make([]string, 0, 0)
  21260. return edges
  21261. }
  21262. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21263. // was cleared in this mutation.
  21264. func (m *TokenMutation) EdgeCleared(name string) bool {
  21265. return false
  21266. }
  21267. // ClearEdge clears the value of the edge with the given name. It returns an error
  21268. // if that edge is not defined in the schema.
  21269. func (m *TokenMutation) ClearEdge(name string) error {
  21270. return fmt.Errorf("unknown Token unique edge %s", name)
  21271. }
  21272. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21273. // It returns an error if the edge is not defined in the schema.
  21274. func (m *TokenMutation) ResetEdge(name string) error {
  21275. return fmt.Errorf("unknown Token edge %s", name)
  21276. }
  21277. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21278. type TutorialMutation struct {
  21279. config
  21280. op Op
  21281. typ string
  21282. id *uint64
  21283. created_at *time.Time
  21284. updated_at *time.Time
  21285. deleted_at *time.Time
  21286. index *int
  21287. addindex *int
  21288. title *string
  21289. content *string
  21290. organization_id *uint64
  21291. addorganization_id *int64
  21292. clearedFields map[string]struct{}
  21293. employee *uint64
  21294. clearedemployee bool
  21295. done bool
  21296. oldValue func(context.Context) (*Tutorial, error)
  21297. predicates []predicate.Tutorial
  21298. }
  21299. var _ ent.Mutation = (*TutorialMutation)(nil)
  21300. // tutorialOption allows management of the mutation configuration using functional options.
  21301. type tutorialOption func(*TutorialMutation)
  21302. // newTutorialMutation creates new mutation for the Tutorial entity.
  21303. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21304. m := &TutorialMutation{
  21305. config: c,
  21306. op: op,
  21307. typ: TypeTutorial,
  21308. clearedFields: make(map[string]struct{}),
  21309. }
  21310. for _, opt := range opts {
  21311. opt(m)
  21312. }
  21313. return m
  21314. }
  21315. // withTutorialID sets the ID field of the mutation.
  21316. func withTutorialID(id uint64) tutorialOption {
  21317. return func(m *TutorialMutation) {
  21318. var (
  21319. err error
  21320. once sync.Once
  21321. value *Tutorial
  21322. )
  21323. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21324. once.Do(func() {
  21325. if m.done {
  21326. err = errors.New("querying old values post mutation is not allowed")
  21327. } else {
  21328. value, err = m.Client().Tutorial.Get(ctx, id)
  21329. }
  21330. })
  21331. return value, err
  21332. }
  21333. m.id = &id
  21334. }
  21335. }
  21336. // withTutorial sets the old Tutorial of the mutation.
  21337. func withTutorial(node *Tutorial) tutorialOption {
  21338. return func(m *TutorialMutation) {
  21339. m.oldValue = func(context.Context) (*Tutorial, error) {
  21340. return node, nil
  21341. }
  21342. m.id = &node.ID
  21343. }
  21344. }
  21345. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21346. // executed in a transaction (ent.Tx), a transactional client is returned.
  21347. func (m TutorialMutation) Client() *Client {
  21348. client := &Client{config: m.config}
  21349. client.init()
  21350. return client
  21351. }
  21352. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21353. // it returns an error otherwise.
  21354. func (m TutorialMutation) Tx() (*Tx, error) {
  21355. if _, ok := m.driver.(*txDriver); !ok {
  21356. return nil, errors.New("ent: mutation is not running in a transaction")
  21357. }
  21358. tx := &Tx{config: m.config}
  21359. tx.init()
  21360. return tx, nil
  21361. }
  21362. // SetID sets the value of the id field. Note that this
  21363. // operation is only accepted on creation of Tutorial entities.
  21364. func (m *TutorialMutation) SetID(id uint64) {
  21365. m.id = &id
  21366. }
  21367. // ID returns the ID value in the mutation. Note that the ID is only available
  21368. // if it was provided to the builder or after it was returned from the database.
  21369. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21370. if m.id == nil {
  21371. return
  21372. }
  21373. return *m.id, true
  21374. }
  21375. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21376. // That means, if the mutation is applied within a transaction with an isolation level such
  21377. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21378. // or updated by the mutation.
  21379. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21380. switch {
  21381. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21382. id, exists := m.ID()
  21383. if exists {
  21384. return []uint64{id}, nil
  21385. }
  21386. fallthrough
  21387. case m.op.Is(OpUpdate | OpDelete):
  21388. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21389. default:
  21390. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21391. }
  21392. }
  21393. // SetCreatedAt sets the "created_at" field.
  21394. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21395. m.created_at = &t
  21396. }
  21397. // CreatedAt returns the value of the "created_at" field in the mutation.
  21398. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21399. v := m.created_at
  21400. if v == nil {
  21401. return
  21402. }
  21403. return *v, true
  21404. }
  21405. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21406. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21408. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21409. if !m.op.Is(OpUpdateOne) {
  21410. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21411. }
  21412. if m.id == nil || m.oldValue == nil {
  21413. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21414. }
  21415. oldValue, err := m.oldValue(ctx)
  21416. if err != nil {
  21417. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21418. }
  21419. return oldValue.CreatedAt, nil
  21420. }
  21421. // ResetCreatedAt resets all changes to the "created_at" field.
  21422. func (m *TutorialMutation) ResetCreatedAt() {
  21423. m.created_at = nil
  21424. }
  21425. // SetUpdatedAt sets the "updated_at" field.
  21426. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21427. m.updated_at = &t
  21428. }
  21429. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21430. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21431. v := m.updated_at
  21432. if v == nil {
  21433. return
  21434. }
  21435. return *v, true
  21436. }
  21437. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21438. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21440. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21441. if !m.op.Is(OpUpdateOne) {
  21442. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21443. }
  21444. if m.id == nil || m.oldValue == nil {
  21445. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21446. }
  21447. oldValue, err := m.oldValue(ctx)
  21448. if err != nil {
  21449. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21450. }
  21451. return oldValue.UpdatedAt, nil
  21452. }
  21453. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21454. func (m *TutorialMutation) ResetUpdatedAt() {
  21455. m.updated_at = nil
  21456. }
  21457. // SetDeletedAt sets the "deleted_at" field.
  21458. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21459. m.deleted_at = &t
  21460. }
  21461. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21462. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21463. v := m.deleted_at
  21464. if v == nil {
  21465. return
  21466. }
  21467. return *v, true
  21468. }
  21469. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21470. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21472. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21473. if !m.op.Is(OpUpdateOne) {
  21474. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21475. }
  21476. if m.id == nil || m.oldValue == nil {
  21477. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21478. }
  21479. oldValue, err := m.oldValue(ctx)
  21480. if err != nil {
  21481. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21482. }
  21483. return oldValue.DeletedAt, nil
  21484. }
  21485. // ClearDeletedAt clears the value of the "deleted_at" field.
  21486. func (m *TutorialMutation) ClearDeletedAt() {
  21487. m.deleted_at = nil
  21488. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21489. }
  21490. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21491. func (m *TutorialMutation) DeletedAtCleared() bool {
  21492. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21493. return ok
  21494. }
  21495. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21496. func (m *TutorialMutation) ResetDeletedAt() {
  21497. m.deleted_at = nil
  21498. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21499. }
  21500. // SetEmployeeID sets the "employee_id" field.
  21501. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21502. m.employee = &u
  21503. }
  21504. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21505. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21506. v := m.employee
  21507. if v == nil {
  21508. return
  21509. }
  21510. return *v, true
  21511. }
  21512. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21513. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21515. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21516. if !m.op.Is(OpUpdateOne) {
  21517. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21518. }
  21519. if m.id == nil || m.oldValue == nil {
  21520. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21521. }
  21522. oldValue, err := m.oldValue(ctx)
  21523. if err != nil {
  21524. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21525. }
  21526. return oldValue.EmployeeID, nil
  21527. }
  21528. // ResetEmployeeID resets all changes to the "employee_id" field.
  21529. func (m *TutorialMutation) ResetEmployeeID() {
  21530. m.employee = nil
  21531. }
  21532. // SetIndex sets the "index" field.
  21533. func (m *TutorialMutation) SetIndex(i int) {
  21534. m.index = &i
  21535. m.addindex = nil
  21536. }
  21537. // Index returns the value of the "index" field in the mutation.
  21538. func (m *TutorialMutation) Index() (r int, exists bool) {
  21539. v := m.index
  21540. if v == nil {
  21541. return
  21542. }
  21543. return *v, true
  21544. }
  21545. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21546. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21548. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21549. if !m.op.Is(OpUpdateOne) {
  21550. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21551. }
  21552. if m.id == nil || m.oldValue == nil {
  21553. return v, errors.New("OldIndex requires an ID field in the mutation")
  21554. }
  21555. oldValue, err := m.oldValue(ctx)
  21556. if err != nil {
  21557. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21558. }
  21559. return oldValue.Index, nil
  21560. }
  21561. // AddIndex adds i to the "index" field.
  21562. func (m *TutorialMutation) AddIndex(i int) {
  21563. if m.addindex != nil {
  21564. *m.addindex += i
  21565. } else {
  21566. m.addindex = &i
  21567. }
  21568. }
  21569. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21570. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21571. v := m.addindex
  21572. if v == nil {
  21573. return
  21574. }
  21575. return *v, true
  21576. }
  21577. // ResetIndex resets all changes to the "index" field.
  21578. func (m *TutorialMutation) ResetIndex() {
  21579. m.index = nil
  21580. m.addindex = nil
  21581. }
  21582. // SetTitle sets the "title" field.
  21583. func (m *TutorialMutation) SetTitle(s string) {
  21584. m.title = &s
  21585. }
  21586. // Title returns the value of the "title" field in the mutation.
  21587. func (m *TutorialMutation) Title() (r string, exists bool) {
  21588. v := m.title
  21589. if v == nil {
  21590. return
  21591. }
  21592. return *v, true
  21593. }
  21594. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21595. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21597. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21598. if !m.op.Is(OpUpdateOne) {
  21599. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21600. }
  21601. if m.id == nil || m.oldValue == nil {
  21602. return v, errors.New("OldTitle requires an ID field in the mutation")
  21603. }
  21604. oldValue, err := m.oldValue(ctx)
  21605. if err != nil {
  21606. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21607. }
  21608. return oldValue.Title, nil
  21609. }
  21610. // ResetTitle resets all changes to the "title" field.
  21611. func (m *TutorialMutation) ResetTitle() {
  21612. m.title = nil
  21613. }
  21614. // SetContent sets the "content" field.
  21615. func (m *TutorialMutation) SetContent(s string) {
  21616. m.content = &s
  21617. }
  21618. // Content returns the value of the "content" field in the mutation.
  21619. func (m *TutorialMutation) Content() (r string, exists bool) {
  21620. v := m.content
  21621. if v == nil {
  21622. return
  21623. }
  21624. return *v, true
  21625. }
  21626. // OldContent returns the old "content" field's value of the Tutorial entity.
  21627. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21629. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21630. if !m.op.Is(OpUpdateOne) {
  21631. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21632. }
  21633. if m.id == nil || m.oldValue == nil {
  21634. return v, errors.New("OldContent requires an ID field in the mutation")
  21635. }
  21636. oldValue, err := m.oldValue(ctx)
  21637. if err != nil {
  21638. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21639. }
  21640. return oldValue.Content, nil
  21641. }
  21642. // ResetContent resets all changes to the "content" field.
  21643. func (m *TutorialMutation) ResetContent() {
  21644. m.content = nil
  21645. }
  21646. // SetOrganizationID sets the "organization_id" field.
  21647. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21648. m.organization_id = &u
  21649. m.addorganization_id = nil
  21650. }
  21651. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21652. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21653. v := m.organization_id
  21654. if v == nil {
  21655. return
  21656. }
  21657. return *v, true
  21658. }
  21659. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21660. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21662. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21663. if !m.op.Is(OpUpdateOne) {
  21664. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21665. }
  21666. if m.id == nil || m.oldValue == nil {
  21667. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21668. }
  21669. oldValue, err := m.oldValue(ctx)
  21670. if err != nil {
  21671. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21672. }
  21673. return oldValue.OrganizationID, nil
  21674. }
  21675. // AddOrganizationID adds u to the "organization_id" field.
  21676. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21677. if m.addorganization_id != nil {
  21678. *m.addorganization_id += u
  21679. } else {
  21680. m.addorganization_id = &u
  21681. }
  21682. }
  21683. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21684. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21685. v := m.addorganization_id
  21686. if v == nil {
  21687. return
  21688. }
  21689. return *v, true
  21690. }
  21691. // ResetOrganizationID resets all changes to the "organization_id" field.
  21692. func (m *TutorialMutation) ResetOrganizationID() {
  21693. m.organization_id = nil
  21694. m.addorganization_id = nil
  21695. }
  21696. // ClearEmployee clears the "employee" edge to the Employee entity.
  21697. func (m *TutorialMutation) ClearEmployee() {
  21698. m.clearedemployee = true
  21699. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21700. }
  21701. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21702. func (m *TutorialMutation) EmployeeCleared() bool {
  21703. return m.clearedemployee
  21704. }
  21705. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21706. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21707. // EmployeeID instead. It exists only for internal usage by the builders.
  21708. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21709. if id := m.employee; id != nil {
  21710. ids = append(ids, *id)
  21711. }
  21712. return
  21713. }
  21714. // ResetEmployee resets all changes to the "employee" edge.
  21715. func (m *TutorialMutation) ResetEmployee() {
  21716. m.employee = nil
  21717. m.clearedemployee = false
  21718. }
  21719. // Where appends a list predicates to the TutorialMutation builder.
  21720. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21721. m.predicates = append(m.predicates, ps...)
  21722. }
  21723. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21724. // users can use type-assertion to append predicates that do not depend on any generated package.
  21725. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21726. p := make([]predicate.Tutorial, len(ps))
  21727. for i := range ps {
  21728. p[i] = ps[i]
  21729. }
  21730. m.Where(p...)
  21731. }
  21732. // Op returns the operation name.
  21733. func (m *TutorialMutation) Op() Op {
  21734. return m.op
  21735. }
  21736. // SetOp allows setting the mutation operation.
  21737. func (m *TutorialMutation) SetOp(op Op) {
  21738. m.op = op
  21739. }
  21740. // Type returns the node type of this mutation (Tutorial).
  21741. func (m *TutorialMutation) Type() string {
  21742. return m.typ
  21743. }
  21744. // Fields returns all fields that were changed during this mutation. Note that in
  21745. // order to get all numeric fields that were incremented/decremented, call
  21746. // AddedFields().
  21747. func (m *TutorialMutation) Fields() []string {
  21748. fields := make([]string, 0, 8)
  21749. if m.created_at != nil {
  21750. fields = append(fields, tutorial.FieldCreatedAt)
  21751. }
  21752. if m.updated_at != nil {
  21753. fields = append(fields, tutorial.FieldUpdatedAt)
  21754. }
  21755. if m.deleted_at != nil {
  21756. fields = append(fields, tutorial.FieldDeletedAt)
  21757. }
  21758. if m.employee != nil {
  21759. fields = append(fields, tutorial.FieldEmployeeID)
  21760. }
  21761. if m.index != nil {
  21762. fields = append(fields, tutorial.FieldIndex)
  21763. }
  21764. if m.title != nil {
  21765. fields = append(fields, tutorial.FieldTitle)
  21766. }
  21767. if m.content != nil {
  21768. fields = append(fields, tutorial.FieldContent)
  21769. }
  21770. if m.organization_id != nil {
  21771. fields = append(fields, tutorial.FieldOrganizationID)
  21772. }
  21773. return fields
  21774. }
  21775. // Field returns the value of a field with the given name. The second boolean
  21776. // return value indicates that this field was not set, or was not defined in the
  21777. // schema.
  21778. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  21779. switch name {
  21780. case tutorial.FieldCreatedAt:
  21781. return m.CreatedAt()
  21782. case tutorial.FieldUpdatedAt:
  21783. return m.UpdatedAt()
  21784. case tutorial.FieldDeletedAt:
  21785. return m.DeletedAt()
  21786. case tutorial.FieldEmployeeID:
  21787. return m.EmployeeID()
  21788. case tutorial.FieldIndex:
  21789. return m.Index()
  21790. case tutorial.FieldTitle:
  21791. return m.Title()
  21792. case tutorial.FieldContent:
  21793. return m.Content()
  21794. case tutorial.FieldOrganizationID:
  21795. return m.OrganizationID()
  21796. }
  21797. return nil, false
  21798. }
  21799. // OldField returns the old value of the field from the database. An error is
  21800. // returned if the mutation operation is not UpdateOne, or the query to the
  21801. // database failed.
  21802. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21803. switch name {
  21804. case tutorial.FieldCreatedAt:
  21805. return m.OldCreatedAt(ctx)
  21806. case tutorial.FieldUpdatedAt:
  21807. return m.OldUpdatedAt(ctx)
  21808. case tutorial.FieldDeletedAt:
  21809. return m.OldDeletedAt(ctx)
  21810. case tutorial.FieldEmployeeID:
  21811. return m.OldEmployeeID(ctx)
  21812. case tutorial.FieldIndex:
  21813. return m.OldIndex(ctx)
  21814. case tutorial.FieldTitle:
  21815. return m.OldTitle(ctx)
  21816. case tutorial.FieldContent:
  21817. return m.OldContent(ctx)
  21818. case tutorial.FieldOrganizationID:
  21819. return m.OldOrganizationID(ctx)
  21820. }
  21821. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  21822. }
  21823. // SetField sets the value of a field with the given name. It returns an error if
  21824. // the field is not defined in the schema, or if the type mismatched the field
  21825. // type.
  21826. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  21827. switch name {
  21828. case tutorial.FieldCreatedAt:
  21829. v, ok := value.(time.Time)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.SetCreatedAt(v)
  21834. return nil
  21835. case tutorial.FieldUpdatedAt:
  21836. v, ok := value.(time.Time)
  21837. if !ok {
  21838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21839. }
  21840. m.SetUpdatedAt(v)
  21841. return nil
  21842. case tutorial.FieldDeletedAt:
  21843. v, ok := value.(time.Time)
  21844. if !ok {
  21845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21846. }
  21847. m.SetDeletedAt(v)
  21848. return nil
  21849. case tutorial.FieldEmployeeID:
  21850. v, ok := value.(uint64)
  21851. if !ok {
  21852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21853. }
  21854. m.SetEmployeeID(v)
  21855. return nil
  21856. case tutorial.FieldIndex:
  21857. v, ok := value.(int)
  21858. if !ok {
  21859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21860. }
  21861. m.SetIndex(v)
  21862. return nil
  21863. case tutorial.FieldTitle:
  21864. v, ok := value.(string)
  21865. if !ok {
  21866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21867. }
  21868. m.SetTitle(v)
  21869. return nil
  21870. case tutorial.FieldContent:
  21871. v, ok := value.(string)
  21872. if !ok {
  21873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21874. }
  21875. m.SetContent(v)
  21876. return nil
  21877. case tutorial.FieldOrganizationID:
  21878. v, ok := value.(uint64)
  21879. if !ok {
  21880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21881. }
  21882. m.SetOrganizationID(v)
  21883. return nil
  21884. }
  21885. return fmt.Errorf("unknown Tutorial field %s", name)
  21886. }
  21887. // AddedFields returns all numeric fields that were incremented/decremented during
  21888. // this mutation.
  21889. func (m *TutorialMutation) AddedFields() []string {
  21890. var fields []string
  21891. if m.addindex != nil {
  21892. fields = append(fields, tutorial.FieldIndex)
  21893. }
  21894. if m.addorganization_id != nil {
  21895. fields = append(fields, tutorial.FieldOrganizationID)
  21896. }
  21897. return fields
  21898. }
  21899. // AddedField returns the numeric value that was incremented/decremented on a field
  21900. // with the given name. The second boolean return value indicates that this field
  21901. // was not set, or was not defined in the schema.
  21902. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  21903. switch name {
  21904. case tutorial.FieldIndex:
  21905. return m.AddedIndex()
  21906. case tutorial.FieldOrganizationID:
  21907. return m.AddedOrganizationID()
  21908. }
  21909. return nil, false
  21910. }
  21911. // AddField adds the value to the field with the given name. It returns an error if
  21912. // the field is not defined in the schema, or if the type mismatched the field
  21913. // type.
  21914. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  21915. switch name {
  21916. case tutorial.FieldIndex:
  21917. v, ok := value.(int)
  21918. if !ok {
  21919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21920. }
  21921. m.AddIndex(v)
  21922. return nil
  21923. case tutorial.FieldOrganizationID:
  21924. v, ok := value.(int64)
  21925. if !ok {
  21926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21927. }
  21928. m.AddOrganizationID(v)
  21929. return nil
  21930. }
  21931. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  21932. }
  21933. // ClearedFields returns all nullable fields that were cleared during this
  21934. // mutation.
  21935. func (m *TutorialMutation) ClearedFields() []string {
  21936. var fields []string
  21937. if m.FieldCleared(tutorial.FieldDeletedAt) {
  21938. fields = append(fields, tutorial.FieldDeletedAt)
  21939. }
  21940. return fields
  21941. }
  21942. // FieldCleared returns a boolean indicating if a field with the given name was
  21943. // cleared in this mutation.
  21944. func (m *TutorialMutation) FieldCleared(name string) bool {
  21945. _, ok := m.clearedFields[name]
  21946. return ok
  21947. }
  21948. // ClearField clears the value of the field with the given name. It returns an
  21949. // error if the field is not defined in the schema.
  21950. func (m *TutorialMutation) ClearField(name string) error {
  21951. switch name {
  21952. case tutorial.FieldDeletedAt:
  21953. m.ClearDeletedAt()
  21954. return nil
  21955. }
  21956. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  21957. }
  21958. // ResetField resets all changes in the mutation for the field with the given name.
  21959. // It returns an error if the field is not defined in the schema.
  21960. func (m *TutorialMutation) ResetField(name string) error {
  21961. switch name {
  21962. case tutorial.FieldCreatedAt:
  21963. m.ResetCreatedAt()
  21964. return nil
  21965. case tutorial.FieldUpdatedAt:
  21966. m.ResetUpdatedAt()
  21967. return nil
  21968. case tutorial.FieldDeletedAt:
  21969. m.ResetDeletedAt()
  21970. return nil
  21971. case tutorial.FieldEmployeeID:
  21972. m.ResetEmployeeID()
  21973. return nil
  21974. case tutorial.FieldIndex:
  21975. m.ResetIndex()
  21976. return nil
  21977. case tutorial.FieldTitle:
  21978. m.ResetTitle()
  21979. return nil
  21980. case tutorial.FieldContent:
  21981. m.ResetContent()
  21982. return nil
  21983. case tutorial.FieldOrganizationID:
  21984. m.ResetOrganizationID()
  21985. return nil
  21986. }
  21987. return fmt.Errorf("unknown Tutorial field %s", name)
  21988. }
  21989. // AddedEdges returns all edge names that were set/added in this mutation.
  21990. func (m *TutorialMutation) AddedEdges() []string {
  21991. edges := make([]string, 0, 1)
  21992. if m.employee != nil {
  21993. edges = append(edges, tutorial.EdgeEmployee)
  21994. }
  21995. return edges
  21996. }
  21997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21998. // name in this mutation.
  21999. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22000. switch name {
  22001. case tutorial.EdgeEmployee:
  22002. if id := m.employee; id != nil {
  22003. return []ent.Value{*id}
  22004. }
  22005. }
  22006. return nil
  22007. }
  22008. // RemovedEdges returns all edge names that were removed in this mutation.
  22009. func (m *TutorialMutation) RemovedEdges() []string {
  22010. edges := make([]string, 0, 1)
  22011. return edges
  22012. }
  22013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22014. // the given name in this mutation.
  22015. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22016. return nil
  22017. }
  22018. // ClearedEdges returns all edge names that were cleared in this mutation.
  22019. func (m *TutorialMutation) ClearedEdges() []string {
  22020. edges := make([]string, 0, 1)
  22021. if m.clearedemployee {
  22022. edges = append(edges, tutorial.EdgeEmployee)
  22023. }
  22024. return edges
  22025. }
  22026. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22027. // was cleared in this mutation.
  22028. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22029. switch name {
  22030. case tutorial.EdgeEmployee:
  22031. return m.clearedemployee
  22032. }
  22033. return false
  22034. }
  22035. // ClearEdge clears the value of the edge with the given name. It returns an error
  22036. // if that edge is not defined in the schema.
  22037. func (m *TutorialMutation) ClearEdge(name string) error {
  22038. switch name {
  22039. case tutorial.EdgeEmployee:
  22040. m.ClearEmployee()
  22041. return nil
  22042. }
  22043. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22044. }
  22045. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22046. // It returns an error if the edge is not defined in the schema.
  22047. func (m *TutorialMutation) ResetEdge(name string) error {
  22048. switch name {
  22049. case tutorial.EdgeEmployee:
  22050. m.ResetEmployee()
  22051. return nil
  22052. }
  22053. return fmt.Errorf("unknown Tutorial edge %s", name)
  22054. }
  22055. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  22056. type WorkExperienceMutation struct {
  22057. config
  22058. op Op
  22059. typ string
  22060. id *uint64
  22061. created_at *time.Time
  22062. updated_at *time.Time
  22063. deleted_at *time.Time
  22064. start_date *time.Time
  22065. end_date *time.Time
  22066. company *string
  22067. experience *string
  22068. organization_id *uint64
  22069. addorganization_id *int64
  22070. clearedFields map[string]struct{}
  22071. employee *uint64
  22072. clearedemployee bool
  22073. done bool
  22074. oldValue func(context.Context) (*WorkExperience, error)
  22075. predicates []predicate.WorkExperience
  22076. }
  22077. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  22078. // workexperienceOption allows management of the mutation configuration using functional options.
  22079. type workexperienceOption func(*WorkExperienceMutation)
  22080. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  22081. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  22082. m := &WorkExperienceMutation{
  22083. config: c,
  22084. op: op,
  22085. typ: TypeWorkExperience,
  22086. clearedFields: make(map[string]struct{}),
  22087. }
  22088. for _, opt := range opts {
  22089. opt(m)
  22090. }
  22091. return m
  22092. }
  22093. // withWorkExperienceID sets the ID field of the mutation.
  22094. func withWorkExperienceID(id uint64) workexperienceOption {
  22095. return func(m *WorkExperienceMutation) {
  22096. var (
  22097. err error
  22098. once sync.Once
  22099. value *WorkExperience
  22100. )
  22101. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  22102. once.Do(func() {
  22103. if m.done {
  22104. err = errors.New("querying old values post mutation is not allowed")
  22105. } else {
  22106. value, err = m.Client().WorkExperience.Get(ctx, id)
  22107. }
  22108. })
  22109. return value, err
  22110. }
  22111. m.id = &id
  22112. }
  22113. }
  22114. // withWorkExperience sets the old WorkExperience of the mutation.
  22115. func withWorkExperience(node *WorkExperience) workexperienceOption {
  22116. return func(m *WorkExperienceMutation) {
  22117. m.oldValue = func(context.Context) (*WorkExperience, error) {
  22118. return node, nil
  22119. }
  22120. m.id = &node.ID
  22121. }
  22122. }
  22123. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22124. // executed in a transaction (ent.Tx), a transactional client is returned.
  22125. func (m WorkExperienceMutation) Client() *Client {
  22126. client := &Client{config: m.config}
  22127. client.init()
  22128. return client
  22129. }
  22130. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22131. // it returns an error otherwise.
  22132. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  22133. if _, ok := m.driver.(*txDriver); !ok {
  22134. return nil, errors.New("ent: mutation is not running in a transaction")
  22135. }
  22136. tx := &Tx{config: m.config}
  22137. tx.init()
  22138. return tx, nil
  22139. }
  22140. // SetID sets the value of the id field. Note that this
  22141. // operation is only accepted on creation of WorkExperience entities.
  22142. func (m *WorkExperienceMutation) SetID(id uint64) {
  22143. m.id = &id
  22144. }
  22145. // ID returns the ID value in the mutation. Note that the ID is only available
  22146. // if it was provided to the builder or after it was returned from the database.
  22147. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  22148. if m.id == nil {
  22149. return
  22150. }
  22151. return *m.id, true
  22152. }
  22153. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22154. // That means, if the mutation is applied within a transaction with an isolation level such
  22155. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22156. // or updated by the mutation.
  22157. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  22158. switch {
  22159. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22160. id, exists := m.ID()
  22161. if exists {
  22162. return []uint64{id}, nil
  22163. }
  22164. fallthrough
  22165. case m.op.Is(OpUpdate | OpDelete):
  22166. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  22167. default:
  22168. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22169. }
  22170. }
  22171. // SetCreatedAt sets the "created_at" field.
  22172. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  22173. m.created_at = &t
  22174. }
  22175. // CreatedAt returns the value of the "created_at" field in the mutation.
  22176. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  22177. v := m.created_at
  22178. if v == nil {
  22179. return
  22180. }
  22181. return *v, true
  22182. }
  22183. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  22184. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22186. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22187. if !m.op.Is(OpUpdateOne) {
  22188. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22189. }
  22190. if m.id == nil || m.oldValue == nil {
  22191. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22192. }
  22193. oldValue, err := m.oldValue(ctx)
  22194. if err != nil {
  22195. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22196. }
  22197. return oldValue.CreatedAt, nil
  22198. }
  22199. // ResetCreatedAt resets all changes to the "created_at" field.
  22200. func (m *WorkExperienceMutation) ResetCreatedAt() {
  22201. m.created_at = nil
  22202. }
  22203. // SetUpdatedAt sets the "updated_at" field.
  22204. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  22205. m.updated_at = &t
  22206. }
  22207. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22208. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  22209. v := m.updated_at
  22210. if v == nil {
  22211. return
  22212. }
  22213. return *v, true
  22214. }
  22215. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  22216. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22218. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22219. if !m.op.Is(OpUpdateOne) {
  22220. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22221. }
  22222. if m.id == nil || m.oldValue == nil {
  22223. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22224. }
  22225. oldValue, err := m.oldValue(ctx)
  22226. if err != nil {
  22227. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22228. }
  22229. return oldValue.UpdatedAt, nil
  22230. }
  22231. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22232. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  22233. m.updated_at = nil
  22234. }
  22235. // SetDeletedAt sets the "deleted_at" field.
  22236. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  22237. m.deleted_at = &t
  22238. }
  22239. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22240. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  22241. v := m.deleted_at
  22242. if v == nil {
  22243. return
  22244. }
  22245. return *v, true
  22246. }
  22247. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  22248. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22250. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22251. if !m.op.Is(OpUpdateOne) {
  22252. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22253. }
  22254. if m.id == nil || m.oldValue == nil {
  22255. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22256. }
  22257. oldValue, err := m.oldValue(ctx)
  22258. if err != nil {
  22259. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22260. }
  22261. return oldValue.DeletedAt, nil
  22262. }
  22263. // ClearDeletedAt clears the value of the "deleted_at" field.
  22264. func (m *WorkExperienceMutation) ClearDeletedAt() {
  22265. m.deleted_at = nil
  22266. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  22267. }
  22268. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22269. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  22270. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  22271. return ok
  22272. }
  22273. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22274. func (m *WorkExperienceMutation) ResetDeletedAt() {
  22275. m.deleted_at = nil
  22276. delete(m.clearedFields, workexperience.FieldDeletedAt)
  22277. }
  22278. // SetEmployeeID sets the "employee_id" field.
  22279. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  22280. m.employee = &u
  22281. }
  22282. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22283. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  22284. v := m.employee
  22285. if v == nil {
  22286. return
  22287. }
  22288. return *v, true
  22289. }
  22290. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  22291. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22293. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22294. if !m.op.Is(OpUpdateOne) {
  22295. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22296. }
  22297. if m.id == nil || m.oldValue == nil {
  22298. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22299. }
  22300. oldValue, err := m.oldValue(ctx)
  22301. if err != nil {
  22302. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22303. }
  22304. return oldValue.EmployeeID, nil
  22305. }
  22306. // ResetEmployeeID resets all changes to the "employee_id" field.
  22307. func (m *WorkExperienceMutation) ResetEmployeeID() {
  22308. m.employee = nil
  22309. }
  22310. // SetStartDate sets the "start_date" field.
  22311. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  22312. m.start_date = &t
  22313. }
  22314. // StartDate returns the value of the "start_date" field in the mutation.
  22315. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  22316. v := m.start_date
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  22323. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldStartDate requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  22335. }
  22336. return oldValue.StartDate, nil
  22337. }
  22338. // ResetStartDate resets all changes to the "start_date" field.
  22339. func (m *WorkExperienceMutation) ResetStartDate() {
  22340. m.start_date = nil
  22341. }
  22342. // SetEndDate sets the "end_date" field.
  22343. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  22344. m.end_date = &t
  22345. }
  22346. // EndDate returns the value of the "end_date" field in the mutation.
  22347. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  22348. v := m.end_date
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  22355. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldEndDate requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  22367. }
  22368. return oldValue.EndDate, nil
  22369. }
  22370. // ResetEndDate resets all changes to the "end_date" field.
  22371. func (m *WorkExperienceMutation) ResetEndDate() {
  22372. m.end_date = nil
  22373. }
  22374. // SetCompany sets the "company" field.
  22375. func (m *WorkExperienceMutation) SetCompany(s string) {
  22376. m.company = &s
  22377. }
  22378. // Company returns the value of the "company" field in the mutation.
  22379. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  22380. v := m.company
  22381. if v == nil {
  22382. return
  22383. }
  22384. return *v, true
  22385. }
  22386. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  22387. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22389. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  22390. if !m.op.Is(OpUpdateOne) {
  22391. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  22392. }
  22393. if m.id == nil || m.oldValue == nil {
  22394. return v, errors.New("OldCompany requires an ID field in the mutation")
  22395. }
  22396. oldValue, err := m.oldValue(ctx)
  22397. if err != nil {
  22398. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  22399. }
  22400. return oldValue.Company, nil
  22401. }
  22402. // ResetCompany resets all changes to the "company" field.
  22403. func (m *WorkExperienceMutation) ResetCompany() {
  22404. m.company = nil
  22405. }
  22406. // SetExperience sets the "experience" field.
  22407. func (m *WorkExperienceMutation) SetExperience(s string) {
  22408. m.experience = &s
  22409. }
  22410. // Experience returns the value of the "experience" field in the mutation.
  22411. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  22412. v := m.experience
  22413. if v == nil {
  22414. return
  22415. }
  22416. return *v, true
  22417. }
  22418. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  22419. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22421. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  22422. if !m.op.Is(OpUpdateOne) {
  22423. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  22424. }
  22425. if m.id == nil || m.oldValue == nil {
  22426. return v, errors.New("OldExperience requires an ID field in the mutation")
  22427. }
  22428. oldValue, err := m.oldValue(ctx)
  22429. if err != nil {
  22430. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  22431. }
  22432. return oldValue.Experience, nil
  22433. }
  22434. // ResetExperience resets all changes to the "experience" field.
  22435. func (m *WorkExperienceMutation) ResetExperience() {
  22436. m.experience = nil
  22437. }
  22438. // SetOrganizationID sets the "organization_id" field.
  22439. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  22440. m.organization_id = &u
  22441. m.addorganization_id = nil
  22442. }
  22443. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22444. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  22445. v := m.organization_id
  22446. if v == nil {
  22447. return
  22448. }
  22449. return *v, true
  22450. }
  22451. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  22452. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22454. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22455. if !m.op.Is(OpUpdateOne) {
  22456. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22457. }
  22458. if m.id == nil || m.oldValue == nil {
  22459. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22460. }
  22461. oldValue, err := m.oldValue(ctx)
  22462. if err != nil {
  22463. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22464. }
  22465. return oldValue.OrganizationID, nil
  22466. }
  22467. // AddOrganizationID adds u to the "organization_id" field.
  22468. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  22469. if m.addorganization_id != nil {
  22470. *m.addorganization_id += u
  22471. } else {
  22472. m.addorganization_id = &u
  22473. }
  22474. }
  22475. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22476. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  22477. v := m.addorganization_id
  22478. if v == nil {
  22479. return
  22480. }
  22481. return *v, true
  22482. }
  22483. // ResetOrganizationID resets all changes to the "organization_id" field.
  22484. func (m *WorkExperienceMutation) ResetOrganizationID() {
  22485. m.organization_id = nil
  22486. m.addorganization_id = nil
  22487. }
  22488. // ClearEmployee clears the "employee" edge to the Employee entity.
  22489. func (m *WorkExperienceMutation) ClearEmployee() {
  22490. m.clearedemployee = true
  22491. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  22492. }
  22493. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22494. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  22495. return m.clearedemployee
  22496. }
  22497. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22498. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22499. // EmployeeID instead. It exists only for internal usage by the builders.
  22500. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  22501. if id := m.employee; id != nil {
  22502. ids = append(ids, *id)
  22503. }
  22504. return
  22505. }
  22506. // ResetEmployee resets all changes to the "employee" edge.
  22507. func (m *WorkExperienceMutation) ResetEmployee() {
  22508. m.employee = nil
  22509. m.clearedemployee = false
  22510. }
  22511. // Where appends a list predicates to the WorkExperienceMutation builder.
  22512. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  22513. m.predicates = append(m.predicates, ps...)
  22514. }
  22515. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  22516. // users can use type-assertion to append predicates that do not depend on any generated package.
  22517. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  22518. p := make([]predicate.WorkExperience, len(ps))
  22519. for i := range ps {
  22520. p[i] = ps[i]
  22521. }
  22522. m.Where(p...)
  22523. }
  22524. // Op returns the operation name.
  22525. func (m *WorkExperienceMutation) Op() Op {
  22526. return m.op
  22527. }
  22528. // SetOp allows setting the mutation operation.
  22529. func (m *WorkExperienceMutation) SetOp(op Op) {
  22530. m.op = op
  22531. }
  22532. // Type returns the node type of this mutation (WorkExperience).
  22533. func (m *WorkExperienceMutation) Type() string {
  22534. return m.typ
  22535. }
  22536. // Fields returns all fields that were changed during this mutation. Note that in
  22537. // order to get all numeric fields that were incremented/decremented, call
  22538. // AddedFields().
  22539. func (m *WorkExperienceMutation) Fields() []string {
  22540. fields := make([]string, 0, 9)
  22541. if m.created_at != nil {
  22542. fields = append(fields, workexperience.FieldCreatedAt)
  22543. }
  22544. if m.updated_at != nil {
  22545. fields = append(fields, workexperience.FieldUpdatedAt)
  22546. }
  22547. if m.deleted_at != nil {
  22548. fields = append(fields, workexperience.FieldDeletedAt)
  22549. }
  22550. if m.employee != nil {
  22551. fields = append(fields, workexperience.FieldEmployeeID)
  22552. }
  22553. if m.start_date != nil {
  22554. fields = append(fields, workexperience.FieldStartDate)
  22555. }
  22556. if m.end_date != nil {
  22557. fields = append(fields, workexperience.FieldEndDate)
  22558. }
  22559. if m.company != nil {
  22560. fields = append(fields, workexperience.FieldCompany)
  22561. }
  22562. if m.experience != nil {
  22563. fields = append(fields, workexperience.FieldExperience)
  22564. }
  22565. if m.organization_id != nil {
  22566. fields = append(fields, workexperience.FieldOrganizationID)
  22567. }
  22568. return fields
  22569. }
  22570. // Field returns the value of a field with the given name. The second boolean
  22571. // return value indicates that this field was not set, or was not defined in the
  22572. // schema.
  22573. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  22574. switch name {
  22575. case workexperience.FieldCreatedAt:
  22576. return m.CreatedAt()
  22577. case workexperience.FieldUpdatedAt:
  22578. return m.UpdatedAt()
  22579. case workexperience.FieldDeletedAt:
  22580. return m.DeletedAt()
  22581. case workexperience.FieldEmployeeID:
  22582. return m.EmployeeID()
  22583. case workexperience.FieldStartDate:
  22584. return m.StartDate()
  22585. case workexperience.FieldEndDate:
  22586. return m.EndDate()
  22587. case workexperience.FieldCompany:
  22588. return m.Company()
  22589. case workexperience.FieldExperience:
  22590. return m.Experience()
  22591. case workexperience.FieldOrganizationID:
  22592. return m.OrganizationID()
  22593. }
  22594. return nil, false
  22595. }
  22596. // OldField returns the old value of the field from the database. An error is
  22597. // returned if the mutation operation is not UpdateOne, or the query to the
  22598. // database failed.
  22599. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22600. switch name {
  22601. case workexperience.FieldCreatedAt:
  22602. return m.OldCreatedAt(ctx)
  22603. case workexperience.FieldUpdatedAt:
  22604. return m.OldUpdatedAt(ctx)
  22605. case workexperience.FieldDeletedAt:
  22606. return m.OldDeletedAt(ctx)
  22607. case workexperience.FieldEmployeeID:
  22608. return m.OldEmployeeID(ctx)
  22609. case workexperience.FieldStartDate:
  22610. return m.OldStartDate(ctx)
  22611. case workexperience.FieldEndDate:
  22612. return m.OldEndDate(ctx)
  22613. case workexperience.FieldCompany:
  22614. return m.OldCompany(ctx)
  22615. case workexperience.FieldExperience:
  22616. return m.OldExperience(ctx)
  22617. case workexperience.FieldOrganizationID:
  22618. return m.OldOrganizationID(ctx)
  22619. }
  22620. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  22621. }
  22622. // SetField sets the value of a field with the given name. It returns an error if
  22623. // the field is not defined in the schema, or if the type mismatched the field
  22624. // type.
  22625. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  22626. switch name {
  22627. case workexperience.FieldCreatedAt:
  22628. v, ok := value.(time.Time)
  22629. if !ok {
  22630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22631. }
  22632. m.SetCreatedAt(v)
  22633. return nil
  22634. case workexperience.FieldUpdatedAt:
  22635. v, ok := value.(time.Time)
  22636. if !ok {
  22637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22638. }
  22639. m.SetUpdatedAt(v)
  22640. return nil
  22641. case workexperience.FieldDeletedAt:
  22642. v, ok := value.(time.Time)
  22643. if !ok {
  22644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22645. }
  22646. m.SetDeletedAt(v)
  22647. return nil
  22648. case workexperience.FieldEmployeeID:
  22649. v, ok := value.(uint64)
  22650. if !ok {
  22651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22652. }
  22653. m.SetEmployeeID(v)
  22654. return nil
  22655. case workexperience.FieldStartDate:
  22656. v, ok := value.(time.Time)
  22657. if !ok {
  22658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22659. }
  22660. m.SetStartDate(v)
  22661. return nil
  22662. case workexperience.FieldEndDate:
  22663. v, ok := value.(time.Time)
  22664. if !ok {
  22665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22666. }
  22667. m.SetEndDate(v)
  22668. return nil
  22669. case workexperience.FieldCompany:
  22670. v, ok := value.(string)
  22671. if !ok {
  22672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22673. }
  22674. m.SetCompany(v)
  22675. return nil
  22676. case workexperience.FieldExperience:
  22677. v, ok := value.(string)
  22678. if !ok {
  22679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22680. }
  22681. m.SetExperience(v)
  22682. return nil
  22683. case workexperience.FieldOrganizationID:
  22684. v, ok := value.(uint64)
  22685. if !ok {
  22686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22687. }
  22688. m.SetOrganizationID(v)
  22689. return nil
  22690. }
  22691. return fmt.Errorf("unknown WorkExperience field %s", name)
  22692. }
  22693. // AddedFields returns all numeric fields that were incremented/decremented during
  22694. // this mutation.
  22695. func (m *WorkExperienceMutation) AddedFields() []string {
  22696. var fields []string
  22697. if m.addorganization_id != nil {
  22698. fields = append(fields, workexperience.FieldOrganizationID)
  22699. }
  22700. return fields
  22701. }
  22702. // AddedField returns the numeric value that was incremented/decremented on a field
  22703. // with the given name. The second boolean return value indicates that this field
  22704. // was not set, or was not defined in the schema.
  22705. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  22706. switch name {
  22707. case workexperience.FieldOrganizationID:
  22708. return m.AddedOrganizationID()
  22709. }
  22710. return nil, false
  22711. }
  22712. // AddField adds the value to the field with the given name. It returns an error if
  22713. // the field is not defined in the schema, or if the type mismatched the field
  22714. // type.
  22715. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  22716. switch name {
  22717. case workexperience.FieldOrganizationID:
  22718. v, ok := value.(int64)
  22719. if !ok {
  22720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22721. }
  22722. m.AddOrganizationID(v)
  22723. return nil
  22724. }
  22725. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  22726. }
  22727. // ClearedFields returns all nullable fields that were cleared during this
  22728. // mutation.
  22729. func (m *WorkExperienceMutation) ClearedFields() []string {
  22730. var fields []string
  22731. if m.FieldCleared(workexperience.FieldDeletedAt) {
  22732. fields = append(fields, workexperience.FieldDeletedAt)
  22733. }
  22734. return fields
  22735. }
  22736. // FieldCleared returns a boolean indicating if a field with the given name was
  22737. // cleared in this mutation.
  22738. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  22739. _, ok := m.clearedFields[name]
  22740. return ok
  22741. }
  22742. // ClearField clears the value of the field with the given name. It returns an
  22743. // error if the field is not defined in the schema.
  22744. func (m *WorkExperienceMutation) ClearField(name string) error {
  22745. switch name {
  22746. case workexperience.FieldDeletedAt:
  22747. m.ClearDeletedAt()
  22748. return nil
  22749. }
  22750. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  22751. }
  22752. // ResetField resets all changes in the mutation for the field with the given name.
  22753. // It returns an error if the field is not defined in the schema.
  22754. func (m *WorkExperienceMutation) ResetField(name string) error {
  22755. switch name {
  22756. case workexperience.FieldCreatedAt:
  22757. m.ResetCreatedAt()
  22758. return nil
  22759. case workexperience.FieldUpdatedAt:
  22760. m.ResetUpdatedAt()
  22761. return nil
  22762. case workexperience.FieldDeletedAt:
  22763. m.ResetDeletedAt()
  22764. return nil
  22765. case workexperience.FieldEmployeeID:
  22766. m.ResetEmployeeID()
  22767. return nil
  22768. case workexperience.FieldStartDate:
  22769. m.ResetStartDate()
  22770. return nil
  22771. case workexperience.FieldEndDate:
  22772. m.ResetEndDate()
  22773. return nil
  22774. case workexperience.FieldCompany:
  22775. m.ResetCompany()
  22776. return nil
  22777. case workexperience.FieldExperience:
  22778. m.ResetExperience()
  22779. return nil
  22780. case workexperience.FieldOrganizationID:
  22781. m.ResetOrganizationID()
  22782. return nil
  22783. }
  22784. return fmt.Errorf("unknown WorkExperience field %s", name)
  22785. }
  22786. // AddedEdges returns all edge names that were set/added in this mutation.
  22787. func (m *WorkExperienceMutation) AddedEdges() []string {
  22788. edges := make([]string, 0, 1)
  22789. if m.employee != nil {
  22790. edges = append(edges, workexperience.EdgeEmployee)
  22791. }
  22792. return edges
  22793. }
  22794. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22795. // name in this mutation.
  22796. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  22797. switch name {
  22798. case workexperience.EdgeEmployee:
  22799. if id := m.employee; id != nil {
  22800. return []ent.Value{*id}
  22801. }
  22802. }
  22803. return nil
  22804. }
  22805. // RemovedEdges returns all edge names that were removed in this mutation.
  22806. func (m *WorkExperienceMutation) RemovedEdges() []string {
  22807. edges := make([]string, 0, 1)
  22808. return edges
  22809. }
  22810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22811. // the given name in this mutation.
  22812. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  22813. return nil
  22814. }
  22815. // ClearedEdges returns all edge names that were cleared in this mutation.
  22816. func (m *WorkExperienceMutation) ClearedEdges() []string {
  22817. edges := make([]string, 0, 1)
  22818. if m.clearedemployee {
  22819. edges = append(edges, workexperience.EdgeEmployee)
  22820. }
  22821. return edges
  22822. }
  22823. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22824. // was cleared in this mutation.
  22825. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  22826. switch name {
  22827. case workexperience.EdgeEmployee:
  22828. return m.clearedemployee
  22829. }
  22830. return false
  22831. }
  22832. // ClearEdge clears the value of the edge with the given name. It returns an error
  22833. // if that edge is not defined in the schema.
  22834. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  22835. switch name {
  22836. case workexperience.EdgeEmployee:
  22837. m.ClearEmployee()
  22838. return nil
  22839. }
  22840. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  22841. }
  22842. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22843. // It returns an error if the edge is not defined in the schema.
  22844. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  22845. switch name {
  22846. case workexperience.EdgeEmployee:
  22847. m.ResetEmployee()
  22848. return nil
  22849. }
  22850. return fmt.Errorf("unknown WorkExperience edge %s", name)
  22851. }
  22852. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  22853. type WxMutation struct {
  22854. config
  22855. op Op
  22856. typ string
  22857. id *uint64
  22858. created_at *time.Time
  22859. updated_at *time.Time
  22860. status *uint8
  22861. addstatus *int8
  22862. deleted_at *time.Time
  22863. port *string
  22864. process_id *string
  22865. callback *string
  22866. wxid *string
  22867. account *string
  22868. nickname *string
  22869. tel *string
  22870. head_big *string
  22871. organization_id *uint64
  22872. addorganization_id *int64
  22873. api_base *string
  22874. api_key *string
  22875. allow_list *[]string
  22876. appendallow_list []string
  22877. group_allow_list *[]string
  22878. appendgroup_allow_list []string
  22879. block_list *[]string
  22880. appendblock_list []string
  22881. group_block_list *[]string
  22882. appendgroup_block_list []string
  22883. clearedFields map[string]struct{}
  22884. server *uint64
  22885. clearedserver bool
  22886. agent *uint64
  22887. clearedagent bool
  22888. done bool
  22889. oldValue func(context.Context) (*Wx, error)
  22890. predicates []predicate.Wx
  22891. }
  22892. var _ ent.Mutation = (*WxMutation)(nil)
  22893. // wxOption allows management of the mutation configuration using functional options.
  22894. type wxOption func(*WxMutation)
  22895. // newWxMutation creates new mutation for the Wx entity.
  22896. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  22897. m := &WxMutation{
  22898. config: c,
  22899. op: op,
  22900. typ: TypeWx,
  22901. clearedFields: make(map[string]struct{}),
  22902. }
  22903. for _, opt := range opts {
  22904. opt(m)
  22905. }
  22906. return m
  22907. }
  22908. // withWxID sets the ID field of the mutation.
  22909. func withWxID(id uint64) wxOption {
  22910. return func(m *WxMutation) {
  22911. var (
  22912. err error
  22913. once sync.Once
  22914. value *Wx
  22915. )
  22916. m.oldValue = func(ctx context.Context) (*Wx, error) {
  22917. once.Do(func() {
  22918. if m.done {
  22919. err = errors.New("querying old values post mutation is not allowed")
  22920. } else {
  22921. value, err = m.Client().Wx.Get(ctx, id)
  22922. }
  22923. })
  22924. return value, err
  22925. }
  22926. m.id = &id
  22927. }
  22928. }
  22929. // withWx sets the old Wx of the mutation.
  22930. func withWx(node *Wx) wxOption {
  22931. return func(m *WxMutation) {
  22932. m.oldValue = func(context.Context) (*Wx, error) {
  22933. return node, nil
  22934. }
  22935. m.id = &node.ID
  22936. }
  22937. }
  22938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22939. // executed in a transaction (ent.Tx), a transactional client is returned.
  22940. func (m WxMutation) Client() *Client {
  22941. client := &Client{config: m.config}
  22942. client.init()
  22943. return client
  22944. }
  22945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22946. // it returns an error otherwise.
  22947. func (m WxMutation) Tx() (*Tx, error) {
  22948. if _, ok := m.driver.(*txDriver); !ok {
  22949. return nil, errors.New("ent: mutation is not running in a transaction")
  22950. }
  22951. tx := &Tx{config: m.config}
  22952. tx.init()
  22953. return tx, nil
  22954. }
  22955. // SetID sets the value of the id field. Note that this
  22956. // operation is only accepted on creation of Wx entities.
  22957. func (m *WxMutation) SetID(id uint64) {
  22958. m.id = &id
  22959. }
  22960. // ID returns the ID value in the mutation. Note that the ID is only available
  22961. // if it was provided to the builder or after it was returned from the database.
  22962. func (m *WxMutation) ID() (id uint64, exists bool) {
  22963. if m.id == nil {
  22964. return
  22965. }
  22966. return *m.id, true
  22967. }
  22968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22969. // That means, if the mutation is applied within a transaction with an isolation level such
  22970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22971. // or updated by the mutation.
  22972. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  22973. switch {
  22974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22975. id, exists := m.ID()
  22976. if exists {
  22977. return []uint64{id}, nil
  22978. }
  22979. fallthrough
  22980. case m.op.Is(OpUpdate | OpDelete):
  22981. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  22982. default:
  22983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22984. }
  22985. }
  22986. // SetCreatedAt sets the "created_at" field.
  22987. func (m *WxMutation) SetCreatedAt(t time.Time) {
  22988. m.created_at = &t
  22989. }
  22990. // CreatedAt returns the value of the "created_at" field in the mutation.
  22991. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  22992. v := m.created_at
  22993. if v == nil {
  22994. return
  22995. }
  22996. return *v, true
  22997. }
  22998. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  22999. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23001. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23002. if !m.op.Is(OpUpdateOne) {
  23003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23004. }
  23005. if m.id == nil || m.oldValue == nil {
  23006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23007. }
  23008. oldValue, err := m.oldValue(ctx)
  23009. if err != nil {
  23010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23011. }
  23012. return oldValue.CreatedAt, nil
  23013. }
  23014. // ResetCreatedAt resets all changes to the "created_at" field.
  23015. func (m *WxMutation) ResetCreatedAt() {
  23016. m.created_at = nil
  23017. }
  23018. // SetUpdatedAt sets the "updated_at" field.
  23019. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  23020. m.updated_at = &t
  23021. }
  23022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23023. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  23024. v := m.updated_at
  23025. if v == nil {
  23026. return
  23027. }
  23028. return *v, true
  23029. }
  23030. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  23031. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23033. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23034. if !m.op.Is(OpUpdateOne) {
  23035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23036. }
  23037. if m.id == nil || m.oldValue == nil {
  23038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23039. }
  23040. oldValue, err := m.oldValue(ctx)
  23041. if err != nil {
  23042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23043. }
  23044. return oldValue.UpdatedAt, nil
  23045. }
  23046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23047. func (m *WxMutation) ResetUpdatedAt() {
  23048. m.updated_at = nil
  23049. }
  23050. // SetStatus sets the "status" field.
  23051. func (m *WxMutation) SetStatus(u uint8) {
  23052. m.status = &u
  23053. m.addstatus = nil
  23054. }
  23055. // Status returns the value of the "status" field in the mutation.
  23056. func (m *WxMutation) Status() (r uint8, exists bool) {
  23057. v := m.status
  23058. if v == nil {
  23059. return
  23060. }
  23061. return *v, true
  23062. }
  23063. // OldStatus returns the old "status" field's value of the Wx entity.
  23064. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23066. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23067. if !m.op.Is(OpUpdateOne) {
  23068. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23069. }
  23070. if m.id == nil || m.oldValue == nil {
  23071. return v, errors.New("OldStatus requires an ID field in the mutation")
  23072. }
  23073. oldValue, err := m.oldValue(ctx)
  23074. if err != nil {
  23075. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23076. }
  23077. return oldValue.Status, nil
  23078. }
  23079. // AddStatus adds u to the "status" field.
  23080. func (m *WxMutation) AddStatus(u int8) {
  23081. if m.addstatus != nil {
  23082. *m.addstatus += u
  23083. } else {
  23084. m.addstatus = &u
  23085. }
  23086. }
  23087. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23088. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  23089. v := m.addstatus
  23090. if v == nil {
  23091. return
  23092. }
  23093. return *v, true
  23094. }
  23095. // ClearStatus clears the value of the "status" field.
  23096. func (m *WxMutation) ClearStatus() {
  23097. m.status = nil
  23098. m.addstatus = nil
  23099. m.clearedFields[wx.FieldStatus] = struct{}{}
  23100. }
  23101. // StatusCleared returns if the "status" field was cleared in this mutation.
  23102. func (m *WxMutation) StatusCleared() bool {
  23103. _, ok := m.clearedFields[wx.FieldStatus]
  23104. return ok
  23105. }
  23106. // ResetStatus resets all changes to the "status" field.
  23107. func (m *WxMutation) ResetStatus() {
  23108. m.status = nil
  23109. m.addstatus = nil
  23110. delete(m.clearedFields, wx.FieldStatus)
  23111. }
  23112. // SetDeletedAt sets the "deleted_at" field.
  23113. func (m *WxMutation) SetDeletedAt(t time.Time) {
  23114. m.deleted_at = &t
  23115. }
  23116. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23117. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  23118. v := m.deleted_at
  23119. if v == nil {
  23120. return
  23121. }
  23122. return *v, true
  23123. }
  23124. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  23125. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23127. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23128. if !m.op.Is(OpUpdateOne) {
  23129. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23130. }
  23131. if m.id == nil || m.oldValue == nil {
  23132. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23133. }
  23134. oldValue, err := m.oldValue(ctx)
  23135. if err != nil {
  23136. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23137. }
  23138. return oldValue.DeletedAt, nil
  23139. }
  23140. // ClearDeletedAt clears the value of the "deleted_at" field.
  23141. func (m *WxMutation) ClearDeletedAt() {
  23142. m.deleted_at = nil
  23143. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  23144. }
  23145. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23146. func (m *WxMutation) DeletedAtCleared() bool {
  23147. _, ok := m.clearedFields[wx.FieldDeletedAt]
  23148. return ok
  23149. }
  23150. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23151. func (m *WxMutation) ResetDeletedAt() {
  23152. m.deleted_at = nil
  23153. delete(m.clearedFields, wx.FieldDeletedAt)
  23154. }
  23155. // SetServerID sets the "server_id" field.
  23156. func (m *WxMutation) SetServerID(u uint64) {
  23157. m.server = &u
  23158. }
  23159. // ServerID returns the value of the "server_id" field in the mutation.
  23160. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  23161. v := m.server
  23162. if v == nil {
  23163. return
  23164. }
  23165. return *v, true
  23166. }
  23167. // OldServerID returns the old "server_id" field's value of the Wx entity.
  23168. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23170. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  23171. if !m.op.Is(OpUpdateOne) {
  23172. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  23173. }
  23174. if m.id == nil || m.oldValue == nil {
  23175. return v, errors.New("OldServerID requires an ID field in the mutation")
  23176. }
  23177. oldValue, err := m.oldValue(ctx)
  23178. if err != nil {
  23179. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  23180. }
  23181. return oldValue.ServerID, nil
  23182. }
  23183. // ClearServerID clears the value of the "server_id" field.
  23184. func (m *WxMutation) ClearServerID() {
  23185. m.server = nil
  23186. m.clearedFields[wx.FieldServerID] = struct{}{}
  23187. }
  23188. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  23189. func (m *WxMutation) ServerIDCleared() bool {
  23190. _, ok := m.clearedFields[wx.FieldServerID]
  23191. return ok
  23192. }
  23193. // ResetServerID resets all changes to the "server_id" field.
  23194. func (m *WxMutation) ResetServerID() {
  23195. m.server = nil
  23196. delete(m.clearedFields, wx.FieldServerID)
  23197. }
  23198. // SetPort sets the "port" field.
  23199. func (m *WxMutation) SetPort(s string) {
  23200. m.port = &s
  23201. }
  23202. // Port returns the value of the "port" field in the mutation.
  23203. func (m *WxMutation) Port() (r string, exists bool) {
  23204. v := m.port
  23205. if v == nil {
  23206. return
  23207. }
  23208. return *v, true
  23209. }
  23210. // OldPort returns the old "port" field's value of the Wx entity.
  23211. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23213. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  23214. if !m.op.Is(OpUpdateOne) {
  23215. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  23216. }
  23217. if m.id == nil || m.oldValue == nil {
  23218. return v, errors.New("OldPort requires an ID field in the mutation")
  23219. }
  23220. oldValue, err := m.oldValue(ctx)
  23221. if err != nil {
  23222. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  23223. }
  23224. return oldValue.Port, nil
  23225. }
  23226. // ResetPort resets all changes to the "port" field.
  23227. func (m *WxMutation) ResetPort() {
  23228. m.port = nil
  23229. }
  23230. // SetProcessID sets the "process_id" field.
  23231. func (m *WxMutation) SetProcessID(s string) {
  23232. m.process_id = &s
  23233. }
  23234. // ProcessID returns the value of the "process_id" field in the mutation.
  23235. func (m *WxMutation) ProcessID() (r string, exists bool) {
  23236. v := m.process_id
  23237. if v == nil {
  23238. return
  23239. }
  23240. return *v, true
  23241. }
  23242. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  23243. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23245. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  23246. if !m.op.Is(OpUpdateOne) {
  23247. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  23248. }
  23249. if m.id == nil || m.oldValue == nil {
  23250. return v, errors.New("OldProcessID requires an ID field in the mutation")
  23251. }
  23252. oldValue, err := m.oldValue(ctx)
  23253. if err != nil {
  23254. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  23255. }
  23256. return oldValue.ProcessID, nil
  23257. }
  23258. // ResetProcessID resets all changes to the "process_id" field.
  23259. func (m *WxMutation) ResetProcessID() {
  23260. m.process_id = nil
  23261. }
  23262. // SetCallback sets the "callback" field.
  23263. func (m *WxMutation) SetCallback(s string) {
  23264. m.callback = &s
  23265. }
  23266. // Callback returns the value of the "callback" field in the mutation.
  23267. func (m *WxMutation) Callback() (r string, exists bool) {
  23268. v := m.callback
  23269. if v == nil {
  23270. return
  23271. }
  23272. return *v, true
  23273. }
  23274. // OldCallback returns the old "callback" field's value of the Wx entity.
  23275. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23277. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  23278. if !m.op.Is(OpUpdateOne) {
  23279. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  23280. }
  23281. if m.id == nil || m.oldValue == nil {
  23282. return v, errors.New("OldCallback requires an ID field in the mutation")
  23283. }
  23284. oldValue, err := m.oldValue(ctx)
  23285. if err != nil {
  23286. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  23287. }
  23288. return oldValue.Callback, nil
  23289. }
  23290. // ResetCallback resets all changes to the "callback" field.
  23291. func (m *WxMutation) ResetCallback() {
  23292. m.callback = nil
  23293. }
  23294. // SetWxid sets the "wxid" field.
  23295. func (m *WxMutation) SetWxid(s string) {
  23296. m.wxid = &s
  23297. }
  23298. // Wxid returns the value of the "wxid" field in the mutation.
  23299. func (m *WxMutation) Wxid() (r string, exists bool) {
  23300. v := m.wxid
  23301. if v == nil {
  23302. return
  23303. }
  23304. return *v, true
  23305. }
  23306. // OldWxid returns the old "wxid" field's value of the Wx entity.
  23307. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23309. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  23310. if !m.op.Is(OpUpdateOne) {
  23311. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23312. }
  23313. if m.id == nil || m.oldValue == nil {
  23314. return v, errors.New("OldWxid requires an ID field in the mutation")
  23315. }
  23316. oldValue, err := m.oldValue(ctx)
  23317. if err != nil {
  23318. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23319. }
  23320. return oldValue.Wxid, nil
  23321. }
  23322. // ResetWxid resets all changes to the "wxid" field.
  23323. func (m *WxMutation) ResetWxid() {
  23324. m.wxid = nil
  23325. }
  23326. // SetAccount sets the "account" field.
  23327. func (m *WxMutation) SetAccount(s string) {
  23328. m.account = &s
  23329. }
  23330. // Account returns the value of the "account" field in the mutation.
  23331. func (m *WxMutation) Account() (r string, exists bool) {
  23332. v := m.account
  23333. if v == nil {
  23334. return
  23335. }
  23336. return *v, true
  23337. }
  23338. // OldAccount returns the old "account" field's value of the Wx entity.
  23339. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23341. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  23342. if !m.op.Is(OpUpdateOne) {
  23343. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  23344. }
  23345. if m.id == nil || m.oldValue == nil {
  23346. return v, errors.New("OldAccount requires an ID field in the mutation")
  23347. }
  23348. oldValue, err := m.oldValue(ctx)
  23349. if err != nil {
  23350. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  23351. }
  23352. return oldValue.Account, nil
  23353. }
  23354. // ResetAccount resets all changes to the "account" field.
  23355. func (m *WxMutation) ResetAccount() {
  23356. m.account = nil
  23357. }
  23358. // SetNickname sets the "nickname" field.
  23359. func (m *WxMutation) SetNickname(s string) {
  23360. m.nickname = &s
  23361. }
  23362. // Nickname returns the value of the "nickname" field in the mutation.
  23363. func (m *WxMutation) Nickname() (r string, exists bool) {
  23364. v := m.nickname
  23365. if v == nil {
  23366. return
  23367. }
  23368. return *v, true
  23369. }
  23370. // OldNickname returns the old "nickname" field's value of the Wx entity.
  23371. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23373. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  23374. if !m.op.Is(OpUpdateOne) {
  23375. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  23376. }
  23377. if m.id == nil || m.oldValue == nil {
  23378. return v, errors.New("OldNickname requires an ID field in the mutation")
  23379. }
  23380. oldValue, err := m.oldValue(ctx)
  23381. if err != nil {
  23382. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  23383. }
  23384. return oldValue.Nickname, nil
  23385. }
  23386. // ResetNickname resets all changes to the "nickname" field.
  23387. func (m *WxMutation) ResetNickname() {
  23388. m.nickname = nil
  23389. }
  23390. // SetTel sets the "tel" field.
  23391. func (m *WxMutation) SetTel(s string) {
  23392. m.tel = &s
  23393. }
  23394. // Tel returns the value of the "tel" field in the mutation.
  23395. func (m *WxMutation) Tel() (r string, exists bool) {
  23396. v := m.tel
  23397. if v == nil {
  23398. return
  23399. }
  23400. return *v, true
  23401. }
  23402. // OldTel returns the old "tel" field's value of the Wx entity.
  23403. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23405. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  23406. if !m.op.Is(OpUpdateOne) {
  23407. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  23408. }
  23409. if m.id == nil || m.oldValue == nil {
  23410. return v, errors.New("OldTel requires an ID field in the mutation")
  23411. }
  23412. oldValue, err := m.oldValue(ctx)
  23413. if err != nil {
  23414. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  23415. }
  23416. return oldValue.Tel, nil
  23417. }
  23418. // ResetTel resets all changes to the "tel" field.
  23419. func (m *WxMutation) ResetTel() {
  23420. m.tel = nil
  23421. }
  23422. // SetHeadBig sets the "head_big" field.
  23423. func (m *WxMutation) SetHeadBig(s string) {
  23424. m.head_big = &s
  23425. }
  23426. // HeadBig returns the value of the "head_big" field in the mutation.
  23427. func (m *WxMutation) HeadBig() (r string, exists bool) {
  23428. v := m.head_big
  23429. if v == nil {
  23430. return
  23431. }
  23432. return *v, true
  23433. }
  23434. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  23435. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23437. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  23438. if !m.op.Is(OpUpdateOne) {
  23439. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  23440. }
  23441. if m.id == nil || m.oldValue == nil {
  23442. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  23443. }
  23444. oldValue, err := m.oldValue(ctx)
  23445. if err != nil {
  23446. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  23447. }
  23448. return oldValue.HeadBig, nil
  23449. }
  23450. // ResetHeadBig resets all changes to the "head_big" field.
  23451. func (m *WxMutation) ResetHeadBig() {
  23452. m.head_big = nil
  23453. }
  23454. // SetOrganizationID sets the "organization_id" field.
  23455. func (m *WxMutation) SetOrganizationID(u uint64) {
  23456. m.organization_id = &u
  23457. m.addorganization_id = nil
  23458. }
  23459. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23460. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  23461. v := m.organization_id
  23462. if v == nil {
  23463. return
  23464. }
  23465. return *v, true
  23466. }
  23467. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  23468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23470. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23471. if !m.op.Is(OpUpdateOne) {
  23472. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23473. }
  23474. if m.id == nil || m.oldValue == nil {
  23475. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23476. }
  23477. oldValue, err := m.oldValue(ctx)
  23478. if err != nil {
  23479. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23480. }
  23481. return oldValue.OrganizationID, nil
  23482. }
  23483. // AddOrganizationID adds u to the "organization_id" field.
  23484. func (m *WxMutation) AddOrganizationID(u int64) {
  23485. if m.addorganization_id != nil {
  23486. *m.addorganization_id += u
  23487. } else {
  23488. m.addorganization_id = &u
  23489. }
  23490. }
  23491. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23492. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  23493. v := m.addorganization_id
  23494. if v == nil {
  23495. return
  23496. }
  23497. return *v, true
  23498. }
  23499. // ClearOrganizationID clears the value of the "organization_id" field.
  23500. func (m *WxMutation) ClearOrganizationID() {
  23501. m.organization_id = nil
  23502. m.addorganization_id = nil
  23503. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  23504. }
  23505. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23506. func (m *WxMutation) OrganizationIDCleared() bool {
  23507. _, ok := m.clearedFields[wx.FieldOrganizationID]
  23508. return ok
  23509. }
  23510. // ResetOrganizationID resets all changes to the "organization_id" field.
  23511. func (m *WxMutation) ResetOrganizationID() {
  23512. m.organization_id = nil
  23513. m.addorganization_id = nil
  23514. delete(m.clearedFields, wx.FieldOrganizationID)
  23515. }
  23516. // SetAgentID sets the "agent_id" field.
  23517. func (m *WxMutation) SetAgentID(u uint64) {
  23518. m.agent = &u
  23519. }
  23520. // AgentID returns the value of the "agent_id" field in the mutation.
  23521. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  23522. v := m.agent
  23523. if v == nil {
  23524. return
  23525. }
  23526. return *v, true
  23527. }
  23528. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  23529. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23531. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  23532. if !m.op.Is(OpUpdateOne) {
  23533. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  23534. }
  23535. if m.id == nil || m.oldValue == nil {
  23536. return v, errors.New("OldAgentID requires an ID field in the mutation")
  23537. }
  23538. oldValue, err := m.oldValue(ctx)
  23539. if err != nil {
  23540. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  23541. }
  23542. return oldValue.AgentID, nil
  23543. }
  23544. // ResetAgentID resets all changes to the "agent_id" field.
  23545. func (m *WxMutation) ResetAgentID() {
  23546. m.agent = nil
  23547. }
  23548. // SetAPIBase sets the "api_base" field.
  23549. func (m *WxMutation) SetAPIBase(s string) {
  23550. m.api_base = &s
  23551. }
  23552. // APIBase returns the value of the "api_base" field in the mutation.
  23553. func (m *WxMutation) APIBase() (r string, exists bool) {
  23554. v := m.api_base
  23555. if v == nil {
  23556. return
  23557. }
  23558. return *v, true
  23559. }
  23560. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  23561. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23563. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23564. if !m.op.Is(OpUpdateOne) {
  23565. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23566. }
  23567. if m.id == nil || m.oldValue == nil {
  23568. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23569. }
  23570. oldValue, err := m.oldValue(ctx)
  23571. if err != nil {
  23572. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23573. }
  23574. return oldValue.APIBase, nil
  23575. }
  23576. // ClearAPIBase clears the value of the "api_base" field.
  23577. func (m *WxMutation) ClearAPIBase() {
  23578. m.api_base = nil
  23579. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  23580. }
  23581. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23582. func (m *WxMutation) APIBaseCleared() bool {
  23583. _, ok := m.clearedFields[wx.FieldAPIBase]
  23584. return ok
  23585. }
  23586. // ResetAPIBase resets all changes to the "api_base" field.
  23587. func (m *WxMutation) ResetAPIBase() {
  23588. m.api_base = nil
  23589. delete(m.clearedFields, wx.FieldAPIBase)
  23590. }
  23591. // SetAPIKey sets the "api_key" field.
  23592. func (m *WxMutation) SetAPIKey(s string) {
  23593. m.api_key = &s
  23594. }
  23595. // APIKey returns the value of the "api_key" field in the mutation.
  23596. func (m *WxMutation) APIKey() (r string, exists bool) {
  23597. v := m.api_key
  23598. if v == nil {
  23599. return
  23600. }
  23601. return *v, true
  23602. }
  23603. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  23604. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23606. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23607. if !m.op.Is(OpUpdateOne) {
  23608. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23609. }
  23610. if m.id == nil || m.oldValue == nil {
  23611. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23612. }
  23613. oldValue, err := m.oldValue(ctx)
  23614. if err != nil {
  23615. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23616. }
  23617. return oldValue.APIKey, nil
  23618. }
  23619. // ClearAPIKey clears the value of the "api_key" field.
  23620. func (m *WxMutation) ClearAPIKey() {
  23621. m.api_key = nil
  23622. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  23623. }
  23624. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23625. func (m *WxMutation) APIKeyCleared() bool {
  23626. _, ok := m.clearedFields[wx.FieldAPIKey]
  23627. return ok
  23628. }
  23629. // ResetAPIKey resets all changes to the "api_key" field.
  23630. func (m *WxMutation) ResetAPIKey() {
  23631. m.api_key = nil
  23632. delete(m.clearedFields, wx.FieldAPIKey)
  23633. }
  23634. // SetAllowList sets the "allow_list" field.
  23635. func (m *WxMutation) SetAllowList(s []string) {
  23636. m.allow_list = &s
  23637. m.appendallow_list = nil
  23638. }
  23639. // AllowList returns the value of the "allow_list" field in the mutation.
  23640. func (m *WxMutation) AllowList() (r []string, exists bool) {
  23641. v := m.allow_list
  23642. if v == nil {
  23643. return
  23644. }
  23645. return *v, true
  23646. }
  23647. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  23648. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23650. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  23651. if !m.op.Is(OpUpdateOne) {
  23652. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  23653. }
  23654. if m.id == nil || m.oldValue == nil {
  23655. return v, errors.New("OldAllowList requires an ID field in the mutation")
  23656. }
  23657. oldValue, err := m.oldValue(ctx)
  23658. if err != nil {
  23659. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  23660. }
  23661. return oldValue.AllowList, nil
  23662. }
  23663. // AppendAllowList adds s to the "allow_list" field.
  23664. func (m *WxMutation) AppendAllowList(s []string) {
  23665. m.appendallow_list = append(m.appendallow_list, s...)
  23666. }
  23667. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  23668. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  23669. if len(m.appendallow_list) == 0 {
  23670. return nil, false
  23671. }
  23672. return m.appendallow_list, true
  23673. }
  23674. // ResetAllowList resets all changes to the "allow_list" field.
  23675. func (m *WxMutation) ResetAllowList() {
  23676. m.allow_list = nil
  23677. m.appendallow_list = nil
  23678. }
  23679. // SetGroupAllowList sets the "group_allow_list" field.
  23680. func (m *WxMutation) SetGroupAllowList(s []string) {
  23681. m.group_allow_list = &s
  23682. m.appendgroup_allow_list = nil
  23683. }
  23684. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  23685. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  23686. v := m.group_allow_list
  23687. if v == nil {
  23688. return
  23689. }
  23690. return *v, true
  23691. }
  23692. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  23693. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23695. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  23696. if !m.op.Is(OpUpdateOne) {
  23697. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  23698. }
  23699. if m.id == nil || m.oldValue == nil {
  23700. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  23701. }
  23702. oldValue, err := m.oldValue(ctx)
  23703. if err != nil {
  23704. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  23705. }
  23706. return oldValue.GroupAllowList, nil
  23707. }
  23708. // AppendGroupAllowList adds s to the "group_allow_list" field.
  23709. func (m *WxMutation) AppendGroupAllowList(s []string) {
  23710. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  23711. }
  23712. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  23713. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  23714. if len(m.appendgroup_allow_list) == 0 {
  23715. return nil, false
  23716. }
  23717. return m.appendgroup_allow_list, true
  23718. }
  23719. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  23720. func (m *WxMutation) ResetGroupAllowList() {
  23721. m.group_allow_list = nil
  23722. m.appendgroup_allow_list = nil
  23723. }
  23724. // SetBlockList sets the "block_list" field.
  23725. func (m *WxMutation) SetBlockList(s []string) {
  23726. m.block_list = &s
  23727. m.appendblock_list = nil
  23728. }
  23729. // BlockList returns the value of the "block_list" field in the mutation.
  23730. func (m *WxMutation) BlockList() (r []string, exists bool) {
  23731. v := m.block_list
  23732. if v == nil {
  23733. return
  23734. }
  23735. return *v, true
  23736. }
  23737. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  23738. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23740. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  23741. if !m.op.Is(OpUpdateOne) {
  23742. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  23743. }
  23744. if m.id == nil || m.oldValue == nil {
  23745. return v, errors.New("OldBlockList requires an ID field in the mutation")
  23746. }
  23747. oldValue, err := m.oldValue(ctx)
  23748. if err != nil {
  23749. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  23750. }
  23751. return oldValue.BlockList, nil
  23752. }
  23753. // AppendBlockList adds s to the "block_list" field.
  23754. func (m *WxMutation) AppendBlockList(s []string) {
  23755. m.appendblock_list = append(m.appendblock_list, s...)
  23756. }
  23757. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  23758. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  23759. if len(m.appendblock_list) == 0 {
  23760. return nil, false
  23761. }
  23762. return m.appendblock_list, true
  23763. }
  23764. // ResetBlockList resets all changes to the "block_list" field.
  23765. func (m *WxMutation) ResetBlockList() {
  23766. m.block_list = nil
  23767. m.appendblock_list = nil
  23768. }
  23769. // SetGroupBlockList sets the "group_block_list" field.
  23770. func (m *WxMutation) SetGroupBlockList(s []string) {
  23771. m.group_block_list = &s
  23772. m.appendgroup_block_list = nil
  23773. }
  23774. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  23775. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  23776. v := m.group_block_list
  23777. if v == nil {
  23778. return
  23779. }
  23780. return *v, true
  23781. }
  23782. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  23783. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23785. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  23786. if !m.op.Is(OpUpdateOne) {
  23787. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  23788. }
  23789. if m.id == nil || m.oldValue == nil {
  23790. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  23791. }
  23792. oldValue, err := m.oldValue(ctx)
  23793. if err != nil {
  23794. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  23795. }
  23796. return oldValue.GroupBlockList, nil
  23797. }
  23798. // AppendGroupBlockList adds s to the "group_block_list" field.
  23799. func (m *WxMutation) AppendGroupBlockList(s []string) {
  23800. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  23801. }
  23802. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  23803. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  23804. if len(m.appendgroup_block_list) == 0 {
  23805. return nil, false
  23806. }
  23807. return m.appendgroup_block_list, true
  23808. }
  23809. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  23810. func (m *WxMutation) ResetGroupBlockList() {
  23811. m.group_block_list = nil
  23812. m.appendgroup_block_list = nil
  23813. }
  23814. // ClearServer clears the "server" edge to the Server entity.
  23815. func (m *WxMutation) ClearServer() {
  23816. m.clearedserver = true
  23817. m.clearedFields[wx.FieldServerID] = struct{}{}
  23818. }
  23819. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  23820. func (m *WxMutation) ServerCleared() bool {
  23821. return m.ServerIDCleared() || m.clearedserver
  23822. }
  23823. // ServerIDs returns the "server" edge IDs in the mutation.
  23824. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23825. // ServerID instead. It exists only for internal usage by the builders.
  23826. func (m *WxMutation) ServerIDs() (ids []uint64) {
  23827. if id := m.server; id != nil {
  23828. ids = append(ids, *id)
  23829. }
  23830. return
  23831. }
  23832. // ResetServer resets all changes to the "server" edge.
  23833. func (m *WxMutation) ResetServer() {
  23834. m.server = nil
  23835. m.clearedserver = false
  23836. }
  23837. // ClearAgent clears the "agent" edge to the Agent entity.
  23838. func (m *WxMutation) ClearAgent() {
  23839. m.clearedagent = true
  23840. m.clearedFields[wx.FieldAgentID] = struct{}{}
  23841. }
  23842. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  23843. func (m *WxMutation) AgentCleared() bool {
  23844. return m.clearedagent
  23845. }
  23846. // AgentIDs returns the "agent" edge IDs in the mutation.
  23847. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23848. // AgentID instead. It exists only for internal usage by the builders.
  23849. func (m *WxMutation) AgentIDs() (ids []uint64) {
  23850. if id := m.agent; id != nil {
  23851. ids = append(ids, *id)
  23852. }
  23853. return
  23854. }
  23855. // ResetAgent resets all changes to the "agent" edge.
  23856. func (m *WxMutation) ResetAgent() {
  23857. m.agent = nil
  23858. m.clearedagent = false
  23859. }
  23860. // Where appends a list predicates to the WxMutation builder.
  23861. func (m *WxMutation) Where(ps ...predicate.Wx) {
  23862. m.predicates = append(m.predicates, ps...)
  23863. }
  23864. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  23865. // users can use type-assertion to append predicates that do not depend on any generated package.
  23866. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  23867. p := make([]predicate.Wx, len(ps))
  23868. for i := range ps {
  23869. p[i] = ps[i]
  23870. }
  23871. m.Where(p...)
  23872. }
  23873. // Op returns the operation name.
  23874. func (m *WxMutation) Op() Op {
  23875. return m.op
  23876. }
  23877. // SetOp allows setting the mutation operation.
  23878. func (m *WxMutation) SetOp(op Op) {
  23879. m.op = op
  23880. }
  23881. // Type returns the node type of this mutation (Wx).
  23882. func (m *WxMutation) Type() string {
  23883. return m.typ
  23884. }
  23885. // Fields returns all fields that were changed during this mutation. Note that in
  23886. // order to get all numeric fields that were incremented/decremented, call
  23887. // AddedFields().
  23888. func (m *WxMutation) Fields() []string {
  23889. fields := make([]string, 0, 21)
  23890. if m.created_at != nil {
  23891. fields = append(fields, wx.FieldCreatedAt)
  23892. }
  23893. if m.updated_at != nil {
  23894. fields = append(fields, wx.FieldUpdatedAt)
  23895. }
  23896. if m.status != nil {
  23897. fields = append(fields, wx.FieldStatus)
  23898. }
  23899. if m.deleted_at != nil {
  23900. fields = append(fields, wx.FieldDeletedAt)
  23901. }
  23902. if m.server != nil {
  23903. fields = append(fields, wx.FieldServerID)
  23904. }
  23905. if m.port != nil {
  23906. fields = append(fields, wx.FieldPort)
  23907. }
  23908. if m.process_id != nil {
  23909. fields = append(fields, wx.FieldProcessID)
  23910. }
  23911. if m.callback != nil {
  23912. fields = append(fields, wx.FieldCallback)
  23913. }
  23914. if m.wxid != nil {
  23915. fields = append(fields, wx.FieldWxid)
  23916. }
  23917. if m.account != nil {
  23918. fields = append(fields, wx.FieldAccount)
  23919. }
  23920. if m.nickname != nil {
  23921. fields = append(fields, wx.FieldNickname)
  23922. }
  23923. if m.tel != nil {
  23924. fields = append(fields, wx.FieldTel)
  23925. }
  23926. if m.head_big != nil {
  23927. fields = append(fields, wx.FieldHeadBig)
  23928. }
  23929. if m.organization_id != nil {
  23930. fields = append(fields, wx.FieldOrganizationID)
  23931. }
  23932. if m.agent != nil {
  23933. fields = append(fields, wx.FieldAgentID)
  23934. }
  23935. if m.api_base != nil {
  23936. fields = append(fields, wx.FieldAPIBase)
  23937. }
  23938. if m.api_key != nil {
  23939. fields = append(fields, wx.FieldAPIKey)
  23940. }
  23941. if m.allow_list != nil {
  23942. fields = append(fields, wx.FieldAllowList)
  23943. }
  23944. if m.group_allow_list != nil {
  23945. fields = append(fields, wx.FieldGroupAllowList)
  23946. }
  23947. if m.block_list != nil {
  23948. fields = append(fields, wx.FieldBlockList)
  23949. }
  23950. if m.group_block_list != nil {
  23951. fields = append(fields, wx.FieldGroupBlockList)
  23952. }
  23953. return fields
  23954. }
  23955. // Field returns the value of a field with the given name. The second boolean
  23956. // return value indicates that this field was not set, or was not defined in the
  23957. // schema.
  23958. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  23959. switch name {
  23960. case wx.FieldCreatedAt:
  23961. return m.CreatedAt()
  23962. case wx.FieldUpdatedAt:
  23963. return m.UpdatedAt()
  23964. case wx.FieldStatus:
  23965. return m.Status()
  23966. case wx.FieldDeletedAt:
  23967. return m.DeletedAt()
  23968. case wx.FieldServerID:
  23969. return m.ServerID()
  23970. case wx.FieldPort:
  23971. return m.Port()
  23972. case wx.FieldProcessID:
  23973. return m.ProcessID()
  23974. case wx.FieldCallback:
  23975. return m.Callback()
  23976. case wx.FieldWxid:
  23977. return m.Wxid()
  23978. case wx.FieldAccount:
  23979. return m.Account()
  23980. case wx.FieldNickname:
  23981. return m.Nickname()
  23982. case wx.FieldTel:
  23983. return m.Tel()
  23984. case wx.FieldHeadBig:
  23985. return m.HeadBig()
  23986. case wx.FieldOrganizationID:
  23987. return m.OrganizationID()
  23988. case wx.FieldAgentID:
  23989. return m.AgentID()
  23990. case wx.FieldAPIBase:
  23991. return m.APIBase()
  23992. case wx.FieldAPIKey:
  23993. return m.APIKey()
  23994. case wx.FieldAllowList:
  23995. return m.AllowList()
  23996. case wx.FieldGroupAllowList:
  23997. return m.GroupAllowList()
  23998. case wx.FieldBlockList:
  23999. return m.BlockList()
  24000. case wx.FieldGroupBlockList:
  24001. return m.GroupBlockList()
  24002. }
  24003. return nil, false
  24004. }
  24005. // OldField returns the old value of the field from the database. An error is
  24006. // returned if the mutation operation is not UpdateOne, or the query to the
  24007. // database failed.
  24008. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24009. switch name {
  24010. case wx.FieldCreatedAt:
  24011. return m.OldCreatedAt(ctx)
  24012. case wx.FieldUpdatedAt:
  24013. return m.OldUpdatedAt(ctx)
  24014. case wx.FieldStatus:
  24015. return m.OldStatus(ctx)
  24016. case wx.FieldDeletedAt:
  24017. return m.OldDeletedAt(ctx)
  24018. case wx.FieldServerID:
  24019. return m.OldServerID(ctx)
  24020. case wx.FieldPort:
  24021. return m.OldPort(ctx)
  24022. case wx.FieldProcessID:
  24023. return m.OldProcessID(ctx)
  24024. case wx.FieldCallback:
  24025. return m.OldCallback(ctx)
  24026. case wx.FieldWxid:
  24027. return m.OldWxid(ctx)
  24028. case wx.FieldAccount:
  24029. return m.OldAccount(ctx)
  24030. case wx.FieldNickname:
  24031. return m.OldNickname(ctx)
  24032. case wx.FieldTel:
  24033. return m.OldTel(ctx)
  24034. case wx.FieldHeadBig:
  24035. return m.OldHeadBig(ctx)
  24036. case wx.FieldOrganizationID:
  24037. return m.OldOrganizationID(ctx)
  24038. case wx.FieldAgentID:
  24039. return m.OldAgentID(ctx)
  24040. case wx.FieldAPIBase:
  24041. return m.OldAPIBase(ctx)
  24042. case wx.FieldAPIKey:
  24043. return m.OldAPIKey(ctx)
  24044. case wx.FieldAllowList:
  24045. return m.OldAllowList(ctx)
  24046. case wx.FieldGroupAllowList:
  24047. return m.OldGroupAllowList(ctx)
  24048. case wx.FieldBlockList:
  24049. return m.OldBlockList(ctx)
  24050. case wx.FieldGroupBlockList:
  24051. return m.OldGroupBlockList(ctx)
  24052. }
  24053. return nil, fmt.Errorf("unknown Wx field %s", name)
  24054. }
  24055. // SetField sets the value of a field with the given name. It returns an error if
  24056. // the field is not defined in the schema, or if the type mismatched the field
  24057. // type.
  24058. func (m *WxMutation) SetField(name string, value ent.Value) error {
  24059. switch name {
  24060. case wx.FieldCreatedAt:
  24061. v, ok := value.(time.Time)
  24062. if !ok {
  24063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24064. }
  24065. m.SetCreatedAt(v)
  24066. return nil
  24067. case wx.FieldUpdatedAt:
  24068. v, ok := value.(time.Time)
  24069. if !ok {
  24070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24071. }
  24072. m.SetUpdatedAt(v)
  24073. return nil
  24074. case wx.FieldStatus:
  24075. v, ok := value.(uint8)
  24076. if !ok {
  24077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24078. }
  24079. m.SetStatus(v)
  24080. return nil
  24081. case wx.FieldDeletedAt:
  24082. v, ok := value.(time.Time)
  24083. if !ok {
  24084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24085. }
  24086. m.SetDeletedAt(v)
  24087. return nil
  24088. case wx.FieldServerID:
  24089. v, ok := value.(uint64)
  24090. if !ok {
  24091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24092. }
  24093. m.SetServerID(v)
  24094. return nil
  24095. case wx.FieldPort:
  24096. v, ok := value.(string)
  24097. if !ok {
  24098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24099. }
  24100. m.SetPort(v)
  24101. return nil
  24102. case wx.FieldProcessID:
  24103. v, ok := value.(string)
  24104. if !ok {
  24105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24106. }
  24107. m.SetProcessID(v)
  24108. return nil
  24109. case wx.FieldCallback:
  24110. v, ok := value.(string)
  24111. if !ok {
  24112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24113. }
  24114. m.SetCallback(v)
  24115. return nil
  24116. case wx.FieldWxid:
  24117. v, ok := value.(string)
  24118. if !ok {
  24119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24120. }
  24121. m.SetWxid(v)
  24122. return nil
  24123. case wx.FieldAccount:
  24124. v, ok := value.(string)
  24125. if !ok {
  24126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24127. }
  24128. m.SetAccount(v)
  24129. return nil
  24130. case wx.FieldNickname:
  24131. v, ok := value.(string)
  24132. if !ok {
  24133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24134. }
  24135. m.SetNickname(v)
  24136. return nil
  24137. case wx.FieldTel:
  24138. v, ok := value.(string)
  24139. if !ok {
  24140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24141. }
  24142. m.SetTel(v)
  24143. return nil
  24144. case wx.FieldHeadBig:
  24145. v, ok := value.(string)
  24146. if !ok {
  24147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24148. }
  24149. m.SetHeadBig(v)
  24150. return nil
  24151. case wx.FieldOrganizationID:
  24152. v, ok := value.(uint64)
  24153. if !ok {
  24154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24155. }
  24156. m.SetOrganizationID(v)
  24157. return nil
  24158. case wx.FieldAgentID:
  24159. v, ok := value.(uint64)
  24160. if !ok {
  24161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24162. }
  24163. m.SetAgentID(v)
  24164. return nil
  24165. case wx.FieldAPIBase:
  24166. v, ok := value.(string)
  24167. if !ok {
  24168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24169. }
  24170. m.SetAPIBase(v)
  24171. return nil
  24172. case wx.FieldAPIKey:
  24173. v, ok := value.(string)
  24174. if !ok {
  24175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24176. }
  24177. m.SetAPIKey(v)
  24178. return nil
  24179. case wx.FieldAllowList:
  24180. v, ok := value.([]string)
  24181. if !ok {
  24182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24183. }
  24184. m.SetAllowList(v)
  24185. return nil
  24186. case wx.FieldGroupAllowList:
  24187. v, ok := value.([]string)
  24188. if !ok {
  24189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24190. }
  24191. m.SetGroupAllowList(v)
  24192. return nil
  24193. case wx.FieldBlockList:
  24194. v, ok := value.([]string)
  24195. if !ok {
  24196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24197. }
  24198. m.SetBlockList(v)
  24199. return nil
  24200. case wx.FieldGroupBlockList:
  24201. v, ok := value.([]string)
  24202. if !ok {
  24203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24204. }
  24205. m.SetGroupBlockList(v)
  24206. return nil
  24207. }
  24208. return fmt.Errorf("unknown Wx field %s", name)
  24209. }
  24210. // AddedFields returns all numeric fields that were incremented/decremented during
  24211. // this mutation.
  24212. func (m *WxMutation) AddedFields() []string {
  24213. var fields []string
  24214. if m.addstatus != nil {
  24215. fields = append(fields, wx.FieldStatus)
  24216. }
  24217. if m.addorganization_id != nil {
  24218. fields = append(fields, wx.FieldOrganizationID)
  24219. }
  24220. return fields
  24221. }
  24222. // AddedField returns the numeric value that was incremented/decremented on a field
  24223. // with the given name. The second boolean return value indicates that this field
  24224. // was not set, or was not defined in the schema.
  24225. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  24226. switch name {
  24227. case wx.FieldStatus:
  24228. return m.AddedStatus()
  24229. case wx.FieldOrganizationID:
  24230. return m.AddedOrganizationID()
  24231. }
  24232. return nil, false
  24233. }
  24234. // AddField adds the value to the field with the given name. It returns an error if
  24235. // the field is not defined in the schema, or if the type mismatched the field
  24236. // type.
  24237. func (m *WxMutation) AddField(name string, value ent.Value) error {
  24238. switch name {
  24239. case wx.FieldStatus:
  24240. v, ok := value.(int8)
  24241. if !ok {
  24242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24243. }
  24244. m.AddStatus(v)
  24245. return nil
  24246. case wx.FieldOrganizationID:
  24247. v, ok := value.(int64)
  24248. if !ok {
  24249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24250. }
  24251. m.AddOrganizationID(v)
  24252. return nil
  24253. }
  24254. return fmt.Errorf("unknown Wx numeric field %s", name)
  24255. }
  24256. // ClearedFields returns all nullable fields that were cleared during this
  24257. // mutation.
  24258. func (m *WxMutation) ClearedFields() []string {
  24259. var fields []string
  24260. if m.FieldCleared(wx.FieldStatus) {
  24261. fields = append(fields, wx.FieldStatus)
  24262. }
  24263. if m.FieldCleared(wx.FieldDeletedAt) {
  24264. fields = append(fields, wx.FieldDeletedAt)
  24265. }
  24266. if m.FieldCleared(wx.FieldServerID) {
  24267. fields = append(fields, wx.FieldServerID)
  24268. }
  24269. if m.FieldCleared(wx.FieldOrganizationID) {
  24270. fields = append(fields, wx.FieldOrganizationID)
  24271. }
  24272. if m.FieldCleared(wx.FieldAPIBase) {
  24273. fields = append(fields, wx.FieldAPIBase)
  24274. }
  24275. if m.FieldCleared(wx.FieldAPIKey) {
  24276. fields = append(fields, wx.FieldAPIKey)
  24277. }
  24278. return fields
  24279. }
  24280. // FieldCleared returns a boolean indicating if a field with the given name was
  24281. // cleared in this mutation.
  24282. func (m *WxMutation) FieldCleared(name string) bool {
  24283. _, ok := m.clearedFields[name]
  24284. return ok
  24285. }
  24286. // ClearField clears the value of the field with the given name. It returns an
  24287. // error if the field is not defined in the schema.
  24288. func (m *WxMutation) ClearField(name string) error {
  24289. switch name {
  24290. case wx.FieldStatus:
  24291. m.ClearStatus()
  24292. return nil
  24293. case wx.FieldDeletedAt:
  24294. m.ClearDeletedAt()
  24295. return nil
  24296. case wx.FieldServerID:
  24297. m.ClearServerID()
  24298. return nil
  24299. case wx.FieldOrganizationID:
  24300. m.ClearOrganizationID()
  24301. return nil
  24302. case wx.FieldAPIBase:
  24303. m.ClearAPIBase()
  24304. return nil
  24305. case wx.FieldAPIKey:
  24306. m.ClearAPIKey()
  24307. return nil
  24308. }
  24309. return fmt.Errorf("unknown Wx nullable field %s", name)
  24310. }
  24311. // ResetField resets all changes in the mutation for the field with the given name.
  24312. // It returns an error if the field is not defined in the schema.
  24313. func (m *WxMutation) ResetField(name string) error {
  24314. switch name {
  24315. case wx.FieldCreatedAt:
  24316. m.ResetCreatedAt()
  24317. return nil
  24318. case wx.FieldUpdatedAt:
  24319. m.ResetUpdatedAt()
  24320. return nil
  24321. case wx.FieldStatus:
  24322. m.ResetStatus()
  24323. return nil
  24324. case wx.FieldDeletedAt:
  24325. m.ResetDeletedAt()
  24326. return nil
  24327. case wx.FieldServerID:
  24328. m.ResetServerID()
  24329. return nil
  24330. case wx.FieldPort:
  24331. m.ResetPort()
  24332. return nil
  24333. case wx.FieldProcessID:
  24334. m.ResetProcessID()
  24335. return nil
  24336. case wx.FieldCallback:
  24337. m.ResetCallback()
  24338. return nil
  24339. case wx.FieldWxid:
  24340. m.ResetWxid()
  24341. return nil
  24342. case wx.FieldAccount:
  24343. m.ResetAccount()
  24344. return nil
  24345. case wx.FieldNickname:
  24346. m.ResetNickname()
  24347. return nil
  24348. case wx.FieldTel:
  24349. m.ResetTel()
  24350. return nil
  24351. case wx.FieldHeadBig:
  24352. m.ResetHeadBig()
  24353. return nil
  24354. case wx.FieldOrganizationID:
  24355. m.ResetOrganizationID()
  24356. return nil
  24357. case wx.FieldAgentID:
  24358. m.ResetAgentID()
  24359. return nil
  24360. case wx.FieldAPIBase:
  24361. m.ResetAPIBase()
  24362. return nil
  24363. case wx.FieldAPIKey:
  24364. m.ResetAPIKey()
  24365. return nil
  24366. case wx.FieldAllowList:
  24367. m.ResetAllowList()
  24368. return nil
  24369. case wx.FieldGroupAllowList:
  24370. m.ResetGroupAllowList()
  24371. return nil
  24372. case wx.FieldBlockList:
  24373. m.ResetBlockList()
  24374. return nil
  24375. case wx.FieldGroupBlockList:
  24376. m.ResetGroupBlockList()
  24377. return nil
  24378. }
  24379. return fmt.Errorf("unknown Wx field %s", name)
  24380. }
  24381. // AddedEdges returns all edge names that were set/added in this mutation.
  24382. func (m *WxMutation) AddedEdges() []string {
  24383. edges := make([]string, 0, 2)
  24384. if m.server != nil {
  24385. edges = append(edges, wx.EdgeServer)
  24386. }
  24387. if m.agent != nil {
  24388. edges = append(edges, wx.EdgeAgent)
  24389. }
  24390. return edges
  24391. }
  24392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24393. // name in this mutation.
  24394. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  24395. switch name {
  24396. case wx.EdgeServer:
  24397. if id := m.server; id != nil {
  24398. return []ent.Value{*id}
  24399. }
  24400. case wx.EdgeAgent:
  24401. if id := m.agent; id != nil {
  24402. return []ent.Value{*id}
  24403. }
  24404. }
  24405. return nil
  24406. }
  24407. // RemovedEdges returns all edge names that were removed in this mutation.
  24408. func (m *WxMutation) RemovedEdges() []string {
  24409. edges := make([]string, 0, 2)
  24410. return edges
  24411. }
  24412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24413. // the given name in this mutation.
  24414. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  24415. return nil
  24416. }
  24417. // ClearedEdges returns all edge names that were cleared in this mutation.
  24418. func (m *WxMutation) ClearedEdges() []string {
  24419. edges := make([]string, 0, 2)
  24420. if m.clearedserver {
  24421. edges = append(edges, wx.EdgeServer)
  24422. }
  24423. if m.clearedagent {
  24424. edges = append(edges, wx.EdgeAgent)
  24425. }
  24426. return edges
  24427. }
  24428. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24429. // was cleared in this mutation.
  24430. func (m *WxMutation) EdgeCleared(name string) bool {
  24431. switch name {
  24432. case wx.EdgeServer:
  24433. return m.clearedserver
  24434. case wx.EdgeAgent:
  24435. return m.clearedagent
  24436. }
  24437. return false
  24438. }
  24439. // ClearEdge clears the value of the edge with the given name. It returns an error
  24440. // if that edge is not defined in the schema.
  24441. func (m *WxMutation) ClearEdge(name string) error {
  24442. switch name {
  24443. case wx.EdgeServer:
  24444. m.ClearServer()
  24445. return nil
  24446. case wx.EdgeAgent:
  24447. m.ClearAgent()
  24448. return nil
  24449. }
  24450. return fmt.Errorf("unknown Wx unique edge %s", name)
  24451. }
  24452. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24453. // It returns an error if the edge is not defined in the schema.
  24454. func (m *WxMutation) ResetEdge(name string) error {
  24455. switch name {
  24456. case wx.EdgeServer:
  24457. m.ResetServer()
  24458. return nil
  24459. case wx.EdgeAgent:
  24460. m.ResetAgent()
  24461. return nil
  24462. }
  24463. return fmt.Errorf("unknown Wx edge %s", name)
  24464. }
  24465. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  24466. type WxCardMutation struct {
  24467. config
  24468. op Op
  24469. typ string
  24470. id *uint64
  24471. created_at *time.Time
  24472. updated_at *time.Time
  24473. deleted_at *time.Time
  24474. user_id *uint64
  24475. adduser_id *int64
  24476. wx_user_id *uint64
  24477. addwx_user_id *int64
  24478. avatar *string
  24479. logo *string
  24480. name *string
  24481. company *string
  24482. address *string
  24483. phone *string
  24484. official_account *string
  24485. wechat_account *string
  24486. email *string
  24487. api_base *string
  24488. api_key *string
  24489. ai_info *string
  24490. intro *string
  24491. clearedFields map[string]struct{}
  24492. done bool
  24493. oldValue func(context.Context) (*WxCard, error)
  24494. predicates []predicate.WxCard
  24495. }
  24496. var _ ent.Mutation = (*WxCardMutation)(nil)
  24497. // wxcardOption allows management of the mutation configuration using functional options.
  24498. type wxcardOption func(*WxCardMutation)
  24499. // newWxCardMutation creates new mutation for the WxCard entity.
  24500. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  24501. m := &WxCardMutation{
  24502. config: c,
  24503. op: op,
  24504. typ: TypeWxCard,
  24505. clearedFields: make(map[string]struct{}),
  24506. }
  24507. for _, opt := range opts {
  24508. opt(m)
  24509. }
  24510. return m
  24511. }
  24512. // withWxCardID sets the ID field of the mutation.
  24513. func withWxCardID(id uint64) wxcardOption {
  24514. return func(m *WxCardMutation) {
  24515. var (
  24516. err error
  24517. once sync.Once
  24518. value *WxCard
  24519. )
  24520. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  24521. once.Do(func() {
  24522. if m.done {
  24523. err = errors.New("querying old values post mutation is not allowed")
  24524. } else {
  24525. value, err = m.Client().WxCard.Get(ctx, id)
  24526. }
  24527. })
  24528. return value, err
  24529. }
  24530. m.id = &id
  24531. }
  24532. }
  24533. // withWxCard sets the old WxCard of the mutation.
  24534. func withWxCard(node *WxCard) wxcardOption {
  24535. return func(m *WxCardMutation) {
  24536. m.oldValue = func(context.Context) (*WxCard, error) {
  24537. return node, nil
  24538. }
  24539. m.id = &node.ID
  24540. }
  24541. }
  24542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24543. // executed in a transaction (ent.Tx), a transactional client is returned.
  24544. func (m WxCardMutation) Client() *Client {
  24545. client := &Client{config: m.config}
  24546. client.init()
  24547. return client
  24548. }
  24549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24550. // it returns an error otherwise.
  24551. func (m WxCardMutation) Tx() (*Tx, error) {
  24552. if _, ok := m.driver.(*txDriver); !ok {
  24553. return nil, errors.New("ent: mutation is not running in a transaction")
  24554. }
  24555. tx := &Tx{config: m.config}
  24556. tx.init()
  24557. return tx, nil
  24558. }
  24559. // SetID sets the value of the id field. Note that this
  24560. // operation is only accepted on creation of WxCard entities.
  24561. func (m *WxCardMutation) SetID(id uint64) {
  24562. m.id = &id
  24563. }
  24564. // ID returns the ID value in the mutation. Note that the ID is only available
  24565. // if it was provided to the builder or after it was returned from the database.
  24566. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  24567. if m.id == nil {
  24568. return
  24569. }
  24570. return *m.id, true
  24571. }
  24572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24573. // That means, if the mutation is applied within a transaction with an isolation level such
  24574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24575. // or updated by the mutation.
  24576. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  24577. switch {
  24578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24579. id, exists := m.ID()
  24580. if exists {
  24581. return []uint64{id}, nil
  24582. }
  24583. fallthrough
  24584. case m.op.Is(OpUpdate | OpDelete):
  24585. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  24586. default:
  24587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24588. }
  24589. }
  24590. // SetCreatedAt sets the "created_at" field.
  24591. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  24592. m.created_at = &t
  24593. }
  24594. // CreatedAt returns the value of the "created_at" field in the mutation.
  24595. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  24596. v := m.created_at
  24597. if v == nil {
  24598. return
  24599. }
  24600. return *v, true
  24601. }
  24602. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  24603. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24605. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24606. if !m.op.Is(OpUpdateOne) {
  24607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24608. }
  24609. if m.id == nil || m.oldValue == nil {
  24610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24611. }
  24612. oldValue, err := m.oldValue(ctx)
  24613. if err != nil {
  24614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24615. }
  24616. return oldValue.CreatedAt, nil
  24617. }
  24618. // ResetCreatedAt resets all changes to the "created_at" field.
  24619. func (m *WxCardMutation) ResetCreatedAt() {
  24620. m.created_at = nil
  24621. }
  24622. // SetUpdatedAt sets the "updated_at" field.
  24623. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  24624. m.updated_at = &t
  24625. }
  24626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24627. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  24628. v := m.updated_at
  24629. if v == nil {
  24630. return
  24631. }
  24632. return *v, true
  24633. }
  24634. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  24635. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24637. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24638. if !m.op.Is(OpUpdateOne) {
  24639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24640. }
  24641. if m.id == nil || m.oldValue == nil {
  24642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24643. }
  24644. oldValue, err := m.oldValue(ctx)
  24645. if err != nil {
  24646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24647. }
  24648. return oldValue.UpdatedAt, nil
  24649. }
  24650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24651. func (m *WxCardMutation) ResetUpdatedAt() {
  24652. m.updated_at = nil
  24653. }
  24654. // SetDeletedAt sets the "deleted_at" field.
  24655. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  24656. m.deleted_at = &t
  24657. }
  24658. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24659. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  24660. v := m.deleted_at
  24661. if v == nil {
  24662. return
  24663. }
  24664. return *v, true
  24665. }
  24666. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  24667. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24669. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24670. if !m.op.Is(OpUpdateOne) {
  24671. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24672. }
  24673. if m.id == nil || m.oldValue == nil {
  24674. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24675. }
  24676. oldValue, err := m.oldValue(ctx)
  24677. if err != nil {
  24678. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24679. }
  24680. return oldValue.DeletedAt, nil
  24681. }
  24682. // ClearDeletedAt clears the value of the "deleted_at" field.
  24683. func (m *WxCardMutation) ClearDeletedAt() {
  24684. m.deleted_at = nil
  24685. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  24686. }
  24687. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24688. func (m *WxCardMutation) DeletedAtCleared() bool {
  24689. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  24690. return ok
  24691. }
  24692. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24693. func (m *WxCardMutation) ResetDeletedAt() {
  24694. m.deleted_at = nil
  24695. delete(m.clearedFields, wxcard.FieldDeletedAt)
  24696. }
  24697. // SetUserID sets the "user_id" field.
  24698. func (m *WxCardMutation) SetUserID(u uint64) {
  24699. m.user_id = &u
  24700. m.adduser_id = nil
  24701. }
  24702. // UserID returns the value of the "user_id" field in the mutation.
  24703. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  24704. v := m.user_id
  24705. if v == nil {
  24706. return
  24707. }
  24708. return *v, true
  24709. }
  24710. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  24711. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24713. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  24714. if !m.op.Is(OpUpdateOne) {
  24715. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  24716. }
  24717. if m.id == nil || m.oldValue == nil {
  24718. return v, errors.New("OldUserID requires an ID field in the mutation")
  24719. }
  24720. oldValue, err := m.oldValue(ctx)
  24721. if err != nil {
  24722. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  24723. }
  24724. return oldValue.UserID, nil
  24725. }
  24726. // AddUserID adds u to the "user_id" field.
  24727. func (m *WxCardMutation) AddUserID(u int64) {
  24728. if m.adduser_id != nil {
  24729. *m.adduser_id += u
  24730. } else {
  24731. m.adduser_id = &u
  24732. }
  24733. }
  24734. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  24735. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  24736. v := m.adduser_id
  24737. if v == nil {
  24738. return
  24739. }
  24740. return *v, true
  24741. }
  24742. // ClearUserID clears the value of the "user_id" field.
  24743. func (m *WxCardMutation) ClearUserID() {
  24744. m.user_id = nil
  24745. m.adduser_id = nil
  24746. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  24747. }
  24748. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  24749. func (m *WxCardMutation) UserIDCleared() bool {
  24750. _, ok := m.clearedFields[wxcard.FieldUserID]
  24751. return ok
  24752. }
  24753. // ResetUserID resets all changes to the "user_id" field.
  24754. func (m *WxCardMutation) ResetUserID() {
  24755. m.user_id = nil
  24756. m.adduser_id = nil
  24757. delete(m.clearedFields, wxcard.FieldUserID)
  24758. }
  24759. // SetWxUserID sets the "wx_user_id" field.
  24760. func (m *WxCardMutation) SetWxUserID(u uint64) {
  24761. m.wx_user_id = &u
  24762. m.addwx_user_id = nil
  24763. }
  24764. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  24765. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  24766. v := m.wx_user_id
  24767. if v == nil {
  24768. return
  24769. }
  24770. return *v, true
  24771. }
  24772. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  24773. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24775. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  24776. if !m.op.Is(OpUpdateOne) {
  24777. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  24778. }
  24779. if m.id == nil || m.oldValue == nil {
  24780. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  24781. }
  24782. oldValue, err := m.oldValue(ctx)
  24783. if err != nil {
  24784. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  24785. }
  24786. return oldValue.WxUserID, nil
  24787. }
  24788. // AddWxUserID adds u to the "wx_user_id" field.
  24789. func (m *WxCardMutation) AddWxUserID(u int64) {
  24790. if m.addwx_user_id != nil {
  24791. *m.addwx_user_id += u
  24792. } else {
  24793. m.addwx_user_id = &u
  24794. }
  24795. }
  24796. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  24797. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  24798. v := m.addwx_user_id
  24799. if v == nil {
  24800. return
  24801. }
  24802. return *v, true
  24803. }
  24804. // ClearWxUserID clears the value of the "wx_user_id" field.
  24805. func (m *WxCardMutation) ClearWxUserID() {
  24806. m.wx_user_id = nil
  24807. m.addwx_user_id = nil
  24808. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  24809. }
  24810. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  24811. func (m *WxCardMutation) WxUserIDCleared() bool {
  24812. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  24813. return ok
  24814. }
  24815. // ResetWxUserID resets all changes to the "wx_user_id" field.
  24816. func (m *WxCardMutation) ResetWxUserID() {
  24817. m.wx_user_id = nil
  24818. m.addwx_user_id = nil
  24819. delete(m.clearedFields, wxcard.FieldWxUserID)
  24820. }
  24821. // SetAvatar sets the "avatar" field.
  24822. func (m *WxCardMutation) SetAvatar(s string) {
  24823. m.avatar = &s
  24824. }
  24825. // Avatar returns the value of the "avatar" field in the mutation.
  24826. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  24827. v := m.avatar
  24828. if v == nil {
  24829. return
  24830. }
  24831. return *v, true
  24832. }
  24833. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  24834. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24836. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24837. if !m.op.Is(OpUpdateOne) {
  24838. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24839. }
  24840. if m.id == nil || m.oldValue == nil {
  24841. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24842. }
  24843. oldValue, err := m.oldValue(ctx)
  24844. if err != nil {
  24845. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24846. }
  24847. return oldValue.Avatar, nil
  24848. }
  24849. // ResetAvatar resets all changes to the "avatar" field.
  24850. func (m *WxCardMutation) ResetAvatar() {
  24851. m.avatar = nil
  24852. }
  24853. // SetLogo sets the "logo" field.
  24854. func (m *WxCardMutation) SetLogo(s string) {
  24855. m.logo = &s
  24856. }
  24857. // Logo returns the value of the "logo" field in the mutation.
  24858. func (m *WxCardMutation) Logo() (r string, exists bool) {
  24859. v := m.logo
  24860. if v == nil {
  24861. return
  24862. }
  24863. return *v, true
  24864. }
  24865. // OldLogo returns the old "logo" field's value of the WxCard entity.
  24866. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24868. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  24869. if !m.op.Is(OpUpdateOne) {
  24870. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  24871. }
  24872. if m.id == nil || m.oldValue == nil {
  24873. return v, errors.New("OldLogo requires an ID field in the mutation")
  24874. }
  24875. oldValue, err := m.oldValue(ctx)
  24876. if err != nil {
  24877. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  24878. }
  24879. return oldValue.Logo, nil
  24880. }
  24881. // ResetLogo resets all changes to the "logo" field.
  24882. func (m *WxCardMutation) ResetLogo() {
  24883. m.logo = nil
  24884. }
  24885. // SetName sets the "name" field.
  24886. func (m *WxCardMutation) SetName(s string) {
  24887. m.name = &s
  24888. }
  24889. // Name returns the value of the "name" field in the mutation.
  24890. func (m *WxCardMutation) Name() (r string, exists bool) {
  24891. v := m.name
  24892. if v == nil {
  24893. return
  24894. }
  24895. return *v, true
  24896. }
  24897. // OldName returns the old "name" field's value of the WxCard entity.
  24898. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24900. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  24901. if !m.op.Is(OpUpdateOne) {
  24902. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24903. }
  24904. if m.id == nil || m.oldValue == nil {
  24905. return v, errors.New("OldName requires an ID field in the mutation")
  24906. }
  24907. oldValue, err := m.oldValue(ctx)
  24908. if err != nil {
  24909. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24910. }
  24911. return oldValue.Name, nil
  24912. }
  24913. // ResetName resets all changes to the "name" field.
  24914. func (m *WxCardMutation) ResetName() {
  24915. m.name = nil
  24916. }
  24917. // SetCompany sets the "company" field.
  24918. func (m *WxCardMutation) SetCompany(s string) {
  24919. m.company = &s
  24920. }
  24921. // Company returns the value of the "company" field in the mutation.
  24922. func (m *WxCardMutation) Company() (r string, exists bool) {
  24923. v := m.company
  24924. if v == nil {
  24925. return
  24926. }
  24927. return *v, true
  24928. }
  24929. // OldCompany returns the old "company" field's value of the WxCard entity.
  24930. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24932. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  24933. if !m.op.Is(OpUpdateOne) {
  24934. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  24935. }
  24936. if m.id == nil || m.oldValue == nil {
  24937. return v, errors.New("OldCompany requires an ID field in the mutation")
  24938. }
  24939. oldValue, err := m.oldValue(ctx)
  24940. if err != nil {
  24941. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  24942. }
  24943. return oldValue.Company, nil
  24944. }
  24945. // ResetCompany resets all changes to the "company" field.
  24946. func (m *WxCardMutation) ResetCompany() {
  24947. m.company = nil
  24948. }
  24949. // SetAddress sets the "address" field.
  24950. func (m *WxCardMutation) SetAddress(s string) {
  24951. m.address = &s
  24952. }
  24953. // Address returns the value of the "address" field in the mutation.
  24954. func (m *WxCardMutation) Address() (r string, exists bool) {
  24955. v := m.address
  24956. if v == nil {
  24957. return
  24958. }
  24959. return *v, true
  24960. }
  24961. // OldAddress returns the old "address" field's value of the WxCard entity.
  24962. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24964. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  24965. if !m.op.Is(OpUpdateOne) {
  24966. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  24967. }
  24968. if m.id == nil || m.oldValue == nil {
  24969. return v, errors.New("OldAddress requires an ID field in the mutation")
  24970. }
  24971. oldValue, err := m.oldValue(ctx)
  24972. if err != nil {
  24973. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  24974. }
  24975. return oldValue.Address, nil
  24976. }
  24977. // ResetAddress resets all changes to the "address" field.
  24978. func (m *WxCardMutation) ResetAddress() {
  24979. m.address = nil
  24980. }
  24981. // SetPhone sets the "phone" field.
  24982. func (m *WxCardMutation) SetPhone(s string) {
  24983. m.phone = &s
  24984. }
  24985. // Phone returns the value of the "phone" field in the mutation.
  24986. func (m *WxCardMutation) Phone() (r string, exists bool) {
  24987. v := m.phone
  24988. if v == nil {
  24989. return
  24990. }
  24991. return *v, true
  24992. }
  24993. // OldPhone returns the old "phone" field's value of the WxCard entity.
  24994. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24996. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  24997. if !m.op.Is(OpUpdateOne) {
  24998. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24999. }
  25000. if m.id == nil || m.oldValue == nil {
  25001. return v, errors.New("OldPhone requires an ID field in the mutation")
  25002. }
  25003. oldValue, err := m.oldValue(ctx)
  25004. if err != nil {
  25005. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25006. }
  25007. return oldValue.Phone, nil
  25008. }
  25009. // ResetPhone resets all changes to the "phone" field.
  25010. func (m *WxCardMutation) ResetPhone() {
  25011. m.phone = nil
  25012. }
  25013. // SetOfficialAccount sets the "official_account" field.
  25014. func (m *WxCardMutation) SetOfficialAccount(s string) {
  25015. m.official_account = &s
  25016. }
  25017. // OfficialAccount returns the value of the "official_account" field in the mutation.
  25018. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  25019. v := m.official_account
  25020. if v == nil {
  25021. return
  25022. }
  25023. return *v, true
  25024. }
  25025. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  25026. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25028. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  25029. if !m.op.Is(OpUpdateOne) {
  25030. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  25031. }
  25032. if m.id == nil || m.oldValue == nil {
  25033. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  25034. }
  25035. oldValue, err := m.oldValue(ctx)
  25036. if err != nil {
  25037. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  25038. }
  25039. return oldValue.OfficialAccount, nil
  25040. }
  25041. // ResetOfficialAccount resets all changes to the "official_account" field.
  25042. func (m *WxCardMutation) ResetOfficialAccount() {
  25043. m.official_account = nil
  25044. }
  25045. // SetWechatAccount sets the "wechat_account" field.
  25046. func (m *WxCardMutation) SetWechatAccount(s string) {
  25047. m.wechat_account = &s
  25048. }
  25049. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  25050. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  25051. v := m.wechat_account
  25052. if v == nil {
  25053. return
  25054. }
  25055. return *v, true
  25056. }
  25057. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  25058. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25060. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  25061. if !m.op.Is(OpUpdateOne) {
  25062. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  25063. }
  25064. if m.id == nil || m.oldValue == nil {
  25065. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  25066. }
  25067. oldValue, err := m.oldValue(ctx)
  25068. if err != nil {
  25069. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  25070. }
  25071. return oldValue.WechatAccount, nil
  25072. }
  25073. // ResetWechatAccount resets all changes to the "wechat_account" field.
  25074. func (m *WxCardMutation) ResetWechatAccount() {
  25075. m.wechat_account = nil
  25076. }
  25077. // SetEmail sets the "email" field.
  25078. func (m *WxCardMutation) SetEmail(s string) {
  25079. m.email = &s
  25080. }
  25081. // Email returns the value of the "email" field in the mutation.
  25082. func (m *WxCardMutation) Email() (r string, exists bool) {
  25083. v := m.email
  25084. if v == nil {
  25085. return
  25086. }
  25087. return *v, true
  25088. }
  25089. // OldEmail returns the old "email" field's value of the WxCard entity.
  25090. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25092. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  25093. if !m.op.Is(OpUpdateOne) {
  25094. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  25095. }
  25096. if m.id == nil || m.oldValue == nil {
  25097. return v, errors.New("OldEmail requires an ID field in the mutation")
  25098. }
  25099. oldValue, err := m.oldValue(ctx)
  25100. if err != nil {
  25101. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  25102. }
  25103. return oldValue.Email, nil
  25104. }
  25105. // ClearEmail clears the value of the "email" field.
  25106. func (m *WxCardMutation) ClearEmail() {
  25107. m.email = nil
  25108. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  25109. }
  25110. // EmailCleared returns if the "email" field was cleared in this mutation.
  25111. func (m *WxCardMutation) EmailCleared() bool {
  25112. _, ok := m.clearedFields[wxcard.FieldEmail]
  25113. return ok
  25114. }
  25115. // ResetEmail resets all changes to the "email" field.
  25116. func (m *WxCardMutation) ResetEmail() {
  25117. m.email = nil
  25118. delete(m.clearedFields, wxcard.FieldEmail)
  25119. }
  25120. // SetAPIBase sets the "api_base" field.
  25121. func (m *WxCardMutation) SetAPIBase(s string) {
  25122. m.api_base = &s
  25123. }
  25124. // APIBase returns the value of the "api_base" field in the mutation.
  25125. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  25126. v := m.api_base
  25127. if v == nil {
  25128. return
  25129. }
  25130. return *v, true
  25131. }
  25132. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  25133. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25135. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  25136. if !m.op.Is(OpUpdateOne) {
  25137. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  25138. }
  25139. if m.id == nil || m.oldValue == nil {
  25140. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  25141. }
  25142. oldValue, err := m.oldValue(ctx)
  25143. if err != nil {
  25144. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  25145. }
  25146. return oldValue.APIBase, nil
  25147. }
  25148. // ClearAPIBase clears the value of the "api_base" field.
  25149. func (m *WxCardMutation) ClearAPIBase() {
  25150. m.api_base = nil
  25151. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  25152. }
  25153. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  25154. func (m *WxCardMutation) APIBaseCleared() bool {
  25155. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  25156. return ok
  25157. }
  25158. // ResetAPIBase resets all changes to the "api_base" field.
  25159. func (m *WxCardMutation) ResetAPIBase() {
  25160. m.api_base = nil
  25161. delete(m.clearedFields, wxcard.FieldAPIBase)
  25162. }
  25163. // SetAPIKey sets the "api_key" field.
  25164. func (m *WxCardMutation) SetAPIKey(s string) {
  25165. m.api_key = &s
  25166. }
  25167. // APIKey returns the value of the "api_key" field in the mutation.
  25168. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  25169. v := m.api_key
  25170. if v == nil {
  25171. return
  25172. }
  25173. return *v, true
  25174. }
  25175. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  25176. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25178. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  25179. if !m.op.Is(OpUpdateOne) {
  25180. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  25181. }
  25182. if m.id == nil || m.oldValue == nil {
  25183. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  25184. }
  25185. oldValue, err := m.oldValue(ctx)
  25186. if err != nil {
  25187. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  25188. }
  25189. return oldValue.APIKey, nil
  25190. }
  25191. // ClearAPIKey clears the value of the "api_key" field.
  25192. func (m *WxCardMutation) ClearAPIKey() {
  25193. m.api_key = nil
  25194. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  25195. }
  25196. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  25197. func (m *WxCardMutation) APIKeyCleared() bool {
  25198. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  25199. return ok
  25200. }
  25201. // ResetAPIKey resets all changes to the "api_key" field.
  25202. func (m *WxCardMutation) ResetAPIKey() {
  25203. m.api_key = nil
  25204. delete(m.clearedFields, wxcard.FieldAPIKey)
  25205. }
  25206. // SetAiInfo sets the "ai_info" field.
  25207. func (m *WxCardMutation) SetAiInfo(s string) {
  25208. m.ai_info = &s
  25209. }
  25210. // AiInfo returns the value of the "ai_info" field in the mutation.
  25211. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  25212. v := m.ai_info
  25213. if v == nil {
  25214. return
  25215. }
  25216. return *v, true
  25217. }
  25218. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  25219. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25221. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  25222. if !m.op.Is(OpUpdateOne) {
  25223. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  25224. }
  25225. if m.id == nil || m.oldValue == nil {
  25226. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  25227. }
  25228. oldValue, err := m.oldValue(ctx)
  25229. if err != nil {
  25230. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  25231. }
  25232. return oldValue.AiInfo, nil
  25233. }
  25234. // ClearAiInfo clears the value of the "ai_info" field.
  25235. func (m *WxCardMutation) ClearAiInfo() {
  25236. m.ai_info = nil
  25237. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  25238. }
  25239. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  25240. func (m *WxCardMutation) AiInfoCleared() bool {
  25241. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  25242. return ok
  25243. }
  25244. // ResetAiInfo resets all changes to the "ai_info" field.
  25245. func (m *WxCardMutation) ResetAiInfo() {
  25246. m.ai_info = nil
  25247. delete(m.clearedFields, wxcard.FieldAiInfo)
  25248. }
  25249. // SetIntro sets the "intro" field.
  25250. func (m *WxCardMutation) SetIntro(s string) {
  25251. m.intro = &s
  25252. }
  25253. // Intro returns the value of the "intro" field in the mutation.
  25254. func (m *WxCardMutation) Intro() (r string, exists bool) {
  25255. v := m.intro
  25256. if v == nil {
  25257. return
  25258. }
  25259. return *v, true
  25260. }
  25261. // OldIntro returns the old "intro" field's value of the WxCard entity.
  25262. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  25263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25264. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  25265. if !m.op.Is(OpUpdateOne) {
  25266. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  25267. }
  25268. if m.id == nil || m.oldValue == nil {
  25269. return v, errors.New("OldIntro requires an ID field in the mutation")
  25270. }
  25271. oldValue, err := m.oldValue(ctx)
  25272. if err != nil {
  25273. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  25274. }
  25275. return oldValue.Intro, nil
  25276. }
  25277. // ClearIntro clears the value of the "intro" field.
  25278. func (m *WxCardMutation) ClearIntro() {
  25279. m.intro = nil
  25280. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  25281. }
  25282. // IntroCleared returns if the "intro" field was cleared in this mutation.
  25283. func (m *WxCardMutation) IntroCleared() bool {
  25284. _, ok := m.clearedFields[wxcard.FieldIntro]
  25285. return ok
  25286. }
  25287. // ResetIntro resets all changes to the "intro" field.
  25288. func (m *WxCardMutation) ResetIntro() {
  25289. m.intro = nil
  25290. delete(m.clearedFields, wxcard.FieldIntro)
  25291. }
  25292. // Where appends a list predicates to the WxCardMutation builder.
  25293. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  25294. m.predicates = append(m.predicates, ps...)
  25295. }
  25296. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  25297. // users can use type-assertion to append predicates that do not depend on any generated package.
  25298. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  25299. p := make([]predicate.WxCard, len(ps))
  25300. for i := range ps {
  25301. p[i] = ps[i]
  25302. }
  25303. m.Where(p...)
  25304. }
  25305. // Op returns the operation name.
  25306. func (m *WxCardMutation) Op() Op {
  25307. return m.op
  25308. }
  25309. // SetOp allows setting the mutation operation.
  25310. func (m *WxCardMutation) SetOp(op Op) {
  25311. m.op = op
  25312. }
  25313. // Type returns the node type of this mutation (WxCard).
  25314. func (m *WxCardMutation) Type() string {
  25315. return m.typ
  25316. }
  25317. // Fields returns all fields that were changed during this mutation. Note that in
  25318. // order to get all numeric fields that were incremented/decremented, call
  25319. // AddedFields().
  25320. func (m *WxCardMutation) Fields() []string {
  25321. fields := make([]string, 0, 18)
  25322. if m.created_at != nil {
  25323. fields = append(fields, wxcard.FieldCreatedAt)
  25324. }
  25325. if m.updated_at != nil {
  25326. fields = append(fields, wxcard.FieldUpdatedAt)
  25327. }
  25328. if m.deleted_at != nil {
  25329. fields = append(fields, wxcard.FieldDeletedAt)
  25330. }
  25331. if m.user_id != nil {
  25332. fields = append(fields, wxcard.FieldUserID)
  25333. }
  25334. if m.wx_user_id != nil {
  25335. fields = append(fields, wxcard.FieldWxUserID)
  25336. }
  25337. if m.avatar != nil {
  25338. fields = append(fields, wxcard.FieldAvatar)
  25339. }
  25340. if m.logo != nil {
  25341. fields = append(fields, wxcard.FieldLogo)
  25342. }
  25343. if m.name != nil {
  25344. fields = append(fields, wxcard.FieldName)
  25345. }
  25346. if m.company != nil {
  25347. fields = append(fields, wxcard.FieldCompany)
  25348. }
  25349. if m.address != nil {
  25350. fields = append(fields, wxcard.FieldAddress)
  25351. }
  25352. if m.phone != nil {
  25353. fields = append(fields, wxcard.FieldPhone)
  25354. }
  25355. if m.official_account != nil {
  25356. fields = append(fields, wxcard.FieldOfficialAccount)
  25357. }
  25358. if m.wechat_account != nil {
  25359. fields = append(fields, wxcard.FieldWechatAccount)
  25360. }
  25361. if m.email != nil {
  25362. fields = append(fields, wxcard.FieldEmail)
  25363. }
  25364. if m.api_base != nil {
  25365. fields = append(fields, wxcard.FieldAPIBase)
  25366. }
  25367. if m.api_key != nil {
  25368. fields = append(fields, wxcard.FieldAPIKey)
  25369. }
  25370. if m.ai_info != nil {
  25371. fields = append(fields, wxcard.FieldAiInfo)
  25372. }
  25373. if m.intro != nil {
  25374. fields = append(fields, wxcard.FieldIntro)
  25375. }
  25376. return fields
  25377. }
  25378. // Field returns the value of a field with the given name. The second boolean
  25379. // return value indicates that this field was not set, or was not defined in the
  25380. // schema.
  25381. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  25382. switch name {
  25383. case wxcard.FieldCreatedAt:
  25384. return m.CreatedAt()
  25385. case wxcard.FieldUpdatedAt:
  25386. return m.UpdatedAt()
  25387. case wxcard.FieldDeletedAt:
  25388. return m.DeletedAt()
  25389. case wxcard.FieldUserID:
  25390. return m.UserID()
  25391. case wxcard.FieldWxUserID:
  25392. return m.WxUserID()
  25393. case wxcard.FieldAvatar:
  25394. return m.Avatar()
  25395. case wxcard.FieldLogo:
  25396. return m.Logo()
  25397. case wxcard.FieldName:
  25398. return m.Name()
  25399. case wxcard.FieldCompany:
  25400. return m.Company()
  25401. case wxcard.FieldAddress:
  25402. return m.Address()
  25403. case wxcard.FieldPhone:
  25404. return m.Phone()
  25405. case wxcard.FieldOfficialAccount:
  25406. return m.OfficialAccount()
  25407. case wxcard.FieldWechatAccount:
  25408. return m.WechatAccount()
  25409. case wxcard.FieldEmail:
  25410. return m.Email()
  25411. case wxcard.FieldAPIBase:
  25412. return m.APIBase()
  25413. case wxcard.FieldAPIKey:
  25414. return m.APIKey()
  25415. case wxcard.FieldAiInfo:
  25416. return m.AiInfo()
  25417. case wxcard.FieldIntro:
  25418. return m.Intro()
  25419. }
  25420. return nil, false
  25421. }
  25422. // OldField returns the old value of the field from the database. An error is
  25423. // returned if the mutation operation is not UpdateOne, or the query to the
  25424. // database failed.
  25425. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25426. switch name {
  25427. case wxcard.FieldCreatedAt:
  25428. return m.OldCreatedAt(ctx)
  25429. case wxcard.FieldUpdatedAt:
  25430. return m.OldUpdatedAt(ctx)
  25431. case wxcard.FieldDeletedAt:
  25432. return m.OldDeletedAt(ctx)
  25433. case wxcard.FieldUserID:
  25434. return m.OldUserID(ctx)
  25435. case wxcard.FieldWxUserID:
  25436. return m.OldWxUserID(ctx)
  25437. case wxcard.FieldAvatar:
  25438. return m.OldAvatar(ctx)
  25439. case wxcard.FieldLogo:
  25440. return m.OldLogo(ctx)
  25441. case wxcard.FieldName:
  25442. return m.OldName(ctx)
  25443. case wxcard.FieldCompany:
  25444. return m.OldCompany(ctx)
  25445. case wxcard.FieldAddress:
  25446. return m.OldAddress(ctx)
  25447. case wxcard.FieldPhone:
  25448. return m.OldPhone(ctx)
  25449. case wxcard.FieldOfficialAccount:
  25450. return m.OldOfficialAccount(ctx)
  25451. case wxcard.FieldWechatAccount:
  25452. return m.OldWechatAccount(ctx)
  25453. case wxcard.FieldEmail:
  25454. return m.OldEmail(ctx)
  25455. case wxcard.FieldAPIBase:
  25456. return m.OldAPIBase(ctx)
  25457. case wxcard.FieldAPIKey:
  25458. return m.OldAPIKey(ctx)
  25459. case wxcard.FieldAiInfo:
  25460. return m.OldAiInfo(ctx)
  25461. case wxcard.FieldIntro:
  25462. return m.OldIntro(ctx)
  25463. }
  25464. return nil, fmt.Errorf("unknown WxCard field %s", name)
  25465. }
  25466. // SetField sets the value of a field with the given name. It returns an error if
  25467. // the field is not defined in the schema, or if the type mismatched the field
  25468. // type.
  25469. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  25470. switch name {
  25471. case wxcard.FieldCreatedAt:
  25472. v, ok := value.(time.Time)
  25473. if !ok {
  25474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25475. }
  25476. m.SetCreatedAt(v)
  25477. return nil
  25478. case wxcard.FieldUpdatedAt:
  25479. v, ok := value.(time.Time)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetUpdatedAt(v)
  25484. return nil
  25485. case wxcard.FieldDeletedAt:
  25486. v, ok := value.(time.Time)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetDeletedAt(v)
  25491. return nil
  25492. case wxcard.FieldUserID:
  25493. v, ok := value.(uint64)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetUserID(v)
  25498. return nil
  25499. case wxcard.FieldWxUserID:
  25500. v, ok := value.(uint64)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetWxUserID(v)
  25505. return nil
  25506. case wxcard.FieldAvatar:
  25507. v, ok := value.(string)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetAvatar(v)
  25512. return nil
  25513. case wxcard.FieldLogo:
  25514. v, ok := value.(string)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetLogo(v)
  25519. return nil
  25520. case wxcard.FieldName:
  25521. v, ok := value.(string)
  25522. if !ok {
  25523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25524. }
  25525. m.SetName(v)
  25526. return nil
  25527. case wxcard.FieldCompany:
  25528. v, ok := value.(string)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.SetCompany(v)
  25533. return nil
  25534. case wxcard.FieldAddress:
  25535. v, ok := value.(string)
  25536. if !ok {
  25537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25538. }
  25539. m.SetAddress(v)
  25540. return nil
  25541. case wxcard.FieldPhone:
  25542. v, ok := value.(string)
  25543. if !ok {
  25544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25545. }
  25546. m.SetPhone(v)
  25547. return nil
  25548. case wxcard.FieldOfficialAccount:
  25549. v, ok := value.(string)
  25550. if !ok {
  25551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25552. }
  25553. m.SetOfficialAccount(v)
  25554. return nil
  25555. case wxcard.FieldWechatAccount:
  25556. v, ok := value.(string)
  25557. if !ok {
  25558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25559. }
  25560. m.SetWechatAccount(v)
  25561. return nil
  25562. case wxcard.FieldEmail:
  25563. v, ok := value.(string)
  25564. if !ok {
  25565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25566. }
  25567. m.SetEmail(v)
  25568. return nil
  25569. case wxcard.FieldAPIBase:
  25570. v, ok := value.(string)
  25571. if !ok {
  25572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25573. }
  25574. m.SetAPIBase(v)
  25575. return nil
  25576. case wxcard.FieldAPIKey:
  25577. v, ok := value.(string)
  25578. if !ok {
  25579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25580. }
  25581. m.SetAPIKey(v)
  25582. return nil
  25583. case wxcard.FieldAiInfo:
  25584. v, ok := value.(string)
  25585. if !ok {
  25586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25587. }
  25588. m.SetAiInfo(v)
  25589. return nil
  25590. case wxcard.FieldIntro:
  25591. v, ok := value.(string)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.SetIntro(v)
  25596. return nil
  25597. }
  25598. return fmt.Errorf("unknown WxCard field %s", name)
  25599. }
  25600. // AddedFields returns all numeric fields that were incremented/decremented during
  25601. // this mutation.
  25602. func (m *WxCardMutation) AddedFields() []string {
  25603. var fields []string
  25604. if m.adduser_id != nil {
  25605. fields = append(fields, wxcard.FieldUserID)
  25606. }
  25607. if m.addwx_user_id != nil {
  25608. fields = append(fields, wxcard.FieldWxUserID)
  25609. }
  25610. return fields
  25611. }
  25612. // AddedField returns the numeric value that was incremented/decremented on a field
  25613. // with the given name. The second boolean return value indicates that this field
  25614. // was not set, or was not defined in the schema.
  25615. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  25616. switch name {
  25617. case wxcard.FieldUserID:
  25618. return m.AddedUserID()
  25619. case wxcard.FieldWxUserID:
  25620. return m.AddedWxUserID()
  25621. }
  25622. return nil, false
  25623. }
  25624. // AddField adds the value to the field with the given name. It returns an error if
  25625. // the field is not defined in the schema, or if the type mismatched the field
  25626. // type.
  25627. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  25628. switch name {
  25629. case wxcard.FieldUserID:
  25630. v, ok := value.(int64)
  25631. if !ok {
  25632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25633. }
  25634. m.AddUserID(v)
  25635. return nil
  25636. case wxcard.FieldWxUserID:
  25637. v, ok := value.(int64)
  25638. if !ok {
  25639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25640. }
  25641. m.AddWxUserID(v)
  25642. return nil
  25643. }
  25644. return fmt.Errorf("unknown WxCard numeric field %s", name)
  25645. }
  25646. // ClearedFields returns all nullable fields that were cleared during this
  25647. // mutation.
  25648. func (m *WxCardMutation) ClearedFields() []string {
  25649. var fields []string
  25650. if m.FieldCleared(wxcard.FieldDeletedAt) {
  25651. fields = append(fields, wxcard.FieldDeletedAt)
  25652. }
  25653. if m.FieldCleared(wxcard.FieldUserID) {
  25654. fields = append(fields, wxcard.FieldUserID)
  25655. }
  25656. if m.FieldCleared(wxcard.FieldWxUserID) {
  25657. fields = append(fields, wxcard.FieldWxUserID)
  25658. }
  25659. if m.FieldCleared(wxcard.FieldEmail) {
  25660. fields = append(fields, wxcard.FieldEmail)
  25661. }
  25662. if m.FieldCleared(wxcard.FieldAPIBase) {
  25663. fields = append(fields, wxcard.FieldAPIBase)
  25664. }
  25665. if m.FieldCleared(wxcard.FieldAPIKey) {
  25666. fields = append(fields, wxcard.FieldAPIKey)
  25667. }
  25668. if m.FieldCleared(wxcard.FieldAiInfo) {
  25669. fields = append(fields, wxcard.FieldAiInfo)
  25670. }
  25671. if m.FieldCleared(wxcard.FieldIntro) {
  25672. fields = append(fields, wxcard.FieldIntro)
  25673. }
  25674. return fields
  25675. }
  25676. // FieldCleared returns a boolean indicating if a field with the given name was
  25677. // cleared in this mutation.
  25678. func (m *WxCardMutation) FieldCleared(name string) bool {
  25679. _, ok := m.clearedFields[name]
  25680. return ok
  25681. }
  25682. // ClearField clears the value of the field with the given name. It returns an
  25683. // error if the field is not defined in the schema.
  25684. func (m *WxCardMutation) ClearField(name string) error {
  25685. switch name {
  25686. case wxcard.FieldDeletedAt:
  25687. m.ClearDeletedAt()
  25688. return nil
  25689. case wxcard.FieldUserID:
  25690. m.ClearUserID()
  25691. return nil
  25692. case wxcard.FieldWxUserID:
  25693. m.ClearWxUserID()
  25694. return nil
  25695. case wxcard.FieldEmail:
  25696. m.ClearEmail()
  25697. return nil
  25698. case wxcard.FieldAPIBase:
  25699. m.ClearAPIBase()
  25700. return nil
  25701. case wxcard.FieldAPIKey:
  25702. m.ClearAPIKey()
  25703. return nil
  25704. case wxcard.FieldAiInfo:
  25705. m.ClearAiInfo()
  25706. return nil
  25707. case wxcard.FieldIntro:
  25708. m.ClearIntro()
  25709. return nil
  25710. }
  25711. return fmt.Errorf("unknown WxCard nullable field %s", name)
  25712. }
  25713. // ResetField resets all changes in the mutation for the field with the given name.
  25714. // It returns an error if the field is not defined in the schema.
  25715. func (m *WxCardMutation) ResetField(name string) error {
  25716. switch name {
  25717. case wxcard.FieldCreatedAt:
  25718. m.ResetCreatedAt()
  25719. return nil
  25720. case wxcard.FieldUpdatedAt:
  25721. m.ResetUpdatedAt()
  25722. return nil
  25723. case wxcard.FieldDeletedAt:
  25724. m.ResetDeletedAt()
  25725. return nil
  25726. case wxcard.FieldUserID:
  25727. m.ResetUserID()
  25728. return nil
  25729. case wxcard.FieldWxUserID:
  25730. m.ResetWxUserID()
  25731. return nil
  25732. case wxcard.FieldAvatar:
  25733. m.ResetAvatar()
  25734. return nil
  25735. case wxcard.FieldLogo:
  25736. m.ResetLogo()
  25737. return nil
  25738. case wxcard.FieldName:
  25739. m.ResetName()
  25740. return nil
  25741. case wxcard.FieldCompany:
  25742. m.ResetCompany()
  25743. return nil
  25744. case wxcard.FieldAddress:
  25745. m.ResetAddress()
  25746. return nil
  25747. case wxcard.FieldPhone:
  25748. m.ResetPhone()
  25749. return nil
  25750. case wxcard.FieldOfficialAccount:
  25751. m.ResetOfficialAccount()
  25752. return nil
  25753. case wxcard.FieldWechatAccount:
  25754. m.ResetWechatAccount()
  25755. return nil
  25756. case wxcard.FieldEmail:
  25757. m.ResetEmail()
  25758. return nil
  25759. case wxcard.FieldAPIBase:
  25760. m.ResetAPIBase()
  25761. return nil
  25762. case wxcard.FieldAPIKey:
  25763. m.ResetAPIKey()
  25764. return nil
  25765. case wxcard.FieldAiInfo:
  25766. m.ResetAiInfo()
  25767. return nil
  25768. case wxcard.FieldIntro:
  25769. m.ResetIntro()
  25770. return nil
  25771. }
  25772. return fmt.Errorf("unknown WxCard field %s", name)
  25773. }
  25774. // AddedEdges returns all edge names that were set/added in this mutation.
  25775. func (m *WxCardMutation) AddedEdges() []string {
  25776. edges := make([]string, 0, 0)
  25777. return edges
  25778. }
  25779. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25780. // name in this mutation.
  25781. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  25782. return nil
  25783. }
  25784. // RemovedEdges returns all edge names that were removed in this mutation.
  25785. func (m *WxCardMutation) RemovedEdges() []string {
  25786. edges := make([]string, 0, 0)
  25787. return edges
  25788. }
  25789. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25790. // the given name in this mutation.
  25791. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  25792. return nil
  25793. }
  25794. // ClearedEdges returns all edge names that were cleared in this mutation.
  25795. func (m *WxCardMutation) ClearedEdges() []string {
  25796. edges := make([]string, 0, 0)
  25797. return edges
  25798. }
  25799. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25800. // was cleared in this mutation.
  25801. func (m *WxCardMutation) EdgeCleared(name string) bool {
  25802. return false
  25803. }
  25804. // ClearEdge clears the value of the edge with the given name. It returns an error
  25805. // if that edge is not defined in the schema.
  25806. func (m *WxCardMutation) ClearEdge(name string) error {
  25807. return fmt.Errorf("unknown WxCard unique edge %s", name)
  25808. }
  25809. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25810. // It returns an error if the edge is not defined in the schema.
  25811. func (m *WxCardMutation) ResetEdge(name string) error {
  25812. return fmt.Errorf("unknown WxCard edge %s", name)
  25813. }
  25814. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  25815. type WxCardUserMutation struct {
  25816. config
  25817. op Op
  25818. typ string
  25819. id *uint64
  25820. created_at *time.Time
  25821. updated_at *time.Time
  25822. deleted_at *time.Time
  25823. wxid *string
  25824. account *string
  25825. avatar *string
  25826. nickname *string
  25827. remark *string
  25828. phone *string
  25829. open_id *string
  25830. union_id *string
  25831. session_key *string
  25832. is_vip *int
  25833. addis_vip *int
  25834. clearedFields map[string]struct{}
  25835. done bool
  25836. oldValue func(context.Context) (*WxCardUser, error)
  25837. predicates []predicate.WxCardUser
  25838. }
  25839. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  25840. // wxcarduserOption allows management of the mutation configuration using functional options.
  25841. type wxcarduserOption func(*WxCardUserMutation)
  25842. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  25843. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  25844. m := &WxCardUserMutation{
  25845. config: c,
  25846. op: op,
  25847. typ: TypeWxCardUser,
  25848. clearedFields: make(map[string]struct{}),
  25849. }
  25850. for _, opt := range opts {
  25851. opt(m)
  25852. }
  25853. return m
  25854. }
  25855. // withWxCardUserID sets the ID field of the mutation.
  25856. func withWxCardUserID(id uint64) wxcarduserOption {
  25857. return func(m *WxCardUserMutation) {
  25858. var (
  25859. err error
  25860. once sync.Once
  25861. value *WxCardUser
  25862. )
  25863. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  25864. once.Do(func() {
  25865. if m.done {
  25866. err = errors.New("querying old values post mutation is not allowed")
  25867. } else {
  25868. value, err = m.Client().WxCardUser.Get(ctx, id)
  25869. }
  25870. })
  25871. return value, err
  25872. }
  25873. m.id = &id
  25874. }
  25875. }
  25876. // withWxCardUser sets the old WxCardUser of the mutation.
  25877. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  25878. return func(m *WxCardUserMutation) {
  25879. m.oldValue = func(context.Context) (*WxCardUser, error) {
  25880. return node, nil
  25881. }
  25882. m.id = &node.ID
  25883. }
  25884. }
  25885. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25886. // executed in a transaction (ent.Tx), a transactional client is returned.
  25887. func (m WxCardUserMutation) Client() *Client {
  25888. client := &Client{config: m.config}
  25889. client.init()
  25890. return client
  25891. }
  25892. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25893. // it returns an error otherwise.
  25894. func (m WxCardUserMutation) Tx() (*Tx, error) {
  25895. if _, ok := m.driver.(*txDriver); !ok {
  25896. return nil, errors.New("ent: mutation is not running in a transaction")
  25897. }
  25898. tx := &Tx{config: m.config}
  25899. tx.init()
  25900. return tx, nil
  25901. }
  25902. // SetID sets the value of the id field. Note that this
  25903. // operation is only accepted on creation of WxCardUser entities.
  25904. func (m *WxCardUserMutation) SetID(id uint64) {
  25905. m.id = &id
  25906. }
  25907. // ID returns the ID value in the mutation. Note that the ID is only available
  25908. // if it was provided to the builder or after it was returned from the database.
  25909. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  25910. if m.id == nil {
  25911. return
  25912. }
  25913. return *m.id, true
  25914. }
  25915. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25916. // That means, if the mutation is applied within a transaction with an isolation level such
  25917. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25918. // or updated by the mutation.
  25919. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  25920. switch {
  25921. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25922. id, exists := m.ID()
  25923. if exists {
  25924. return []uint64{id}, nil
  25925. }
  25926. fallthrough
  25927. case m.op.Is(OpUpdate | OpDelete):
  25928. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  25929. default:
  25930. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25931. }
  25932. }
  25933. // SetCreatedAt sets the "created_at" field.
  25934. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  25935. m.created_at = &t
  25936. }
  25937. // CreatedAt returns the value of the "created_at" field in the mutation.
  25938. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  25939. v := m.created_at
  25940. if v == nil {
  25941. return
  25942. }
  25943. return *v, true
  25944. }
  25945. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  25946. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25948. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25949. if !m.op.Is(OpUpdateOne) {
  25950. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25951. }
  25952. if m.id == nil || m.oldValue == nil {
  25953. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25954. }
  25955. oldValue, err := m.oldValue(ctx)
  25956. if err != nil {
  25957. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25958. }
  25959. return oldValue.CreatedAt, nil
  25960. }
  25961. // ResetCreatedAt resets all changes to the "created_at" field.
  25962. func (m *WxCardUserMutation) ResetCreatedAt() {
  25963. m.created_at = nil
  25964. }
  25965. // SetUpdatedAt sets the "updated_at" field.
  25966. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  25967. m.updated_at = &t
  25968. }
  25969. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25970. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  25971. v := m.updated_at
  25972. if v == nil {
  25973. return
  25974. }
  25975. return *v, true
  25976. }
  25977. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  25978. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25980. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25981. if !m.op.Is(OpUpdateOne) {
  25982. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25983. }
  25984. if m.id == nil || m.oldValue == nil {
  25985. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25986. }
  25987. oldValue, err := m.oldValue(ctx)
  25988. if err != nil {
  25989. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25990. }
  25991. return oldValue.UpdatedAt, nil
  25992. }
  25993. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25994. func (m *WxCardUserMutation) ResetUpdatedAt() {
  25995. m.updated_at = nil
  25996. }
  25997. // SetDeletedAt sets the "deleted_at" field.
  25998. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  25999. m.deleted_at = &t
  26000. }
  26001. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26002. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  26003. v := m.deleted_at
  26004. if v == nil {
  26005. return
  26006. }
  26007. return *v, true
  26008. }
  26009. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  26010. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26012. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26013. if !m.op.Is(OpUpdateOne) {
  26014. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26015. }
  26016. if m.id == nil || m.oldValue == nil {
  26017. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26018. }
  26019. oldValue, err := m.oldValue(ctx)
  26020. if err != nil {
  26021. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26022. }
  26023. return oldValue.DeletedAt, nil
  26024. }
  26025. // ClearDeletedAt clears the value of the "deleted_at" field.
  26026. func (m *WxCardUserMutation) ClearDeletedAt() {
  26027. m.deleted_at = nil
  26028. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  26029. }
  26030. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26031. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  26032. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  26033. return ok
  26034. }
  26035. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26036. func (m *WxCardUserMutation) ResetDeletedAt() {
  26037. m.deleted_at = nil
  26038. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  26039. }
  26040. // SetWxid sets the "wxid" field.
  26041. func (m *WxCardUserMutation) SetWxid(s string) {
  26042. m.wxid = &s
  26043. }
  26044. // Wxid returns the value of the "wxid" field in the mutation.
  26045. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  26046. v := m.wxid
  26047. if v == nil {
  26048. return
  26049. }
  26050. return *v, true
  26051. }
  26052. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  26053. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26055. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  26056. if !m.op.Is(OpUpdateOne) {
  26057. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  26058. }
  26059. if m.id == nil || m.oldValue == nil {
  26060. return v, errors.New("OldWxid requires an ID field in the mutation")
  26061. }
  26062. oldValue, err := m.oldValue(ctx)
  26063. if err != nil {
  26064. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  26065. }
  26066. return oldValue.Wxid, nil
  26067. }
  26068. // ResetWxid resets all changes to the "wxid" field.
  26069. func (m *WxCardUserMutation) ResetWxid() {
  26070. m.wxid = nil
  26071. }
  26072. // SetAccount sets the "account" field.
  26073. func (m *WxCardUserMutation) SetAccount(s string) {
  26074. m.account = &s
  26075. }
  26076. // Account returns the value of the "account" field in the mutation.
  26077. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  26078. v := m.account
  26079. if v == nil {
  26080. return
  26081. }
  26082. return *v, true
  26083. }
  26084. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  26085. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26087. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  26088. if !m.op.Is(OpUpdateOne) {
  26089. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  26090. }
  26091. if m.id == nil || m.oldValue == nil {
  26092. return v, errors.New("OldAccount requires an ID field in the mutation")
  26093. }
  26094. oldValue, err := m.oldValue(ctx)
  26095. if err != nil {
  26096. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  26097. }
  26098. return oldValue.Account, nil
  26099. }
  26100. // ResetAccount resets all changes to the "account" field.
  26101. func (m *WxCardUserMutation) ResetAccount() {
  26102. m.account = nil
  26103. }
  26104. // SetAvatar sets the "avatar" field.
  26105. func (m *WxCardUserMutation) SetAvatar(s string) {
  26106. m.avatar = &s
  26107. }
  26108. // Avatar returns the value of the "avatar" field in the mutation.
  26109. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  26110. v := m.avatar
  26111. if v == nil {
  26112. return
  26113. }
  26114. return *v, true
  26115. }
  26116. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  26117. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26119. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26120. if !m.op.Is(OpUpdateOne) {
  26121. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26122. }
  26123. if m.id == nil || m.oldValue == nil {
  26124. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26125. }
  26126. oldValue, err := m.oldValue(ctx)
  26127. if err != nil {
  26128. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26129. }
  26130. return oldValue.Avatar, nil
  26131. }
  26132. // ResetAvatar resets all changes to the "avatar" field.
  26133. func (m *WxCardUserMutation) ResetAvatar() {
  26134. m.avatar = nil
  26135. }
  26136. // SetNickname sets the "nickname" field.
  26137. func (m *WxCardUserMutation) SetNickname(s string) {
  26138. m.nickname = &s
  26139. }
  26140. // Nickname returns the value of the "nickname" field in the mutation.
  26141. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  26142. v := m.nickname
  26143. if v == nil {
  26144. return
  26145. }
  26146. return *v, true
  26147. }
  26148. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  26149. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26151. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  26152. if !m.op.Is(OpUpdateOne) {
  26153. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26154. }
  26155. if m.id == nil || m.oldValue == nil {
  26156. return v, errors.New("OldNickname requires an ID field in the mutation")
  26157. }
  26158. oldValue, err := m.oldValue(ctx)
  26159. if err != nil {
  26160. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26161. }
  26162. return oldValue.Nickname, nil
  26163. }
  26164. // ResetNickname resets all changes to the "nickname" field.
  26165. func (m *WxCardUserMutation) ResetNickname() {
  26166. m.nickname = nil
  26167. }
  26168. // SetRemark sets the "remark" field.
  26169. func (m *WxCardUserMutation) SetRemark(s string) {
  26170. m.remark = &s
  26171. }
  26172. // Remark returns the value of the "remark" field in the mutation.
  26173. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  26174. v := m.remark
  26175. if v == nil {
  26176. return
  26177. }
  26178. return *v, true
  26179. }
  26180. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  26181. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26183. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  26184. if !m.op.Is(OpUpdateOne) {
  26185. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  26186. }
  26187. if m.id == nil || m.oldValue == nil {
  26188. return v, errors.New("OldRemark requires an ID field in the mutation")
  26189. }
  26190. oldValue, err := m.oldValue(ctx)
  26191. if err != nil {
  26192. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  26193. }
  26194. return oldValue.Remark, nil
  26195. }
  26196. // ResetRemark resets all changes to the "remark" field.
  26197. func (m *WxCardUserMutation) ResetRemark() {
  26198. m.remark = nil
  26199. }
  26200. // SetPhone sets the "phone" field.
  26201. func (m *WxCardUserMutation) SetPhone(s string) {
  26202. m.phone = &s
  26203. }
  26204. // Phone returns the value of the "phone" field in the mutation.
  26205. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  26206. v := m.phone
  26207. if v == nil {
  26208. return
  26209. }
  26210. return *v, true
  26211. }
  26212. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  26213. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26215. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  26216. if !m.op.Is(OpUpdateOne) {
  26217. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26218. }
  26219. if m.id == nil || m.oldValue == nil {
  26220. return v, errors.New("OldPhone requires an ID field in the mutation")
  26221. }
  26222. oldValue, err := m.oldValue(ctx)
  26223. if err != nil {
  26224. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26225. }
  26226. return oldValue.Phone, nil
  26227. }
  26228. // ResetPhone resets all changes to the "phone" field.
  26229. func (m *WxCardUserMutation) ResetPhone() {
  26230. m.phone = nil
  26231. }
  26232. // SetOpenID sets the "open_id" field.
  26233. func (m *WxCardUserMutation) SetOpenID(s string) {
  26234. m.open_id = &s
  26235. }
  26236. // OpenID returns the value of the "open_id" field in the mutation.
  26237. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  26238. v := m.open_id
  26239. if v == nil {
  26240. return
  26241. }
  26242. return *v, true
  26243. }
  26244. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  26245. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26247. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  26248. if !m.op.Is(OpUpdateOne) {
  26249. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  26250. }
  26251. if m.id == nil || m.oldValue == nil {
  26252. return v, errors.New("OldOpenID requires an ID field in the mutation")
  26253. }
  26254. oldValue, err := m.oldValue(ctx)
  26255. if err != nil {
  26256. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  26257. }
  26258. return oldValue.OpenID, nil
  26259. }
  26260. // ResetOpenID resets all changes to the "open_id" field.
  26261. func (m *WxCardUserMutation) ResetOpenID() {
  26262. m.open_id = nil
  26263. }
  26264. // SetUnionID sets the "union_id" field.
  26265. func (m *WxCardUserMutation) SetUnionID(s string) {
  26266. m.union_id = &s
  26267. }
  26268. // UnionID returns the value of the "union_id" field in the mutation.
  26269. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  26270. v := m.union_id
  26271. if v == nil {
  26272. return
  26273. }
  26274. return *v, true
  26275. }
  26276. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  26277. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26279. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  26280. if !m.op.Is(OpUpdateOne) {
  26281. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  26282. }
  26283. if m.id == nil || m.oldValue == nil {
  26284. return v, errors.New("OldUnionID requires an ID field in the mutation")
  26285. }
  26286. oldValue, err := m.oldValue(ctx)
  26287. if err != nil {
  26288. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  26289. }
  26290. return oldValue.UnionID, nil
  26291. }
  26292. // ResetUnionID resets all changes to the "union_id" field.
  26293. func (m *WxCardUserMutation) ResetUnionID() {
  26294. m.union_id = nil
  26295. }
  26296. // SetSessionKey sets the "session_key" field.
  26297. func (m *WxCardUserMutation) SetSessionKey(s string) {
  26298. m.session_key = &s
  26299. }
  26300. // SessionKey returns the value of the "session_key" field in the mutation.
  26301. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  26302. v := m.session_key
  26303. if v == nil {
  26304. return
  26305. }
  26306. return *v, true
  26307. }
  26308. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  26309. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26311. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  26312. if !m.op.Is(OpUpdateOne) {
  26313. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  26314. }
  26315. if m.id == nil || m.oldValue == nil {
  26316. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  26317. }
  26318. oldValue, err := m.oldValue(ctx)
  26319. if err != nil {
  26320. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  26321. }
  26322. return oldValue.SessionKey, nil
  26323. }
  26324. // ResetSessionKey resets all changes to the "session_key" field.
  26325. func (m *WxCardUserMutation) ResetSessionKey() {
  26326. m.session_key = nil
  26327. }
  26328. // SetIsVip sets the "is_vip" field.
  26329. func (m *WxCardUserMutation) SetIsVip(i int) {
  26330. m.is_vip = &i
  26331. m.addis_vip = nil
  26332. }
  26333. // IsVip returns the value of the "is_vip" field in the mutation.
  26334. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  26335. v := m.is_vip
  26336. if v == nil {
  26337. return
  26338. }
  26339. return *v, true
  26340. }
  26341. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  26342. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  26343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26344. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  26345. if !m.op.Is(OpUpdateOne) {
  26346. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  26347. }
  26348. if m.id == nil || m.oldValue == nil {
  26349. return v, errors.New("OldIsVip requires an ID field in the mutation")
  26350. }
  26351. oldValue, err := m.oldValue(ctx)
  26352. if err != nil {
  26353. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  26354. }
  26355. return oldValue.IsVip, nil
  26356. }
  26357. // AddIsVip adds i to the "is_vip" field.
  26358. func (m *WxCardUserMutation) AddIsVip(i int) {
  26359. if m.addis_vip != nil {
  26360. *m.addis_vip += i
  26361. } else {
  26362. m.addis_vip = &i
  26363. }
  26364. }
  26365. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  26366. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  26367. v := m.addis_vip
  26368. if v == nil {
  26369. return
  26370. }
  26371. return *v, true
  26372. }
  26373. // ResetIsVip resets all changes to the "is_vip" field.
  26374. func (m *WxCardUserMutation) ResetIsVip() {
  26375. m.is_vip = nil
  26376. m.addis_vip = nil
  26377. }
  26378. // Where appends a list predicates to the WxCardUserMutation builder.
  26379. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  26380. m.predicates = append(m.predicates, ps...)
  26381. }
  26382. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  26383. // users can use type-assertion to append predicates that do not depend on any generated package.
  26384. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  26385. p := make([]predicate.WxCardUser, len(ps))
  26386. for i := range ps {
  26387. p[i] = ps[i]
  26388. }
  26389. m.Where(p...)
  26390. }
  26391. // Op returns the operation name.
  26392. func (m *WxCardUserMutation) Op() Op {
  26393. return m.op
  26394. }
  26395. // SetOp allows setting the mutation operation.
  26396. func (m *WxCardUserMutation) SetOp(op Op) {
  26397. m.op = op
  26398. }
  26399. // Type returns the node type of this mutation (WxCardUser).
  26400. func (m *WxCardUserMutation) Type() string {
  26401. return m.typ
  26402. }
  26403. // Fields returns all fields that were changed during this mutation. Note that in
  26404. // order to get all numeric fields that were incremented/decremented, call
  26405. // AddedFields().
  26406. func (m *WxCardUserMutation) Fields() []string {
  26407. fields := make([]string, 0, 13)
  26408. if m.created_at != nil {
  26409. fields = append(fields, wxcarduser.FieldCreatedAt)
  26410. }
  26411. if m.updated_at != nil {
  26412. fields = append(fields, wxcarduser.FieldUpdatedAt)
  26413. }
  26414. if m.deleted_at != nil {
  26415. fields = append(fields, wxcarduser.FieldDeletedAt)
  26416. }
  26417. if m.wxid != nil {
  26418. fields = append(fields, wxcarduser.FieldWxid)
  26419. }
  26420. if m.account != nil {
  26421. fields = append(fields, wxcarduser.FieldAccount)
  26422. }
  26423. if m.avatar != nil {
  26424. fields = append(fields, wxcarduser.FieldAvatar)
  26425. }
  26426. if m.nickname != nil {
  26427. fields = append(fields, wxcarduser.FieldNickname)
  26428. }
  26429. if m.remark != nil {
  26430. fields = append(fields, wxcarduser.FieldRemark)
  26431. }
  26432. if m.phone != nil {
  26433. fields = append(fields, wxcarduser.FieldPhone)
  26434. }
  26435. if m.open_id != nil {
  26436. fields = append(fields, wxcarduser.FieldOpenID)
  26437. }
  26438. if m.union_id != nil {
  26439. fields = append(fields, wxcarduser.FieldUnionID)
  26440. }
  26441. if m.session_key != nil {
  26442. fields = append(fields, wxcarduser.FieldSessionKey)
  26443. }
  26444. if m.is_vip != nil {
  26445. fields = append(fields, wxcarduser.FieldIsVip)
  26446. }
  26447. return fields
  26448. }
  26449. // Field returns the value of a field with the given name. The second boolean
  26450. // return value indicates that this field was not set, or was not defined in the
  26451. // schema.
  26452. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  26453. switch name {
  26454. case wxcarduser.FieldCreatedAt:
  26455. return m.CreatedAt()
  26456. case wxcarduser.FieldUpdatedAt:
  26457. return m.UpdatedAt()
  26458. case wxcarduser.FieldDeletedAt:
  26459. return m.DeletedAt()
  26460. case wxcarduser.FieldWxid:
  26461. return m.Wxid()
  26462. case wxcarduser.FieldAccount:
  26463. return m.Account()
  26464. case wxcarduser.FieldAvatar:
  26465. return m.Avatar()
  26466. case wxcarduser.FieldNickname:
  26467. return m.Nickname()
  26468. case wxcarduser.FieldRemark:
  26469. return m.Remark()
  26470. case wxcarduser.FieldPhone:
  26471. return m.Phone()
  26472. case wxcarduser.FieldOpenID:
  26473. return m.OpenID()
  26474. case wxcarduser.FieldUnionID:
  26475. return m.UnionID()
  26476. case wxcarduser.FieldSessionKey:
  26477. return m.SessionKey()
  26478. case wxcarduser.FieldIsVip:
  26479. return m.IsVip()
  26480. }
  26481. return nil, false
  26482. }
  26483. // OldField returns the old value of the field from the database. An error is
  26484. // returned if the mutation operation is not UpdateOne, or the query to the
  26485. // database failed.
  26486. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26487. switch name {
  26488. case wxcarduser.FieldCreatedAt:
  26489. return m.OldCreatedAt(ctx)
  26490. case wxcarduser.FieldUpdatedAt:
  26491. return m.OldUpdatedAt(ctx)
  26492. case wxcarduser.FieldDeletedAt:
  26493. return m.OldDeletedAt(ctx)
  26494. case wxcarduser.FieldWxid:
  26495. return m.OldWxid(ctx)
  26496. case wxcarduser.FieldAccount:
  26497. return m.OldAccount(ctx)
  26498. case wxcarduser.FieldAvatar:
  26499. return m.OldAvatar(ctx)
  26500. case wxcarduser.FieldNickname:
  26501. return m.OldNickname(ctx)
  26502. case wxcarduser.FieldRemark:
  26503. return m.OldRemark(ctx)
  26504. case wxcarduser.FieldPhone:
  26505. return m.OldPhone(ctx)
  26506. case wxcarduser.FieldOpenID:
  26507. return m.OldOpenID(ctx)
  26508. case wxcarduser.FieldUnionID:
  26509. return m.OldUnionID(ctx)
  26510. case wxcarduser.FieldSessionKey:
  26511. return m.OldSessionKey(ctx)
  26512. case wxcarduser.FieldIsVip:
  26513. return m.OldIsVip(ctx)
  26514. }
  26515. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  26516. }
  26517. // SetField sets the value of a field with the given name. It returns an error if
  26518. // the field is not defined in the schema, or if the type mismatched the field
  26519. // type.
  26520. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  26521. switch name {
  26522. case wxcarduser.FieldCreatedAt:
  26523. v, ok := value.(time.Time)
  26524. if !ok {
  26525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26526. }
  26527. m.SetCreatedAt(v)
  26528. return nil
  26529. case wxcarduser.FieldUpdatedAt:
  26530. v, ok := value.(time.Time)
  26531. if !ok {
  26532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26533. }
  26534. m.SetUpdatedAt(v)
  26535. return nil
  26536. case wxcarduser.FieldDeletedAt:
  26537. v, ok := value.(time.Time)
  26538. if !ok {
  26539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26540. }
  26541. m.SetDeletedAt(v)
  26542. return nil
  26543. case wxcarduser.FieldWxid:
  26544. v, ok := value.(string)
  26545. if !ok {
  26546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26547. }
  26548. m.SetWxid(v)
  26549. return nil
  26550. case wxcarduser.FieldAccount:
  26551. v, ok := value.(string)
  26552. if !ok {
  26553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26554. }
  26555. m.SetAccount(v)
  26556. return nil
  26557. case wxcarduser.FieldAvatar:
  26558. v, ok := value.(string)
  26559. if !ok {
  26560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26561. }
  26562. m.SetAvatar(v)
  26563. return nil
  26564. case wxcarduser.FieldNickname:
  26565. v, ok := value.(string)
  26566. if !ok {
  26567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26568. }
  26569. m.SetNickname(v)
  26570. return nil
  26571. case wxcarduser.FieldRemark:
  26572. v, ok := value.(string)
  26573. if !ok {
  26574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26575. }
  26576. m.SetRemark(v)
  26577. return nil
  26578. case wxcarduser.FieldPhone:
  26579. v, ok := value.(string)
  26580. if !ok {
  26581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26582. }
  26583. m.SetPhone(v)
  26584. return nil
  26585. case wxcarduser.FieldOpenID:
  26586. v, ok := value.(string)
  26587. if !ok {
  26588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26589. }
  26590. m.SetOpenID(v)
  26591. return nil
  26592. case wxcarduser.FieldUnionID:
  26593. v, ok := value.(string)
  26594. if !ok {
  26595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26596. }
  26597. m.SetUnionID(v)
  26598. return nil
  26599. case wxcarduser.FieldSessionKey:
  26600. v, ok := value.(string)
  26601. if !ok {
  26602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26603. }
  26604. m.SetSessionKey(v)
  26605. return nil
  26606. case wxcarduser.FieldIsVip:
  26607. v, ok := value.(int)
  26608. if !ok {
  26609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26610. }
  26611. m.SetIsVip(v)
  26612. return nil
  26613. }
  26614. return fmt.Errorf("unknown WxCardUser field %s", name)
  26615. }
  26616. // AddedFields returns all numeric fields that were incremented/decremented during
  26617. // this mutation.
  26618. func (m *WxCardUserMutation) AddedFields() []string {
  26619. var fields []string
  26620. if m.addis_vip != nil {
  26621. fields = append(fields, wxcarduser.FieldIsVip)
  26622. }
  26623. return fields
  26624. }
  26625. // AddedField returns the numeric value that was incremented/decremented on a field
  26626. // with the given name. The second boolean return value indicates that this field
  26627. // was not set, or was not defined in the schema.
  26628. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  26629. switch name {
  26630. case wxcarduser.FieldIsVip:
  26631. return m.AddedIsVip()
  26632. }
  26633. return nil, false
  26634. }
  26635. // AddField adds the value to the field with the given name. It returns an error if
  26636. // the field is not defined in the schema, or if the type mismatched the field
  26637. // type.
  26638. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  26639. switch name {
  26640. case wxcarduser.FieldIsVip:
  26641. v, ok := value.(int)
  26642. if !ok {
  26643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26644. }
  26645. m.AddIsVip(v)
  26646. return nil
  26647. }
  26648. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  26649. }
  26650. // ClearedFields returns all nullable fields that were cleared during this
  26651. // mutation.
  26652. func (m *WxCardUserMutation) ClearedFields() []string {
  26653. var fields []string
  26654. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  26655. fields = append(fields, wxcarduser.FieldDeletedAt)
  26656. }
  26657. return fields
  26658. }
  26659. // FieldCleared returns a boolean indicating if a field with the given name was
  26660. // cleared in this mutation.
  26661. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  26662. _, ok := m.clearedFields[name]
  26663. return ok
  26664. }
  26665. // ClearField clears the value of the field with the given name. It returns an
  26666. // error if the field is not defined in the schema.
  26667. func (m *WxCardUserMutation) ClearField(name string) error {
  26668. switch name {
  26669. case wxcarduser.FieldDeletedAt:
  26670. m.ClearDeletedAt()
  26671. return nil
  26672. }
  26673. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  26674. }
  26675. // ResetField resets all changes in the mutation for the field with the given name.
  26676. // It returns an error if the field is not defined in the schema.
  26677. func (m *WxCardUserMutation) ResetField(name string) error {
  26678. switch name {
  26679. case wxcarduser.FieldCreatedAt:
  26680. m.ResetCreatedAt()
  26681. return nil
  26682. case wxcarduser.FieldUpdatedAt:
  26683. m.ResetUpdatedAt()
  26684. return nil
  26685. case wxcarduser.FieldDeletedAt:
  26686. m.ResetDeletedAt()
  26687. return nil
  26688. case wxcarduser.FieldWxid:
  26689. m.ResetWxid()
  26690. return nil
  26691. case wxcarduser.FieldAccount:
  26692. m.ResetAccount()
  26693. return nil
  26694. case wxcarduser.FieldAvatar:
  26695. m.ResetAvatar()
  26696. return nil
  26697. case wxcarduser.FieldNickname:
  26698. m.ResetNickname()
  26699. return nil
  26700. case wxcarduser.FieldRemark:
  26701. m.ResetRemark()
  26702. return nil
  26703. case wxcarduser.FieldPhone:
  26704. m.ResetPhone()
  26705. return nil
  26706. case wxcarduser.FieldOpenID:
  26707. m.ResetOpenID()
  26708. return nil
  26709. case wxcarduser.FieldUnionID:
  26710. m.ResetUnionID()
  26711. return nil
  26712. case wxcarduser.FieldSessionKey:
  26713. m.ResetSessionKey()
  26714. return nil
  26715. case wxcarduser.FieldIsVip:
  26716. m.ResetIsVip()
  26717. return nil
  26718. }
  26719. return fmt.Errorf("unknown WxCardUser field %s", name)
  26720. }
  26721. // AddedEdges returns all edge names that were set/added in this mutation.
  26722. func (m *WxCardUserMutation) AddedEdges() []string {
  26723. edges := make([]string, 0, 0)
  26724. return edges
  26725. }
  26726. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26727. // name in this mutation.
  26728. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  26729. return nil
  26730. }
  26731. // RemovedEdges returns all edge names that were removed in this mutation.
  26732. func (m *WxCardUserMutation) RemovedEdges() []string {
  26733. edges := make([]string, 0, 0)
  26734. return edges
  26735. }
  26736. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26737. // the given name in this mutation.
  26738. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  26739. return nil
  26740. }
  26741. // ClearedEdges returns all edge names that were cleared in this mutation.
  26742. func (m *WxCardUserMutation) ClearedEdges() []string {
  26743. edges := make([]string, 0, 0)
  26744. return edges
  26745. }
  26746. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26747. // was cleared in this mutation.
  26748. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  26749. return false
  26750. }
  26751. // ClearEdge clears the value of the edge with the given name. It returns an error
  26752. // if that edge is not defined in the schema.
  26753. func (m *WxCardUserMutation) ClearEdge(name string) error {
  26754. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  26755. }
  26756. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26757. // It returns an error if the edge is not defined in the schema.
  26758. func (m *WxCardUserMutation) ResetEdge(name string) error {
  26759. return fmt.Errorf("unknown WxCardUser edge %s", name)
  26760. }
  26761. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  26762. type WxCardVisitMutation struct {
  26763. config
  26764. op Op
  26765. typ string
  26766. id *uint64
  26767. created_at *time.Time
  26768. updated_at *time.Time
  26769. deleted_at *time.Time
  26770. user_id *uint64
  26771. adduser_id *int64
  26772. bot_id *uint64
  26773. addbot_id *int64
  26774. bot_type *uint8
  26775. addbot_type *int8
  26776. clearedFields map[string]struct{}
  26777. done bool
  26778. oldValue func(context.Context) (*WxCardVisit, error)
  26779. predicates []predicate.WxCardVisit
  26780. }
  26781. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  26782. // wxcardvisitOption allows management of the mutation configuration using functional options.
  26783. type wxcardvisitOption func(*WxCardVisitMutation)
  26784. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  26785. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  26786. m := &WxCardVisitMutation{
  26787. config: c,
  26788. op: op,
  26789. typ: TypeWxCardVisit,
  26790. clearedFields: make(map[string]struct{}),
  26791. }
  26792. for _, opt := range opts {
  26793. opt(m)
  26794. }
  26795. return m
  26796. }
  26797. // withWxCardVisitID sets the ID field of the mutation.
  26798. func withWxCardVisitID(id uint64) wxcardvisitOption {
  26799. return func(m *WxCardVisitMutation) {
  26800. var (
  26801. err error
  26802. once sync.Once
  26803. value *WxCardVisit
  26804. )
  26805. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  26806. once.Do(func() {
  26807. if m.done {
  26808. err = errors.New("querying old values post mutation is not allowed")
  26809. } else {
  26810. value, err = m.Client().WxCardVisit.Get(ctx, id)
  26811. }
  26812. })
  26813. return value, err
  26814. }
  26815. m.id = &id
  26816. }
  26817. }
  26818. // withWxCardVisit sets the old WxCardVisit of the mutation.
  26819. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  26820. return func(m *WxCardVisitMutation) {
  26821. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  26822. return node, nil
  26823. }
  26824. m.id = &node.ID
  26825. }
  26826. }
  26827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26828. // executed in a transaction (ent.Tx), a transactional client is returned.
  26829. func (m WxCardVisitMutation) Client() *Client {
  26830. client := &Client{config: m.config}
  26831. client.init()
  26832. return client
  26833. }
  26834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26835. // it returns an error otherwise.
  26836. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  26837. if _, ok := m.driver.(*txDriver); !ok {
  26838. return nil, errors.New("ent: mutation is not running in a transaction")
  26839. }
  26840. tx := &Tx{config: m.config}
  26841. tx.init()
  26842. return tx, nil
  26843. }
  26844. // SetID sets the value of the id field. Note that this
  26845. // operation is only accepted on creation of WxCardVisit entities.
  26846. func (m *WxCardVisitMutation) SetID(id uint64) {
  26847. m.id = &id
  26848. }
  26849. // ID returns the ID value in the mutation. Note that the ID is only available
  26850. // if it was provided to the builder or after it was returned from the database.
  26851. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  26852. if m.id == nil {
  26853. return
  26854. }
  26855. return *m.id, true
  26856. }
  26857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26858. // That means, if the mutation is applied within a transaction with an isolation level such
  26859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26860. // or updated by the mutation.
  26861. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  26862. switch {
  26863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26864. id, exists := m.ID()
  26865. if exists {
  26866. return []uint64{id}, nil
  26867. }
  26868. fallthrough
  26869. case m.op.Is(OpUpdate | OpDelete):
  26870. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  26871. default:
  26872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26873. }
  26874. }
  26875. // SetCreatedAt sets the "created_at" field.
  26876. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  26877. m.created_at = &t
  26878. }
  26879. // CreatedAt returns the value of the "created_at" field in the mutation.
  26880. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  26881. v := m.created_at
  26882. if v == nil {
  26883. return
  26884. }
  26885. return *v, true
  26886. }
  26887. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  26888. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26890. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26891. if !m.op.Is(OpUpdateOne) {
  26892. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26893. }
  26894. if m.id == nil || m.oldValue == nil {
  26895. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26896. }
  26897. oldValue, err := m.oldValue(ctx)
  26898. if err != nil {
  26899. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26900. }
  26901. return oldValue.CreatedAt, nil
  26902. }
  26903. // ResetCreatedAt resets all changes to the "created_at" field.
  26904. func (m *WxCardVisitMutation) ResetCreatedAt() {
  26905. m.created_at = nil
  26906. }
  26907. // SetUpdatedAt sets the "updated_at" field.
  26908. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  26909. m.updated_at = &t
  26910. }
  26911. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26912. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  26913. v := m.updated_at
  26914. if v == nil {
  26915. return
  26916. }
  26917. return *v, true
  26918. }
  26919. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  26920. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26922. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26923. if !m.op.Is(OpUpdateOne) {
  26924. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26925. }
  26926. if m.id == nil || m.oldValue == nil {
  26927. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26928. }
  26929. oldValue, err := m.oldValue(ctx)
  26930. if err != nil {
  26931. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26932. }
  26933. return oldValue.UpdatedAt, nil
  26934. }
  26935. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26936. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  26937. m.updated_at = nil
  26938. }
  26939. // SetDeletedAt sets the "deleted_at" field.
  26940. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  26941. m.deleted_at = &t
  26942. }
  26943. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26944. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  26945. v := m.deleted_at
  26946. if v == nil {
  26947. return
  26948. }
  26949. return *v, true
  26950. }
  26951. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  26952. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26954. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26955. if !m.op.Is(OpUpdateOne) {
  26956. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26957. }
  26958. if m.id == nil || m.oldValue == nil {
  26959. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26960. }
  26961. oldValue, err := m.oldValue(ctx)
  26962. if err != nil {
  26963. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26964. }
  26965. return oldValue.DeletedAt, nil
  26966. }
  26967. // ClearDeletedAt clears the value of the "deleted_at" field.
  26968. func (m *WxCardVisitMutation) ClearDeletedAt() {
  26969. m.deleted_at = nil
  26970. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  26971. }
  26972. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26973. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  26974. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  26975. return ok
  26976. }
  26977. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26978. func (m *WxCardVisitMutation) ResetDeletedAt() {
  26979. m.deleted_at = nil
  26980. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  26981. }
  26982. // SetUserID sets the "user_id" field.
  26983. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  26984. m.user_id = &u
  26985. m.adduser_id = nil
  26986. }
  26987. // UserID returns the value of the "user_id" field in the mutation.
  26988. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  26989. v := m.user_id
  26990. if v == nil {
  26991. return
  26992. }
  26993. return *v, true
  26994. }
  26995. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  26996. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26998. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  26999. if !m.op.Is(OpUpdateOne) {
  27000. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  27001. }
  27002. if m.id == nil || m.oldValue == nil {
  27003. return v, errors.New("OldUserID requires an ID field in the mutation")
  27004. }
  27005. oldValue, err := m.oldValue(ctx)
  27006. if err != nil {
  27007. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  27008. }
  27009. return oldValue.UserID, nil
  27010. }
  27011. // AddUserID adds u to the "user_id" field.
  27012. func (m *WxCardVisitMutation) AddUserID(u int64) {
  27013. if m.adduser_id != nil {
  27014. *m.adduser_id += u
  27015. } else {
  27016. m.adduser_id = &u
  27017. }
  27018. }
  27019. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  27020. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  27021. v := m.adduser_id
  27022. if v == nil {
  27023. return
  27024. }
  27025. return *v, true
  27026. }
  27027. // ClearUserID clears the value of the "user_id" field.
  27028. func (m *WxCardVisitMutation) ClearUserID() {
  27029. m.user_id = nil
  27030. m.adduser_id = nil
  27031. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  27032. }
  27033. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  27034. func (m *WxCardVisitMutation) UserIDCleared() bool {
  27035. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  27036. return ok
  27037. }
  27038. // ResetUserID resets all changes to the "user_id" field.
  27039. func (m *WxCardVisitMutation) ResetUserID() {
  27040. m.user_id = nil
  27041. m.adduser_id = nil
  27042. delete(m.clearedFields, wxcardvisit.FieldUserID)
  27043. }
  27044. // SetBotID sets the "bot_id" field.
  27045. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  27046. m.bot_id = &u
  27047. m.addbot_id = nil
  27048. }
  27049. // BotID returns the value of the "bot_id" field in the mutation.
  27050. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  27051. v := m.bot_id
  27052. if v == nil {
  27053. return
  27054. }
  27055. return *v, true
  27056. }
  27057. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  27058. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  27059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27060. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  27061. if !m.op.Is(OpUpdateOne) {
  27062. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27063. }
  27064. if m.id == nil || m.oldValue == nil {
  27065. return v, errors.New("OldBotID requires an ID field in the mutation")
  27066. }
  27067. oldValue, err := m.oldValue(ctx)
  27068. if err != nil {
  27069. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27070. }
  27071. return oldValue.BotID, nil
  27072. }
  27073. // AddBotID adds u to the "bot_id" field.
  27074. func (m *WxCardVisitMutation) AddBotID(u int64) {
  27075. if m.addbot_id != nil {
  27076. *m.addbot_id += u
  27077. } else {
  27078. m.addbot_id = &u
  27079. }
  27080. }
  27081. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  27082. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  27083. v := m.addbot_id
  27084. if v == nil {
  27085. return
  27086. }
  27087. return *v, true
  27088. }
  27089. // ResetBotID resets all changes to the "bot_id" field.
  27090. func (m *WxCardVisitMutation) ResetBotID() {
  27091. m.bot_id = nil
  27092. m.addbot_id = nil
  27093. }
  27094. // SetBotType sets the "bot_type" field.
  27095. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  27096. m.bot_type = &u
  27097. m.addbot_type = nil
  27098. }
  27099. // BotType returns the value of the "bot_type" field in the mutation.
  27100. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  27101. v := m.bot_type
  27102. if v == nil {
  27103. return
  27104. }
  27105. return *v, true
  27106. }
  27107. // OldBotType returns the old "bot_type" 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) OldBotType(ctx context.Context) (v uint8, err error) {
  27111. if !m.op.Is(OpUpdateOne) {
  27112. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  27113. }
  27114. if m.id == nil || m.oldValue == nil {
  27115. return v, errors.New("OldBotType 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 OldBotType: %w", err)
  27120. }
  27121. return oldValue.BotType, nil
  27122. }
  27123. // AddBotType adds u to the "bot_type" field.
  27124. func (m *WxCardVisitMutation) AddBotType(u int8) {
  27125. if m.addbot_type != nil {
  27126. *m.addbot_type += u
  27127. } else {
  27128. m.addbot_type = &u
  27129. }
  27130. }
  27131. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  27132. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  27133. v := m.addbot_type
  27134. if v == nil {
  27135. return
  27136. }
  27137. return *v, true
  27138. }
  27139. // ResetBotType resets all changes to the "bot_type" field.
  27140. func (m *WxCardVisitMutation) ResetBotType() {
  27141. m.bot_type = nil
  27142. m.addbot_type = nil
  27143. }
  27144. // Where appends a list predicates to the WxCardVisitMutation builder.
  27145. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  27146. m.predicates = append(m.predicates, ps...)
  27147. }
  27148. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  27149. // users can use type-assertion to append predicates that do not depend on any generated package.
  27150. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  27151. p := make([]predicate.WxCardVisit, len(ps))
  27152. for i := range ps {
  27153. p[i] = ps[i]
  27154. }
  27155. m.Where(p...)
  27156. }
  27157. // Op returns the operation name.
  27158. func (m *WxCardVisitMutation) Op() Op {
  27159. return m.op
  27160. }
  27161. // SetOp allows setting the mutation operation.
  27162. func (m *WxCardVisitMutation) SetOp(op Op) {
  27163. m.op = op
  27164. }
  27165. // Type returns the node type of this mutation (WxCardVisit).
  27166. func (m *WxCardVisitMutation) Type() string {
  27167. return m.typ
  27168. }
  27169. // Fields returns all fields that were changed during this mutation. Note that in
  27170. // order to get all numeric fields that were incremented/decremented, call
  27171. // AddedFields().
  27172. func (m *WxCardVisitMutation) Fields() []string {
  27173. fields := make([]string, 0, 6)
  27174. if m.created_at != nil {
  27175. fields = append(fields, wxcardvisit.FieldCreatedAt)
  27176. }
  27177. if m.updated_at != nil {
  27178. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  27179. }
  27180. if m.deleted_at != nil {
  27181. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27182. }
  27183. if m.user_id != nil {
  27184. fields = append(fields, wxcardvisit.FieldUserID)
  27185. }
  27186. if m.bot_id != nil {
  27187. fields = append(fields, wxcardvisit.FieldBotID)
  27188. }
  27189. if m.bot_type != nil {
  27190. fields = append(fields, wxcardvisit.FieldBotType)
  27191. }
  27192. return fields
  27193. }
  27194. // Field returns the value of a field with the given name. The second boolean
  27195. // return value indicates that this field was not set, or was not defined in the
  27196. // schema.
  27197. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  27198. switch name {
  27199. case wxcardvisit.FieldCreatedAt:
  27200. return m.CreatedAt()
  27201. case wxcardvisit.FieldUpdatedAt:
  27202. return m.UpdatedAt()
  27203. case wxcardvisit.FieldDeletedAt:
  27204. return m.DeletedAt()
  27205. case wxcardvisit.FieldUserID:
  27206. return m.UserID()
  27207. case wxcardvisit.FieldBotID:
  27208. return m.BotID()
  27209. case wxcardvisit.FieldBotType:
  27210. return m.BotType()
  27211. }
  27212. return nil, false
  27213. }
  27214. // OldField returns the old value of the field from the database. An error is
  27215. // returned if the mutation operation is not UpdateOne, or the query to the
  27216. // database failed.
  27217. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27218. switch name {
  27219. case wxcardvisit.FieldCreatedAt:
  27220. return m.OldCreatedAt(ctx)
  27221. case wxcardvisit.FieldUpdatedAt:
  27222. return m.OldUpdatedAt(ctx)
  27223. case wxcardvisit.FieldDeletedAt:
  27224. return m.OldDeletedAt(ctx)
  27225. case wxcardvisit.FieldUserID:
  27226. return m.OldUserID(ctx)
  27227. case wxcardvisit.FieldBotID:
  27228. return m.OldBotID(ctx)
  27229. case wxcardvisit.FieldBotType:
  27230. return m.OldBotType(ctx)
  27231. }
  27232. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  27233. }
  27234. // SetField sets the value of a field with the given name. It returns an error if
  27235. // the field is not defined in the schema, or if the type mismatched the field
  27236. // type.
  27237. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  27238. switch name {
  27239. case wxcardvisit.FieldCreatedAt:
  27240. v, ok := value.(time.Time)
  27241. if !ok {
  27242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27243. }
  27244. m.SetCreatedAt(v)
  27245. return nil
  27246. case wxcardvisit.FieldUpdatedAt:
  27247. v, ok := value.(time.Time)
  27248. if !ok {
  27249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27250. }
  27251. m.SetUpdatedAt(v)
  27252. return nil
  27253. case wxcardvisit.FieldDeletedAt:
  27254. v, ok := value.(time.Time)
  27255. if !ok {
  27256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27257. }
  27258. m.SetDeletedAt(v)
  27259. return nil
  27260. case wxcardvisit.FieldUserID:
  27261. v, ok := value.(uint64)
  27262. if !ok {
  27263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27264. }
  27265. m.SetUserID(v)
  27266. return nil
  27267. case wxcardvisit.FieldBotID:
  27268. v, ok := value.(uint64)
  27269. if !ok {
  27270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27271. }
  27272. m.SetBotID(v)
  27273. return nil
  27274. case wxcardvisit.FieldBotType:
  27275. v, ok := value.(uint8)
  27276. if !ok {
  27277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27278. }
  27279. m.SetBotType(v)
  27280. return nil
  27281. }
  27282. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27283. }
  27284. // AddedFields returns all numeric fields that were incremented/decremented during
  27285. // this mutation.
  27286. func (m *WxCardVisitMutation) AddedFields() []string {
  27287. var fields []string
  27288. if m.adduser_id != nil {
  27289. fields = append(fields, wxcardvisit.FieldUserID)
  27290. }
  27291. if m.addbot_id != nil {
  27292. fields = append(fields, wxcardvisit.FieldBotID)
  27293. }
  27294. if m.addbot_type != nil {
  27295. fields = append(fields, wxcardvisit.FieldBotType)
  27296. }
  27297. return fields
  27298. }
  27299. // AddedField returns the numeric value that was incremented/decremented on a field
  27300. // with the given name. The second boolean return value indicates that this field
  27301. // was not set, or was not defined in the schema.
  27302. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  27303. switch name {
  27304. case wxcardvisit.FieldUserID:
  27305. return m.AddedUserID()
  27306. case wxcardvisit.FieldBotID:
  27307. return m.AddedBotID()
  27308. case wxcardvisit.FieldBotType:
  27309. return m.AddedBotType()
  27310. }
  27311. return nil, false
  27312. }
  27313. // AddField adds the value to the field with the given name. It returns an error if
  27314. // the field is not defined in the schema, or if the type mismatched the field
  27315. // type.
  27316. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  27317. switch name {
  27318. case wxcardvisit.FieldUserID:
  27319. v, ok := value.(int64)
  27320. if !ok {
  27321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27322. }
  27323. m.AddUserID(v)
  27324. return nil
  27325. case wxcardvisit.FieldBotID:
  27326. v, ok := value.(int64)
  27327. if !ok {
  27328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27329. }
  27330. m.AddBotID(v)
  27331. return nil
  27332. case wxcardvisit.FieldBotType:
  27333. v, ok := value.(int8)
  27334. if !ok {
  27335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27336. }
  27337. m.AddBotType(v)
  27338. return nil
  27339. }
  27340. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  27341. }
  27342. // ClearedFields returns all nullable fields that were cleared during this
  27343. // mutation.
  27344. func (m *WxCardVisitMutation) ClearedFields() []string {
  27345. var fields []string
  27346. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  27347. fields = append(fields, wxcardvisit.FieldDeletedAt)
  27348. }
  27349. if m.FieldCleared(wxcardvisit.FieldUserID) {
  27350. fields = append(fields, wxcardvisit.FieldUserID)
  27351. }
  27352. return fields
  27353. }
  27354. // FieldCleared returns a boolean indicating if a field with the given name was
  27355. // cleared in this mutation.
  27356. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  27357. _, ok := m.clearedFields[name]
  27358. return ok
  27359. }
  27360. // ClearField clears the value of the field with the given name. It returns an
  27361. // error if the field is not defined in the schema.
  27362. func (m *WxCardVisitMutation) ClearField(name string) error {
  27363. switch name {
  27364. case wxcardvisit.FieldDeletedAt:
  27365. m.ClearDeletedAt()
  27366. return nil
  27367. case wxcardvisit.FieldUserID:
  27368. m.ClearUserID()
  27369. return nil
  27370. }
  27371. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  27372. }
  27373. // ResetField resets all changes in the mutation for the field with the given name.
  27374. // It returns an error if the field is not defined in the schema.
  27375. func (m *WxCardVisitMutation) ResetField(name string) error {
  27376. switch name {
  27377. case wxcardvisit.FieldCreatedAt:
  27378. m.ResetCreatedAt()
  27379. return nil
  27380. case wxcardvisit.FieldUpdatedAt:
  27381. m.ResetUpdatedAt()
  27382. return nil
  27383. case wxcardvisit.FieldDeletedAt:
  27384. m.ResetDeletedAt()
  27385. return nil
  27386. case wxcardvisit.FieldUserID:
  27387. m.ResetUserID()
  27388. return nil
  27389. case wxcardvisit.FieldBotID:
  27390. m.ResetBotID()
  27391. return nil
  27392. case wxcardvisit.FieldBotType:
  27393. m.ResetBotType()
  27394. return nil
  27395. }
  27396. return fmt.Errorf("unknown WxCardVisit field %s", name)
  27397. }
  27398. // AddedEdges returns all edge names that were set/added in this mutation.
  27399. func (m *WxCardVisitMutation) AddedEdges() []string {
  27400. edges := make([]string, 0, 0)
  27401. return edges
  27402. }
  27403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27404. // name in this mutation.
  27405. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  27406. return nil
  27407. }
  27408. // RemovedEdges returns all edge names that were removed in this mutation.
  27409. func (m *WxCardVisitMutation) RemovedEdges() []string {
  27410. edges := make([]string, 0, 0)
  27411. return edges
  27412. }
  27413. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27414. // the given name in this mutation.
  27415. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  27416. return nil
  27417. }
  27418. // ClearedEdges returns all edge names that were cleared in this mutation.
  27419. func (m *WxCardVisitMutation) ClearedEdges() []string {
  27420. edges := make([]string, 0, 0)
  27421. return edges
  27422. }
  27423. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27424. // was cleared in this mutation.
  27425. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  27426. return false
  27427. }
  27428. // ClearEdge clears the value of the edge with the given name. It returns an error
  27429. // if that edge is not defined in the schema.
  27430. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  27431. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  27432. }
  27433. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27434. // It returns an error if the edge is not defined in the schema.
  27435. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  27436. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  27437. }