mutation.go 836 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347
  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/batchmsg"
  12. "wechat-api/ent/category"
  13. "wechat-api/ent/chatrecords"
  14. "wechat-api/ent/chatsession"
  15. "wechat-api/ent/contact"
  16. "wechat-api/ent/custom_types"
  17. "wechat-api/ent/employee"
  18. "wechat-api/ent/employeeconfig"
  19. "wechat-api/ent/label"
  20. "wechat-api/ent/labelrelationship"
  21. "wechat-api/ent/message"
  22. "wechat-api/ent/messagerecords"
  23. "wechat-api/ent/msg"
  24. "wechat-api/ent/predicate"
  25. "wechat-api/ent/server"
  26. "wechat-api/ent/sopnode"
  27. "wechat-api/ent/sopstage"
  28. "wechat-api/ent/soptask"
  29. "wechat-api/ent/token"
  30. "wechat-api/ent/tutorial"
  31. "wechat-api/ent/workexperience"
  32. "wechat-api/ent/wx"
  33. "wechat-api/ent/wxcard"
  34. "wechat-api/ent/wxcarduser"
  35. "wechat-api/ent/wxcardvisit"
  36. "entgo.io/ent"
  37. "entgo.io/ent/dialect/sql"
  38. )
  39. const (
  40. // Operation types.
  41. OpCreate = ent.OpCreate
  42. OpDelete = ent.OpDelete
  43. OpDeleteOne = ent.OpDeleteOne
  44. OpUpdate = ent.OpUpdate
  45. OpUpdateOne = ent.OpUpdateOne
  46. // Node types.
  47. TypeAgent = "Agent"
  48. TypeAgentBase = "AgentBase"
  49. TypeBatchMsg = "BatchMsg"
  50. TypeCategory = "Category"
  51. TypeChatRecords = "ChatRecords"
  52. TypeChatSession = "ChatSession"
  53. TypeContact = "Contact"
  54. TypeEmployee = "Employee"
  55. TypeEmployeeConfig = "EmployeeConfig"
  56. TypeLabel = "Label"
  57. TypeLabelRelationship = "LabelRelationship"
  58. TypeMessage = "Message"
  59. TypeMessageRecords = "MessageRecords"
  60. TypeMsg = "Msg"
  61. TypeServer = "Server"
  62. TypeSopNode = "SopNode"
  63. TypeSopStage = "SopStage"
  64. TypeSopTask = "SopTask"
  65. TypeToken = "Token"
  66. TypeTutorial = "Tutorial"
  67. TypeWorkExperience = "WorkExperience"
  68. TypeWx = "Wx"
  69. TypeWxCard = "WxCard"
  70. TypeWxCardUser = "WxCardUser"
  71. TypeWxCardVisit = "WxCardVisit"
  72. )
  73. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  74. type AgentMutation struct {
  75. config
  76. op Op
  77. typ string
  78. id *uint64
  79. created_at *time.Time
  80. updated_at *time.Time
  81. deleted_at *time.Time
  82. name *string
  83. role *string
  84. status *int
  85. addstatus *int
  86. background *string
  87. examples *string
  88. organization_id *uint64
  89. addorganization_id *int64
  90. dataset_id *string
  91. collection_id *string
  92. clearedFields map[string]struct{}
  93. wx_agent map[uint64]struct{}
  94. removedwx_agent map[uint64]struct{}
  95. clearedwx_agent bool
  96. done bool
  97. oldValue func(context.Context) (*Agent, error)
  98. predicates []predicate.Agent
  99. }
  100. var _ ent.Mutation = (*AgentMutation)(nil)
  101. // agentOption allows management of the mutation configuration using functional options.
  102. type agentOption func(*AgentMutation)
  103. // newAgentMutation creates new mutation for the Agent entity.
  104. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  105. m := &AgentMutation{
  106. config: c,
  107. op: op,
  108. typ: TypeAgent,
  109. clearedFields: make(map[string]struct{}),
  110. }
  111. for _, opt := range opts {
  112. opt(m)
  113. }
  114. return m
  115. }
  116. // withAgentID sets the ID field of the mutation.
  117. func withAgentID(id uint64) agentOption {
  118. return func(m *AgentMutation) {
  119. var (
  120. err error
  121. once sync.Once
  122. value *Agent
  123. )
  124. m.oldValue = func(ctx context.Context) (*Agent, error) {
  125. once.Do(func() {
  126. if m.done {
  127. err = errors.New("querying old values post mutation is not allowed")
  128. } else {
  129. value, err = m.Client().Agent.Get(ctx, id)
  130. }
  131. })
  132. return value, err
  133. }
  134. m.id = &id
  135. }
  136. }
  137. // withAgent sets the old Agent of the mutation.
  138. func withAgent(node *Agent) agentOption {
  139. return func(m *AgentMutation) {
  140. m.oldValue = func(context.Context) (*Agent, error) {
  141. return node, nil
  142. }
  143. m.id = &node.ID
  144. }
  145. }
  146. // Client returns a new `ent.Client` from the mutation. If the mutation was
  147. // executed in a transaction (ent.Tx), a transactional client is returned.
  148. func (m AgentMutation) Client() *Client {
  149. client := &Client{config: m.config}
  150. client.init()
  151. return client
  152. }
  153. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  154. // it returns an error otherwise.
  155. func (m AgentMutation) Tx() (*Tx, error) {
  156. if _, ok := m.driver.(*txDriver); !ok {
  157. return nil, errors.New("ent: mutation is not running in a transaction")
  158. }
  159. tx := &Tx{config: m.config}
  160. tx.init()
  161. return tx, nil
  162. }
  163. // SetID sets the value of the id field. Note that this
  164. // operation is only accepted on creation of Agent entities.
  165. func (m *AgentMutation) SetID(id uint64) {
  166. m.id = &id
  167. }
  168. // ID returns the ID value in the mutation. Note that the ID is only available
  169. // if it was provided to the builder or after it was returned from the database.
  170. func (m *AgentMutation) ID() (id uint64, exists bool) {
  171. if m.id == nil {
  172. return
  173. }
  174. return *m.id, true
  175. }
  176. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  177. // That means, if the mutation is applied within a transaction with an isolation level such
  178. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  179. // or updated by the mutation.
  180. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  181. switch {
  182. case m.op.Is(OpUpdateOne | OpDeleteOne):
  183. id, exists := m.ID()
  184. if exists {
  185. return []uint64{id}, nil
  186. }
  187. fallthrough
  188. case m.op.Is(OpUpdate | OpDelete):
  189. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  190. default:
  191. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  192. }
  193. }
  194. // SetCreatedAt sets the "created_at" field.
  195. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  196. m.created_at = &t
  197. }
  198. // CreatedAt returns the value of the "created_at" field in the mutation.
  199. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  200. v := m.created_at
  201. if v == nil {
  202. return
  203. }
  204. return *v, true
  205. }
  206. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  207. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  209. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  210. if !m.op.Is(OpUpdateOne) {
  211. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  212. }
  213. if m.id == nil || m.oldValue == nil {
  214. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  215. }
  216. oldValue, err := m.oldValue(ctx)
  217. if err != nil {
  218. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  219. }
  220. return oldValue.CreatedAt, nil
  221. }
  222. // ResetCreatedAt resets all changes to the "created_at" field.
  223. func (m *AgentMutation) ResetCreatedAt() {
  224. m.created_at = nil
  225. }
  226. // SetUpdatedAt sets the "updated_at" field.
  227. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  228. m.updated_at = &t
  229. }
  230. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  231. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  232. v := m.updated_at
  233. if v == nil {
  234. return
  235. }
  236. return *v, true
  237. }
  238. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  239. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  241. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  242. if !m.op.Is(OpUpdateOne) {
  243. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  244. }
  245. if m.id == nil || m.oldValue == nil {
  246. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  247. }
  248. oldValue, err := m.oldValue(ctx)
  249. if err != nil {
  250. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  251. }
  252. return oldValue.UpdatedAt, nil
  253. }
  254. // ResetUpdatedAt resets all changes to the "updated_at" field.
  255. func (m *AgentMutation) ResetUpdatedAt() {
  256. m.updated_at = nil
  257. }
  258. // SetDeletedAt sets the "deleted_at" field.
  259. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  260. m.deleted_at = &t
  261. }
  262. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  263. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  264. v := m.deleted_at
  265. if v == nil {
  266. return
  267. }
  268. return *v, true
  269. }
  270. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  271. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  273. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  274. if !m.op.Is(OpUpdateOne) {
  275. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  276. }
  277. if m.id == nil || m.oldValue == nil {
  278. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  279. }
  280. oldValue, err := m.oldValue(ctx)
  281. if err != nil {
  282. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  283. }
  284. return oldValue.DeletedAt, nil
  285. }
  286. // ClearDeletedAt clears the value of the "deleted_at" field.
  287. func (m *AgentMutation) ClearDeletedAt() {
  288. m.deleted_at = nil
  289. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  290. }
  291. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  292. func (m *AgentMutation) DeletedAtCleared() bool {
  293. _, ok := m.clearedFields[agent.FieldDeletedAt]
  294. return ok
  295. }
  296. // ResetDeletedAt resets all changes to the "deleted_at" field.
  297. func (m *AgentMutation) ResetDeletedAt() {
  298. m.deleted_at = nil
  299. delete(m.clearedFields, agent.FieldDeletedAt)
  300. }
  301. // SetName sets the "name" field.
  302. func (m *AgentMutation) SetName(s string) {
  303. m.name = &s
  304. }
  305. // Name returns the value of the "name" field in the mutation.
  306. func (m *AgentMutation) Name() (r string, exists bool) {
  307. v := m.name
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldName returns the old "name" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldName is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldName requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldName: %w", err)
  326. }
  327. return oldValue.Name, nil
  328. }
  329. // ResetName resets all changes to the "name" field.
  330. func (m *AgentMutation) ResetName() {
  331. m.name = nil
  332. }
  333. // SetRole sets the "role" field.
  334. func (m *AgentMutation) SetRole(s string) {
  335. m.role = &s
  336. }
  337. // Role returns the value of the "role" field in the mutation.
  338. func (m *AgentMutation) Role() (r string, exists bool) {
  339. v := m.role
  340. if v == nil {
  341. return
  342. }
  343. return *v, true
  344. }
  345. // OldRole returns the old "role" field's value of the Agent entity.
  346. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  348. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  349. if !m.op.Is(OpUpdateOne) {
  350. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  351. }
  352. if m.id == nil || m.oldValue == nil {
  353. return v, errors.New("OldRole requires an ID field in the mutation")
  354. }
  355. oldValue, err := m.oldValue(ctx)
  356. if err != nil {
  357. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  358. }
  359. return oldValue.Role, nil
  360. }
  361. // ResetRole resets all changes to the "role" field.
  362. func (m *AgentMutation) ResetRole() {
  363. m.role = nil
  364. }
  365. // SetStatus sets the "status" field.
  366. func (m *AgentMutation) SetStatus(i int) {
  367. m.status = &i
  368. m.addstatus = nil
  369. }
  370. // Status returns the value of the "status" field in the mutation.
  371. func (m *AgentMutation) Status() (r int, exists bool) {
  372. v := m.status
  373. if v == nil {
  374. return
  375. }
  376. return *v, true
  377. }
  378. // OldStatus returns the old "status" field's value of the Agent entity.
  379. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  381. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  382. if !m.op.Is(OpUpdateOne) {
  383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  384. }
  385. if m.id == nil || m.oldValue == nil {
  386. return v, errors.New("OldStatus requires an ID field in the mutation")
  387. }
  388. oldValue, err := m.oldValue(ctx)
  389. if err != nil {
  390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  391. }
  392. return oldValue.Status, nil
  393. }
  394. // AddStatus adds i to the "status" field.
  395. func (m *AgentMutation) AddStatus(i int) {
  396. if m.addstatus != nil {
  397. *m.addstatus += i
  398. } else {
  399. m.addstatus = &i
  400. }
  401. }
  402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  403. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  404. v := m.addstatus
  405. if v == nil {
  406. return
  407. }
  408. return *v, true
  409. }
  410. // ClearStatus clears the value of the "status" field.
  411. func (m *AgentMutation) ClearStatus() {
  412. m.status = nil
  413. m.addstatus = nil
  414. m.clearedFields[agent.FieldStatus] = struct{}{}
  415. }
  416. // StatusCleared returns if the "status" field was cleared in this mutation.
  417. func (m *AgentMutation) StatusCleared() bool {
  418. _, ok := m.clearedFields[agent.FieldStatus]
  419. return ok
  420. }
  421. // ResetStatus resets all changes to the "status" field.
  422. func (m *AgentMutation) ResetStatus() {
  423. m.status = nil
  424. m.addstatus = nil
  425. delete(m.clearedFields, agent.FieldStatus)
  426. }
  427. // SetBackground sets the "background" field.
  428. func (m *AgentMutation) SetBackground(s string) {
  429. m.background = &s
  430. }
  431. // Background returns the value of the "background" field in the mutation.
  432. func (m *AgentMutation) Background() (r string, exists bool) {
  433. v := m.background
  434. if v == nil {
  435. return
  436. }
  437. return *v, true
  438. }
  439. // OldBackground returns the old "background" field's value of the Agent entity.
  440. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  442. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  443. if !m.op.Is(OpUpdateOne) {
  444. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  445. }
  446. if m.id == nil || m.oldValue == nil {
  447. return v, errors.New("OldBackground requires an ID field in the mutation")
  448. }
  449. oldValue, err := m.oldValue(ctx)
  450. if err != nil {
  451. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  452. }
  453. return oldValue.Background, nil
  454. }
  455. // ClearBackground clears the value of the "background" field.
  456. func (m *AgentMutation) ClearBackground() {
  457. m.background = nil
  458. m.clearedFields[agent.FieldBackground] = struct{}{}
  459. }
  460. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  461. func (m *AgentMutation) BackgroundCleared() bool {
  462. _, ok := m.clearedFields[agent.FieldBackground]
  463. return ok
  464. }
  465. // ResetBackground resets all changes to the "background" field.
  466. func (m *AgentMutation) ResetBackground() {
  467. m.background = nil
  468. delete(m.clearedFields, agent.FieldBackground)
  469. }
  470. // SetExamples sets the "examples" field.
  471. func (m *AgentMutation) SetExamples(s string) {
  472. m.examples = &s
  473. }
  474. // Examples returns the value of the "examples" field in the mutation.
  475. func (m *AgentMutation) Examples() (r string, exists bool) {
  476. v := m.examples
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldExamples returns the old "examples" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldExamples requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  495. }
  496. return oldValue.Examples, nil
  497. }
  498. // ClearExamples clears the value of the "examples" field.
  499. func (m *AgentMutation) ClearExamples() {
  500. m.examples = nil
  501. m.clearedFields[agent.FieldExamples] = struct{}{}
  502. }
  503. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  504. func (m *AgentMutation) ExamplesCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldExamples]
  506. return ok
  507. }
  508. // ResetExamples resets all changes to the "examples" field.
  509. func (m *AgentMutation) ResetExamples() {
  510. m.examples = nil
  511. delete(m.clearedFields, agent.FieldExamples)
  512. }
  513. // SetOrganizationID sets the "organization_id" field.
  514. func (m *AgentMutation) SetOrganizationID(u uint64) {
  515. m.organization_id = &u
  516. m.addorganization_id = nil
  517. }
  518. // OrganizationID returns the value of the "organization_id" field in the mutation.
  519. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  520. v := m.organization_id
  521. if v == nil {
  522. return
  523. }
  524. return *v, true
  525. }
  526. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  527. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  529. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  530. if !m.op.Is(OpUpdateOne) {
  531. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  532. }
  533. if m.id == nil || m.oldValue == nil {
  534. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  535. }
  536. oldValue, err := m.oldValue(ctx)
  537. if err != nil {
  538. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  539. }
  540. return oldValue.OrganizationID, nil
  541. }
  542. // AddOrganizationID adds u to the "organization_id" field.
  543. func (m *AgentMutation) AddOrganizationID(u int64) {
  544. if m.addorganization_id != nil {
  545. *m.addorganization_id += u
  546. } else {
  547. m.addorganization_id = &u
  548. }
  549. }
  550. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  551. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  552. v := m.addorganization_id
  553. if v == nil {
  554. return
  555. }
  556. return *v, true
  557. }
  558. // ResetOrganizationID resets all changes to the "organization_id" field.
  559. func (m *AgentMutation) ResetOrganizationID() {
  560. m.organization_id = nil
  561. m.addorganization_id = nil
  562. }
  563. // SetDatasetID sets the "dataset_id" field.
  564. func (m *AgentMutation) SetDatasetID(s string) {
  565. m.dataset_id = &s
  566. }
  567. // DatasetID returns the value of the "dataset_id" field in the mutation.
  568. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  569. v := m.dataset_id
  570. if v == nil {
  571. return
  572. }
  573. return *v, true
  574. }
  575. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  576. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  578. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  579. if !m.op.Is(OpUpdateOne) {
  580. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  581. }
  582. if m.id == nil || m.oldValue == nil {
  583. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  584. }
  585. oldValue, err := m.oldValue(ctx)
  586. if err != nil {
  587. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  588. }
  589. return oldValue.DatasetID, nil
  590. }
  591. // ResetDatasetID resets all changes to the "dataset_id" field.
  592. func (m *AgentMutation) ResetDatasetID() {
  593. m.dataset_id = nil
  594. }
  595. // SetCollectionID sets the "collection_id" field.
  596. func (m *AgentMutation) SetCollectionID(s string) {
  597. m.collection_id = &s
  598. }
  599. // CollectionID returns the value of the "collection_id" field in the mutation.
  600. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  601. v := m.collection_id
  602. if v == nil {
  603. return
  604. }
  605. return *v, true
  606. }
  607. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  608. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  610. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  611. if !m.op.Is(OpUpdateOne) {
  612. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  613. }
  614. if m.id == nil || m.oldValue == nil {
  615. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  616. }
  617. oldValue, err := m.oldValue(ctx)
  618. if err != nil {
  619. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  620. }
  621. return oldValue.CollectionID, nil
  622. }
  623. // ResetCollectionID resets all changes to the "collection_id" field.
  624. func (m *AgentMutation) ResetCollectionID() {
  625. m.collection_id = nil
  626. }
  627. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  628. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  629. if m.wx_agent == nil {
  630. m.wx_agent = make(map[uint64]struct{})
  631. }
  632. for i := range ids {
  633. m.wx_agent[ids[i]] = struct{}{}
  634. }
  635. }
  636. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  637. func (m *AgentMutation) ClearWxAgent() {
  638. m.clearedwx_agent = true
  639. }
  640. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  641. func (m *AgentMutation) WxAgentCleared() bool {
  642. return m.clearedwx_agent
  643. }
  644. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  645. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  646. if m.removedwx_agent == nil {
  647. m.removedwx_agent = make(map[uint64]struct{})
  648. }
  649. for i := range ids {
  650. delete(m.wx_agent, ids[i])
  651. m.removedwx_agent[ids[i]] = struct{}{}
  652. }
  653. }
  654. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  655. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  656. for id := range m.removedwx_agent {
  657. ids = append(ids, id)
  658. }
  659. return
  660. }
  661. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  662. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  663. for id := range m.wx_agent {
  664. ids = append(ids, id)
  665. }
  666. return
  667. }
  668. // ResetWxAgent resets all changes to the "wx_agent" edge.
  669. func (m *AgentMutation) ResetWxAgent() {
  670. m.wx_agent = nil
  671. m.clearedwx_agent = false
  672. m.removedwx_agent = nil
  673. }
  674. // Where appends a list predicates to the AgentMutation builder.
  675. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  676. m.predicates = append(m.predicates, ps...)
  677. }
  678. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  679. // users can use type-assertion to append predicates that do not depend on any generated package.
  680. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  681. p := make([]predicate.Agent, len(ps))
  682. for i := range ps {
  683. p[i] = ps[i]
  684. }
  685. m.Where(p...)
  686. }
  687. // Op returns the operation name.
  688. func (m *AgentMutation) Op() Op {
  689. return m.op
  690. }
  691. // SetOp allows setting the mutation operation.
  692. func (m *AgentMutation) SetOp(op Op) {
  693. m.op = op
  694. }
  695. // Type returns the node type of this mutation (Agent).
  696. func (m *AgentMutation) Type() string {
  697. return m.typ
  698. }
  699. // Fields returns all fields that were changed during this mutation. Note that in
  700. // order to get all numeric fields that were incremented/decremented, call
  701. // AddedFields().
  702. func (m *AgentMutation) Fields() []string {
  703. fields := make([]string, 0, 11)
  704. if m.created_at != nil {
  705. fields = append(fields, agent.FieldCreatedAt)
  706. }
  707. if m.updated_at != nil {
  708. fields = append(fields, agent.FieldUpdatedAt)
  709. }
  710. if m.deleted_at != nil {
  711. fields = append(fields, agent.FieldDeletedAt)
  712. }
  713. if m.name != nil {
  714. fields = append(fields, agent.FieldName)
  715. }
  716. if m.role != nil {
  717. fields = append(fields, agent.FieldRole)
  718. }
  719. if m.status != nil {
  720. fields = append(fields, agent.FieldStatus)
  721. }
  722. if m.background != nil {
  723. fields = append(fields, agent.FieldBackground)
  724. }
  725. if m.examples != nil {
  726. fields = append(fields, agent.FieldExamples)
  727. }
  728. if m.organization_id != nil {
  729. fields = append(fields, agent.FieldOrganizationID)
  730. }
  731. if m.dataset_id != nil {
  732. fields = append(fields, agent.FieldDatasetID)
  733. }
  734. if m.collection_id != nil {
  735. fields = append(fields, agent.FieldCollectionID)
  736. }
  737. return fields
  738. }
  739. // Field returns the value of a field with the given name. The second boolean
  740. // return value indicates that this field was not set, or was not defined in the
  741. // schema.
  742. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  743. switch name {
  744. case agent.FieldCreatedAt:
  745. return m.CreatedAt()
  746. case agent.FieldUpdatedAt:
  747. return m.UpdatedAt()
  748. case agent.FieldDeletedAt:
  749. return m.DeletedAt()
  750. case agent.FieldName:
  751. return m.Name()
  752. case agent.FieldRole:
  753. return m.Role()
  754. case agent.FieldStatus:
  755. return m.Status()
  756. case agent.FieldBackground:
  757. return m.Background()
  758. case agent.FieldExamples:
  759. return m.Examples()
  760. case agent.FieldOrganizationID:
  761. return m.OrganizationID()
  762. case agent.FieldDatasetID:
  763. return m.DatasetID()
  764. case agent.FieldCollectionID:
  765. return m.CollectionID()
  766. }
  767. return nil, false
  768. }
  769. // OldField returns the old value of the field from the database. An error is
  770. // returned if the mutation operation is not UpdateOne, or the query to the
  771. // database failed.
  772. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  773. switch name {
  774. case agent.FieldCreatedAt:
  775. return m.OldCreatedAt(ctx)
  776. case agent.FieldUpdatedAt:
  777. return m.OldUpdatedAt(ctx)
  778. case agent.FieldDeletedAt:
  779. return m.OldDeletedAt(ctx)
  780. case agent.FieldName:
  781. return m.OldName(ctx)
  782. case agent.FieldRole:
  783. return m.OldRole(ctx)
  784. case agent.FieldStatus:
  785. return m.OldStatus(ctx)
  786. case agent.FieldBackground:
  787. return m.OldBackground(ctx)
  788. case agent.FieldExamples:
  789. return m.OldExamples(ctx)
  790. case agent.FieldOrganizationID:
  791. return m.OldOrganizationID(ctx)
  792. case agent.FieldDatasetID:
  793. return m.OldDatasetID(ctx)
  794. case agent.FieldCollectionID:
  795. return m.OldCollectionID(ctx)
  796. }
  797. return nil, fmt.Errorf("unknown Agent field %s", name)
  798. }
  799. // SetField sets the value of a field with the given name. It returns an error if
  800. // the field is not defined in the schema, or if the type mismatched the field
  801. // type.
  802. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  803. switch name {
  804. case agent.FieldCreatedAt:
  805. v, ok := value.(time.Time)
  806. if !ok {
  807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  808. }
  809. m.SetCreatedAt(v)
  810. return nil
  811. case agent.FieldUpdatedAt:
  812. v, ok := value.(time.Time)
  813. if !ok {
  814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  815. }
  816. m.SetUpdatedAt(v)
  817. return nil
  818. case agent.FieldDeletedAt:
  819. v, ok := value.(time.Time)
  820. if !ok {
  821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  822. }
  823. m.SetDeletedAt(v)
  824. return nil
  825. case agent.FieldName:
  826. v, ok := value.(string)
  827. if !ok {
  828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  829. }
  830. m.SetName(v)
  831. return nil
  832. case agent.FieldRole:
  833. v, ok := value.(string)
  834. if !ok {
  835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  836. }
  837. m.SetRole(v)
  838. return nil
  839. case agent.FieldStatus:
  840. v, ok := value.(int)
  841. if !ok {
  842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  843. }
  844. m.SetStatus(v)
  845. return nil
  846. case agent.FieldBackground:
  847. v, ok := value.(string)
  848. if !ok {
  849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  850. }
  851. m.SetBackground(v)
  852. return nil
  853. case agent.FieldExamples:
  854. v, ok := value.(string)
  855. if !ok {
  856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  857. }
  858. m.SetExamples(v)
  859. return nil
  860. case agent.FieldOrganizationID:
  861. v, ok := value.(uint64)
  862. if !ok {
  863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  864. }
  865. m.SetOrganizationID(v)
  866. return nil
  867. case agent.FieldDatasetID:
  868. v, ok := value.(string)
  869. if !ok {
  870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  871. }
  872. m.SetDatasetID(v)
  873. return nil
  874. case agent.FieldCollectionID:
  875. v, ok := value.(string)
  876. if !ok {
  877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  878. }
  879. m.SetCollectionID(v)
  880. return nil
  881. }
  882. return fmt.Errorf("unknown Agent field %s", name)
  883. }
  884. // AddedFields returns all numeric fields that were incremented/decremented during
  885. // this mutation.
  886. func (m *AgentMutation) AddedFields() []string {
  887. var fields []string
  888. if m.addstatus != nil {
  889. fields = append(fields, agent.FieldStatus)
  890. }
  891. if m.addorganization_id != nil {
  892. fields = append(fields, agent.FieldOrganizationID)
  893. }
  894. return fields
  895. }
  896. // AddedField returns the numeric value that was incremented/decremented on a field
  897. // with the given name. The second boolean return value indicates that this field
  898. // was not set, or was not defined in the schema.
  899. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  900. switch name {
  901. case agent.FieldStatus:
  902. return m.AddedStatus()
  903. case agent.FieldOrganizationID:
  904. return m.AddedOrganizationID()
  905. }
  906. return nil, false
  907. }
  908. // AddField adds the value to the field with the given name. It returns an error if
  909. // the field is not defined in the schema, or if the type mismatched the field
  910. // type.
  911. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  912. switch name {
  913. case agent.FieldStatus:
  914. v, ok := value.(int)
  915. if !ok {
  916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  917. }
  918. m.AddStatus(v)
  919. return nil
  920. case agent.FieldOrganizationID:
  921. v, ok := value.(int64)
  922. if !ok {
  923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  924. }
  925. m.AddOrganizationID(v)
  926. return nil
  927. }
  928. return fmt.Errorf("unknown Agent numeric field %s", name)
  929. }
  930. // ClearedFields returns all nullable fields that were cleared during this
  931. // mutation.
  932. func (m *AgentMutation) ClearedFields() []string {
  933. var fields []string
  934. if m.FieldCleared(agent.FieldDeletedAt) {
  935. fields = append(fields, agent.FieldDeletedAt)
  936. }
  937. if m.FieldCleared(agent.FieldStatus) {
  938. fields = append(fields, agent.FieldStatus)
  939. }
  940. if m.FieldCleared(agent.FieldBackground) {
  941. fields = append(fields, agent.FieldBackground)
  942. }
  943. if m.FieldCleared(agent.FieldExamples) {
  944. fields = append(fields, agent.FieldExamples)
  945. }
  946. return fields
  947. }
  948. // FieldCleared returns a boolean indicating if a field with the given name was
  949. // cleared in this mutation.
  950. func (m *AgentMutation) FieldCleared(name string) bool {
  951. _, ok := m.clearedFields[name]
  952. return ok
  953. }
  954. // ClearField clears the value of the field with the given name. It returns an
  955. // error if the field is not defined in the schema.
  956. func (m *AgentMutation) ClearField(name string) error {
  957. switch name {
  958. case agent.FieldDeletedAt:
  959. m.ClearDeletedAt()
  960. return nil
  961. case agent.FieldStatus:
  962. m.ClearStatus()
  963. return nil
  964. case agent.FieldBackground:
  965. m.ClearBackground()
  966. return nil
  967. case agent.FieldExamples:
  968. m.ClearExamples()
  969. return nil
  970. }
  971. return fmt.Errorf("unknown Agent nullable field %s", name)
  972. }
  973. // ResetField resets all changes in the mutation for the field with the given name.
  974. // It returns an error if the field is not defined in the schema.
  975. func (m *AgentMutation) ResetField(name string) error {
  976. switch name {
  977. case agent.FieldCreatedAt:
  978. m.ResetCreatedAt()
  979. return nil
  980. case agent.FieldUpdatedAt:
  981. m.ResetUpdatedAt()
  982. return nil
  983. case agent.FieldDeletedAt:
  984. m.ResetDeletedAt()
  985. return nil
  986. case agent.FieldName:
  987. m.ResetName()
  988. return nil
  989. case agent.FieldRole:
  990. m.ResetRole()
  991. return nil
  992. case agent.FieldStatus:
  993. m.ResetStatus()
  994. return nil
  995. case agent.FieldBackground:
  996. m.ResetBackground()
  997. return nil
  998. case agent.FieldExamples:
  999. m.ResetExamples()
  1000. return nil
  1001. case agent.FieldOrganizationID:
  1002. m.ResetOrganizationID()
  1003. return nil
  1004. case agent.FieldDatasetID:
  1005. m.ResetDatasetID()
  1006. return nil
  1007. case agent.FieldCollectionID:
  1008. m.ResetCollectionID()
  1009. return nil
  1010. }
  1011. return fmt.Errorf("unknown Agent field %s", name)
  1012. }
  1013. // AddedEdges returns all edge names that were set/added in this mutation.
  1014. func (m *AgentMutation) AddedEdges() []string {
  1015. edges := make([]string, 0, 1)
  1016. if m.wx_agent != nil {
  1017. edges = append(edges, agent.EdgeWxAgent)
  1018. }
  1019. return edges
  1020. }
  1021. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1022. // name in this mutation.
  1023. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1024. switch name {
  1025. case agent.EdgeWxAgent:
  1026. ids := make([]ent.Value, 0, len(m.wx_agent))
  1027. for id := range m.wx_agent {
  1028. ids = append(ids, id)
  1029. }
  1030. return ids
  1031. }
  1032. return nil
  1033. }
  1034. // RemovedEdges returns all edge names that were removed in this mutation.
  1035. func (m *AgentMutation) RemovedEdges() []string {
  1036. edges := make([]string, 0, 1)
  1037. if m.removedwx_agent != nil {
  1038. edges = append(edges, agent.EdgeWxAgent)
  1039. }
  1040. return edges
  1041. }
  1042. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1043. // the given name in this mutation.
  1044. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1045. switch name {
  1046. case agent.EdgeWxAgent:
  1047. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1048. for id := range m.removedwx_agent {
  1049. ids = append(ids, id)
  1050. }
  1051. return ids
  1052. }
  1053. return nil
  1054. }
  1055. // ClearedEdges returns all edge names that were cleared in this mutation.
  1056. func (m *AgentMutation) ClearedEdges() []string {
  1057. edges := make([]string, 0, 1)
  1058. if m.clearedwx_agent {
  1059. edges = append(edges, agent.EdgeWxAgent)
  1060. }
  1061. return edges
  1062. }
  1063. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1064. // was cleared in this mutation.
  1065. func (m *AgentMutation) EdgeCleared(name string) bool {
  1066. switch name {
  1067. case agent.EdgeWxAgent:
  1068. return m.clearedwx_agent
  1069. }
  1070. return false
  1071. }
  1072. // ClearEdge clears the value of the edge with the given name. It returns an error
  1073. // if that edge is not defined in the schema.
  1074. func (m *AgentMutation) ClearEdge(name string) error {
  1075. switch name {
  1076. }
  1077. return fmt.Errorf("unknown Agent unique edge %s", name)
  1078. }
  1079. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1080. // It returns an error if the edge is not defined in the schema.
  1081. func (m *AgentMutation) ResetEdge(name string) error {
  1082. switch name {
  1083. case agent.EdgeWxAgent:
  1084. m.ResetWxAgent()
  1085. return nil
  1086. }
  1087. return fmt.Errorf("unknown Agent edge %s", name)
  1088. }
  1089. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1090. type AgentBaseMutation struct {
  1091. config
  1092. op Op
  1093. typ string
  1094. id *string
  1095. q *string
  1096. a *string
  1097. chunk_index *uint64
  1098. addchunk_index *int64
  1099. indexes *[]string
  1100. appendindexes []string
  1101. dataset_id *string
  1102. collection_id *string
  1103. source_name *string
  1104. can_write *[]bool
  1105. appendcan_write []bool
  1106. is_owner *[]bool
  1107. appendis_owner []bool
  1108. clearedFields map[string]struct{}
  1109. wx_agent map[uint64]struct{}
  1110. removedwx_agent map[uint64]struct{}
  1111. clearedwx_agent bool
  1112. done bool
  1113. oldValue func(context.Context) (*AgentBase, error)
  1114. predicates []predicate.AgentBase
  1115. }
  1116. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1117. // agentbaseOption allows management of the mutation configuration using functional options.
  1118. type agentbaseOption func(*AgentBaseMutation)
  1119. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1120. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1121. m := &AgentBaseMutation{
  1122. config: c,
  1123. op: op,
  1124. typ: TypeAgentBase,
  1125. clearedFields: make(map[string]struct{}),
  1126. }
  1127. for _, opt := range opts {
  1128. opt(m)
  1129. }
  1130. return m
  1131. }
  1132. // withAgentBaseID sets the ID field of the mutation.
  1133. func withAgentBaseID(id string) agentbaseOption {
  1134. return func(m *AgentBaseMutation) {
  1135. var (
  1136. err error
  1137. once sync.Once
  1138. value *AgentBase
  1139. )
  1140. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1141. once.Do(func() {
  1142. if m.done {
  1143. err = errors.New("querying old values post mutation is not allowed")
  1144. } else {
  1145. value, err = m.Client().AgentBase.Get(ctx, id)
  1146. }
  1147. })
  1148. return value, err
  1149. }
  1150. m.id = &id
  1151. }
  1152. }
  1153. // withAgentBase sets the old AgentBase of the mutation.
  1154. func withAgentBase(node *AgentBase) agentbaseOption {
  1155. return func(m *AgentBaseMutation) {
  1156. m.oldValue = func(context.Context) (*AgentBase, error) {
  1157. return node, nil
  1158. }
  1159. m.id = &node.ID
  1160. }
  1161. }
  1162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1163. // executed in a transaction (ent.Tx), a transactional client is returned.
  1164. func (m AgentBaseMutation) Client() *Client {
  1165. client := &Client{config: m.config}
  1166. client.init()
  1167. return client
  1168. }
  1169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1170. // it returns an error otherwise.
  1171. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1172. if _, ok := m.driver.(*txDriver); !ok {
  1173. return nil, errors.New("ent: mutation is not running in a transaction")
  1174. }
  1175. tx := &Tx{config: m.config}
  1176. tx.init()
  1177. return tx, nil
  1178. }
  1179. // SetID sets the value of the id field. Note that this
  1180. // operation is only accepted on creation of AgentBase entities.
  1181. func (m *AgentBaseMutation) SetID(id string) {
  1182. m.id = &id
  1183. }
  1184. // ID returns the ID value in the mutation. Note that the ID is only available
  1185. // if it was provided to the builder or after it was returned from the database.
  1186. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1187. if m.id == nil {
  1188. return
  1189. }
  1190. return *m.id, true
  1191. }
  1192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1193. // That means, if the mutation is applied within a transaction with an isolation level such
  1194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1195. // or updated by the mutation.
  1196. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1197. switch {
  1198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1199. id, exists := m.ID()
  1200. if exists {
  1201. return []string{id}, nil
  1202. }
  1203. fallthrough
  1204. case m.op.Is(OpUpdate | OpDelete):
  1205. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1206. default:
  1207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1208. }
  1209. }
  1210. // SetQ sets the "q" field.
  1211. func (m *AgentBaseMutation) SetQ(s string) {
  1212. m.q = &s
  1213. }
  1214. // Q returns the value of the "q" field in the mutation.
  1215. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1216. v := m.q
  1217. if v == nil {
  1218. return
  1219. }
  1220. return *v, true
  1221. }
  1222. // OldQ returns the old "q" field's value of the AgentBase entity.
  1223. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1225. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1226. if !m.op.Is(OpUpdateOne) {
  1227. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1228. }
  1229. if m.id == nil || m.oldValue == nil {
  1230. return v, errors.New("OldQ requires an ID field in the mutation")
  1231. }
  1232. oldValue, err := m.oldValue(ctx)
  1233. if err != nil {
  1234. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1235. }
  1236. return oldValue.Q, nil
  1237. }
  1238. // ClearQ clears the value of the "q" field.
  1239. func (m *AgentBaseMutation) ClearQ() {
  1240. m.q = nil
  1241. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1242. }
  1243. // QCleared returns if the "q" field was cleared in this mutation.
  1244. func (m *AgentBaseMutation) QCleared() bool {
  1245. _, ok := m.clearedFields[agentbase.FieldQ]
  1246. return ok
  1247. }
  1248. // ResetQ resets all changes to the "q" field.
  1249. func (m *AgentBaseMutation) ResetQ() {
  1250. m.q = nil
  1251. delete(m.clearedFields, agentbase.FieldQ)
  1252. }
  1253. // SetA sets the "a" field.
  1254. func (m *AgentBaseMutation) SetA(s string) {
  1255. m.a = &s
  1256. }
  1257. // A returns the value of the "a" field in the mutation.
  1258. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1259. v := m.a
  1260. if v == nil {
  1261. return
  1262. }
  1263. return *v, true
  1264. }
  1265. // OldA returns the old "a" field's value of the AgentBase entity.
  1266. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1268. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1269. if !m.op.Is(OpUpdateOne) {
  1270. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1271. }
  1272. if m.id == nil || m.oldValue == nil {
  1273. return v, errors.New("OldA requires an ID field in the mutation")
  1274. }
  1275. oldValue, err := m.oldValue(ctx)
  1276. if err != nil {
  1277. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1278. }
  1279. return oldValue.A, nil
  1280. }
  1281. // ClearA clears the value of the "a" field.
  1282. func (m *AgentBaseMutation) ClearA() {
  1283. m.a = nil
  1284. m.clearedFields[agentbase.FieldA] = struct{}{}
  1285. }
  1286. // ACleared returns if the "a" field was cleared in this mutation.
  1287. func (m *AgentBaseMutation) ACleared() bool {
  1288. _, ok := m.clearedFields[agentbase.FieldA]
  1289. return ok
  1290. }
  1291. // ResetA resets all changes to the "a" field.
  1292. func (m *AgentBaseMutation) ResetA() {
  1293. m.a = nil
  1294. delete(m.clearedFields, agentbase.FieldA)
  1295. }
  1296. // SetChunkIndex sets the "chunk_index" field.
  1297. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1298. m.chunk_index = &u
  1299. m.addchunk_index = nil
  1300. }
  1301. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1302. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1303. v := m.chunk_index
  1304. if v == nil {
  1305. return
  1306. }
  1307. return *v, true
  1308. }
  1309. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1310. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1312. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1313. if !m.op.Is(OpUpdateOne) {
  1314. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1315. }
  1316. if m.id == nil || m.oldValue == nil {
  1317. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1318. }
  1319. oldValue, err := m.oldValue(ctx)
  1320. if err != nil {
  1321. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1322. }
  1323. return oldValue.ChunkIndex, nil
  1324. }
  1325. // AddChunkIndex adds u to the "chunk_index" field.
  1326. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1327. if m.addchunk_index != nil {
  1328. *m.addchunk_index += u
  1329. } else {
  1330. m.addchunk_index = &u
  1331. }
  1332. }
  1333. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1334. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1335. v := m.addchunk_index
  1336. if v == nil {
  1337. return
  1338. }
  1339. return *v, true
  1340. }
  1341. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1342. func (m *AgentBaseMutation) ResetChunkIndex() {
  1343. m.chunk_index = nil
  1344. m.addchunk_index = nil
  1345. }
  1346. // SetIndexes sets the "indexes" field.
  1347. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1348. m.indexes = &s
  1349. m.appendindexes = nil
  1350. }
  1351. // Indexes returns the value of the "indexes" field in the mutation.
  1352. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1353. v := m.indexes
  1354. if v == nil {
  1355. return
  1356. }
  1357. return *v, true
  1358. }
  1359. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1360. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1362. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1363. if !m.op.Is(OpUpdateOne) {
  1364. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1365. }
  1366. if m.id == nil || m.oldValue == nil {
  1367. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1368. }
  1369. oldValue, err := m.oldValue(ctx)
  1370. if err != nil {
  1371. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1372. }
  1373. return oldValue.Indexes, nil
  1374. }
  1375. // AppendIndexes adds s to the "indexes" field.
  1376. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1377. m.appendindexes = append(m.appendindexes, s...)
  1378. }
  1379. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1380. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1381. if len(m.appendindexes) == 0 {
  1382. return nil, false
  1383. }
  1384. return m.appendindexes, true
  1385. }
  1386. // ClearIndexes clears the value of the "indexes" field.
  1387. func (m *AgentBaseMutation) ClearIndexes() {
  1388. m.indexes = nil
  1389. m.appendindexes = nil
  1390. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1391. }
  1392. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1393. func (m *AgentBaseMutation) IndexesCleared() bool {
  1394. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1395. return ok
  1396. }
  1397. // ResetIndexes resets all changes to the "indexes" field.
  1398. func (m *AgentBaseMutation) ResetIndexes() {
  1399. m.indexes = nil
  1400. m.appendindexes = nil
  1401. delete(m.clearedFields, agentbase.FieldIndexes)
  1402. }
  1403. // SetDatasetID sets the "dataset_id" field.
  1404. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1405. m.dataset_id = &s
  1406. }
  1407. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1408. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1409. v := m.dataset_id
  1410. if v == nil {
  1411. return
  1412. }
  1413. return *v, true
  1414. }
  1415. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1416. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1418. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1419. if !m.op.Is(OpUpdateOne) {
  1420. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1421. }
  1422. if m.id == nil || m.oldValue == nil {
  1423. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1424. }
  1425. oldValue, err := m.oldValue(ctx)
  1426. if err != nil {
  1427. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1428. }
  1429. return oldValue.DatasetID, nil
  1430. }
  1431. // ClearDatasetID clears the value of the "dataset_id" field.
  1432. func (m *AgentBaseMutation) ClearDatasetID() {
  1433. m.dataset_id = nil
  1434. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1435. }
  1436. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1437. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1438. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1439. return ok
  1440. }
  1441. // ResetDatasetID resets all changes to the "dataset_id" field.
  1442. func (m *AgentBaseMutation) ResetDatasetID() {
  1443. m.dataset_id = nil
  1444. delete(m.clearedFields, agentbase.FieldDatasetID)
  1445. }
  1446. // SetCollectionID sets the "collection_id" field.
  1447. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1448. m.collection_id = &s
  1449. }
  1450. // CollectionID returns the value of the "collection_id" field in the mutation.
  1451. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1452. v := m.collection_id
  1453. if v == nil {
  1454. return
  1455. }
  1456. return *v, true
  1457. }
  1458. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1459. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1461. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1462. if !m.op.Is(OpUpdateOne) {
  1463. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1464. }
  1465. if m.id == nil || m.oldValue == nil {
  1466. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1467. }
  1468. oldValue, err := m.oldValue(ctx)
  1469. if err != nil {
  1470. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1471. }
  1472. return oldValue.CollectionID, nil
  1473. }
  1474. // ClearCollectionID clears the value of the "collection_id" field.
  1475. func (m *AgentBaseMutation) ClearCollectionID() {
  1476. m.collection_id = nil
  1477. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1478. }
  1479. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1480. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1481. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1482. return ok
  1483. }
  1484. // ResetCollectionID resets all changes to the "collection_id" field.
  1485. func (m *AgentBaseMutation) ResetCollectionID() {
  1486. m.collection_id = nil
  1487. delete(m.clearedFields, agentbase.FieldCollectionID)
  1488. }
  1489. // SetSourceName sets the "source_name" field.
  1490. func (m *AgentBaseMutation) SetSourceName(s string) {
  1491. m.source_name = &s
  1492. }
  1493. // SourceName returns the value of the "source_name" field in the mutation.
  1494. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1495. v := m.source_name
  1496. if v == nil {
  1497. return
  1498. }
  1499. return *v, true
  1500. }
  1501. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1502. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1504. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1505. if !m.op.Is(OpUpdateOne) {
  1506. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1507. }
  1508. if m.id == nil || m.oldValue == nil {
  1509. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1510. }
  1511. oldValue, err := m.oldValue(ctx)
  1512. if err != nil {
  1513. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1514. }
  1515. return oldValue.SourceName, nil
  1516. }
  1517. // ClearSourceName clears the value of the "source_name" field.
  1518. func (m *AgentBaseMutation) ClearSourceName() {
  1519. m.source_name = nil
  1520. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1521. }
  1522. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1523. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1524. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1525. return ok
  1526. }
  1527. // ResetSourceName resets all changes to the "source_name" field.
  1528. func (m *AgentBaseMutation) ResetSourceName() {
  1529. m.source_name = nil
  1530. delete(m.clearedFields, agentbase.FieldSourceName)
  1531. }
  1532. // SetCanWrite sets the "can_write" field.
  1533. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1534. m.can_write = &b
  1535. m.appendcan_write = nil
  1536. }
  1537. // CanWrite returns the value of the "can_write" field in the mutation.
  1538. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1539. v := m.can_write
  1540. if v == nil {
  1541. return
  1542. }
  1543. return *v, true
  1544. }
  1545. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1546. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1548. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1549. if !m.op.Is(OpUpdateOne) {
  1550. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1551. }
  1552. if m.id == nil || m.oldValue == nil {
  1553. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1554. }
  1555. oldValue, err := m.oldValue(ctx)
  1556. if err != nil {
  1557. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1558. }
  1559. return oldValue.CanWrite, nil
  1560. }
  1561. // AppendCanWrite adds b to the "can_write" field.
  1562. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1563. m.appendcan_write = append(m.appendcan_write, b...)
  1564. }
  1565. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1566. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1567. if len(m.appendcan_write) == 0 {
  1568. return nil, false
  1569. }
  1570. return m.appendcan_write, true
  1571. }
  1572. // ClearCanWrite clears the value of the "can_write" field.
  1573. func (m *AgentBaseMutation) ClearCanWrite() {
  1574. m.can_write = nil
  1575. m.appendcan_write = nil
  1576. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1577. }
  1578. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1579. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1580. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1581. return ok
  1582. }
  1583. // ResetCanWrite resets all changes to the "can_write" field.
  1584. func (m *AgentBaseMutation) ResetCanWrite() {
  1585. m.can_write = nil
  1586. m.appendcan_write = nil
  1587. delete(m.clearedFields, agentbase.FieldCanWrite)
  1588. }
  1589. // SetIsOwner sets the "is_owner" field.
  1590. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1591. m.is_owner = &b
  1592. m.appendis_owner = nil
  1593. }
  1594. // IsOwner returns the value of the "is_owner" field in the mutation.
  1595. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1596. v := m.is_owner
  1597. if v == nil {
  1598. return
  1599. }
  1600. return *v, true
  1601. }
  1602. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1603. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1605. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1606. if !m.op.Is(OpUpdateOne) {
  1607. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1608. }
  1609. if m.id == nil || m.oldValue == nil {
  1610. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1611. }
  1612. oldValue, err := m.oldValue(ctx)
  1613. if err != nil {
  1614. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1615. }
  1616. return oldValue.IsOwner, nil
  1617. }
  1618. // AppendIsOwner adds b to the "is_owner" field.
  1619. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1620. m.appendis_owner = append(m.appendis_owner, b...)
  1621. }
  1622. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1623. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1624. if len(m.appendis_owner) == 0 {
  1625. return nil, false
  1626. }
  1627. return m.appendis_owner, true
  1628. }
  1629. // ClearIsOwner clears the value of the "is_owner" field.
  1630. func (m *AgentBaseMutation) ClearIsOwner() {
  1631. m.is_owner = nil
  1632. m.appendis_owner = nil
  1633. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1634. }
  1635. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1636. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1637. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1638. return ok
  1639. }
  1640. // ResetIsOwner resets all changes to the "is_owner" field.
  1641. func (m *AgentBaseMutation) ResetIsOwner() {
  1642. m.is_owner = nil
  1643. m.appendis_owner = nil
  1644. delete(m.clearedFields, agentbase.FieldIsOwner)
  1645. }
  1646. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1647. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1648. if m.wx_agent == nil {
  1649. m.wx_agent = make(map[uint64]struct{})
  1650. }
  1651. for i := range ids {
  1652. m.wx_agent[ids[i]] = struct{}{}
  1653. }
  1654. }
  1655. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1656. func (m *AgentBaseMutation) ClearWxAgent() {
  1657. m.clearedwx_agent = true
  1658. }
  1659. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1660. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1661. return m.clearedwx_agent
  1662. }
  1663. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1664. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1665. if m.removedwx_agent == nil {
  1666. m.removedwx_agent = make(map[uint64]struct{})
  1667. }
  1668. for i := range ids {
  1669. delete(m.wx_agent, ids[i])
  1670. m.removedwx_agent[ids[i]] = struct{}{}
  1671. }
  1672. }
  1673. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1674. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1675. for id := range m.removedwx_agent {
  1676. ids = append(ids, id)
  1677. }
  1678. return
  1679. }
  1680. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1681. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1682. for id := range m.wx_agent {
  1683. ids = append(ids, id)
  1684. }
  1685. return
  1686. }
  1687. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1688. func (m *AgentBaseMutation) ResetWxAgent() {
  1689. m.wx_agent = nil
  1690. m.clearedwx_agent = false
  1691. m.removedwx_agent = nil
  1692. }
  1693. // Where appends a list predicates to the AgentBaseMutation builder.
  1694. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1695. m.predicates = append(m.predicates, ps...)
  1696. }
  1697. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1698. // users can use type-assertion to append predicates that do not depend on any generated package.
  1699. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1700. p := make([]predicate.AgentBase, len(ps))
  1701. for i := range ps {
  1702. p[i] = ps[i]
  1703. }
  1704. m.Where(p...)
  1705. }
  1706. // Op returns the operation name.
  1707. func (m *AgentBaseMutation) Op() Op {
  1708. return m.op
  1709. }
  1710. // SetOp allows setting the mutation operation.
  1711. func (m *AgentBaseMutation) SetOp(op Op) {
  1712. m.op = op
  1713. }
  1714. // Type returns the node type of this mutation (AgentBase).
  1715. func (m *AgentBaseMutation) Type() string {
  1716. return m.typ
  1717. }
  1718. // Fields returns all fields that were changed during this mutation. Note that in
  1719. // order to get all numeric fields that were incremented/decremented, call
  1720. // AddedFields().
  1721. func (m *AgentBaseMutation) Fields() []string {
  1722. fields := make([]string, 0, 9)
  1723. if m.q != nil {
  1724. fields = append(fields, agentbase.FieldQ)
  1725. }
  1726. if m.a != nil {
  1727. fields = append(fields, agentbase.FieldA)
  1728. }
  1729. if m.chunk_index != nil {
  1730. fields = append(fields, agentbase.FieldChunkIndex)
  1731. }
  1732. if m.indexes != nil {
  1733. fields = append(fields, agentbase.FieldIndexes)
  1734. }
  1735. if m.dataset_id != nil {
  1736. fields = append(fields, agentbase.FieldDatasetID)
  1737. }
  1738. if m.collection_id != nil {
  1739. fields = append(fields, agentbase.FieldCollectionID)
  1740. }
  1741. if m.source_name != nil {
  1742. fields = append(fields, agentbase.FieldSourceName)
  1743. }
  1744. if m.can_write != nil {
  1745. fields = append(fields, agentbase.FieldCanWrite)
  1746. }
  1747. if m.is_owner != nil {
  1748. fields = append(fields, agentbase.FieldIsOwner)
  1749. }
  1750. return fields
  1751. }
  1752. // Field returns the value of a field with the given name. The second boolean
  1753. // return value indicates that this field was not set, or was not defined in the
  1754. // schema.
  1755. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1756. switch name {
  1757. case agentbase.FieldQ:
  1758. return m.Q()
  1759. case agentbase.FieldA:
  1760. return m.A()
  1761. case agentbase.FieldChunkIndex:
  1762. return m.ChunkIndex()
  1763. case agentbase.FieldIndexes:
  1764. return m.Indexes()
  1765. case agentbase.FieldDatasetID:
  1766. return m.DatasetID()
  1767. case agentbase.FieldCollectionID:
  1768. return m.CollectionID()
  1769. case agentbase.FieldSourceName:
  1770. return m.SourceName()
  1771. case agentbase.FieldCanWrite:
  1772. return m.CanWrite()
  1773. case agentbase.FieldIsOwner:
  1774. return m.IsOwner()
  1775. }
  1776. return nil, false
  1777. }
  1778. // OldField returns the old value of the field from the database. An error is
  1779. // returned if the mutation operation is not UpdateOne, or the query to the
  1780. // database failed.
  1781. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1782. switch name {
  1783. case agentbase.FieldQ:
  1784. return m.OldQ(ctx)
  1785. case agentbase.FieldA:
  1786. return m.OldA(ctx)
  1787. case agentbase.FieldChunkIndex:
  1788. return m.OldChunkIndex(ctx)
  1789. case agentbase.FieldIndexes:
  1790. return m.OldIndexes(ctx)
  1791. case agentbase.FieldDatasetID:
  1792. return m.OldDatasetID(ctx)
  1793. case agentbase.FieldCollectionID:
  1794. return m.OldCollectionID(ctx)
  1795. case agentbase.FieldSourceName:
  1796. return m.OldSourceName(ctx)
  1797. case agentbase.FieldCanWrite:
  1798. return m.OldCanWrite(ctx)
  1799. case agentbase.FieldIsOwner:
  1800. return m.OldIsOwner(ctx)
  1801. }
  1802. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1803. }
  1804. // SetField sets the value of a field with the given name. It returns an error if
  1805. // the field is not defined in the schema, or if the type mismatched the field
  1806. // type.
  1807. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1808. switch name {
  1809. case agentbase.FieldQ:
  1810. v, ok := value.(string)
  1811. if !ok {
  1812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1813. }
  1814. m.SetQ(v)
  1815. return nil
  1816. case agentbase.FieldA:
  1817. v, ok := value.(string)
  1818. if !ok {
  1819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1820. }
  1821. m.SetA(v)
  1822. return nil
  1823. case agentbase.FieldChunkIndex:
  1824. v, ok := value.(uint64)
  1825. if !ok {
  1826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1827. }
  1828. m.SetChunkIndex(v)
  1829. return nil
  1830. case agentbase.FieldIndexes:
  1831. v, ok := value.([]string)
  1832. if !ok {
  1833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1834. }
  1835. m.SetIndexes(v)
  1836. return nil
  1837. case agentbase.FieldDatasetID:
  1838. v, ok := value.(string)
  1839. if !ok {
  1840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1841. }
  1842. m.SetDatasetID(v)
  1843. return nil
  1844. case agentbase.FieldCollectionID:
  1845. v, ok := value.(string)
  1846. if !ok {
  1847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1848. }
  1849. m.SetCollectionID(v)
  1850. return nil
  1851. case agentbase.FieldSourceName:
  1852. v, ok := value.(string)
  1853. if !ok {
  1854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1855. }
  1856. m.SetSourceName(v)
  1857. return nil
  1858. case agentbase.FieldCanWrite:
  1859. v, ok := value.([]bool)
  1860. if !ok {
  1861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1862. }
  1863. m.SetCanWrite(v)
  1864. return nil
  1865. case agentbase.FieldIsOwner:
  1866. v, ok := value.([]bool)
  1867. if !ok {
  1868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1869. }
  1870. m.SetIsOwner(v)
  1871. return nil
  1872. }
  1873. return fmt.Errorf("unknown AgentBase field %s", name)
  1874. }
  1875. // AddedFields returns all numeric fields that were incremented/decremented during
  1876. // this mutation.
  1877. func (m *AgentBaseMutation) AddedFields() []string {
  1878. var fields []string
  1879. if m.addchunk_index != nil {
  1880. fields = append(fields, agentbase.FieldChunkIndex)
  1881. }
  1882. return fields
  1883. }
  1884. // AddedField returns the numeric value that was incremented/decremented on a field
  1885. // with the given name. The second boolean return value indicates that this field
  1886. // was not set, or was not defined in the schema.
  1887. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1888. switch name {
  1889. case agentbase.FieldChunkIndex:
  1890. return m.AddedChunkIndex()
  1891. }
  1892. return nil, false
  1893. }
  1894. // AddField adds the value to the field with the given name. It returns an error if
  1895. // the field is not defined in the schema, or if the type mismatched the field
  1896. // type.
  1897. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1898. switch name {
  1899. case agentbase.FieldChunkIndex:
  1900. v, ok := value.(int64)
  1901. if !ok {
  1902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1903. }
  1904. m.AddChunkIndex(v)
  1905. return nil
  1906. }
  1907. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1908. }
  1909. // ClearedFields returns all nullable fields that were cleared during this
  1910. // mutation.
  1911. func (m *AgentBaseMutation) ClearedFields() []string {
  1912. var fields []string
  1913. if m.FieldCleared(agentbase.FieldQ) {
  1914. fields = append(fields, agentbase.FieldQ)
  1915. }
  1916. if m.FieldCleared(agentbase.FieldA) {
  1917. fields = append(fields, agentbase.FieldA)
  1918. }
  1919. if m.FieldCleared(agentbase.FieldIndexes) {
  1920. fields = append(fields, agentbase.FieldIndexes)
  1921. }
  1922. if m.FieldCleared(agentbase.FieldDatasetID) {
  1923. fields = append(fields, agentbase.FieldDatasetID)
  1924. }
  1925. if m.FieldCleared(agentbase.FieldCollectionID) {
  1926. fields = append(fields, agentbase.FieldCollectionID)
  1927. }
  1928. if m.FieldCleared(agentbase.FieldSourceName) {
  1929. fields = append(fields, agentbase.FieldSourceName)
  1930. }
  1931. if m.FieldCleared(agentbase.FieldCanWrite) {
  1932. fields = append(fields, agentbase.FieldCanWrite)
  1933. }
  1934. if m.FieldCleared(agentbase.FieldIsOwner) {
  1935. fields = append(fields, agentbase.FieldIsOwner)
  1936. }
  1937. return fields
  1938. }
  1939. // FieldCleared returns a boolean indicating if a field with the given name was
  1940. // cleared in this mutation.
  1941. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  1942. _, ok := m.clearedFields[name]
  1943. return ok
  1944. }
  1945. // ClearField clears the value of the field with the given name. It returns an
  1946. // error if the field is not defined in the schema.
  1947. func (m *AgentBaseMutation) ClearField(name string) error {
  1948. switch name {
  1949. case agentbase.FieldQ:
  1950. m.ClearQ()
  1951. return nil
  1952. case agentbase.FieldA:
  1953. m.ClearA()
  1954. return nil
  1955. case agentbase.FieldIndexes:
  1956. m.ClearIndexes()
  1957. return nil
  1958. case agentbase.FieldDatasetID:
  1959. m.ClearDatasetID()
  1960. return nil
  1961. case agentbase.FieldCollectionID:
  1962. m.ClearCollectionID()
  1963. return nil
  1964. case agentbase.FieldSourceName:
  1965. m.ClearSourceName()
  1966. return nil
  1967. case agentbase.FieldCanWrite:
  1968. m.ClearCanWrite()
  1969. return nil
  1970. case agentbase.FieldIsOwner:
  1971. m.ClearIsOwner()
  1972. return nil
  1973. }
  1974. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  1975. }
  1976. // ResetField resets all changes in the mutation for the field with the given name.
  1977. // It returns an error if the field is not defined in the schema.
  1978. func (m *AgentBaseMutation) ResetField(name string) error {
  1979. switch name {
  1980. case agentbase.FieldQ:
  1981. m.ResetQ()
  1982. return nil
  1983. case agentbase.FieldA:
  1984. m.ResetA()
  1985. return nil
  1986. case agentbase.FieldChunkIndex:
  1987. m.ResetChunkIndex()
  1988. return nil
  1989. case agentbase.FieldIndexes:
  1990. m.ResetIndexes()
  1991. return nil
  1992. case agentbase.FieldDatasetID:
  1993. m.ResetDatasetID()
  1994. return nil
  1995. case agentbase.FieldCollectionID:
  1996. m.ResetCollectionID()
  1997. return nil
  1998. case agentbase.FieldSourceName:
  1999. m.ResetSourceName()
  2000. return nil
  2001. case agentbase.FieldCanWrite:
  2002. m.ResetCanWrite()
  2003. return nil
  2004. case agentbase.FieldIsOwner:
  2005. m.ResetIsOwner()
  2006. return nil
  2007. }
  2008. return fmt.Errorf("unknown AgentBase field %s", name)
  2009. }
  2010. // AddedEdges returns all edge names that were set/added in this mutation.
  2011. func (m *AgentBaseMutation) AddedEdges() []string {
  2012. edges := make([]string, 0, 1)
  2013. if m.wx_agent != nil {
  2014. edges = append(edges, agentbase.EdgeWxAgent)
  2015. }
  2016. return edges
  2017. }
  2018. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2019. // name in this mutation.
  2020. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2021. switch name {
  2022. case agentbase.EdgeWxAgent:
  2023. ids := make([]ent.Value, 0, len(m.wx_agent))
  2024. for id := range m.wx_agent {
  2025. ids = append(ids, id)
  2026. }
  2027. return ids
  2028. }
  2029. return nil
  2030. }
  2031. // RemovedEdges returns all edge names that were removed in this mutation.
  2032. func (m *AgentBaseMutation) RemovedEdges() []string {
  2033. edges := make([]string, 0, 1)
  2034. if m.removedwx_agent != nil {
  2035. edges = append(edges, agentbase.EdgeWxAgent)
  2036. }
  2037. return edges
  2038. }
  2039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2040. // the given name in this mutation.
  2041. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2042. switch name {
  2043. case agentbase.EdgeWxAgent:
  2044. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2045. for id := range m.removedwx_agent {
  2046. ids = append(ids, id)
  2047. }
  2048. return ids
  2049. }
  2050. return nil
  2051. }
  2052. // ClearedEdges returns all edge names that were cleared in this mutation.
  2053. func (m *AgentBaseMutation) ClearedEdges() []string {
  2054. edges := make([]string, 0, 1)
  2055. if m.clearedwx_agent {
  2056. edges = append(edges, agentbase.EdgeWxAgent)
  2057. }
  2058. return edges
  2059. }
  2060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2061. // was cleared in this mutation.
  2062. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2063. switch name {
  2064. case agentbase.EdgeWxAgent:
  2065. return m.clearedwx_agent
  2066. }
  2067. return false
  2068. }
  2069. // ClearEdge clears the value of the edge with the given name. It returns an error
  2070. // if that edge is not defined in the schema.
  2071. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2072. switch name {
  2073. }
  2074. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2075. }
  2076. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2077. // It returns an error if the edge is not defined in the schema.
  2078. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2079. switch name {
  2080. case agentbase.EdgeWxAgent:
  2081. m.ResetWxAgent()
  2082. return nil
  2083. }
  2084. return fmt.Errorf("unknown AgentBase edge %s", name)
  2085. }
  2086. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  2087. type BatchMsgMutation struct {
  2088. config
  2089. op Op
  2090. typ string
  2091. id *uint64
  2092. created_at *time.Time
  2093. updated_at *time.Time
  2094. deleted_at *time.Time
  2095. status *uint8
  2096. addstatus *int8
  2097. batch_no *string
  2098. task_name *string
  2099. fromwxid *string
  2100. msg *string
  2101. tag *string
  2102. tagids *string
  2103. total *int32
  2104. addtotal *int32
  2105. success *int32
  2106. addsuccess *int32
  2107. fail *int32
  2108. addfail *int32
  2109. start_time *time.Time
  2110. stop_time *time.Time
  2111. send_time *time.Time
  2112. _type *int32
  2113. add_type *int32
  2114. organization_id *uint64
  2115. addorganization_id *int64
  2116. clearedFields map[string]struct{}
  2117. done bool
  2118. oldValue func(context.Context) (*BatchMsg, error)
  2119. predicates []predicate.BatchMsg
  2120. }
  2121. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  2122. // batchmsgOption allows management of the mutation configuration using functional options.
  2123. type batchmsgOption func(*BatchMsgMutation)
  2124. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  2125. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  2126. m := &BatchMsgMutation{
  2127. config: c,
  2128. op: op,
  2129. typ: TypeBatchMsg,
  2130. clearedFields: make(map[string]struct{}),
  2131. }
  2132. for _, opt := range opts {
  2133. opt(m)
  2134. }
  2135. return m
  2136. }
  2137. // withBatchMsgID sets the ID field of the mutation.
  2138. func withBatchMsgID(id uint64) batchmsgOption {
  2139. return func(m *BatchMsgMutation) {
  2140. var (
  2141. err error
  2142. once sync.Once
  2143. value *BatchMsg
  2144. )
  2145. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  2146. once.Do(func() {
  2147. if m.done {
  2148. err = errors.New("querying old values post mutation is not allowed")
  2149. } else {
  2150. value, err = m.Client().BatchMsg.Get(ctx, id)
  2151. }
  2152. })
  2153. return value, err
  2154. }
  2155. m.id = &id
  2156. }
  2157. }
  2158. // withBatchMsg sets the old BatchMsg of the mutation.
  2159. func withBatchMsg(node *BatchMsg) batchmsgOption {
  2160. return func(m *BatchMsgMutation) {
  2161. m.oldValue = func(context.Context) (*BatchMsg, error) {
  2162. return node, nil
  2163. }
  2164. m.id = &node.ID
  2165. }
  2166. }
  2167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2168. // executed in a transaction (ent.Tx), a transactional client is returned.
  2169. func (m BatchMsgMutation) Client() *Client {
  2170. client := &Client{config: m.config}
  2171. client.init()
  2172. return client
  2173. }
  2174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2175. // it returns an error otherwise.
  2176. func (m BatchMsgMutation) Tx() (*Tx, error) {
  2177. if _, ok := m.driver.(*txDriver); !ok {
  2178. return nil, errors.New("ent: mutation is not running in a transaction")
  2179. }
  2180. tx := &Tx{config: m.config}
  2181. tx.init()
  2182. return tx, nil
  2183. }
  2184. // SetID sets the value of the id field. Note that this
  2185. // operation is only accepted on creation of BatchMsg entities.
  2186. func (m *BatchMsgMutation) SetID(id uint64) {
  2187. m.id = &id
  2188. }
  2189. // ID returns the ID value in the mutation. Note that the ID is only available
  2190. // if it was provided to the builder or after it was returned from the database.
  2191. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  2192. if m.id == nil {
  2193. return
  2194. }
  2195. return *m.id, true
  2196. }
  2197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2198. // That means, if the mutation is applied within a transaction with an isolation level such
  2199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2200. // or updated by the mutation.
  2201. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  2202. switch {
  2203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2204. id, exists := m.ID()
  2205. if exists {
  2206. return []uint64{id}, nil
  2207. }
  2208. fallthrough
  2209. case m.op.Is(OpUpdate | OpDelete):
  2210. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  2211. default:
  2212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2213. }
  2214. }
  2215. // SetCreatedAt sets the "created_at" field.
  2216. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  2217. m.created_at = &t
  2218. }
  2219. // CreatedAt returns the value of the "created_at" field in the mutation.
  2220. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  2221. v := m.created_at
  2222. if v == nil {
  2223. return
  2224. }
  2225. return *v, true
  2226. }
  2227. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  2228. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2230. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2231. if !m.op.Is(OpUpdateOne) {
  2232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2233. }
  2234. if m.id == nil || m.oldValue == nil {
  2235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2236. }
  2237. oldValue, err := m.oldValue(ctx)
  2238. if err != nil {
  2239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2240. }
  2241. return oldValue.CreatedAt, nil
  2242. }
  2243. // ResetCreatedAt resets all changes to the "created_at" field.
  2244. func (m *BatchMsgMutation) ResetCreatedAt() {
  2245. m.created_at = nil
  2246. }
  2247. // SetUpdatedAt sets the "updated_at" field.
  2248. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  2249. m.updated_at = &t
  2250. }
  2251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2252. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  2253. v := m.updated_at
  2254. if v == nil {
  2255. return
  2256. }
  2257. return *v, true
  2258. }
  2259. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  2260. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2262. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2263. if !m.op.Is(OpUpdateOne) {
  2264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2265. }
  2266. if m.id == nil || m.oldValue == nil {
  2267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2268. }
  2269. oldValue, err := m.oldValue(ctx)
  2270. if err != nil {
  2271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2272. }
  2273. return oldValue.UpdatedAt, nil
  2274. }
  2275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2276. func (m *BatchMsgMutation) ResetUpdatedAt() {
  2277. m.updated_at = nil
  2278. }
  2279. // SetDeletedAt sets the "deleted_at" field.
  2280. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  2281. m.deleted_at = &t
  2282. }
  2283. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2284. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  2285. v := m.deleted_at
  2286. if v == nil {
  2287. return
  2288. }
  2289. return *v, true
  2290. }
  2291. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  2292. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2294. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2295. if !m.op.Is(OpUpdateOne) {
  2296. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2297. }
  2298. if m.id == nil || m.oldValue == nil {
  2299. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2300. }
  2301. oldValue, err := m.oldValue(ctx)
  2302. if err != nil {
  2303. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2304. }
  2305. return oldValue.DeletedAt, nil
  2306. }
  2307. // ClearDeletedAt clears the value of the "deleted_at" field.
  2308. func (m *BatchMsgMutation) ClearDeletedAt() {
  2309. m.deleted_at = nil
  2310. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  2311. }
  2312. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2313. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  2314. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  2315. return ok
  2316. }
  2317. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2318. func (m *BatchMsgMutation) ResetDeletedAt() {
  2319. m.deleted_at = nil
  2320. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  2321. }
  2322. // SetStatus sets the "status" field.
  2323. func (m *BatchMsgMutation) SetStatus(u uint8) {
  2324. m.status = &u
  2325. m.addstatus = nil
  2326. }
  2327. // Status returns the value of the "status" field in the mutation.
  2328. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  2329. v := m.status
  2330. if v == nil {
  2331. return
  2332. }
  2333. return *v, true
  2334. }
  2335. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  2336. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2338. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2339. if !m.op.Is(OpUpdateOne) {
  2340. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2341. }
  2342. if m.id == nil || m.oldValue == nil {
  2343. return v, errors.New("OldStatus requires an ID field in the mutation")
  2344. }
  2345. oldValue, err := m.oldValue(ctx)
  2346. if err != nil {
  2347. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2348. }
  2349. return oldValue.Status, nil
  2350. }
  2351. // AddStatus adds u to the "status" field.
  2352. func (m *BatchMsgMutation) AddStatus(u int8) {
  2353. if m.addstatus != nil {
  2354. *m.addstatus += u
  2355. } else {
  2356. m.addstatus = &u
  2357. }
  2358. }
  2359. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2360. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  2361. v := m.addstatus
  2362. if v == nil {
  2363. return
  2364. }
  2365. return *v, true
  2366. }
  2367. // ClearStatus clears the value of the "status" field.
  2368. func (m *BatchMsgMutation) ClearStatus() {
  2369. m.status = nil
  2370. m.addstatus = nil
  2371. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  2372. }
  2373. // StatusCleared returns if the "status" field was cleared in this mutation.
  2374. func (m *BatchMsgMutation) StatusCleared() bool {
  2375. _, ok := m.clearedFields[batchmsg.FieldStatus]
  2376. return ok
  2377. }
  2378. // ResetStatus resets all changes to the "status" field.
  2379. func (m *BatchMsgMutation) ResetStatus() {
  2380. m.status = nil
  2381. m.addstatus = nil
  2382. delete(m.clearedFields, batchmsg.FieldStatus)
  2383. }
  2384. // SetBatchNo sets the "batch_no" field.
  2385. func (m *BatchMsgMutation) SetBatchNo(s string) {
  2386. m.batch_no = &s
  2387. }
  2388. // BatchNo returns the value of the "batch_no" field in the mutation.
  2389. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  2390. v := m.batch_no
  2391. if v == nil {
  2392. return
  2393. }
  2394. return *v, true
  2395. }
  2396. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  2397. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2399. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  2400. if !m.op.Is(OpUpdateOne) {
  2401. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  2402. }
  2403. if m.id == nil || m.oldValue == nil {
  2404. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  2405. }
  2406. oldValue, err := m.oldValue(ctx)
  2407. if err != nil {
  2408. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  2409. }
  2410. return oldValue.BatchNo, nil
  2411. }
  2412. // ClearBatchNo clears the value of the "batch_no" field.
  2413. func (m *BatchMsgMutation) ClearBatchNo() {
  2414. m.batch_no = nil
  2415. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  2416. }
  2417. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  2418. func (m *BatchMsgMutation) BatchNoCleared() bool {
  2419. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  2420. return ok
  2421. }
  2422. // ResetBatchNo resets all changes to the "batch_no" field.
  2423. func (m *BatchMsgMutation) ResetBatchNo() {
  2424. m.batch_no = nil
  2425. delete(m.clearedFields, batchmsg.FieldBatchNo)
  2426. }
  2427. // SetTaskName sets the "task_name" field.
  2428. func (m *BatchMsgMutation) SetTaskName(s string) {
  2429. m.task_name = &s
  2430. }
  2431. // TaskName returns the value of the "task_name" field in the mutation.
  2432. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  2433. v := m.task_name
  2434. if v == nil {
  2435. return
  2436. }
  2437. return *v, true
  2438. }
  2439. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  2440. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2442. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  2443. if !m.op.Is(OpUpdateOne) {
  2444. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  2445. }
  2446. if m.id == nil || m.oldValue == nil {
  2447. return v, errors.New("OldTaskName requires an ID field in the mutation")
  2448. }
  2449. oldValue, err := m.oldValue(ctx)
  2450. if err != nil {
  2451. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  2452. }
  2453. return oldValue.TaskName, nil
  2454. }
  2455. // ClearTaskName clears the value of the "task_name" field.
  2456. func (m *BatchMsgMutation) ClearTaskName() {
  2457. m.task_name = nil
  2458. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  2459. }
  2460. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  2461. func (m *BatchMsgMutation) TaskNameCleared() bool {
  2462. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  2463. return ok
  2464. }
  2465. // ResetTaskName resets all changes to the "task_name" field.
  2466. func (m *BatchMsgMutation) ResetTaskName() {
  2467. m.task_name = nil
  2468. delete(m.clearedFields, batchmsg.FieldTaskName)
  2469. }
  2470. // SetFromwxid sets the "fromwxid" field.
  2471. func (m *BatchMsgMutation) SetFromwxid(s string) {
  2472. m.fromwxid = &s
  2473. }
  2474. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  2475. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  2476. v := m.fromwxid
  2477. if v == nil {
  2478. return
  2479. }
  2480. return *v, true
  2481. }
  2482. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  2483. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2485. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  2486. if !m.op.Is(OpUpdateOne) {
  2487. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  2488. }
  2489. if m.id == nil || m.oldValue == nil {
  2490. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  2491. }
  2492. oldValue, err := m.oldValue(ctx)
  2493. if err != nil {
  2494. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  2495. }
  2496. return oldValue.Fromwxid, nil
  2497. }
  2498. // ClearFromwxid clears the value of the "fromwxid" field.
  2499. func (m *BatchMsgMutation) ClearFromwxid() {
  2500. m.fromwxid = nil
  2501. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  2502. }
  2503. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  2504. func (m *BatchMsgMutation) FromwxidCleared() bool {
  2505. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  2506. return ok
  2507. }
  2508. // ResetFromwxid resets all changes to the "fromwxid" field.
  2509. func (m *BatchMsgMutation) ResetFromwxid() {
  2510. m.fromwxid = nil
  2511. delete(m.clearedFields, batchmsg.FieldFromwxid)
  2512. }
  2513. // SetMsg sets the "msg" field.
  2514. func (m *BatchMsgMutation) SetMsg(s string) {
  2515. m.msg = &s
  2516. }
  2517. // Msg returns the value of the "msg" field in the mutation.
  2518. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  2519. v := m.msg
  2520. if v == nil {
  2521. return
  2522. }
  2523. return *v, true
  2524. }
  2525. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  2526. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2528. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  2529. if !m.op.Is(OpUpdateOne) {
  2530. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  2531. }
  2532. if m.id == nil || m.oldValue == nil {
  2533. return v, errors.New("OldMsg requires an ID field in the mutation")
  2534. }
  2535. oldValue, err := m.oldValue(ctx)
  2536. if err != nil {
  2537. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  2538. }
  2539. return oldValue.Msg, nil
  2540. }
  2541. // ClearMsg clears the value of the "msg" field.
  2542. func (m *BatchMsgMutation) ClearMsg() {
  2543. m.msg = nil
  2544. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  2545. }
  2546. // MsgCleared returns if the "msg" field was cleared in this mutation.
  2547. func (m *BatchMsgMutation) MsgCleared() bool {
  2548. _, ok := m.clearedFields[batchmsg.FieldMsg]
  2549. return ok
  2550. }
  2551. // ResetMsg resets all changes to the "msg" field.
  2552. func (m *BatchMsgMutation) ResetMsg() {
  2553. m.msg = nil
  2554. delete(m.clearedFields, batchmsg.FieldMsg)
  2555. }
  2556. // SetTag sets the "tag" field.
  2557. func (m *BatchMsgMutation) SetTag(s string) {
  2558. m.tag = &s
  2559. }
  2560. // Tag returns the value of the "tag" field in the mutation.
  2561. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  2562. v := m.tag
  2563. if v == nil {
  2564. return
  2565. }
  2566. return *v, true
  2567. }
  2568. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  2569. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2571. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  2572. if !m.op.Is(OpUpdateOne) {
  2573. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  2574. }
  2575. if m.id == nil || m.oldValue == nil {
  2576. return v, errors.New("OldTag requires an ID field in the mutation")
  2577. }
  2578. oldValue, err := m.oldValue(ctx)
  2579. if err != nil {
  2580. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  2581. }
  2582. return oldValue.Tag, nil
  2583. }
  2584. // ClearTag clears the value of the "tag" field.
  2585. func (m *BatchMsgMutation) ClearTag() {
  2586. m.tag = nil
  2587. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  2588. }
  2589. // TagCleared returns if the "tag" field was cleared in this mutation.
  2590. func (m *BatchMsgMutation) TagCleared() bool {
  2591. _, ok := m.clearedFields[batchmsg.FieldTag]
  2592. return ok
  2593. }
  2594. // ResetTag resets all changes to the "tag" field.
  2595. func (m *BatchMsgMutation) ResetTag() {
  2596. m.tag = nil
  2597. delete(m.clearedFields, batchmsg.FieldTag)
  2598. }
  2599. // SetTagids sets the "tagids" field.
  2600. func (m *BatchMsgMutation) SetTagids(s string) {
  2601. m.tagids = &s
  2602. }
  2603. // Tagids returns the value of the "tagids" field in the mutation.
  2604. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  2605. v := m.tagids
  2606. if v == nil {
  2607. return
  2608. }
  2609. return *v, true
  2610. }
  2611. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  2612. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2614. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  2615. if !m.op.Is(OpUpdateOne) {
  2616. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  2617. }
  2618. if m.id == nil || m.oldValue == nil {
  2619. return v, errors.New("OldTagids requires an ID field in the mutation")
  2620. }
  2621. oldValue, err := m.oldValue(ctx)
  2622. if err != nil {
  2623. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  2624. }
  2625. return oldValue.Tagids, nil
  2626. }
  2627. // ClearTagids clears the value of the "tagids" field.
  2628. func (m *BatchMsgMutation) ClearTagids() {
  2629. m.tagids = nil
  2630. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  2631. }
  2632. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  2633. func (m *BatchMsgMutation) TagidsCleared() bool {
  2634. _, ok := m.clearedFields[batchmsg.FieldTagids]
  2635. return ok
  2636. }
  2637. // ResetTagids resets all changes to the "tagids" field.
  2638. func (m *BatchMsgMutation) ResetTagids() {
  2639. m.tagids = nil
  2640. delete(m.clearedFields, batchmsg.FieldTagids)
  2641. }
  2642. // SetTotal sets the "total" field.
  2643. func (m *BatchMsgMutation) SetTotal(i int32) {
  2644. m.total = &i
  2645. m.addtotal = nil
  2646. }
  2647. // Total returns the value of the "total" field in the mutation.
  2648. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  2649. v := m.total
  2650. if v == nil {
  2651. return
  2652. }
  2653. return *v, true
  2654. }
  2655. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  2656. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2658. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  2659. if !m.op.Is(OpUpdateOne) {
  2660. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  2661. }
  2662. if m.id == nil || m.oldValue == nil {
  2663. return v, errors.New("OldTotal requires an ID field in the mutation")
  2664. }
  2665. oldValue, err := m.oldValue(ctx)
  2666. if err != nil {
  2667. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  2668. }
  2669. return oldValue.Total, nil
  2670. }
  2671. // AddTotal adds i to the "total" field.
  2672. func (m *BatchMsgMutation) AddTotal(i int32) {
  2673. if m.addtotal != nil {
  2674. *m.addtotal += i
  2675. } else {
  2676. m.addtotal = &i
  2677. }
  2678. }
  2679. // AddedTotal returns the value that was added to the "total" field in this mutation.
  2680. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  2681. v := m.addtotal
  2682. if v == nil {
  2683. return
  2684. }
  2685. return *v, true
  2686. }
  2687. // ClearTotal clears the value of the "total" field.
  2688. func (m *BatchMsgMutation) ClearTotal() {
  2689. m.total = nil
  2690. m.addtotal = nil
  2691. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  2692. }
  2693. // TotalCleared returns if the "total" field was cleared in this mutation.
  2694. func (m *BatchMsgMutation) TotalCleared() bool {
  2695. _, ok := m.clearedFields[batchmsg.FieldTotal]
  2696. return ok
  2697. }
  2698. // ResetTotal resets all changes to the "total" field.
  2699. func (m *BatchMsgMutation) ResetTotal() {
  2700. m.total = nil
  2701. m.addtotal = nil
  2702. delete(m.clearedFields, batchmsg.FieldTotal)
  2703. }
  2704. // SetSuccess sets the "success" field.
  2705. func (m *BatchMsgMutation) SetSuccess(i int32) {
  2706. m.success = &i
  2707. m.addsuccess = nil
  2708. }
  2709. // Success returns the value of the "success" field in the mutation.
  2710. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  2711. v := m.success
  2712. if v == nil {
  2713. return
  2714. }
  2715. return *v, true
  2716. }
  2717. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  2718. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2720. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  2721. if !m.op.Is(OpUpdateOne) {
  2722. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  2723. }
  2724. if m.id == nil || m.oldValue == nil {
  2725. return v, errors.New("OldSuccess requires an ID field in the mutation")
  2726. }
  2727. oldValue, err := m.oldValue(ctx)
  2728. if err != nil {
  2729. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  2730. }
  2731. return oldValue.Success, nil
  2732. }
  2733. // AddSuccess adds i to the "success" field.
  2734. func (m *BatchMsgMutation) AddSuccess(i int32) {
  2735. if m.addsuccess != nil {
  2736. *m.addsuccess += i
  2737. } else {
  2738. m.addsuccess = &i
  2739. }
  2740. }
  2741. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  2742. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  2743. v := m.addsuccess
  2744. if v == nil {
  2745. return
  2746. }
  2747. return *v, true
  2748. }
  2749. // ClearSuccess clears the value of the "success" field.
  2750. func (m *BatchMsgMutation) ClearSuccess() {
  2751. m.success = nil
  2752. m.addsuccess = nil
  2753. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  2754. }
  2755. // SuccessCleared returns if the "success" field was cleared in this mutation.
  2756. func (m *BatchMsgMutation) SuccessCleared() bool {
  2757. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  2758. return ok
  2759. }
  2760. // ResetSuccess resets all changes to the "success" field.
  2761. func (m *BatchMsgMutation) ResetSuccess() {
  2762. m.success = nil
  2763. m.addsuccess = nil
  2764. delete(m.clearedFields, batchmsg.FieldSuccess)
  2765. }
  2766. // SetFail sets the "fail" field.
  2767. func (m *BatchMsgMutation) SetFail(i int32) {
  2768. m.fail = &i
  2769. m.addfail = nil
  2770. }
  2771. // Fail returns the value of the "fail" field in the mutation.
  2772. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  2773. v := m.fail
  2774. if v == nil {
  2775. return
  2776. }
  2777. return *v, true
  2778. }
  2779. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  2780. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2782. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  2783. if !m.op.Is(OpUpdateOne) {
  2784. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  2785. }
  2786. if m.id == nil || m.oldValue == nil {
  2787. return v, errors.New("OldFail requires an ID field in the mutation")
  2788. }
  2789. oldValue, err := m.oldValue(ctx)
  2790. if err != nil {
  2791. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  2792. }
  2793. return oldValue.Fail, nil
  2794. }
  2795. // AddFail adds i to the "fail" field.
  2796. func (m *BatchMsgMutation) AddFail(i int32) {
  2797. if m.addfail != nil {
  2798. *m.addfail += i
  2799. } else {
  2800. m.addfail = &i
  2801. }
  2802. }
  2803. // AddedFail returns the value that was added to the "fail" field in this mutation.
  2804. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  2805. v := m.addfail
  2806. if v == nil {
  2807. return
  2808. }
  2809. return *v, true
  2810. }
  2811. // ClearFail clears the value of the "fail" field.
  2812. func (m *BatchMsgMutation) ClearFail() {
  2813. m.fail = nil
  2814. m.addfail = nil
  2815. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  2816. }
  2817. // FailCleared returns if the "fail" field was cleared in this mutation.
  2818. func (m *BatchMsgMutation) FailCleared() bool {
  2819. _, ok := m.clearedFields[batchmsg.FieldFail]
  2820. return ok
  2821. }
  2822. // ResetFail resets all changes to the "fail" field.
  2823. func (m *BatchMsgMutation) ResetFail() {
  2824. m.fail = nil
  2825. m.addfail = nil
  2826. delete(m.clearedFields, batchmsg.FieldFail)
  2827. }
  2828. // SetStartTime sets the "start_time" field.
  2829. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  2830. m.start_time = &t
  2831. }
  2832. // StartTime returns the value of the "start_time" field in the mutation.
  2833. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  2834. v := m.start_time
  2835. if v == nil {
  2836. return
  2837. }
  2838. return *v, true
  2839. }
  2840. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  2841. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2843. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  2844. if !m.op.Is(OpUpdateOne) {
  2845. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  2846. }
  2847. if m.id == nil || m.oldValue == nil {
  2848. return v, errors.New("OldStartTime requires an ID field in the mutation")
  2849. }
  2850. oldValue, err := m.oldValue(ctx)
  2851. if err != nil {
  2852. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  2853. }
  2854. return oldValue.StartTime, nil
  2855. }
  2856. // ClearStartTime clears the value of the "start_time" field.
  2857. func (m *BatchMsgMutation) ClearStartTime() {
  2858. m.start_time = nil
  2859. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  2860. }
  2861. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  2862. func (m *BatchMsgMutation) StartTimeCleared() bool {
  2863. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  2864. return ok
  2865. }
  2866. // ResetStartTime resets all changes to the "start_time" field.
  2867. func (m *BatchMsgMutation) ResetStartTime() {
  2868. m.start_time = nil
  2869. delete(m.clearedFields, batchmsg.FieldStartTime)
  2870. }
  2871. // SetStopTime sets the "stop_time" field.
  2872. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  2873. m.stop_time = &t
  2874. }
  2875. // StopTime returns the value of the "stop_time" field in the mutation.
  2876. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  2877. v := m.stop_time
  2878. if v == nil {
  2879. return
  2880. }
  2881. return *v, true
  2882. }
  2883. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  2884. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2886. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  2887. if !m.op.Is(OpUpdateOne) {
  2888. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  2889. }
  2890. if m.id == nil || m.oldValue == nil {
  2891. return v, errors.New("OldStopTime requires an ID field in the mutation")
  2892. }
  2893. oldValue, err := m.oldValue(ctx)
  2894. if err != nil {
  2895. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  2896. }
  2897. return oldValue.StopTime, nil
  2898. }
  2899. // ClearStopTime clears the value of the "stop_time" field.
  2900. func (m *BatchMsgMutation) ClearStopTime() {
  2901. m.stop_time = nil
  2902. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  2903. }
  2904. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  2905. func (m *BatchMsgMutation) StopTimeCleared() bool {
  2906. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  2907. return ok
  2908. }
  2909. // ResetStopTime resets all changes to the "stop_time" field.
  2910. func (m *BatchMsgMutation) ResetStopTime() {
  2911. m.stop_time = nil
  2912. delete(m.clearedFields, batchmsg.FieldStopTime)
  2913. }
  2914. // SetSendTime sets the "send_time" field.
  2915. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  2916. m.send_time = &t
  2917. }
  2918. // SendTime returns the value of the "send_time" field in the mutation.
  2919. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  2920. v := m.send_time
  2921. if v == nil {
  2922. return
  2923. }
  2924. return *v, true
  2925. }
  2926. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  2927. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2929. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  2930. if !m.op.Is(OpUpdateOne) {
  2931. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  2932. }
  2933. if m.id == nil || m.oldValue == nil {
  2934. return v, errors.New("OldSendTime requires an ID field in the mutation")
  2935. }
  2936. oldValue, err := m.oldValue(ctx)
  2937. if err != nil {
  2938. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  2939. }
  2940. return oldValue.SendTime, nil
  2941. }
  2942. // ClearSendTime clears the value of the "send_time" field.
  2943. func (m *BatchMsgMutation) ClearSendTime() {
  2944. m.send_time = nil
  2945. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  2946. }
  2947. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  2948. func (m *BatchMsgMutation) SendTimeCleared() bool {
  2949. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  2950. return ok
  2951. }
  2952. // ResetSendTime resets all changes to the "send_time" field.
  2953. func (m *BatchMsgMutation) ResetSendTime() {
  2954. m.send_time = nil
  2955. delete(m.clearedFields, batchmsg.FieldSendTime)
  2956. }
  2957. // SetType sets the "type" field.
  2958. func (m *BatchMsgMutation) SetType(i int32) {
  2959. m._type = &i
  2960. m.add_type = nil
  2961. }
  2962. // GetType returns the value of the "type" field in the mutation.
  2963. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  2964. v := m._type
  2965. if v == nil {
  2966. return
  2967. }
  2968. return *v, true
  2969. }
  2970. // OldType returns the old "type" field's value of the BatchMsg entity.
  2971. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2973. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  2974. if !m.op.Is(OpUpdateOne) {
  2975. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2976. }
  2977. if m.id == nil || m.oldValue == nil {
  2978. return v, errors.New("OldType requires an ID field in the mutation")
  2979. }
  2980. oldValue, err := m.oldValue(ctx)
  2981. if err != nil {
  2982. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2983. }
  2984. return oldValue.Type, nil
  2985. }
  2986. // AddType adds i to the "type" field.
  2987. func (m *BatchMsgMutation) AddType(i int32) {
  2988. if m.add_type != nil {
  2989. *m.add_type += i
  2990. } else {
  2991. m.add_type = &i
  2992. }
  2993. }
  2994. // AddedType returns the value that was added to the "type" field in this mutation.
  2995. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  2996. v := m.add_type
  2997. if v == nil {
  2998. return
  2999. }
  3000. return *v, true
  3001. }
  3002. // ClearType clears the value of the "type" field.
  3003. func (m *BatchMsgMutation) ClearType() {
  3004. m._type = nil
  3005. m.add_type = nil
  3006. m.clearedFields[batchmsg.FieldType] = struct{}{}
  3007. }
  3008. // TypeCleared returns if the "type" field was cleared in this mutation.
  3009. func (m *BatchMsgMutation) TypeCleared() bool {
  3010. _, ok := m.clearedFields[batchmsg.FieldType]
  3011. return ok
  3012. }
  3013. // ResetType resets all changes to the "type" field.
  3014. func (m *BatchMsgMutation) ResetType() {
  3015. m._type = nil
  3016. m.add_type = nil
  3017. delete(m.clearedFields, batchmsg.FieldType)
  3018. }
  3019. // SetOrganizationID sets the "organization_id" field.
  3020. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  3021. m.organization_id = &u
  3022. m.addorganization_id = nil
  3023. }
  3024. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3025. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  3026. v := m.organization_id
  3027. if v == nil {
  3028. return
  3029. }
  3030. return *v, true
  3031. }
  3032. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  3033. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3035. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3036. if !m.op.Is(OpUpdateOne) {
  3037. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3038. }
  3039. if m.id == nil || m.oldValue == nil {
  3040. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3041. }
  3042. oldValue, err := m.oldValue(ctx)
  3043. if err != nil {
  3044. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3045. }
  3046. return oldValue.OrganizationID, nil
  3047. }
  3048. // AddOrganizationID adds u to the "organization_id" field.
  3049. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  3050. if m.addorganization_id != nil {
  3051. *m.addorganization_id += u
  3052. } else {
  3053. m.addorganization_id = &u
  3054. }
  3055. }
  3056. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3057. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  3058. v := m.addorganization_id
  3059. if v == nil {
  3060. return
  3061. }
  3062. return *v, true
  3063. }
  3064. // ResetOrganizationID resets all changes to the "organization_id" field.
  3065. func (m *BatchMsgMutation) ResetOrganizationID() {
  3066. m.organization_id = nil
  3067. m.addorganization_id = nil
  3068. }
  3069. // Where appends a list predicates to the BatchMsgMutation builder.
  3070. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  3071. m.predicates = append(m.predicates, ps...)
  3072. }
  3073. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  3074. // users can use type-assertion to append predicates that do not depend on any generated package.
  3075. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  3076. p := make([]predicate.BatchMsg, len(ps))
  3077. for i := range ps {
  3078. p[i] = ps[i]
  3079. }
  3080. m.Where(p...)
  3081. }
  3082. // Op returns the operation name.
  3083. func (m *BatchMsgMutation) Op() Op {
  3084. return m.op
  3085. }
  3086. // SetOp allows setting the mutation operation.
  3087. func (m *BatchMsgMutation) SetOp(op Op) {
  3088. m.op = op
  3089. }
  3090. // Type returns the node type of this mutation (BatchMsg).
  3091. func (m *BatchMsgMutation) Type() string {
  3092. return m.typ
  3093. }
  3094. // Fields returns all fields that were changed during this mutation. Note that in
  3095. // order to get all numeric fields that were incremented/decremented, call
  3096. // AddedFields().
  3097. func (m *BatchMsgMutation) Fields() []string {
  3098. fields := make([]string, 0, 18)
  3099. if m.created_at != nil {
  3100. fields = append(fields, batchmsg.FieldCreatedAt)
  3101. }
  3102. if m.updated_at != nil {
  3103. fields = append(fields, batchmsg.FieldUpdatedAt)
  3104. }
  3105. if m.deleted_at != nil {
  3106. fields = append(fields, batchmsg.FieldDeletedAt)
  3107. }
  3108. if m.status != nil {
  3109. fields = append(fields, batchmsg.FieldStatus)
  3110. }
  3111. if m.batch_no != nil {
  3112. fields = append(fields, batchmsg.FieldBatchNo)
  3113. }
  3114. if m.task_name != nil {
  3115. fields = append(fields, batchmsg.FieldTaskName)
  3116. }
  3117. if m.fromwxid != nil {
  3118. fields = append(fields, batchmsg.FieldFromwxid)
  3119. }
  3120. if m.msg != nil {
  3121. fields = append(fields, batchmsg.FieldMsg)
  3122. }
  3123. if m.tag != nil {
  3124. fields = append(fields, batchmsg.FieldTag)
  3125. }
  3126. if m.tagids != nil {
  3127. fields = append(fields, batchmsg.FieldTagids)
  3128. }
  3129. if m.total != nil {
  3130. fields = append(fields, batchmsg.FieldTotal)
  3131. }
  3132. if m.success != nil {
  3133. fields = append(fields, batchmsg.FieldSuccess)
  3134. }
  3135. if m.fail != nil {
  3136. fields = append(fields, batchmsg.FieldFail)
  3137. }
  3138. if m.start_time != nil {
  3139. fields = append(fields, batchmsg.FieldStartTime)
  3140. }
  3141. if m.stop_time != nil {
  3142. fields = append(fields, batchmsg.FieldStopTime)
  3143. }
  3144. if m.send_time != nil {
  3145. fields = append(fields, batchmsg.FieldSendTime)
  3146. }
  3147. if m._type != nil {
  3148. fields = append(fields, batchmsg.FieldType)
  3149. }
  3150. if m.organization_id != nil {
  3151. fields = append(fields, batchmsg.FieldOrganizationID)
  3152. }
  3153. return fields
  3154. }
  3155. // Field returns the value of a field with the given name. The second boolean
  3156. // return value indicates that this field was not set, or was not defined in the
  3157. // schema.
  3158. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  3159. switch name {
  3160. case batchmsg.FieldCreatedAt:
  3161. return m.CreatedAt()
  3162. case batchmsg.FieldUpdatedAt:
  3163. return m.UpdatedAt()
  3164. case batchmsg.FieldDeletedAt:
  3165. return m.DeletedAt()
  3166. case batchmsg.FieldStatus:
  3167. return m.Status()
  3168. case batchmsg.FieldBatchNo:
  3169. return m.BatchNo()
  3170. case batchmsg.FieldTaskName:
  3171. return m.TaskName()
  3172. case batchmsg.FieldFromwxid:
  3173. return m.Fromwxid()
  3174. case batchmsg.FieldMsg:
  3175. return m.Msg()
  3176. case batchmsg.FieldTag:
  3177. return m.Tag()
  3178. case batchmsg.FieldTagids:
  3179. return m.Tagids()
  3180. case batchmsg.FieldTotal:
  3181. return m.Total()
  3182. case batchmsg.FieldSuccess:
  3183. return m.Success()
  3184. case batchmsg.FieldFail:
  3185. return m.Fail()
  3186. case batchmsg.FieldStartTime:
  3187. return m.StartTime()
  3188. case batchmsg.FieldStopTime:
  3189. return m.StopTime()
  3190. case batchmsg.FieldSendTime:
  3191. return m.SendTime()
  3192. case batchmsg.FieldType:
  3193. return m.GetType()
  3194. case batchmsg.FieldOrganizationID:
  3195. return m.OrganizationID()
  3196. }
  3197. return nil, false
  3198. }
  3199. // OldField returns the old value of the field from the database. An error is
  3200. // returned if the mutation operation is not UpdateOne, or the query to the
  3201. // database failed.
  3202. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3203. switch name {
  3204. case batchmsg.FieldCreatedAt:
  3205. return m.OldCreatedAt(ctx)
  3206. case batchmsg.FieldUpdatedAt:
  3207. return m.OldUpdatedAt(ctx)
  3208. case batchmsg.FieldDeletedAt:
  3209. return m.OldDeletedAt(ctx)
  3210. case batchmsg.FieldStatus:
  3211. return m.OldStatus(ctx)
  3212. case batchmsg.FieldBatchNo:
  3213. return m.OldBatchNo(ctx)
  3214. case batchmsg.FieldTaskName:
  3215. return m.OldTaskName(ctx)
  3216. case batchmsg.FieldFromwxid:
  3217. return m.OldFromwxid(ctx)
  3218. case batchmsg.FieldMsg:
  3219. return m.OldMsg(ctx)
  3220. case batchmsg.FieldTag:
  3221. return m.OldTag(ctx)
  3222. case batchmsg.FieldTagids:
  3223. return m.OldTagids(ctx)
  3224. case batchmsg.FieldTotal:
  3225. return m.OldTotal(ctx)
  3226. case batchmsg.FieldSuccess:
  3227. return m.OldSuccess(ctx)
  3228. case batchmsg.FieldFail:
  3229. return m.OldFail(ctx)
  3230. case batchmsg.FieldStartTime:
  3231. return m.OldStartTime(ctx)
  3232. case batchmsg.FieldStopTime:
  3233. return m.OldStopTime(ctx)
  3234. case batchmsg.FieldSendTime:
  3235. return m.OldSendTime(ctx)
  3236. case batchmsg.FieldType:
  3237. return m.OldType(ctx)
  3238. case batchmsg.FieldOrganizationID:
  3239. return m.OldOrganizationID(ctx)
  3240. }
  3241. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  3242. }
  3243. // SetField sets the value of a field with the given name. It returns an error if
  3244. // the field is not defined in the schema, or if the type mismatched the field
  3245. // type.
  3246. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  3247. switch name {
  3248. case batchmsg.FieldCreatedAt:
  3249. v, ok := value.(time.Time)
  3250. if !ok {
  3251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3252. }
  3253. m.SetCreatedAt(v)
  3254. return nil
  3255. case batchmsg.FieldUpdatedAt:
  3256. v, ok := value.(time.Time)
  3257. if !ok {
  3258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3259. }
  3260. m.SetUpdatedAt(v)
  3261. return nil
  3262. case batchmsg.FieldDeletedAt:
  3263. v, ok := value.(time.Time)
  3264. if !ok {
  3265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3266. }
  3267. m.SetDeletedAt(v)
  3268. return nil
  3269. case batchmsg.FieldStatus:
  3270. v, ok := value.(uint8)
  3271. if !ok {
  3272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3273. }
  3274. m.SetStatus(v)
  3275. return nil
  3276. case batchmsg.FieldBatchNo:
  3277. v, ok := value.(string)
  3278. if !ok {
  3279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3280. }
  3281. m.SetBatchNo(v)
  3282. return nil
  3283. case batchmsg.FieldTaskName:
  3284. v, ok := value.(string)
  3285. if !ok {
  3286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3287. }
  3288. m.SetTaskName(v)
  3289. return nil
  3290. case batchmsg.FieldFromwxid:
  3291. v, ok := value.(string)
  3292. if !ok {
  3293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3294. }
  3295. m.SetFromwxid(v)
  3296. return nil
  3297. case batchmsg.FieldMsg:
  3298. v, ok := value.(string)
  3299. if !ok {
  3300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3301. }
  3302. m.SetMsg(v)
  3303. return nil
  3304. case batchmsg.FieldTag:
  3305. v, ok := value.(string)
  3306. if !ok {
  3307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3308. }
  3309. m.SetTag(v)
  3310. return nil
  3311. case batchmsg.FieldTagids:
  3312. v, ok := value.(string)
  3313. if !ok {
  3314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3315. }
  3316. m.SetTagids(v)
  3317. return nil
  3318. case batchmsg.FieldTotal:
  3319. v, ok := value.(int32)
  3320. if !ok {
  3321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3322. }
  3323. m.SetTotal(v)
  3324. return nil
  3325. case batchmsg.FieldSuccess:
  3326. v, ok := value.(int32)
  3327. if !ok {
  3328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3329. }
  3330. m.SetSuccess(v)
  3331. return nil
  3332. case batchmsg.FieldFail:
  3333. v, ok := value.(int32)
  3334. if !ok {
  3335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3336. }
  3337. m.SetFail(v)
  3338. return nil
  3339. case batchmsg.FieldStartTime:
  3340. v, ok := value.(time.Time)
  3341. if !ok {
  3342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3343. }
  3344. m.SetStartTime(v)
  3345. return nil
  3346. case batchmsg.FieldStopTime:
  3347. v, ok := value.(time.Time)
  3348. if !ok {
  3349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3350. }
  3351. m.SetStopTime(v)
  3352. return nil
  3353. case batchmsg.FieldSendTime:
  3354. v, ok := value.(time.Time)
  3355. if !ok {
  3356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3357. }
  3358. m.SetSendTime(v)
  3359. return nil
  3360. case batchmsg.FieldType:
  3361. v, ok := value.(int32)
  3362. if !ok {
  3363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3364. }
  3365. m.SetType(v)
  3366. return nil
  3367. case batchmsg.FieldOrganizationID:
  3368. v, ok := value.(uint64)
  3369. if !ok {
  3370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3371. }
  3372. m.SetOrganizationID(v)
  3373. return nil
  3374. }
  3375. return fmt.Errorf("unknown BatchMsg field %s", name)
  3376. }
  3377. // AddedFields returns all numeric fields that were incremented/decremented during
  3378. // this mutation.
  3379. func (m *BatchMsgMutation) AddedFields() []string {
  3380. var fields []string
  3381. if m.addstatus != nil {
  3382. fields = append(fields, batchmsg.FieldStatus)
  3383. }
  3384. if m.addtotal != nil {
  3385. fields = append(fields, batchmsg.FieldTotal)
  3386. }
  3387. if m.addsuccess != nil {
  3388. fields = append(fields, batchmsg.FieldSuccess)
  3389. }
  3390. if m.addfail != nil {
  3391. fields = append(fields, batchmsg.FieldFail)
  3392. }
  3393. if m.add_type != nil {
  3394. fields = append(fields, batchmsg.FieldType)
  3395. }
  3396. if m.addorganization_id != nil {
  3397. fields = append(fields, batchmsg.FieldOrganizationID)
  3398. }
  3399. return fields
  3400. }
  3401. // AddedField returns the numeric value that was incremented/decremented on a field
  3402. // with the given name. The second boolean return value indicates that this field
  3403. // was not set, or was not defined in the schema.
  3404. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  3405. switch name {
  3406. case batchmsg.FieldStatus:
  3407. return m.AddedStatus()
  3408. case batchmsg.FieldTotal:
  3409. return m.AddedTotal()
  3410. case batchmsg.FieldSuccess:
  3411. return m.AddedSuccess()
  3412. case batchmsg.FieldFail:
  3413. return m.AddedFail()
  3414. case batchmsg.FieldType:
  3415. return m.AddedType()
  3416. case batchmsg.FieldOrganizationID:
  3417. return m.AddedOrganizationID()
  3418. }
  3419. return nil, false
  3420. }
  3421. // AddField adds the value to the field with the given name. It returns an error if
  3422. // the field is not defined in the schema, or if the type mismatched the field
  3423. // type.
  3424. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  3425. switch name {
  3426. case batchmsg.FieldStatus:
  3427. v, ok := value.(int8)
  3428. if !ok {
  3429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3430. }
  3431. m.AddStatus(v)
  3432. return nil
  3433. case batchmsg.FieldTotal:
  3434. v, ok := value.(int32)
  3435. if !ok {
  3436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3437. }
  3438. m.AddTotal(v)
  3439. return nil
  3440. case batchmsg.FieldSuccess:
  3441. v, ok := value.(int32)
  3442. if !ok {
  3443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3444. }
  3445. m.AddSuccess(v)
  3446. return nil
  3447. case batchmsg.FieldFail:
  3448. v, ok := value.(int32)
  3449. if !ok {
  3450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3451. }
  3452. m.AddFail(v)
  3453. return nil
  3454. case batchmsg.FieldType:
  3455. v, ok := value.(int32)
  3456. if !ok {
  3457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3458. }
  3459. m.AddType(v)
  3460. return nil
  3461. case batchmsg.FieldOrganizationID:
  3462. v, ok := value.(int64)
  3463. if !ok {
  3464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3465. }
  3466. m.AddOrganizationID(v)
  3467. return nil
  3468. }
  3469. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  3470. }
  3471. // ClearedFields returns all nullable fields that were cleared during this
  3472. // mutation.
  3473. func (m *BatchMsgMutation) ClearedFields() []string {
  3474. var fields []string
  3475. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  3476. fields = append(fields, batchmsg.FieldDeletedAt)
  3477. }
  3478. if m.FieldCleared(batchmsg.FieldStatus) {
  3479. fields = append(fields, batchmsg.FieldStatus)
  3480. }
  3481. if m.FieldCleared(batchmsg.FieldBatchNo) {
  3482. fields = append(fields, batchmsg.FieldBatchNo)
  3483. }
  3484. if m.FieldCleared(batchmsg.FieldTaskName) {
  3485. fields = append(fields, batchmsg.FieldTaskName)
  3486. }
  3487. if m.FieldCleared(batchmsg.FieldFromwxid) {
  3488. fields = append(fields, batchmsg.FieldFromwxid)
  3489. }
  3490. if m.FieldCleared(batchmsg.FieldMsg) {
  3491. fields = append(fields, batchmsg.FieldMsg)
  3492. }
  3493. if m.FieldCleared(batchmsg.FieldTag) {
  3494. fields = append(fields, batchmsg.FieldTag)
  3495. }
  3496. if m.FieldCleared(batchmsg.FieldTagids) {
  3497. fields = append(fields, batchmsg.FieldTagids)
  3498. }
  3499. if m.FieldCleared(batchmsg.FieldTotal) {
  3500. fields = append(fields, batchmsg.FieldTotal)
  3501. }
  3502. if m.FieldCleared(batchmsg.FieldSuccess) {
  3503. fields = append(fields, batchmsg.FieldSuccess)
  3504. }
  3505. if m.FieldCleared(batchmsg.FieldFail) {
  3506. fields = append(fields, batchmsg.FieldFail)
  3507. }
  3508. if m.FieldCleared(batchmsg.FieldStartTime) {
  3509. fields = append(fields, batchmsg.FieldStartTime)
  3510. }
  3511. if m.FieldCleared(batchmsg.FieldStopTime) {
  3512. fields = append(fields, batchmsg.FieldStopTime)
  3513. }
  3514. if m.FieldCleared(batchmsg.FieldSendTime) {
  3515. fields = append(fields, batchmsg.FieldSendTime)
  3516. }
  3517. if m.FieldCleared(batchmsg.FieldType) {
  3518. fields = append(fields, batchmsg.FieldType)
  3519. }
  3520. return fields
  3521. }
  3522. // FieldCleared returns a boolean indicating if a field with the given name was
  3523. // cleared in this mutation.
  3524. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  3525. _, ok := m.clearedFields[name]
  3526. return ok
  3527. }
  3528. // ClearField clears the value of the field with the given name. It returns an
  3529. // error if the field is not defined in the schema.
  3530. func (m *BatchMsgMutation) ClearField(name string) error {
  3531. switch name {
  3532. case batchmsg.FieldDeletedAt:
  3533. m.ClearDeletedAt()
  3534. return nil
  3535. case batchmsg.FieldStatus:
  3536. m.ClearStatus()
  3537. return nil
  3538. case batchmsg.FieldBatchNo:
  3539. m.ClearBatchNo()
  3540. return nil
  3541. case batchmsg.FieldTaskName:
  3542. m.ClearTaskName()
  3543. return nil
  3544. case batchmsg.FieldFromwxid:
  3545. m.ClearFromwxid()
  3546. return nil
  3547. case batchmsg.FieldMsg:
  3548. m.ClearMsg()
  3549. return nil
  3550. case batchmsg.FieldTag:
  3551. m.ClearTag()
  3552. return nil
  3553. case batchmsg.FieldTagids:
  3554. m.ClearTagids()
  3555. return nil
  3556. case batchmsg.FieldTotal:
  3557. m.ClearTotal()
  3558. return nil
  3559. case batchmsg.FieldSuccess:
  3560. m.ClearSuccess()
  3561. return nil
  3562. case batchmsg.FieldFail:
  3563. m.ClearFail()
  3564. return nil
  3565. case batchmsg.FieldStartTime:
  3566. m.ClearStartTime()
  3567. return nil
  3568. case batchmsg.FieldStopTime:
  3569. m.ClearStopTime()
  3570. return nil
  3571. case batchmsg.FieldSendTime:
  3572. m.ClearSendTime()
  3573. return nil
  3574. case batchmsg.FieldType:
  3575. m.ClearType()
  3576. return nil
  3577. }
  3578. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  3579. }
  3580. // ResetField resets all changes in the mutation for the field with the given name.
  3581. // It returns an error if the field is not defined in the schema.
  3582. func (m *BatchMsgMutation) ResetField(name string) error {
  3583. switch name {
  3584. case batchmsg.FieldCreatedAt:
  3585. m.ResetCreatedAt()
  3586. return nil
  3587. case batchmsg.FieldUpdatedAt:
  3588. m.ResetUpdatedAt()
  3589. return nil
  3590. case batchmsg.FieldDeletedAt:
  3591. m.ResetDeletedAt()
  3592. return nil
  3593. case batchmsg.FieldStatus:
  3594. m.ResetStatus()
  3595. return nil
  3596. case batchmsg.FieldBatchNo:
  3597. m.ResetBatchNo()
  3598. return nil
  3599. case batchmsg.FieldTaskName:
  3600. m.ResetTaskName()
  3601. return nil
  3602. case batchmsg.FieldFromwxid:
  3603. m.ResetFromwxid()
  3604. return nil
  3605. case batchmsg.FieldMsg:
  3606. m.ResetMsg()
  3607. return nil
  3608. case batchmsg.FieldTag:
  3609. m.ResetTag()
  3610. return nil
  3611. case batchmsg.FieldTagids:
  3612. m.ResetTagids()
  3613. return nil
  3614. case batchmsg.FieldTotal:
  3615. m.ResetTotal()
  3616. return nil
  3617. case batchmsg.FieldSuccess:
  3618. m.ResetSuccess()
  3619. return nil
  3620. case batchmsg.FieldFail:
  3621. m.ResetFail()
  3622. return nil
  3623. case batchmsg.FieldStartTime:
  3624. m.ResetStartTime()
  3625. return nil
  3626. case batchmsg.FieldStopTime:
  3627. m.ResetStopTime()
  3628. return nil
  3629. case batchmsg.FieldSendTime:
  3630. m.ResetSendTime()
  3631. return nil
  3632. case batchmsg.FieldType:
  3633. m.ResetType()
  3634. return nil
  3635. case batchmsg.FieldOrganizationID:
  3636. m.ResetOrganizationID()
  3637. return nil
  3638. }
  3639. return fmt.Errorf("unknown BatchMsg field %s", name)
  3640. }
  3641. // AddedEdges returns all edge names that were set/added in this mutation.
  3642. func (m *BatchMsgMutation) AddedEdges() []string {
  3643. edges := make([]string, 0, 0)
  3644. return edges
  3645. }
  3646. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3647. // name in this mutation.
  3648. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  3649. return nil
  3650. }
  3651. // RemovedEdges returns all edge names that were removed in this mutation.
  3652. func (m *BatchMsgMutation) RemovedEdges() []string {
  3653. edges := make([]string, 0, 0)
  3654. return edges
  3655. }
  3656. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3657. // the given name in this mutation.
  3658. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  3659. return nil
  3660. }
  3661. // ClearedEdges returns all edge names that were cleared in this mutation.
  3662. func (m *BatchMsgMutation) ClearedEdges() []string {
  3663. edges := make([]string, 0, 0)
  3664. return edges
  3665. }
  3666. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3667. // was cleared in this mutation.
  3668. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  3669. return false
  3670. }
  3671. // ClearEdge clears the value of the edge with the given name. It returns an error
  3672. // if that edge is not defined in the schema.
  3673. func (m *BatchMsgMutation) ClearEdge(name string) error {
  3674. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  3675. }
  3676. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3677. // It returns an error if the edge is not defined in the schema.
  3678. func (m *BatchMsgMutation) ResetEdge(name string) error {
  3679. return fmt.Errorf("unknown BatchMsg edge %s", name)
  3680. }
  3681. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  3682. type CategoryMutation struct {
  3683. config
  3684. op Op
  3685. typ string
  3686. id *uint64
  3687. created_at *time.Time
  3688. updated_at *time.Time
  3689. deleted_at *time.Time
  3690. name *string
  3691. organization_id *uint64
  3692. addorganization_id *int64
  3693. clearedFields map[string]struct{}
  3694. done bool
  3695. oldValue func(context.Context) (*Category, error)
  3696. predicates []predicate.Category
  3697. }
  3698. var _ ent.Mutation = (*CategoryMutation)(nil)
  3699. // categoryOption allows management of the mutation configuration using functional options.
  3700. type categoryOption func(*CategoryMutation)
  3701. // newCategoryMutation creates new mutation for the Category entity.
  3702. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  3703. m := &CategoryMutation{
  3704. config: c,
  3705. op: op,
  3706. typ: TypeCategory,
  3707. clearedFields: make(map[string]struct{}),
  3708. }
  3709. for _, opt := range opts {
  3710. opt(m)
  3711. }
  3712. return m
  3713. }
  3714. // withCategoryID sets the ID field of the mutation.
  3715. func withCategoryID(id uint64) categoryOption {
  3716. return func(m *CategoryMutation) {
  3717. var (
  3718. err error
  3719. once sync.Once
  3720. value *Category
  3721. )
  3722. m.oldValue = func(ctx context.Context) (*Category, error) {
  3723. once.Do(func() {
  3724. if m.done {
  3725. err = errors.New("querying old values post mutation is not allowed")
  3726. } else {
  3727. value, err = m.Client().Category.Get(ctx, id)
  3728. }
  3729. })
  3730. return value, err
  3731. }
  3732. m.id = &id
  3733. }
  3734. }
  3735. // withCategory sets the old Category of the mutation.
  3736. func withCategory(node *Category) categoryOption {
  3737. return func(m *CategoryMutation) {
  3738. m.oldValue = func(context.Context) (*Category, error) {
  3739. return node, nil
  3740. }
  3741. m.id = &node.ID
  3742. }
  3743. }
  3744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3745. // executed in a transaction (ent.Tx), a transactional client is returned.
  3746. func (m CategoryMutation) Client() *Client {
  3747. client := &Client{config: m.config}
  3748. client.init()
  3749. return client
  3750. }
  3751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3752. // it returns an error otherwise.
  3753. func (m CategoryMutation) Tx() (*Tx, error) {
  3754. if _, ok := m.driver.(*txDriver); !ok {
  3755. return nil, errors.New("ent: mutation is not running in a transaction")
  3756. }
  3757. tx := &Tx{config: m.config}
  3758. tx.init()
  3759. return tx, nil
  3760. }
  3761. // SetID sets the value of the id field. Note that this
  3762. // operation is only accepted on creation of Category entities.
  3763. func (m *CategoryMutation) SetID(id uint64) {
  3764. m.id = &id
  3765. }
  3766. // ID returns the ID value in the mutation. Note that the ID is only available
  3767. // if it was provided to the builder or after it was returned from the database.
  3768. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  3769. if m.id == nil {
  3770. return
  3771. }
  3772. return *m.id, true
  3773. }
  3774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3775. // That means, if the mutation is applied within a transaction with an isolation level such
  3776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3777. // or updated by the mutation.
  3778. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  3779. switch {
  3780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3781. id, exists := m.ID()
  3782. if exists {
  3783. return []uint64{id}, nil
  3784. }
  3785. fallthrough
  3786. case m.op.Is(OpUpdate | OpDelete):
  3787. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  3788. default:
  3789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3790. }
  3791. }
  3792. // SetCreatedAt sets the "created_at" field.
  3793. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  3794. m.created_at = &t
  3795. }
  3796. // CreatedAt returns the value of the "created_at" field in the mutation.
  3797. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  3798. v := m.created_at
  3799. if v == nil {
  3800. return
  3801. }
  3802. return *v, true
  3803. }
  3804. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  3805. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3807. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3808. if !m.op.Is(OpUpdateOne) {
  3809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3810. }
  3811. if m.id == nil || m.oldValue == nil {
  3812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3813. }
  3814. oldValue, err := m.oldValue(ctx)
  3815. if err != nil {
  3816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3817. }
  3818. return oldValue.CreatedAt, nil
  3819. }
  3820. // ResetCreatedAt resets all changes to the "created_at" field.
  3821. func (m *CategoryMutation) ResetCreatedAt() {
  3822. m.created_at = nil
  3823. }
  3824. // SetUpdatedAt sets the "updated_at" field.
  3825. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  3826. m.updated_at = &t
  3827. }
  3828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3829. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  3830. v := m.updated_at
  3831. if v == nil {
  3832. return
  3833. }
  3834. return *v, true
  3835. }
  3836. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  3837. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3839. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3840. if !m.op.Is(OpUpdateOne) {
  3841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3842. }
  3843. if m.id == nil || m.oldValue == nil {
  3844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3845. }
  3846. oldValue, err := m.oldValue(ctx)
  3847. if err != nil {
  3848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3849. }
  3850. return oldValue.UpdatedAt, nil
  3851. }
  3852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3853. func (m *CategoryMutation) ResetUpdatedAt() {
  3854. m.updated_at = nil
  3855. }
  3856. // SetDeletedAt sets the "deleted_at" field.
  3857. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  3858. m.deleted_at = &t
  3859. }
  3860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3861. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  3862. v := m.deleted_at
  3863. if v == nil {
  3864. return
  3865. }
  3866. return *v, true
  3867. }
  3868. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  3869. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3871. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3872. if !m.op.Is(OpUpdateOne) {
  3873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3874. }
  3875. if m.id == nil || m.oldValue == nil {
  3876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3877. }
  3878. oldValue, err := m.oldValue(ctx)
  3879. if err != nil {
  3880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3881. }
  3882. return oldValue.DeletedAt, nil
  3883. }
  3884. // ClearDeletedAt clears the value of the "deleted_at" field.
  3885. func (m *CategoryMutation) ClearDeletedAt() {
  3886. m.deleted_at = nil
  3887. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  3888. }
  3889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3890. func (m *CategoryMutation) DeletedAtCleared() bool {
  3891. _, ok := m.clearedFields[category.FieldDeletedAt]
  3892. return ok
  3893. }
  3894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3895. func (m *CategoryMutation) ResetDeletedAt() {
  3896. m.deleted_at = nil
  3897. delete(m.clearedFields, category.FieldDeletedAt)
  3898. }
  3899. // SetName sets the "name" field.
  3900. func (m *CategoryMutation) SetName(s string) {
  3901. m.name = &s
  3902. }
  3903. // Name returns the value of the "name" field in the mutation.
  3904. func (m *CategoryMutation) Name() (r string, exists bool) {
  3905. v := m.name
  3906. if v == nil {
  3907. return
  3908. }
  3909. return *v, true
  3910. }
  3911. // OldName returns the old "name" field's value of the Category entity.
  3912. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3914. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  3915. if !m.op.Is(OpUpdateOne) {
  3916. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3917. }
  3918. if m.id == nil || m.oldValue == nil {
  3919. return v, errors.New("OldName requires an ID field in the mutation")
  3920. }
  3921. oldValue, err := m.oldValue(ctx)
  3922. if err != nil {
  3923. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3924. }
  3925. return oldValue.Name, nil
  3926. }
  3927. // ResetName resets all changes to the "name" field.
  3928. func (m *CategoryMutation) ResetName() {
  3929. m.name = nil
  3930. }
  3931. // SetOrganizationID sets the "organization_id" field.
  3932. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  3933. m.organization_id = &u
  3934. m.addorganization_id = nil
  3935. }
  3936. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3937. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  3938. v := m.organization_id
  3939. if v == nil {
  3940. return
  3941. }
  3942. return *v, true
  3943. }
  3944. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  3945. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3947. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3948. if !m.op.Is(OpUpdateOne) {
  3949. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3950. }
  3951. if m.id == nil || m.oldValue == nil {
  3952. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3953. }
  3954. oldValue, err := m.oldValue(ctx)
  3955. if err != nil {
  3956. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3957. }
  3958. return oldValue.OrganizationID, nil
  3959. }
  3960. // AddOrganizationID adds u to the "organization_id" field.
  3961. func (m *CategoryMutation) AddOrganizationID(u int64) {
  3962. if m.addorganization_id != nil {
  3963. *m.addorganization_id += u
  3964. } else {
  3965. m.addorganization_id = &u
  3966. }
  3967. }
  3968. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3969. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  3970. v := m.addorganization_id
  3971. if v == nil {
  3972. return
  3973. }
  3974. return *v, true
  3975. }
  3976. // ResetOrganizationID resets all changes to the "organization_id" field.
  3977. func (m *CategoryMutation) ResetOrganizationID() {
  3978. m.organization_id = nil
  3979. m.addorganization_id = nil
  3980. }
  3981. // Where appends a list predicates to the CategoryMutation builder.
  3982. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  3983. m.predicates = append(m.predicates, ps...)
  3984. }
  3985. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  3986. // users can use type-assertion to append predicates that do not depend on any generated package.
  3987. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  3988. p := make([]predicate.Category, len(ps))
  3989. for i := range ps {
  3990. p[i] = ps[i]
  3991. }
  3992. m.Where(p...)
  3993. }
  3994. // Op returns the operation name.
  3995. func (m *CategoryMutation) Op() Op {
  3996. return m.op
  3997. }
  3998. // SetOp allows setting the mutation operation.
  3999. func (m *CategoryMutation) SetOp(op Op) {
  4000. m.op = op
  4001. }
  4002. // Type returns the node type of this mutation (Category).
  4003. func (m *CategoryMutation) Type() string {
  4004. return m.typ
  4005. }
  4006. // Fields returns all fields that were changed during this mutation. Note that in
  4007. // order to get all numeric fields that were incremented/decremented, call
  4008. // AddedFields().
  4009. func (m *CategoryMutation) Fields() []string {
  4010. fields := make([]string, 0, 5)
  4011. if m.created_at != nil {
  4012. fields = append(fields, category.FieldCreatedAt)
  4013. }
  4014. if m.updated_at != nil {
  4015. fields = append(fields, category.FieldUpdatedAt)
  4016. }
  4017. if m.deleted_at != nil {
  4018. fields = append(fields, category.FieldDeletedAt)
  4019. }
  4020. if m.name != nil {
  4021. fields = append(fields, category.FieldName)
  4022. }
  4023. if m.organization_id != nil {
  4024. fields = append(fields, category.FieldOrganizationID)
  4025. }
  4026. return fields
  4027. }
  4028. // Field returns the value of a field with the given name. The second boolean
  4029. // return value indicates that this field was not set, or was not defined in the
  4030. // schema.
  4031. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  4032. switch name {
  4033. case category.FieldCreatedAt:
  4034. return m.CreatedAt()
  4035. case category.FieldUpdatedAt:
  4036. return m.UpdatedAt()
  4037. case category.FieldDeletedAt:
  4038. return m.DeletedAt()
  4039. case category.FieldName:
  4040. return m.Name()
  4041. case category.FieldOrganizationID:
  4042. return m.OrganizationID()
  4043. }
  4044. return nil, false
  4045. }
  4046. // OldField returns the old value of the field from the database. An error is
  4047. // returned if the mutation operation is not UpdateOne, or the query to the
  4048. // database failed.
  4049. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4050. switch name {
  4051. case category.FieldCreatedAt:
  4052. return m.OldCreatedAt(ctx)
  4053. case category.FieldUpdatedAt:
  4054. return m.OldUpdatedAt(ctx)
  4055. case category.FieldDeletedAt:
  4056. return m.OldDeletedAt(ctx)
  4057. case category.FieldName:
  4058. return m.OldName(ctx)
  4059. case category.FieldOrganizationID:
  4060. return m.OldOrganizationID(ctx)
  4061. }
  4062. return nil, fmt.Errorf("unknown Category field %s", name)
  4063. }
  4064. // SetField sets the value of a field with the given name. It returns an error if
  4065. // the field is not defined in the schema, or if the type mismatched the field
  4066. // type.
  4067. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  4068. switch name {
  4069. case category.FieldCreatedAt:
  4070. v, ok := value.(time.Time)
  4071. if !ok {
  4072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4073. }
  4074. m.SetCreatedAt(v)
  4075. return nil
  4076. case category.FieldUpdatedAt:
  4077. v, ok := value.(time.Time)
  4078. if !ok {
  4079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4080. }
  4081. m.SetUpdatedAt(v)
  4082. return nil
  4083. case category.FieldDeletedAt:
  4084. v, ok := value.(time.Time)
  4085. if !ok {
  4086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4087. }
  4088. m.SetDeletedAt(v)
  4089. return nil
  4090. case category.FieldName:
  4091. v, ok := value.(string)
  4092. if !ok {
  4093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4094. }
  4095. m.SetName(v)
  4096. return nil
  4097. case category.FieldOrganizationID:
  4098. v, ok := value.(uint64)
  4099. if !ok {
  4100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4101. }
  4102. m.SetOrganizationID(v)
  4103. return nil
  4104. }
  4105. return fmt.Errorf("unknown Category field %s", name)
  4106. }
  4107. // AddedFields returns all numeric fields that were incremented/decremented during
  4108. // this mutation.
  4109. func (m *CategoryMutation) AddedFields() []string {
  4110. var fields []string
  4111. if m.addorganization_id != nil {
  4112. fields = append(fields, category.FieldOrganizationID)
  4113. }
  4114. return fields
  4115. }
  4116. // AddedField returns the numeric value that was incremented/decremented on a field
  4117. // with the given name. The second boolean return value indicates that this field
  4118. // was not set, or was not defined in the schema.
  4119. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  4120. switch name {
  4121. case category.FieldOrganizationID:
  4122. return m.AddedOrganizationID()
  4123. }
  4124. return nil, false
  4125. }
  4126. // AddField adds the value to the field with the given name. It returns an error if
  4127. // the field is not defined in the schema, or if the type mismatched the field
  4128. // type.
  4129. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  4130. switch name {
  4131. case category.FieldOrganizationID:
  4132. v, ok := value.(int64)
  4133. if !ok {
  4134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4135. }
  4136. m.AddOrganizationID(v)
  4137. return nil
  4138. }
  4139. return fmt.Errorf("unknown Category numeric field %s", name)
  4140. }
  4141. // ClearedFields returns all nullable fields that were cleared during this
  4142. // mutation.
  4143. func (m *CategoryMutation) ClearedFields() []string {
  4144. var fields []string
  4145. if m.FieldCleared(category.FieldDeletedAt) {
  4146. fields = append(fields, category.FieldDeletedAt)
  4147. }
  4148. return fields
  4149. }
  4150. // FieldCleared returns a boolean indicating if a field with the given name was
  4151. // cleared in this mutation.
  4152. func (m *CategoryMutation) FieldCleared(name string) bool {
  4153. _, ok := m.clearedFields[name]
  4154. return ok
  4155. }
  4156. // ClearField clears the value of the field with the given name. It returns an
  4157. // error if the field is not defined in the schema.
  4158. func (m *CategoryMutation) ClearField(name string) error {
  4159. switch name {
  4160. case category.FieldDeletedAt:
  4161. m.ClearDeletedAt()
  4162. return nil
  4163. }
  4164. return fmt.Errorf("unknown Category nullable field %s", name)
  4165. }
  4166. // ResetField resets all changes in the mutation for the field with the given name.
  4167. // It returns an error if the field is not defined in the schema.
  4168. func (m *CategoryMutation) ResetField(name string) error {
  4169. switch name {
  4170. case category.FieldCreatedAt:
  4171. m.ResetCreatedAt()
  4172. return nil
  4173. case category.FieldUpdatedAt:
  4174. m.ResetUpdatedAt()
  4175. return nil
  4176. case category.FieldDeletedAt:
  4177. m.ResetDeletedAt()
  4178. return nil
  4179. case category.FieldName:
  4180. m.ResetName()
  4181. return nil
  4182. case category.FieldOrganizationID:
  4183. m.ResetOrganizationID()
  4184. return nil
  4185. }
  4186. return fmt.Errorf("unknown Category field %s", name)
  4187. }
  4188. // AddedEdges returns all edge names that were set/added in this mutation.
  4189. func (m *CategoryMutation) AddedEdges() []string {
  4190. edges := make([]string, 0, 0)
  4191. return edges
  4192. }
  4193. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4194. // name in this mutation.
  4195. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  4196. return nil
  4197. }
  4198. // RemovedEdges returns all edge names that were removed in this mutation.
  4199. func (m *CategoryMutation) RemovedEdges() []string {
  4200. edges := make([]string, 0, 0)
  4201. return edges
  4202. }
  4203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4204. // the given name in this mutation.
  4205. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  4206. return nil
  4207. }
  4208. // ClearedEdges returns all edge names that were cleared in this mutation.
  4209. func (m *CategoryMutation) ClearedEdges() []string {
  4210. edges := make([]string, 0, 0)
  4211. return edges
  4212. }
  4213. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4214. // was cleared in this mutation.
  4215. func (m *CategoryMutation) EdgeCleared(name string) bool {
  4216. return false
  4217. }
  4218. // ClearEdge clears the value of the edge with the given name. It returns an error
  4219. // if that edge is not defined in the schema.
  4220. func (m *CategoryMutation) ClearEdge(name string) error {
  4221. return fmt.Errorf("unknown Category unique edge %s", name)
  4222. }
  4223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4224. // It returns an error if the edge is not defined in the schema.
  4225. func (m *CategoryMutation) ResetEdge(name string) error {
  4226. return fmt.Errorf("unknown Category edge %s", name)
  4227. }
  4228. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  4229. type ChatRecordsMutation struct {
  4230. config
  4231. op Op
  4232. typ string
  4233. id *uint64
  4234. created_at *time.Time
  4235. updated_at *time.Time
  4236. deleted_at *time.Time
  4237. content *string
  4238. content_type *uint8
  4239. addcontent_type *int8
  4240. session_id *uint64
  4241. addsession_id *int64
  4242. user_id *uint64
  4243. adduser_id *int64
  4244. bot_id *uint64
  4245. addbot_id *int64
  4246. bot_type *uint8
  4247. addbot_type *int8
  4248. clearedFields map[string]struct{}
  4249. done bool
  4250. oldValue func(context.Context) (*ChatRecords, error)
  4251. predicates []predicate.ChatRecords
  4252. }
  4253. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  4254. // chatrecordsOption allows management of the mutation configuration using functional options.
  4255. type chatrecordsOption func(*ChatRecordsMutation)
  4256. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  4257. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  4258. m := &ChatRecordsMutation{
  4259. config: c,
  4260. op: op,
  4261. typ: TypeChatRecords,
  4262. clearedFields: make(map[string]struct{}),
  4263. }
  4264. for _, opt := range opts {
  4265. opt(m)
  4266. }
  4267. return m
  4268. }
  4269. // withChatRecordsID sets the ID field of the mutation.
  4270. func withChatRecordsID(id uint64) chatrecordsOption {
  4271. return func(m *ChatRecordsMutation) {
  4272. var (
  4273. err error
  4274. once sync.Once
  4275. value *ChatRecords
  4276. )
  4277. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  4278. once.Do(func() {
  4279. if m.done {
  4280. err = errors.New("querying old values post mutation is not allowed")
  4281. } else {
  4282. value, err = m.Client().ChatRecords.Get(ctx, id)
  4283. }
  4284. })
  4285. return value, err
  4286. }
  4287. m.id = &id
  4288. }
  4289. }
  4290. // withChatRecords sets the old ChatRecords of the mutation.
  4291. func withChatRecords(node *ChatRecords) chatrecordsOption {
  4292. return func(m *ChatRecordsMutation) {
  4293. m.oldValue = func(context.Context) (*ChatRecords, error) {
  4294. return node, nil
  4295. }
  4296. m.id = &node.ID
  4297. }
  4298. }
  4299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4300. // executed in a transaction (ent.Tx), a transactional client is returned.
  4301. func (m ChatRecordsMutation) Client() *Client {
  4302. client := &Client{config: m.config}
  4303. client.init()
  4304. return client
  4305. }
  4306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4307. // it returns an error otherwise.
  4308. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  4309. if _, ok := m.driver.(*txDriver); !ok {
  4310. return nil, errors.New("ent: mutation is not running in a transaction")
  4311. }
  4312. tx := &Tx{config: m.config}
  4313. tx.init()
  4314. return tx, nil
  4315. }
  4316. // SetID sets the value of the id field. Note that this
  4317. // operation is only accepted on creation of ChatRecords entities.
  4318. func (m *ChatRecordsMutation) SetID(id uint64) {
  4319. m.id = &id
  4320. }
  4321. // ID returns the ID value in the mutation. Note that the ID is only available
  4322. // if it was provided to the builder or after it was returned from the database.
  4323. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  4324. if m.id == nil {
  4325. return
  4326. }
  4327. return *m.id, true
  4328. }
  4329. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4330. // That means, if the mutation is applied within a transaction with an isolation level such
  4331. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4332. // or updated by the mutation.
  4333. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  4334. switch {
  4335. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4336. id, exists := m.ID()
  4337. if exists {
  4338. return []uint64{id}, nil
  4339. }
  4340. fallthrough
  4341. case m.op.Is(OpUpdate | OpDelete):
  4342. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  4343. default:
  4344. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4345. }
  4346. }
  4347. // SetCreatedAt sets the "created_at" field.
  4348. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  4349. m.created_at = &t
  4350. }
  4351. // CreatedAt returns the value of the "created_at" field in the mutation.
  4352. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  4353. v := m.created_at
  4354. if v == nil {
  4355. return
  4356. }
  4357. return *v, true
  4358. }
  4359. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  4360. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4362. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4363. if !m.op.Is(OpUpdateOne) {
  4364. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4365. }
  4366. if m.id == nil || m.oldValue == nil {
  4367. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4368. }
  4369. oldValue, err := m.oldValue(ctx)
  4370. if err != nil {
  4371. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4372. }
  4373. return oldValue.CreatedAt, nil
  4374. }
  4375. // ResetCreatedAt resets all changes to the "created_at" field.
  4376. func (m *ChatRecordsMutation) ResetCreatedAt() {
  4377. m.created_at = nil
  4378. }
  4379. // SetUpdatedAt sets the "updated_at" field.
  4380. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  4381. m.updated_at = &t
  4382. }
  4383. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4384. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  4385. v := m.updated_at
  4386. if v == nil {
  4387. return
  4388. }
  4389. return *v, true
  4390. }
  4391. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  4392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4394. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4395. if !m.op.Is(OpUpdateOne) {
  4396. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4397. }
  4398. if m.id == nil || m.oldValue == nil {
  4399. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4400. }
  4401. oldValue, err := m.oldValue(ctx)
  4402. if err != nil {
  4403. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4404. }
  4405. return oldValue.UpdatedAt, nil
  4406. }
  4407. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4408. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  4409. m.updated_at = nil
  4410. }
  4411. // SetDeletedAt sets the "deleted_at" field.
  4412. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  4413. m.deleted_at = &t
  4414. }
  4415. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4416. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  4417. v := m.deleted_at
  4418. if v == nil {
  4419. return
  4420. }
  4421. return *v, true
  4422. }
  4423. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  4424. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4426. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4427. if !m.op.Is(OpUpdateOne) {
  4428. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4429. }
  4430. if m.id == nil || m.oldValue == nil {
  4431. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4432. }
  4433. oldValue, err := m.oldValue(ctx)
  4434. if err != nil {
  4435. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4436. }
  4437. return oldValue.DeletedAt, nil
  4438. }
  4439. // ClearDeletedAt clears the value of the "deleted_at" field.
  4440. func (m *ChatRecordsMutation) ClearDeletedAt() {
  4441. m.deleted_at = nil
  4442. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  4443. }
  4444. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4445. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  4446. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  4447. return ok
  4448. }
  4449. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4450. func (m *ChatRecordsMutation) ResetDeletedAt() {
  4451. m.deleted_at = nil
  4452. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  4453. }
  4454. // SetContent sets the "content" field.
  4455. func (m *ChatRecordsMutation) SetContent(s string) {
  4456. m.content = &s
  4457. }
  4458. // Content returns the value of the "content" field in the mutation.
  4459. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  4460. v := m.content
  4461. if v == nil {
  4462. return
  4463. }
  4464. return *v, true
  4465. }
  4466. // OldContent returns the old "content" field's value of the ChatRecords entity.
  4467. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4469. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  4470. if !m.op.Is(OpUpdateOne) {
  4471. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4472. }
  4473. if m.id == nil || m.oldValue == nil {
  4474. return v, errors.New("OldContent requires an ID field in the mutation")
  4475. }
  4476. oldValue, err := m.oldValue(ctx)
  4477. if err != nil {
  4478. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4479. }
  4480. return oldValue.Content, nil
  4481. }
  4482. // ResetContent resets all changes to the "content" field.
  4483. func (m *ChatRecordsMutation) ResetContent() {
  4484. m.content = nil
  4485. }
  4486. // SetContentType sets the "content_type" field.
  4487. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  4488. m.content_type = &u
  4489. m.addcontent_type = nil
  4490. }
  4491. // ContentType returns the value of the "content_type" field in the mutation.
  4492. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  4493. v := m.content_type
  4494. if v == nil {
  4495. return
  4496. }
  4497. return *v, true
  4498. }
  4499. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  4500. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4502. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  4503. if !m.op.Is(OpUpdateOne) {
  4504. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  4505. }
  4506. if m.id == nil || m.oldValue == nil {
  4507. return v, errors.New("OldContentType requires an ID field in the mutation")
  4508. }
  4509. oldValue, err := m.oldValue(ctx)
  4510. if err != nil {
  4511. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  4512. }
  4513. return oldValue.ContentType, nil
  4514. }
  4515. // AddContentType adds u to the "content_type" field.
  4516. func (m *ChatRecordsMutation) AddContentType(u int8) {
  4517. if m.addcontent_type != nil {
  4518. *m.addcontent_type += u
  4519. } else {
  4520. m.addcontent_type = &u
  4521. }
  4522. }
  4523. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  4524. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  4525. v := m.addcontent_type
  4526. if v == nil {
  4527. return
  4528. }
  4529. return *v, true
  4530. }
  4531. // ResetContentType resets all changes to the "content_type" field.
  4532. func (m *ChatRecordsMutation) ResetContentType() {
  4533. m.content_type = nil
  4534. m.addcontent_type = nil
  4535. }
  4536. // SetSessionID sets the "session_id" field.
  4537. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  4538. m.session_id = &u
  4539. m.addsession_id = nil
  4540. }
  4541. // SessionID returns the value of the "session_id" field in the mutation.
  4542. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  4543. v := m.session_id
  4544. if v == nil {
  4545. return
  4546. }
  4547. return *v, true
  4548. }
  4549. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  4550. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4552. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  4553. if !m.op.Is(OpUpdateOne) {
  4554. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4555. }
  4556. if m.id == nil || m.oldValue == nil {
  4557. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4558. }
  4559. oldValue, err := m.oldValue(ctx)
  4560. if err != nil {
  4561. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4562. }
  4563. return oldValue.SessionID, nil
  4564. }
  4565. // AddSessionID adds u to the "session_id" field.
  4566. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  4567. if m.addsession_id != nil {
  4568. *m.addsession_id += u
  4569. } else {
  4570. m.addsession_id = &u
  4571. }
  4572. }
  4573. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  4574. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  4575. v := m.addsession_id
  4576. if v == nil {
  4577. return
  4578. }
  4579. return *v, true
  4580. }
  4581. // ResetSessionID resets all changes to the "session_id" field.
  4582. func (m *ChatRecordsMutation) ResetSessionID() {
  4583. m.session_id = nil
  4584. m.addsession_id = nil
  4585. }
  4586. // SetUserID sets the "user_id" field.
  4587. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  4588. m.user_id = &u
  4589. m.adduser_id = nil
  4590. }
  4591. // UserID returns the value of the "user_id" field in the mutation.
  4592. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  4593. v := m.user_id
  4594. if v == nil {
  4595. return
  4596. }
  4597. return *v, true
  4598. }
  4599. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  4600. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4602. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4603. if !m.op.Is(OpUpdateOne) {
  4604. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4605. }
  4606. if m.id == nil || m.oldValue == nil {
  4607. return v, errors.New("OldUserID requires an ID field in the mutation")
  4608. }
  4609. oldValue, err := m.oldValue(ctx)
  4610. if err != nil {
  4611. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4612. }
  4613. return oldValue.UserID, nil
  4614. }
  4615. // AddUserID adds u to the "user_id" field.
  4616. func (m *ChatRecordsMutation) AddUserID(u int64) {
  4617. if m.adduser_id != nil {
  4618. *m.adduser_id += u
  4619. } else {
  4620. m.adduser_id = &u
  4621. }
  4622. }
  4623. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4624. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  4625. v := m.adduser_id
  4626. if v == nil {
  4627. return
  4628. }
  4629. return *v, true
  4630. }
  4631. // ResetUserID resets all changes to the "user_id" field.
  4632. func (m *ChatRecordsMutation) ResetUserID() {
  4633. m.user_id = nil
  4634. m.adduser_id = nil
  4635. }
  4636. // SetBotID sets the "bot_id" field.
  4637. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  4638. m.bot_id = &u
  4639. m.addbot_id = nil
  4640. }
  4641. // BotID returns the value of the "bot_id" field in the mutation.
  4642. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  4643. v := m.bot_id
  4644. if v == nil {
  4645. return
  4646. }
  4647. return *v, true
  4648. }
  4649. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  4650. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4652. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  4653. if !m.op.Is(OpUpdateOne) {
  4654. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  4655. }
  4656. if m.id == nil || m.oldValue == nil {
  4657. return v, errors.New("OldBotID requires an ID field in the mutation")
  4658. }
  4659. oldValue, err := m.oldValue(ctx)
  4660. if err != nil {
  4661. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  4662. }
  4663. return oldValue.BotID, nil
  4664. }
  4665. // AddBotID adds u to the "bot_id" field.
  4666. func (m *ChatRecordsMutation) AddBotID(u int64) {
  4667. if m.addbot_id != nil {
  4668. *m.addbot_id += u
  4669. } else {
  4670. m.addbot_id = &u
  4671. }
  4672. }
  4673. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  4674. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  4675. v := m.addbot_id
  4676. if v == nil {
  4677. return
  4678. }
  4679. return *v, true
  4680. }
  4681. // ResetBotID resets all changes to the "bot_id" field.
  4682. func (m *ChatRecordsMutation) ResetBotID() {
  4683. m.bot_id = nil
  4684. m.addbot_id = nil
  4685. }
  4686. // SetBotType sets the "bot_type" field.
  4687. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  4688. m.bot_type = &u
  4689. m.addbot_type = nil
  4690. }
  4691. // BotType returns the value of the "bot_type" field in the mutation.
  4692. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  4693. v := m.bot_type
  4694. if v == nil {
  4695. return
  4696. }
  4697. return *v, true
  4698. }
  4699. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  4700. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  4701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4702. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  4703. if !m.op.Is(OpUpdateOne) {
  4704. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  4705. }
  4706. if m.id == nil || m.oldValue == nil {
  4707. return v, errors.New("OldBotType requires an ID field in the mutation")
  4708. }
  4709. oldValue, err := m.oldValue(ctx)
  4710. if err != nil {
  4711. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  4712. }
  4713. return oldValue.BotType, nil
  4714. }
  4715. // AddBotType adds u to the "bot_type" field.
  4716. func (m *ChatRecordsMutation) AddBotType(u int8) {
  4717. if m.addbot_type != nil {
  4718. *m.addbot_type += u
  4719. } else {
  4720. m.addbot_type = &u
  4721. }
  4722. }
  4723. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  4724. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  4725. v := m.addbot_type
  4726. if v == nil {
  4727. return
  4728. }
  4729. return *v, true
  4730. }
  4731. // ResetBotType resets all changes to the "bot_type" field.
  4732. func (m *ChatRecordsMutation) ResetBotType() {
  4733. m.bot_type = nil
  4734. m.addbot_type = nil
  4735. }
  4736. // Where appends a list predicates to the ChatRecordsMutation builder.
  4737. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  4738. m.predicates = append(m.predicates, ps...)
  4739. }
  4740. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  4741. // users can use type-assertion to append predicates that do not depend on any generated package.
  4742. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  4743. p := make([]predicate.ChatRecords, len(ps))
  4744. for i := range ps {
  4745. p[i] = ps[i]
  4746. }
  4747. m.Where(p...)
  4748. }
  4749. // Op returns the operation name.
  4750. func (m *ChatRecordsMutation) Op() Op {
  4751. return m.op
  4752. }
  4753. // SetOp allows setting the mutation operation.
  4754. func (m *ChatRecordsMutation) SetOp(op Op) {
  4755. m.op = op
  4756. }
  4757. // Type returns the node type of this mutation (ChatRecords).
  4758. func (m *ChatRecordsMutation) Type() string {
  4759. return m.typ
  4760. }
  4761. // Fields returns all fields that were changed during this mutation. Note that in
  4762. // order to get all numeric fields that were incremented/decremented, call
  4763. // AddedFields().
  4764. func (m *ChatRecordsMutation) Fields() []string {
  4765. fields := make([]string, 0, 9)
  4766. if m.created_at != nil {
  4767. fields = append(fields, chatrecords.FieldCreatedAt)
  4768. }
  4769. if m.updated_at != nil {
  4770. fields = append(fields, chatrecords.FieldUpdatedAt)
  4771. }
  4772. if m.deleted_at != nil {
  4773. fields = append(fields, chatrecords.FieldDeletedAt)
  4774. }
  4775. if m.content != nil {
  4776. fields = append(fields, chatrecords.FieldContent)
  4777. }
  4778. if m.content_type != nil {
  4779. fields = append(fields, chatrecords.FieldContentType)
  4780. }
  4781. if m.session_id != nil {
  4782. fields = append(fields, chatrecords.FieldSessionID)
  4783. }
  4784. if m.user_id != nil {
  4785. fields = append(fields, chatrecords.FieldUserID)
  4786. }
  4787. if m.bot_id != nil {
  4788. fields = append(fields, chatrecords.FieldBotID)
  4789. }
  4790. if m.bot_type != nil {
  4791. fields = append(fields, chatrecords.FieldBotType)
  4792. }
  4793. return fields
  4794. }
  4795. // Field returns the value of a field with the given name. The second boolean
  4796. // return value indicates that this field was not set, or was not defined in the
  4797. // schema.
  4798. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  4799. switch name {
  4800. case chatrecords.FieldCreatedAt:
  4801. return m.CreatedAt()
  4802. case chatrecords.FieldUpdatedAt:
  4803. return m.UpdatedAt()
  4804. case chatrecords.FieldDeletedAt:
  4805. return m.DeletedAt()
  4806. case chatrecords.FieldContent:
  4807. return m.Content()
  4808. case chatrecords.FieldContentType:
  4809. return m.ContentType()
  4810. case chatrecords.FieldSessionID:
  4811. return m.SessionID()
  4812. case chatrecords.FieldUserID:
  4813. return m.UserID()
  4814. case chatrecords.FieldBotID:
  4815. return m.BotID()
  4816. case chatrecords.FieldBotType:
  4817. return m.BotType()
  4818. }
  4819. return nil, false
  4820. }
  4821. // OldField returns the old value of the field from the database. An error is
  4822. // returned if the mutation operation is not UpdateOne, or the query to the
  4823. // database failed.
  4824. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4825. switch name {
  4826. case chatrecords.FieldCreatedAt:
  4827. return m.OldCreatedAt(ctx)
  4828. case chatrecords.FieldUpdatedAt:
  4829. return m.OldUpdatedAt(ctx)
  4830. case chatrecords.FieldDeletedAt:
  4831. return m.OldDeletedAt(ctx)
  4832. case chatrecords.FieldContent:
  4833. return m.OldContent(ctx)
  4834. case chatrecords.FieldContentType:
  4835. return m.OldContentType(ctx)
  4836. case chatrecords.FieldSessionID:
  4837. return m.OldSessionID(ctx)
  4838. case chatrecords.FieldUserID:
  4839. return m.OldUserID(ctx)
  4840. case chatrecords.FieldBotID:
  4841. return m.OldBotID(ctx)
  4842. case chatrecords.FieldBotType:
  4843. return m.OldBotType(ctx)
  4844. }
  4845. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  4846. }
  4847. // SetField sets the value of a field with the given name. It returns an error if
  4848. // the field is not defined in the schema, or if the type mismatched the field
  4849. // type.
  4850. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  4851. switch name {
  4852. case chatrecords.FieldCreatedAt:
  4853. v, ok := value.(time.Time)
  4854. if !ok {
  4855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4856. }
  4857. m.SetCreatedAt(v)
  4858. return nil
  4859. case chatrecords.FieldUpdatedAt:
  4860. v, ok := value.(time.Time)
  4861. if !ok {
  4862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4863. }
  4864. m.SetUpdatedAt(v)
  4865. return nil
  4866. case chatrecords.FieldDeletedAt:
  4867. v, ok := value.(time.Time)
  4868. if !ok {
  4869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4870. }
  4871. m.SetDeletedAt(v)
  4872. return nil
  4873. case chatrecords.FieldContent:
  4874. v, ok := value.(string)
  4875. if !ok {
  4876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4877. }
  4878. m.SetContent(v)
  4879. return nil
  4880. case chatrecords.FieldContentType:
  4881. v, ok := value.(uint8)
  4882. if !ok {
  4883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4884. }
  4885. m.SetContentType(v)
  4886. return nil
  4887. case chatrecords.FieldSessionID:
  4888. v, ok := value.(uint64)
  4889. if !ok {
  4890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4891. }
  4892. m.SetSessionID(v)
  4893. return nil
  4894. case chatrecords.FieldUserID:
  4895. v, ok := value.(uint64)
  4896. if !ok {
  4897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4898. }
  4899. m.SetUserID(v)
  4900. return nil
  4901. case chatrecords.FieldBotID:
  4902. v, ok := value.(uint64)
  4903. if !ok {
  4904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4905. }
  4906. m.SetBotID(v)
  4907. return nil
  4908. case chatrecords.FieldBotType:
  4909. v, ok := value.(uint8)
  4910. if !ok {
  4911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4912. }
  4913. m.SetBotType(v)
  4914. return nil
  4915. }
  4916. return fmt.Errorf("unknown ChatRecords field %s", name)
  4917. }
  4918. // AddedFields returns all numeric fields that were incremented/decremented during
  4919. // this mutation.
  4920. func (m *ChatRecordsMutation) AddedFields() []string {
  4921. var fields []string
  4922. if m.addcontent_type != nil {
  4923. fields = append(fields, chatrecords.FieldContentType)
  4924. }
  4925. if m.addsession_id != nil {
  4926. fields = append(fields, chatrecords.FieldSessionID)
  4927. }
  4928. if m.adduser_id != nil {
  4929. fields = append(fields, chatrecords.FieldUserID)
  4930. }
  4931. if m.addbot_id != nil {
  4932. fields = append(fields, chatrecords.FieldBotID)
  4933. }
  4934. if m.addbot_type != nil {
  4935. fields = append(fields, chatrecords.FieldBotType)
  4936. }
  4937. return fields
  4938. }
  4939. // AddedField returns the numeric value that was incremented/decremented on a field
  4940. // with the given name. The second boolean return value indicates that this field
  4941. // was not set, or was not defined in the schema.
  4942. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  4943. switch name {
  4944. case chatrecords.FieldContentType:
  4945. return m.AddedContentType()
  4946. case chatrecords.FieldSessionID:
  4947. return m.AddedSessionID()
  4948. case chatrecords.FieldUserID:
  4949. return m.AddedUserID()
  4950. case chatrecords.FieldBotID:
  4951. return m.AddedBotID()
  4952. case chatrecords.FieldBotType:
  4953. return m.AddedBotType()
  4954. }
  4955. return nil, false
  4956. }
  4957. // AddField adds the value to the field with the given name. It returns an error if
  4958. // the field is not defined in the schema, or if the type mismatched the field
  4959. // type.
  4960. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  4961. switch name {
  4962. case chatrecords.FieldContentType:
  4963. v, ok := value.(int8)
  4964. if !ok {
  4965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4966. }
  4967. m.AddContentType(v)
  4968. return nil
  4969. case chatrecords.FieldSessionID:
  4970. v, ok := value.(int64)
  4971. if !ok {
  4972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4973. }
  4974. m.AddSessionID(v)
  4975. return nil
  4976. case chatrecords.FieldUserID:
  4977. v, ok := value.(int64)
  4978. if !ok {
  4979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4980. }
  4981. m.AddUserID(v)
  4982. return nil
  4983. case chatrecords.FieldBotID:
  4984. v, ok := value.(int64)
  4985. if !ok {
  4986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4987. }
  4988. m.AddBotID(v)
  4989. return nil
  4990. case chatrecords.FieldBotType:
  4991. v, ok := value.(int8)
  4992. if !ok {
  4993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4994. }
  4995. m.AddBotType(v)
  4996. return nil
  4997. }
  4998. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  4999. }
  5000. // ClearedFields returns all nullable fields that were cleared during this
  5001. // mutation.
  5002. func (m *ChatRecordsMutation) ClearedFields() []string {
  5003. var fields []string
  5004. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  5005. fields = append(fields, chatrecords.FieldDeletedAt)
  5006. }
  5007. return fields
  5008. }
  5009. // FieldCleared returns a boolean indicating if a field with the given name was
  5010. // cleared in this mutation.
  5011. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  5012. _, ok := m.clearedFields[name]
  5013. return ok
  5014. }
  5015. // ClearField clears the value of the field with the given name. It returns an
  5016. // error if the field is not defined in the schema.
  5017. func (m *ChatRecordsMutation) ClearField(name string) error {
  5018. switch name {
  5019. case chatrecords.FieldDeletedAt:
  5020. m.ClearDeletedAt()
  5021. return nil
  5022. }
  5023. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  5024. }
  5025. // ResetField resets all changes in the mutation for the field with the given name.
  5026. // It returns an error if the field is not defined in the schema.
  5027. func (m *ChatRecordsMutation) ResetField(name string) error {
  5028. switch name {
  5029. case chatrecords.FieldCreatedAt:
  5030. m.ResetCreatedAt()
  5031. return nil
  5032. case chatrecords.FieldUpdatedAt:
  5033. m.ResetUpdatedAt()
  5034. return nil
  5035. case chatrecords.FieldDeletedAt:
  5036. m.ResetDeletedAt()
  5037. return nil
  5038. case chatrecords.FieldContent:
  5039. m.ResetContent()
  5040. return nil
  5041. case chatrecords.FieldContentType:
  5042. m.ResetContentType()
  5043. return nil
  5044. case chatrecords.FieldSessionID:
  5045. m.ResetSessionID()
  5046. return nil
  5047. case chatrecords.FieldUserID:
  5048. m.ResetUserID()
  5049. return nil
  5050. case chatrecords.FieldBotID:
  5051. m.ResetBotID()
  5052. return nil
  5053. case chatrecords.FieldBotType:
  5054. m.ResetBotType()
  5055. return nil
  5056. }
  5057. return fmt.Errorf("unknown ChatRecords field %s", name)
  5058. }
  5059. // AddedEdges returns all edge names that were set/added in this mutation.
  5060. func (m *ChatRecordsMutation) AddedEdges() []string {
  5061. edges := make([]string, 0, 0)
  5062. return edges
  5063. }
  5064. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5065. // name in this mutation.
  5066. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  5067. return nil
  5068. }
  5069. // RemovedEdges returns all edge names that were removed in this mutation.
  5070. func (m *ChatRecordsMutation) RemovedEdges() []string {
  5071. edges := make([]string, 0, 0)
  5072. return edges
  5073. }
  5074. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5075. // the given name in this mutation.
  5076. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  5077. return nil
  5078. }
  5079. // ClearedEdges returns all edge names that were cleared in this mutation.
  5080. func (m *ChatRecordsMutation) ClearedEdges() []string {
  5081. edges := make([]string, 0, 0)
  5082. return edges
  5083. }
  5084. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5085. // was cleared in this mutation.
  5086. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  5087. return false
  5088. }
  5089. // ClearEdge clears the value of the edge with the given name. It returns an error
  5090. // if that edge is not defined in the schema.
  5091. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  5092. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  5093. }
  5094. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5095. // It returns an error if the edge is not defined in the schema.
  5096. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  5097. return fmt.Errorf("unknown ChatRecords edge %s", name)
  5098. }
  5099. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  5100. type ChatSessionMutation struct {
  5101. config
  5102. op Op
  5103. typ string
  5104. id *uint64
  5105. created_at *time.Time
  5106. updated_at *time.Time
  5107. deleted_at *time.Time
  5108. name *string
  5109. user_id *uint64
  5110. adduser_id *int64
  5111. bot_id *uint64
  5112. addbot_id *int64
  5113. bot_type *uint8
  5114. addbot_type *int8
  5115. clearedFields map[string]struct{}
  5116. done bool
  5117. oldValue func(context.Context) (*ChatSession, error)
  5118. predicates []predicate.ChatSession
  5119. }
  5120. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  5121. // chatsessionOption allows management of the mutation configuration using functional options.
  5122. type chatsessionOption func(*ChatSessionMutation)
  5123. // newChatSessionMutation creates new mutation for the ChatSession entity.
  5124. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  5125. m := &ChatSessionMutation{
  5126. config: c,
  5127. op: op,
  5128. typ: TypeChatSession,
  5129. clearedFields: make(map[string]struct{}),
  5130. }
  5131. for _, opt := range opts {
  5132. opt(m)
  5133. }
  5134. return m
  5135. }
  5136. // withChatSessionID sets the ID field of the mutation.
  5137. func withChatSessionID(id uint64) chatsessionOption {
  5138. return func(m *ChatSessionMutation) {
  5139. var (
  5140. err error
  5141. once sync.Once
  5142. value *ChatSession
  5143. )
  5144. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  5145. once.Do(func() {
  5146. if m.done {
  5147. err = errors.New("querying old values post mutation is not allowed")
  5148. } else {
  5149. value, err = m.Client().ChatSession.Get(ctx, id)
  5150. }
  5151. })
  5152. return value, err
  5153. }
  5154. m.id = &id
  5155. }
  5156. }
  5157. // withChatSession sets the old ChatSession of the mutation.
  5158. func withChatSession(node *ChatSession) chatsessionOption {
  5159. return func(m *ChatSessionMutation) {
  5160. m.oldValue = func(context.Context) (*ChatSession, error) {
  5161. return node, nil
  5162. }
  5163. m.id = &node.ID
  5164. }
  5165. }
  5166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5167. // executed in a transaction (ent.Tx), a transactional client is returned.
  5168. func (m ChatSessionMutation) Client() *Client {
  5169. client := &Client{config: m.config}
  5170. client.init()
  5171. return client
  5172. }
  5173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5174. // it returns an error otherwise.
  5175. func (m ChatSessionMutation) Tx() (*Tx, error) {
  5176. if _, ok := m.driver.(*txDriver); !ok {
  5177. return nil, errors.New("ent: mutation is not running in a transaction")
  5178. }
  5179. tx := &Tx{config: m.config}
  5180. tx.init()
  5181. return tx, nil
  5182. }
  5183. // SetID sets the value of the id field. Note that this
  5184. // operation is only accepted on creation of ChatSession entities.
  5185. func (m *ChatSessionMutation) SetID(id uint64) {
  5186. m.id = &id
  5187. }
  5188. // ID returns the ID value in the mutation. Note that the ID is only available
  5189. // if it was provided to the builder or after it was returned from the database.
  5190. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  5191. if m.id == nil {
  5192. return
  5193. }
  5194. return *m.id, true
  5195. }
  5196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5197. // That means, if the mutation is applied within a transaction with an isolation level such
  5198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5199. // or updated by the mutation.
  5200. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  5201. switch {
  5202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5203. id, exists := m.ID()
  5204. if exists {
  5205. return []uint64{id}, nil
  5206. }
  5207. fallthrough
  5208. case m.op.Is(OpUpdate | OpDelete):
  5209. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  5210. default:
  5211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5212. }
  5213. }
  5214. // SetCreatedAt sets the "created_at" field.
  5215. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  5216. m.created_at = &t
  5217. }
  5218. // CreatedAt returns the value of the "created_at" field in the mutation.
  5219. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  5220. v := m.created_at
  5221. if v == nil {
  5222. return
  5223. }
  5224. return *v, true
  5225. }
  5226. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  5227. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5229. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5230. if !m.op.Is(OpUpdateOne) {
  5231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5232. }
  5233. if m.id == nil || m.oldValue == nil {
  5234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5235. }
  5236. oldValue, err := m.oldValue(ctx)
  5237. if err != nil {
  5238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5239. }
  5240. return oldValue.CreatedAt, nil
  5241. }
  5242. // ResetCreatedAt resets all changes to the "created_at" field.
  5243. func (m *ChatSessionMutation) ResetCreatedAt() {
  5244. m.created_at = nil
  5245. }
  5246. // SetUpdatedAt sets the "updated_at" field.
  5247. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  5248. m.updated_at = &t
  5249. }
  5250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5251. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  5252. v := m.updated_at
  5253. if v == nil {
  5254. return
  5255. }
  5256. return *v, true
  5257. }
  5258. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  5259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5261. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5262. if !m.op.Is(OpUpdateOne) {
  5263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5264. }
  5265. if m.id == nil || m.oldValue == nil {
  5266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5267. }
  5268. oldValue, err := m.oldValue(ctx)
  5269. if err != nil {
  5270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5271. }
  5272. return oldValue.UpdatedAt, nil
  5273. }
  5274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5275. func (m *ChatSessionMutation) ResetUpdatedAt() {
  5276. m.updated_at = nil
  5277. }
  5278. // SetDeletedAt sets the "deleted_at" field.
  5279. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  5280. m.deleted_at = &t
  5281. }
  5282. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5283. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  5284. v := m.deleted_at
  5285. if v == nil {
  5286. return
  5287. }
  5288. return *v, true
  5289. }
  5290. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  5291. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5293. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5294. if !m.op.Is(OpUpdateOne) {
  5295. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5296. }
  5297. if m.id == nil || m.oldValue == nil {
  5298. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5299. }
  5300. oldValue, err := m.oldValue(ctx)
  5301. if err != nil {
  5302. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5303. }
  5304. return oldValue.DeletedAt, nil
  5305. }
  5306. // ClearDeletedAt clears the value of the "deleted_at" field.
  5307. func (m *ChatSessionMutation) ClearDeletedAt() {
  5308. m.deleted_at = nil
  5309. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  5310. }
  5311. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5312. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  5313. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  5314. return ok
  5315. }
  5316. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5317. func (m *ChatSessionMutation) ResetDeletedAt() {
  5318. m.deleted_at = nil
  5319. delete(m.clearedFields, chatsession.FieldDeletedAt)
  5320. }
  5321. // SetName sets the "name" field.
  5322. func (m *ChatSessionMutation) SetName(s string) {
  5323. m.name = &s
  5324. }
  5325. // Name returns the value of the "name" field in the mutation.
  5326. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  5327. v := m.name
  5328. if v == nil {
  5329. return
  5330. }
  5331. return *v, true
  5332. }
  5333. // OldName returns the old "name" field's value of the ChatSession entity.
  5334. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5336. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  5337. if !m.op.Is(OpUpdateOne) {
  5338. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5339. }
  5340. if m.id == nil || m.oldValue == nil {
  5341. return v, errors.New("OldName requires an ID field in the mutation")
  5342. }
  5343. oldValue, err := m.oldValue(ctx)
  5344. if err != nil {
  5345. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5346. }
  5347. return oldValue.Name, nil
  5348. }
  5349. // ResetName resets all changes to the "name" field.
  5350. func (m *ChatSessionMutation) ResetName() {
  5351. m.name = nil
  5352. }
  5353. // SetUserID sets the "user_id" field.
  5354. func (m *ChatSessionMutation) SetUserID(u uint64) {
  5355. m.user_id = &u
  5356. m.adduser_id = nil
  5357. }
  5358. // UserID returns the value of the "user_id" field in the mutation.
  5359. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  5360. v := m.user_id
  5361. if v == nil {
  5362. return
  5363. }
  5364. return *v, true
  5365. }
  5366. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  5367. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5369. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5370. if !m.op.Is(OpUpdateOne) {
  5371. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5372. }
  5373. if m.id == nil || m.oldValue == nil {
  5374. return v, errors.New("OldUserID requires an ID field in the mutation")
  5375. }
  5376. oldValue, err := m.oldValue(ctx)
  5377. if err != nil {
  5378. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5379. }
  5380. return oldValue.UserID, nil
  5381. }
  5382. // AddUserID adds u to the "user_id" field.
  5383. func (m *ChatSessionMutation) AddUserID(u int64) {
  5384. if m.adduser_id != nil {
  5385. *m.adduser_id += u
  5386. } else {
  5387. m.adduser_id = &u
  5388. }
  5389. }
  5390. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5391. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  5392. v := m.adduser_id
  5393. if v == nil {
  5394. return
  5395. }
  5396. return *v, true
  5397. }
  5398. // ResetUserID resets all changes to the "user_id" field.
  5399. func (m *ChatSessionMutation) ResetUserID() {
  5400. m.user_id = nil
  5401. m.adduser_id = nil
  5402. }
  5403. // SetBotID sets the "bot_id" field.
  5404. func (m *ChatSessionMutation) SetBotID(u uint64) {
  5405. m.bot_id = &u
  5406. m.addbot_id = nil
  5407. }
  5408. // BotID returns the value of the "bot_id" field in the mutation.
  5409. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  5410. v := m.bot_id
  5411. if v == nil {
  5412. return
  5413. }
  5414. return *v, true
  5415. }
  5416. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  5417. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5419. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5420. if !m.op.Is(OpUpdateOne) {
  5421. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5422. }
  5423. if m.id == nil || m.oldValue == nil {
  5424. return v, errors.New("OldBotID requires an ID field in the mutation")
  5425. }
  5426. oldValue, err := m.oldValue(ctx)
  5427. if err != nil {
  5428. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5429. }
  5430. return oldValue.BotID, nil
  5431. }
  5432. // AddBotID adds u to the "bot_id" field.
  5433. func (m *ChatSessionMutation) AddBotID(u int64) {
  5434. if m.addbot_id != nil {
  5435. *m.addbot_id += u
  5436. } else {
  5437. m.addbot_id = &u
  5438. }
  5439. }
  5440. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5441. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  5442. v := m.addbot_id
  5443. if v == nil {
  5444. return
  5445. }
  5446. return *v, true
  5447. }
  5448. // ResetBotID resets all changes to the "bot_id" field.
  5449. func (m *ChatSessionMutation) ResetBotID() {
  5450. m.bot_id = nil
  5451. m.addbot_id = nil
  5452. }
  5453. // SetBotType sets the "bot_type" field.
  5454. func (m *ChatSessionMutation) SetBotType(u uint8) {
  5455. m.bot_type = &u
  5456. m.addbot_type = nil
  5457. }
  5458. // BotType returns the value of the "bot_type" field in the mutation.
  5459. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  5460. v := m.bot_type
  5461. if v == nil {
  5462. return
  5463. }
  5464. return *v, true
  5465. }
  5466. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  5467. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  5468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5469. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5470. if !m.op.Is(OpUpdateOne) {
  5471. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5472. }
  5473. if m.id == nil || m.oldValue == nil {
  5474. return v, errors.New("OldBotType requires an ID field in the mutation")
  5475. }
  5476. oldValue, err := m.oldValue(ctx)
  5477. if err != nil {
  5478. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5479. }
  5480. return oldValue.BotType, nil
  5481. }
  5482. // AddBotType adds u to the "bot_type" field.
  5483. func (m *ChatSessionMutation) AddBotType(u int8) {
  5484. if m.addbot_type != nil {
  5485. *m.addbot_type += u
  5486. } else {
  5487. m.addbot_type = &u
  5488. }
  5489. }
  5490. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5491. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  5492. v := m.addbot_type
  5493. if v == nil {
  5494. return
  5495. }
  5496. return *v, true
  5497. }
  5498. // ResetBotType resets all changes to the "bot_type" field.
  5499. func (m *ChatSessionMutation) ResetBotType() {
  5500. m.bot_type = nil
  5501. m.addbot_type = nil
  5502. }
  5503. // Where appends a list predicates to the ChatSessionMutation builder.
  5504. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  5505. m.predicates = append(m.predicates, ps...)
  5506. }
  5507. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  5508. // users can use type-assertion to append predicates that do not depend on any generated package.
  5509. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  5510. p := make([]predicate.ChatSession, len(ps))
  5511. for i := range ps {
  5512. p[i] = ps[i]
  5513. }
  5514. m.Where(p...)
  5515. }
  5516. // Op returns the operation name.
  5517. func (m *ChatSessionMutation) Op() Op {
  5518. return m.op
  5519. }
  5520. // SetOp allows setting the mutation operation.
  5521. func (m *ChatSessionMutation) SetOp(op Op) {
  5522. m.op = op
  5523. }
  5524. // Type returns the node type of this mutation (ChatSession).
  5525. func (m *ChatSessionMutation) Type() string {
  5526. return m.typ
  5527. }
  5528. // Fields returns all fields that were changed during this mutation. Note that in
  5529. // order to get all numeric fields that were incremented/decremented, call
  5530. // AddedFields().
  5531. func (m *ChatSessionMutation) Fields() []string {
  5532. fields := make([]string, 0, 7)
  5533. if m.created_at != nil {
  5534. fields = append(fields, chatsession.FieldCreatedAt)
  5535. }
  5536. if m.updated_at != nil {
  5537. fields = append(fields, chatsession.FieldUpdatedAt)
  5538. }
  5539. if m.deleted_at != nil {
  5540. fields = append(fields, chatsession.FieldDeletedAt)
  5541. }
  5542. if m.name != nil {
  5543. fields = append(fields, chatsession.FieldName)
  5544. }
  5545. if m.user_id != nil {
  5546. fields = append(fields, chatsession.FieldUserID)
  5547. }
  5548. if m.bot_id != nil {
  5549. fields = append(fields, chatsession.FieldBotID)
  5550. }
  5551. if m.bot_type != nil {
  5552. fields = append(fields, chatsession.FieldBotType)
  5553. }
  5554. return fields
  5555. }
  5556. // Field returns the value of a field with the given name. The second boolean
  5557. // return value indicates that this field was not set, or was not defined in the
  5558. // schema.
  5559. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  5560. switch name {
  5561. case chatsession.FieldCreatedAt:
  5562. return m.CreatedAt()
  5563. case chatsession.FieldUpdatedAt:
  5564. return m.UpdatedAt()
  5565. case chatsession.FieldDeletedAt:
  5566. return m.DeletedAt()
  5567. case chatsession.FieldName:
  5568. return m.Name()
  5569. case chatsession.FieldUserID:
  5570. return m.UserID()
  5571. case chatsession.FieldBotID:
  5572. return m.BotID()
  5573. case chatsession.FieldBotType:
  5574. return m.BotType()
  5575. }
  5576. return nil, false
  5577. }
  5578. // OldField returns the old value of the field from the database. An error is
  5579. // returned if the mutation operation is not UpdateOne, or the query to the
  5580. // database failed.
  5581. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5582. switch name {
  5583. case chatsession.FieldCreatedAt:
  5584. return m.OldCreatedAt(ctx)
  5585. case chatsession.FieldUpdatedAt:
  5586. return m.OldUpdatedAt(ctx)
  5587. case chatsession.FieldDeletedAt:
  5588. return m.OldDeletedAt(ctx)
  5589. case chatsession.FieldName:
  5590. return m.OldName(ctx)
  5591. case chatsession.FieldUserID:
  5592. return m.OldUserID(ctx)
  5593. case chatsession.FieldBotID:
  5594. return m.OldBotID(ctx)
  5595. case chatsession.FieldBotType:
  5596. return m.OldBotType(ctx)
  5597. }
  5598. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  5599. }
  5600. // SetField sets the value of a field with the given name. It returns an error if
  5601. // the field is not defined in the schema, or if the type mismatched the field
  5602. // type.
  5603. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  5604. switch name {
  5605. case chatsession.FieldCreatedAt:
  5606. v, ok := value.(time.Time)
  5607. if !ok {
  5608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5609. }
  5610. m.SetCreatedAt(v)
  5611. return nil
  5612. case chatsession.FieldUpdatedAt:
  5613. v, ok := value.(time.Time)
  5614. if !ok {
  5615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5616. }
  5617. m.SetUpdatedAt(v)
  5618. return nil
  5619. case chatsession.FieldDeletedAt:
  5620. v, ok := value.(time.Time)
  5621. if !ok {
  5622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5623. }
  5624. m.SetDeletedAt(v)
  5625. return nil
  5626. case chatsession.FieldName:
  5627. v, ok := value.(string)
  5628. if !ok {
  5629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5630. }
  5631. m.SetName(v)
  5632. return nil
  5633. case chatsession.FieldUserID:
  5634. v, ok := value.(uint64)
  5635. if !ok {
  5636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5637. }
  5638. m.SetUserID(v)
  5639. return nil
  5640. case chatsession.FieldBotID:
  5641. v, ok := value.(uint64)
  5642. if !ok {
  5643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5644. }
  5645. m.SetBotID(v)
  5646. return nil
  5647. case chatsession.FieldBotType:
  5648. v, ok := value.(uint8)
  5649. if !ok {
  5650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5651. }
  5652. m.SetBotType(v)
  5653. return nil
  5654. }
  5655. return fmt.Errorf("unknown ChatSession field %s", name)
  5656. }
  5657. // AddedFields returns all numeric fields that were incremented/decremented during
  5658. // this mutation.
  5659. func (m *ChatSessionMutation) AddedFields() []string {
  5660. var fields []string
  5661. if m.adduser_id != nil {
  5662. fields = append(fields, chatsession.FieldUserID)
  5663. }
  5664. if m.addbot_id != nil {
  5665. fields = append(fields, chatsession.FieldBotID)
  5666. }
  5667. if m.addbot_type != nil {
  5668. fields = append(fields, chatsession.FieldBotType)
  5669. }
  5670. return fields
  5671. }
  5672. // AddedField returns the numeric value that was incremented/decremented on a field
  5673. // with the given name. The second boolean return value indicates that this field
  5674. // was not set, or was not defined in the schema.
  5675. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  5676. switch name {
  5677. case chatsession.FieldUserID:
  5678. return m.AddedUserID()
  5679. case chatsession.FieldBotID:
  5680. return m.AddedBotID()
  5681. case chatsession.FieldBotType:
  5682. return m.AddedBotType()
  5683. }
  5684. return nil, false
  5685. }
  5686. // AddField adds the value to the field with the given name. It returns an error if
  5687. // the field is not defined in the schema, or if the type mismatched the field
  5688. // type.
  5689. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  5690. switch name {
  5691. case chatsession.FieldUserID:
  5692. v, ok := value.(int64)
  5693. if !ok {
  5694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5695. }
  5696. m.AddUserID(v)
  5697. return nil
  5698. case chatsession.FieldBotID:
  5699. v, ok := value.(int64)
  5700. if !ok {
  5701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5702. }
  5703. m.AddBotID(v)
  5704. return nil
  5705. case chatsession.FieldBotType:
  5706. v, ok := value.(int8)
  5707. if !ok {
  5708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5709. }
  5710. m.AddBotType(v)
  5711. return nil
  5712. }
  5713. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  5714. }
  5715. // ClearedFields returns all nullable fields that were cleared during this
  5716. // mutation.
  5717. func (m *ChatSessionMutation) ClearedFields() []string {
  5718. var fields []string
  5719. if m.FieldCleared(chatsession.FieldDeletedAt) {
  5720. fields = append(fields, chatsession.FieldDeletedAt)
  5721. }
  5722. return fields
  5723. }
  5724. // FieldCleared returns a boolean indicating if a field with the given name was
  5725. // cleared in this mutation.
  5726. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  5727. _, ok := m.clearedFields[name]
  5728. return ok
  5729. }
  5730. // ClearField clears the value of the field with the given name. It returns an
  5731. // error if the field is not defined in the schema.
  5732. func (m *ChatSessionMutation) ClearField(name string) error {
  5733. switch name {
  5734. case chatsession.FieldDeletedAt:
  5735. m.ClearDeletedAt()
  5736. return nil
  5737. }
  5738. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  5739. }
  5740. // ResetField resets all changes in the mutation for the field with the given name.
  5741. // It returns an error if the field is not defined in the schema.
  5742. func (m *ChatSessionMutation) ResetField(name string) error {
  5743. switch name {
  5744. case chatsession.FieldCreatedAt:
  5745. m.ResetCreatedAt()
  5746. return nil
  5747. case chatsession.FieldUpdatedAt:
  5748. m.ResetUpdatedAt()
  5749. return nil
  5750. case chatsession.FieldDeletedAt:
  5751. m.ResetDeletedAt()
  5752. return nil
  5753. case chatsession.FieldName:
  5754. m.ResetName()
  5755. return nil
  5756. case chatsession.FieldUserID:
  5757. m.ResetUserID()
  5758. return nil
  5759. case chatsession.FieldBotID:
  5760. m.ResetBotID()
  5761. return nil
  5762. case chatsession.FieldBotType:
  5763. m.ResetBotType()
  5764. return nil
  5765. }
  5766. return fmt.Errorf("unknown ChatSession field %s", name)
  5767. }
  5768. // AddedEdges returns all edge names that were set/added in this mutation.
  5769. func (m *ChatSessionMutation) AddedEdges() []string {
  5770. edges := make([]string, 0, 0)
  5771. return edges
  5772. }
  5773. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5774. // name in this mutation.
  5775. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  5776. return nil
  5777. }
  5778. // RemovedEdges returns all edge names that were removed in this mutation.
  5779. func (m *ChatSessionMutation) RemovedEdges() []string {
  5780. edges := make([]string, 0, 0)
  5781. return edges
  5782. }
  5783. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5784. // the given name in this mutation.
  5785. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  5786. return nil
  5787. }
  5788. // ClearedEdges returns all edge names that were cleared in this mutation.
  5789. func (m *ChatSessionMutation) ClearedEdges() []string {
  5790. edges := make([]string, 0, 0)
  5791. return edges
  5792. }
  5793. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5794. // was cleared in this mutation.
  5795. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  5796. return false
  5797. }
  5798. // ClearEdge clears the value of the edge with the given name. It returns an error
  5799. // if that edge is not defined in the schema.
  5800. func (m *ChatSessionMutation) ClearEdge(name string) error {
  5801. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  5802. }
  5803. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5804. // It returns an error if the edge is not defined in the schema.
  5805. func (m *ChatSessionMutation) ResetEdge(name string) error {
  5806. return fmt.Errorf("unknown ChatSession edge %s", name)
  5807. }
  5808. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  5809. type ContactMutation struct {
  5810. config
  5811. op Op
  5812. typ string
  5813. id *uint64
  5814. created_at *time.Time
  5815. updated_at *time.Time
  5816. status *uint8
  5817. addstatus *int8
  5818. deleted_at *time.Time
  5819. wx_wxid *string
  5820. _type *int
  5821. add_type *int
  5822. wxid *string
  5823. account *string
  5824. nickname *string
  5825. markname *string
  5826. headimg *string
  5827. sex *int
  5828. addsex *int
  5829. starrole *string
  5830. dontseeit *int
  5831. adddontseeit *int
  5832. dontseeme *int
  5833. adddontseeme *int
  5834. lag *string
  5835. gid *string
  5836. gname *string
  5837. v3 *string
  5838. organization_id *uint64
  5839. addorganization_id *int64
  5840. clearedFields map[string]struct{}
  5841. contact_relationships map[uint64]struct{}
  5842. removedcontact_relationships map[uint64]struct{}
  5843. clearedcontact_relationships bool
  5844. contact_messages map[uint64]struct{}
  5845. removedcontact_messages map[uint64]struct{}
  5846. clearedcontact_messages bool
  5847. done bool
  5848. oldValue func(context.Context) (*Contact, error)
  5849. predicates []predicate.Contact
  5850. }
  5851. var _ ent.Mutation = (*ContactMutation)(nil)
  5852. // contactOption allows management of the mutation configuration using functional options.
  5853. type contactOption func(*ContactMutation)
  5854. // newContactMutation creates new mutation for the Contact entity.
  5855. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  5856. m := &ContactMutation{
  5857. config: c,
  5858. op: op,
  5859. typ: TypeContact,
  5860. clearedFields: make(map[string]struct{}),
  5861. }
  5862. for _, opt := range opts {
  5863. opt(m)
  5864. }
  5865. return m
  5866. }
  5867. // withContactID sets the ID field of the mutation.
  5868. func withContactID(id uint64) contactOption {
  5869. return func(m *ContactMutation) {
  5870. var (
  5871. err error
  5872. once sync.Once
  5873. value *Contact
  5874. )
  5875. m.oldValue = func(ctx context.Context) (*Contact, error) {
  5876. once.Do(func() {
  5877. if m.done {
  5878. err = errors.New("querying old values post mutation is not allowed")
  5879. } else {
  5880. value, err = m.Client().Contact.Get(ctx, id)
  5881. }
  5882. })
  5883. return value, err
  5884. }
  5885. m.id = &id
  5886. }
  5887. }
  5888. // withContact sets the old Contact of the mutation.
  5889. func withContact(node *Contact) contactOption {
  5890. return func(m *ContactMutation) {
  5891. m.oldValue = func(context.Context) (*Contact, error) {
  5892. return node, nil
  5893. }
  5894. m.id = &node.ID
  5895. }
  5896. }
  5897. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5898. // executed in a transaction (ent.Tx), a transactional client is returned.
  5899. func (m ContactMutation) Client() *Client {
  5900. client := &Client{config: m.config}
  5901. client.init()
  5902. return client
  5903. }
  5904. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5905. // it returns an error otherwise.
  5906. func (m ContactMutation) Tx() (*Tx, error) {
  5907. if _, ok := m.driver.(*txDriver); !ok {
  5908. return nil, errors.New("ent: mutation is not running in a transaction")
  5909. }
  5910. tx := &Tx{config: m.config}
  5911. tx.init()
  5912. return tx, nil
  5913. }
  5914. // SetID sets the value of the id field. Note that this
  5915. // operation is only accepted on creation of Contact entities.
  5916. func (m *ContactMutation) SetID(id uint64) {
  5917. m.id = &id
  5918. }
  5919. // ID returns the ID value in the mutation. Note that the ID is only available
  5920. // if it was provided to the builder or after it was returned from the database.
  5921. func (m *ContactMutation) ID() (id uint64, exists bool) {
  5922. if m.id == nil {
  5923. return
  5924. }
  5925. return *m.id, true
  5926. }
  5927. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5928. // That means, if the mutation is applied within a transaction with an isolation level such
  5929. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5930. // or updated by the mutation.
  5931. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  5932. switch {
  5933. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5934. id, exists := m.ID()
  5935. if exists {
  5936. return []uint64{id}, nil
  5937. }
  5938. fallthrough
  5939. case m.op.Is(OpUpdate | OpDelete):
  5940. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  5941. default:
  5942. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5943. }
  5944. }
  5945. // SetCreatedAt sets the "created_at" field.
  5946. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  5947. m.created_at = &t
  5948. }
  5949. // CreatedAt returns the value of the "created_at" field in the mutation.
  5950. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  5951. v := m.created_at
  5952. if v == nil {
  5953. return
  5954. }
  5955. return *v, true
  5956. }
  5957. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  5958. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5960. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5961. if !m.op.Is(OpUpdateOne) {
  5962. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5963. }
  5964. if m.id == nil || m.oldValue == nil {
  5965. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5966. }
  5967. oldValue, err := m.oldValue(ctx)
  5968. if err != nil {
  5969. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5970. }
  5971. return oldValue.CreatedAt, nil
  5972. }
  5973. // ResetCreatedAt resets all changes to the "created_at" field.
  5974. func (m *ContactMutation) ResetCreatedAt() {
  5975. m.created_at = nil
  5976. }
  5977. // SetUpdatedAt sets the "updated_at" field.
  5978. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  5979. m.updated_at = &t
  5980. }
  5981. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5982. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  5983. v := m.updated_at
  5984. if v == nil {
  5985. return
  5986. }
  5987. return *v, true
  5988. }
  5989. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  5990. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5992. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5993. if !m.op.Is(OpUpdateOne) {
  5994. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5995. }
  5996. if m.id == nil || m.oldValue == nil {
  5997. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5998. }
  5999. oldValue, err := m.oldValue(ctx)
  6000. if err != nil {
  6001. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6002. }
  6003. return oldValue.UpdatedAt, nil
  6004. }
  6005. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6006. func (m *ContactMutation) ResetUpdatedAt() {
  6007. m.updated_at = nil
  6008. }
  6009. // SetStatus sets the "status" field.
  6010. func (m *ContactMutation) SetStatus(u uint8) {
  6011. m.status = &u
  6012. m.addstatus = nil
  6013. }
  6014. // Status returns the value of the "status" field in the mutation.
  6015. func (m *ContactMutation) Status() (r uint8, exists bool) {
  6016. v := m.status
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // OldStatus returns the old "status" field's value of the Contact entity.
  6023. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6025. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6026. if !m.op.Is(OpUpdateOne) {
  6027. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6028. }
  6029. if m.id == nil || m.oldValue == nil {
  6030. return v, errors.New("OldStatus requires an ID field in the mutation")
  6031. }
  6032. oldValue, err := m.oldValue(ctx)
  6033. if err != nil {
  6034. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6035. }
  6036. return oldValue.Status, nil
  6037. }
  6038. // AddStatus adds u to the "status" field.
  6039. func (m *ContactMutation) AddStatus(u int8) {
  6040. if m.addstatus != nil {
  6041. *m.addstatus += u
  6042. } else {
  6043. m.addstatus = &u
  6044. }
  6045. }
  6046. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6047. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  6048. v := m.addstatus
  6049. if v == nil {
  6050. return
  6051. }
  6052. return *v, true
  6053. }
  6054. // ClearStatus clears the value of the "status" field.
  6055. func (m *ContactMutation) ClearStatus() {
  6056. m.status = nil
  6057. m.addstatus = nil
  6058. m.clearedFields[contact.FieldStatus] = struct{}{}
  6059. }
  6060. // StatusCleared returns if the "status" field was cleared in this mutation.
  6061. func (m *ContactMutation) StatusCleared() bool {
  6062. _, ok := m.clearedFields[contact.FieldStatus]
  6063. return ok
  6064. }
  6065. // ResetStatus resets all changes to the "status" field.
  6066. func (m *ContactMutation) ResetStatus() {
  6067. m.status = nil
  6068. m.addstatus = nil
  6069. delete(m.clearedFields, contact.FieldStatus)
  6070. }
  6071. // SetDeletedAt sets the "deleted_at" field.
  6072. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  6073. m.deleted_at = &t
  6074. }
  6075. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6076. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  6077. v := m.deleted_at
  6078. if v == nil {
  6079. return
  6080. }
  6081. return *v, true
  6082. }
  6083. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  6084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6086. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6087. if !m.op.Is(OpUpdateOne) {
  6088. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6089. }
  6090. if m.id == nil || m.oldValue == nil {
  6091. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6092. }
  6093. oldValue, err := m.oldValue(ctx)
  6094. if err != nil {
  6095. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6096. }
  6097. return oldValue.DeletedAt, nil
  6098. }
  6099. // ClearDeletedAt clears the value of the "deleted_at" field.
  6100. func (m *ContactMutation) ClearDeletedAt() {
  6101. m.deleted_at = nil
  6102. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  6103. }
  6104. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6105. func (m *ContactMutation) DeletedAtCleared() bool {
  6106. _, ok := m.clearedFields[contact.FieldDeletedAt]
  6107. return ok
  6108. }
  6109. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6110. func (m *ContactMutation) ResetDeletedAt() {
  6111. m.deleted_at = nil
  6112. delete(m.clearedFields, contact.FieldDeletedAt)
  6113. }
  6114. // SetWxWxid sets the "wx_wxid" field.
  6115. func (m *ContactMutation) SetWxWxid(s string) {
  6116. m.wx_wxid = &s
  6117. }
  6118. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  6119. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  6120. v := m.wx_wxid
  6121. if v == nil {
  6122. return
  6123. }
  6124. return *v, true
  6125. }
  6126. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  6127. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6129. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  6130. if !m.op.Is(OpUpdateOne) {
  6131. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  6132. }
  6133. if m.id == nil || m.oldValue == nil {
  6134. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  6135. }
  6136. oldValue, err := m.oldValue(ctx)
  6137. if err != nil {
  6138. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  6139. }
  6140. return oldValue.WxWxid, nil
  6141. }
  6142. // ClearWxWxid clears the value of the "wx_wxid" field.
  6143. func (m *ContactMutation) ClearWxWxid() {
  6144. m.wx_wxid = nil
  6145. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  6146. }
  6147. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  6148. func (m *ContactMutation) WxWxidCleared() bool {
  6149. _, ok := m.clearedFields[contact.FieldWxWxid]
  6150. return ok
  6151. }
  6152. // ResetWxWxid resets all changes to the "wx_wxid" field.
  6153. func (m *ContactMutation) ResetWxWxid() {
  6154. m.wx_wxid = nil
  6155. delete(m.clearedFields, contact.FieldWxWxid)
  6156. }
  6157. // SetType sets the "type" field.
  6158. func (m *ContactMutation) SetType(i int) {
  6159. m._type = &i
  6160. m.add_type = nil
  6161. }
  6162. // GetType returns the value of the "type" field in the mutation.
  6163. func (m *ContactMutation) GetType() (r int, exists bool) {
  6164. v := m._type
  6165. if v == nil {
  6166. return
  6167. }
  6168. return *v, true
  6169. }
  6170. // OldType returns the old "type" field's value of the Contact entity.
  6171. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6173. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  6174. if !m.op.Is(OpUpdateOne) {
  6175. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6176. }
  6177. if m.id == nil || m.oldValue == nil {
  6178. return v, errors.New("OldType requires an ID field in the mutation")
  6179. }
  6180. oldValue, err := m.oldValue(ctx)
  6181. if err != nil {
  6182. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6183. }
  6184. return oldValue.Type, nil
  6185. }
  6186. // AddType adds i to the "type" field.
  6187. func (m *ContactMutation) AddType(i int) {
  6188. if m.add_type != nil {
  6189. *m.add_type += i
  6190. } else {
  6191. m.add_type = &i
  6192. }
  6193. }
  6194. // AddedType returns the value that was added to the "type" field in this mutation.
  6195. func (m *ContactMutation) AddedType() (r int, exists bool) {
  6196. v := m.add_type
  6197. if v == nil {
  6198. return
  6199. }
  6200. return *v, true
  6201. }
  6202. // ClearType clears the value of the "type" field.
  6203. func (m *ContactMutation) ClearType() {
  6204. m._type = nil
  6205. m.add_type = nil
  6206. m.clearedFields[contact.FieldType] = struct{}{}
  6207. }
  6208. // TypeCleared returns if the "type" field was cleared in this mutation.
  6209. func (m *ContactMutation) TypeCleared() bool {
  6210. _, ok := m.clearedFields[contact.FieldType]
  6211. return ok
  6212. }
  6213. // ResetType resets all changes to the "type" field.
  6214. func (m *ContactMutation) ResetType() {
  6215. m._type = nil
  6216. m.add_type = nil
  6217. delete(m.clearedFields, contact.FieldType)
  6218. }
  6219. // SetWxid sets the "wxid" field.
  6220. func (m *ContactMutation) SetWxid(s string) {
  6221. m.wxid = &s
  6222. }
  6223. // Wxid returns the value of the "wxid" field in the mutation.
  6224. func (m *ContactMutation) Wxid() (r string, exists bool) {
  6225. v := m.wxid
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldWxid returns the old "wxid" field's value of the Contact entity.
  6232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldWxid requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  6244. }
  6245. return oldValue.Wxid, nil
  6246. }
  6247. // ResetWxid resets all changes to the "wxid" field.
  6248. func (m *ContactMutation) ResetWxid() {
  6249. m.wxid = nil
  6250. }
  6251. // SetAccount sets the "account" field.
  6252. func (m *ContactMutation) SetAccount(s string) {
  6253. m.account = &s
  6254. }
  6255. // Account returns the value of the "account" field in the mutation.
  6256. func (m *ContactMutation) Account() (r string, exists bool) {
  6257. v := m.account
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldAccount returns the old "account" field's value of the Contact entity.
  6264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldAccount requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  6276. }
  6277. return oldValue.Account, nil
  6278. }
  6279. // ResetAccount resets all changes to the "account" field.
  6280. func (m *ContactMutation) ResetAccount() {
  6281. m.account = nil
  6282. }
  6283. // SetNickname sets the "nickname" field.
  6284. func (m *ContactMutation) SetNickname(s string) {
  6285. m.nickname = &s
  6286. }
  6287. // Nickname returns the value of the "nickname" field in the mutation.
  6288. func (m *ContactMutation) Nickname() (r string, exists bool) {
  6289. v := m.nickname
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldNickname returns the old "nickname" field's value of the Contact entity.
  6296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldNickname requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  6308. }
  6309. return oldValue.Nickname, nil
  6310. }
  6311. // ResetNickname resets all changes to the "nickname" field.
  6312. func (m *ContactMutation) ResetNickname() {
  6313. m.nickname = nil
  6314. }
  6315. // SetMarkname sets the "markname" field.
  6316. func (m *ContactMutation) SetMarkname(s string) {
  6317. m.markname = &s
  6318. }
  6319. // Markname returns the value of the "markname" field in the mutation.
  6320. func (m *ContactMutation) Markname() (r string, exists bool) {
  6321. v := m.markname
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldMarkname returns the old "markname" field's value of the Contact entity.
  6328. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldMarkname requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  6340. }
  6341. return oldValue.Markname, nil
  6342. }
  6343. // ResetMarkname resets all changes to the "markname" field.
  6344. func (m *ContactMutation) ResetMarkname() {
  6345. m.markname = nil
  6346. }
  6347. // SetHeadimg sets the "headimg" field.
  6348. func (m *ContactMutation) SetHeadimg(s string) {
  6349. m.headimg = &s
  6350. }
  6351. // Headimg returns the value of the "headimg" field in the mutation.
  6352. func (m *ContactMutation) Headimg() (r string, exists bool) {
  6353. v := m.headimg
  6354. if v == nil {
  6355. return
  6356. }
  6357. return *v, true
  6358. }
  6359. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  6360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6362. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  6363. if !m.op.Is(OpUpdateOne) {
  6364. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  6365. }
  6366. if m.id == nil || m.oldValue == nil {
  6367. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  6368. }
  6369. oldValue, err := m.oldValue(ctx)
  6370. if err != nil {
  6371. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  6372. }
  6373. return oldValue.Headimg, nil
  6374. }
  6375. // ResetHeadimg resets all changes to the "headimg" field.
  6376. func (m *ContactMutation) ResetHeadimg() {
  6377. m.headimg = nil
  6378. }
  6379. // SetSex sets the "sex" field.
  6380. func (m *ContactMutation) SetSex(i int) {
  6381. m.sex = &i
  6382. m.addsex = nil
  6383. }
  6384. // Sex returns the value of the "sex" field in the mutation.
  6385. func (m *ContactMutation) Sex() (r int, exists bool) {
  6386. v := m.sex
  6387. if v == nil {
  6388. return
  6389. }
  6390. return *v, true
  6391. }
  6392. // OldSex returns the old "sex" field's value of the Contact entity.
  6393. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6395. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  6396. if !m.op.Is(OpUpdateOne) {
  6397. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  6398. }
  6399. if m.id == nil || m.oldValue == nil {
  6400. return v, errors.New("OldSex requires an ID field in the mutation")
  6401. }
  6402. oldValue, err := m.oldValue(ctx)
  6403. if err != nil {
  6404. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  6405. }
  6406. return oldValue.Sex, nil
  6407. }
  6408. // AddSex adds i to the "sex" field.
  6409. func (m *ContactMutation) AddSex(i int) {
  6410. if m.addsex != nil {
  6411. *m.addsex += i
  6412. } else {
  6413. m.addsex = &i
  6414. }
  6415. }
  6416. // AddedSex returns the value that was added to the "sex" field in this mutation.
  6417. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  6418. v := m.addsex
  6419. if v == nil {
  6420. return
  6421. }
  6422. return *v, true
  6423. }
  6424. // ResetSex resets all changes to the "sex" field.
  6425. func (m *ContactMutation) ResetSex() {
  6426. m.sex = nil
  6427. m.addsex = nil
  6428. }
  6429. // SetStarrole sets the "starrole" field.
  6430. func (m *ContactMutation) SetStarrole(s string) {
  6431. m.starrole = &s
  6432. }
  6433. // Starrole returns the value of the "starrole" field in the mutation.
  6434. func (m *ContactMutation) Starrole() (r string, exists bool) {
  6435. v := m.starrole
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  6442. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldStarrole requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  6454. }
  6455. return oldValue.Starrole, nil
  6456. }
  6457. // ResetStarrole resets all changes to the "starrole" field.
  6458. func (m *ContactMutation) ResetStarrole() {
  6459. m.starrole = nil
  6460. }
  6461. // SetDontseeit sets the "dontseeit" field.
  6462. func (m *ContactMutation) SetDontseeit(i int) {
  6463. m.dontseeit = &i
  6464. m.adddontseeit = nil
  6465. }
  6466. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  6467. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  6468. v := m.dontseeit
  6469. if v == nil {
  6470. return
  6471. }
  6472. return *v, true
  6473. }
  6474. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  6475. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6477. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  6478. if !m.op.Is(OpUpdateOne) {
  6479. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  6480. }
  6481. if m.id == nil || m.oldValue == nil {
  6482. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  6483. }
  6484. oldValue, err := m.oldValue(ctx)
  6485. if err != nil {
  6486. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  6487. }
  6488. return oldValue.Dontseeit, nil
  6489. }
  6490. // AddDontseeit adds i to the "dontseeit" field.
  6491. func (m *ContactMutation) AddDontseeit(i int) {
  6492. if m.adddontseeit != nil {
  6493. *m.adddontseeit += i
  6494. } else {
  6495. m.adddontseeit = &i
  6496. }
  6497. }
  6498. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  6499. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  6500. v := m.adddontseeit
  6501. if v == nil {
  6502. return
  6503. }
  6504. return *v, true
  6505. }
  6506. // ResetDontseeit resets all changes to the "dontseeit" field.
  6507. func (m *ContactMutation) ResetDontseeit() {
  6508. m.dontseeit = nil
  6509. m.adddontseeit = nil
  6510. }
  6511. // SetDontseeme sets the "dontseeme" field.
  6512. func (m *ContactMutation) SetDontseeme(i int) {
  6513. m.dontseeme = &i
  6514. m.adddontseeme = nil
  6515. }
  6516. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  6517. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  6518. v := m.dontseeme
  6519. if v == nil {
  6520. return
  6521. }
  6522. return *v, true
  6523. }
  6524. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  6525. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6527. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  6528. if !m.op.Is(OpUpdateOne) {
  6529. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  6530. }
  6531. if m.id == nil || m.oldValue == nil {
  6532. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  6533. }
  6534. oldValue, err := m.oldValue(ctx)
  6535. if err != nil {
  6536. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  6537. }
  6538. return oldValue.Dontseeme, nil
  6539. }
  6540. // AddDontseeme adds i to the "dontseeme" field.
  6541. func (m *ContactMutation) AddDontseeme(i int) {
  6542. if m.adddontseeme != nil {
  6543. *m.adddontseeme += i
  6544. } else {
  6545. m.adddontseeme = &i
  6546. }
  6547. }
  6548. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  6549. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  6550. v := m.adddontseeme
  6551. if v == nil {
  6552. return
  6553. }
  6554. return *v, true
  6555. }
  6556. // ResetDontseeme resets all changes to the "dontseeme" field.
  6557. func (m *ContactMutation) ResetDontseeme() {
  6558. m.dontseeme = nil
  6559. m.adddontseeme = nil
  6560. }
  6561. // SetLag sets the "lag" field.
  6562. func (m *ContactMutation) SetLag(s string) {
  6563. m.lag = &s
  6564. }
  6565. // Lag returns the value of the "lag" field in the mutation.
  6566. func (m *ContactMutation) Lag() (r string, exists bool) {
  6567. v := m.lag
  6568. if v == nil {
  6569. return
  6570. }
  6571. return *v, true
  6572. }
  6573. // OldLag returns the old "lag" field's value of the Contact entity.
  6574. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6576. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  6577. if !m.op.Is(OpUpdateOne) {
  6578. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  6579. }
  6580. if m.id == nil || m.oldValue == nil {
  6581. return v, errors.New("OldLag requires an ID field in the mutation")
  6582. }
  6583. oldValue, err := m.oldValue(ctx)
  6584. if err != nil {
  6585. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  6586. }
  6587. return oldValue.Lag, nil
  6588. }
  6589. // ResetLag resets all changes to the "lag" field.
  6590. func (m *ContactMutation) ResetLag() {
  6591. m.lag = nil
  6592. }
  6593. // SetGid sets the "gid" field.
  6594. func (m *ContactMutation) SetGid(s string) {
  6595. m.gid = &s
  6596. }
  6597. // Gid returns the value of the "gid" field in the mutation.
  6598. func (m *ContactMutation) Gid() (r string, exists bool) {
  6599. v := m.gid
  6600. if v == nil {
  6601. return
  6602. }
  6603. return *v, true
  6604. }
  6605. // OldGid returns the old "gid" field's value of the Contact entity.
  6606. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6608. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  6609. if !m.op.Is(OpUpdateOne) {
  6610. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  6611. }
  6612. if m.id == nil || m.oldValue == nil {
  6613. return v, errors.New("OldGid requires an ID field in the mutation")
  6614. }
  6615. oldValue, err := m.oldValue(ctx)
  6616. if err != nil {
  6617. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  6618. }
  6619. return oldValue.Gid, nil
  6620. }
  6621. // ResetGid resets all changes to the "gid" field.
  6622. func (m *ContactMutation) ResetGid() {
  6623. m.gid = nil
  6624. }
  6625. // SetGname sets the "gname" field.
  6626. func (m *ContactMutation) SetGname(s string) {
  6627. m.gname = &s
  6628. }
  6629. // Gname returns the value of the "gname" field in the mutation.
  6630. func (m *ContactMutation) Gname() (r string, exists bool) {
  6631. v := m.gname
  6632. if v == nil {
  6633. return
  6634. }
  6635. return *v, true
  6636. }
  6637. // OldGname returns the old "gname" field's value of the Contact entity.
  6638. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6640. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  6641. if !m.op.Is(OpUpdateOne) {
  6642. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  6643. }
  6644. if m.id == nil || m.oldValue == nil {
  6645. return v, errors.New("OldGname requires an ID field in the mutation")
  6646. }
  6647. oldValue, err := m.oldValue(ctx)
  6648. if err != nil {
  6649. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  6650. }
  6651. return oldValue.Gname, nil
  6652. }
  6653. // ResetGname resets all changes to the "gname" field.
  6654. func (m *ContactMutation) ResetGname() {
  6655. m.gname = nil
  6656. }
  6657. // SetV3 sets the "v3" field.
  6658. func (m *ContactMutation) SetV3(s string) {
  6659. m.v3 = &s
  6660. }
  6661. // V3 returns the value of the "v3" field in the mutation.
  6662. func (m *ContactMutation) V3() (r string, exists bool) {
  6663. v := m.v3
  6664. if v == nil {
  6665. return
  6666. }
  6667. return *v, true
  6668. }
  6669. // OldV3 returns the old "v3" field's value of the Contact entity.
  6670. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6672. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  6673. if !m.op.Is(OpUpdateOne) {
  6674. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  6675. }
  6676. if m.id == nil || m.oldValue == nil {
  6677. return v, errors.New("OldV3 requires an ID field in the mutation")
  6678. }
  6679. oldValue, err := m.oldValue(ctx)
  6680. if err != nil {
  6681. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  6682. }
  6683. return oldValue.V3, nil
  6684. }
  6685. // ResetV3 resets all changes to the "v3" field.
  6686. func (m *ContactMutation) ResetV3() {
  6687. m.v3 = nil
  6688. }
  6689. // SetOrganizationID sets the "organization_id" field.
  6690. func (m *ContactMutation) SetOrganizationID(u uint64) {
  6691. m.organization_id = &u
  6692. m.addorganization_id = nil
  6693. }
  6694. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6695. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  6696. v := m.organization_id
  6697. if v == nil {
  6698. return
  6699. }
  6700. return *v, true
  6701. }
  6702. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  6703. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6705. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6706. if !m.op.Is(OpUpdateOne) {
  6707. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6708. }
  6709. if m.id == nil || m.oldValue == nil {
  6710. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6711. }
  6712. oldValue, err := m.oldValue(ctx)
  6713. if err != nil {
  6714. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6715. }
  6716. return oldValue.OrganizationID, nil
  6717. }
  6718. // AddOrganizationID adds u to the "organization_id" field.
  6719. func (m *ContactMutation) AddOrganizationID(u int64) {
  6720. if m.addorganization_id != nil {
  6721. *m.addorganization_id += u
  6722. } else {
  6723. m.addorganization_id = &u
  6724. }
  6725. }
  6726. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6727. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  6728. v := m.addorganization_id
  6729. if v == nil {
  6730. return
  6731. }
  6732. return *v, true
  6733. }
  6734. // ClearOrganizationID clears the value of the "organization_id" field.
  6735. func (m *ContactMutation) ClearOrganizationID() {
  6736. m.organization_id = nil
  6737. m.addorganization_id = nil
  6738. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  6739. }
  6740. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6741. func (m *ContactMutation) OrganizationIDCleared() bool {
  6742. _, ok := m.clearedFields[contact.FieldOrganizationID]
  6743. return ok
  6744. }
  6745. // ResetOrganizationID resets all changes to the "organization_id" field.
  6746. func (m *ContactMutation) ResetOrganizationID() {
  6747. m.organization_id = nil
  6748. m.addorganization_id = nil
  6749. delete(m.clearedFields, contact.FieldOrganizationID)
  6750. }
  6751. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  6752. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  6753. if m.contact_relationships == nil {
  6754. m.contact_relationships = make(map[uint64]struct{})
  6755. }
  6756. for i := range ids {
  6757. m.contact_relationships[ids[i]] = struct{}{}
  6758. }
  6759. }
  6760. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  6761. func (m *ContactMutation) ClearContactRelationships() {
  6762. m.clearedcontact_relationships = true
  6763. }
  6764. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  6765. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  6766. return m.clearedcontact_relationships
  6767. }
  6768. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  6769. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  6770. if m.removedcontact_relationships == nil {
  6771. m.removedcontact_relationships = make(map[uint64]struct{})
  6772. }
  6773. for i := range ids {
  6774. delete(m.contact_relationships, ids[i])
  6775. m.removedcontact_relationships[ids[i]] = struct{}{}
  6776. }
  6777. }
  6778. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  6779. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  6780. for id := range m.removedcontact_relationships {
  6781. ids = append(ids, id)
  6782. }
  6783. return
  6784. }
  6785. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  6786. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  6787. for id := range m.contact_relationships {
  6788. ids = append(ids, id)
  6789. }
  6790. return
  6791. }
  6792. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  6793. func (m *ContactMutation) ResetContactRelationships() {
  6794. m.contact_relationships = nil
  6795. m.clearedcontact_relationships = false
  6796. m.removedcontact_relationships = nil
  6797. }
  6798. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  6799. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  6800. if m.contact_messages == nil {
  6801. m.contact_messages = make(map[uint64]struct{})
  6802. }
  6803. for i := range ids {
  6804. m.contact_messages[ids[i]] = struct{}{}
  6805. }
  6806. }
  6807. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  6808. func (m *ContactMutation) ClearContactMessages() {
  6809. m.clearedcontact_messages = true
  6810. }
  6811. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  6812. func (m *ContactMutation) ContactMessagesCleared() bool {
  6813. return m.clearedcontact_messages
  6814. }
  6815. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  6816. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  6817. if m.removedcontact_messages == nil {
  6818. m.removedcontact_messages = make(map[uint64]struct{})
  6819. }
  6820. for i := range ids {
  6821. delete(m.contact_messages, ids[i])
  6822. m.removedcontact_messages[ids[i]] = struct{}{}
  6823. }
  6824. }
  6825. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  6826. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  6827. for id := range m.removedcontact_messages {
  6828. ids = append(ids, id)
  6829. }
  6830. return
  6831. }
  6832. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  6833. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  6834. for id := range m.contact_messages {
  6835. ids = append(ids, id)
  6836. }
  6837. return
  6838. }
  6839. // ResetContactMessages resets all changes to the "contact_messages" edge.
  6840. func (m *ContactMutation) ResetContactMessages() {
  6841. m.contact_messages = nil
  6842. m.clearedcontact_messages = false
  6843. m.removedcontact_messages = nil
  6844. }
  6845. // Where appends a list predicates to the ContactMutation builder.
  6846. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  6847. m.predicates = append(m.predicates, ps...)
  6848. }
  6849. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  6850. // users can use type-assertion to append predicates that do not depend on any generated package.
  6851. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  6852. p := make([]predicate.Contact, len(ps))
  6853. for i := range ps {
  6854. p[i] = ps[i]
  6855. }
  6856. m.Where(p...)
  6857. }
  6858. // Op returns the operation name.
  6859. func (m *ContactMutation) Op() Op {
  6860. return m.op
  6861. }
  6862. // SetOp allows setting the mutation operation.
  6863. func (m *ContactMutation) SetOp(op Op) {
  6864. m.op = op
  6865. }
  6866. // Type returns the node type of this mutation (Contact).
  6867. func (m *ContactMutation) Type() string {
  6868. return m.typ
  6869. }
  6870. // Fields returns all fields that were changed during this mutation. Note that in
  6871. // order to get all numeric fields that were incremented/decremented, call
  6872. // AddedFields().
  6873. func (m *ContactMutation) Fields() []string {
  6874. fields := make([]string, 0, 20)
  6875. if m.created_at != nil {
  6876. fields = append(fields, contact.FieldCreatedAt)
  6877. }
  6878. if m.updated_at != nil {
  6879. fields = append(fields, contact.FieldUpdatedAt)
  6880. }
  6881. if m.status != nil {
  6882. fields = append(fields, contact.FieldStatus)
  6883. }
  6884. if m.deleted_at != nil {
  6885. fields = append(fields, contact.FieldDeletedAt)
  6886. }
  6887. if m.wx_wxid != nil {
  6888. fields = append(fields, contact.FieldWxWxid)
  6889. }
  6890. if m._type != nil {
  6891. fields = append(fields, contact.FieldType)
  6892. }
  6893. if m.wxid != nil {
  6894. fields = append(fields, contact.FieldWxid)
  6895. }
  6896. if m.account != nil {
  6897. fields = append(fields, contact.FieldAccount)
  6898. }
  6899. if m.nickname != nil {
  6900. fields = append(fields, contact.FieldNickname)
  6901. }
  6902. if m.markname != nil {
  6903. fields = append(fields, contact.FieldMarkname)
  6904. }
  6905. if m.headimg != nil {
  6906. fields = append(fields, contact.FieldHeadimg)
  6907. }
  6908. if m.sex != nil {
  6909. fields = append(fields, contact.FieldSex)
  6910. }
  6911. if m.starrole != nil {
  6912. fields = append(fields, contact.FieldStarrole)
  6913. }
  6914. if m.dontseeit != nil {
  6915. fields = append(fields, contact.FieldDontseeit)
  6916. }
  6917. if m.dontseeme != nil {
  6918. fields = append(fields, contact.FieldDontseeme)
  6919. }
  6920. if m.lag != nil {
  6921. fields = append(fields, contact.FieldLag)
  6922. }
  6923. if m.gid != nil {
  6924. fields = append(fields, contact.FieldGid)
  6925. }
  6926. if m.gname != nil {
  6927. fields = append(fields, contact.FieldGname)
  6928. }
  6929. if m.v3 != nil {
  6930. fields = append(fields, contact.FieldV3)
  6931. }
  6932. if m.organization_id != nil {
  6933. fields = append(fields, contact.FieldOrganizationID)
  6934. }
  6935. return fields
  6936. }
  6937. // Field returns the value of a field with the given name. The second boolean
  6938. // return value indicates that this field was not set, or was not defined in the
  6939. // schema.
  6940. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  6941. switch name {
  6942. case contact.FieldCreatedAt:
  6943. return m.CreatedAt()
  6944. case contact.FieldUpdatedAt:
  6945. return m.UpdatedAt()
  6946. case contact.FieldStatus:
  6947. return m.Status()
  6948. case contact.FieldDeletedAt:
  6949. return m.DeletedAt()
  6950. case contact.FieldWxWxid:
  6951. return m.WxWxid()
  6952. case contact.FieldType:
  6953. return m.GetType()
  6954. case contact.FieldWxid:
  6955. return m.Wxid()
  6956. case contact.FieldAccount:
  6957. return m.Account()
  6958. case contact.FieldNickname:
  6959. return m.Nickname()
  6960. case contact.FieldMarkname:
  6961. return m.Markname()
  6962. case contact.FieldHeadimg:
  6963. return m.Headimg()
  6964. case contact.FieldSex:
  6965. return m.Sex()
  6966. case contact.FieldStarrole:
  6967. return m.Starrole()
  6968. case contact.FieldDontseeit:
  6969. return m.Dontseeit()
  6970. case contact.FieldDontseeme:
  6971. return m.Dontseeme()
  6972. case contact.FieldLag:
  6973. return m.Lag()
  6974. case contact.FieldGid:
  6975. return m.Gid()
  6976. case contact.FieldGname:
  6977. return m.Gname()
  6978. case contact.FieldV3:
  6979. return m.V3()
  6980. case contact.FieldOrganizationID:
  6981. return m.OrganizationID()
  6982. }
  6983. return nil, false
  6984. }
  6985. // OldField returns the old value of the field from the database. An error is
  6986. // returned if the mutation operation is not UpdateOne, or the query to the
  6987. // database failed.
  6988. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6989. switch name {
  6990. case contact.FieldCreatedAt:
  6991. return m.OldCreatedAt(ctx)
  6992. case contact.FieldUpdatedAt:
  6993. return m.OldUpdatedAt(ctx)
  6994. case contact.FieldStatus:
  6995. return m.OldStatus(ctx)
  6996. case contact.FieldDeletedAt:
  6997. return m.OldDeletedAt(ctx)
  6998. case contact.FieldWxWxid:
  6999. return m.OldWxWxid(ctx)
  7000. case contact.FieldType:
  7001. return m.OldType(ctx)
  7002. case contact.FieldWxid:
  7003. return m.OldWxid(ctx)
  7004. case contact.FieldAccount:
  7005. return m.OldAccount(ctx)
  7006. case contact.FieldNickname:
  7007. return m.OldNickname(ctx)
  7008. case contact.FieldMarkname:
  7009. return m.OldMarkname(ctx)
  7010. case contact.FieldHeadimg:
  7011. return m.OldHeadimg(ctx)
  7012. case contact.FieldSex:
  7013. return m.OldSex(ctx)
  7014. case contact.FieldStarrole:
  7015. return m.OldStarrole(ctx)
  7016. case contact.FieldDontseeit:
  7017. return m.OldDontseeit(ctx)
  7018. case contact.FieldDontseeme:
  7019. return m.OldDontseeme(ctx)
  7020. case contact.FieldLag:
  7021. return m.OldLag(ctx)
  7022. case contact.FieldGid:
  7023. return m.OldGid(ctx)
  7024. case contact.FieldGname:
  7025. return m.OldGname(ctx)
  7026. case contact.FieldV3:
  7027. return m.OldV3(ctx)
  7028. case contact.FieldOrganizationID:
  7029. return m.OldOrganizationID(ctx)
  7030. }
  7031. return nil, fmt.Errorf("unknown Contact field %s", name)
  7032. }
  7033. // SetField sets the value of a field with the given name. It returns an error if
  7034. // the field is not defined in the schema, or if the type mismatched the field
  7035. // type.
  7036. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  7037. switch name {
  7038. case contact.FieldCreatedAt:
  7039. v, ok := value.(time.Time)
  7040. if !ok {
  7041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7042. }
  7043. m.SetCreatedAt(v)
  7044. return nil
  7045. case contact.FieldUpdatedAt:
  7046. v, ok := value.(time.Time)
  7047. if !ok {
  7048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7049. }
  7050. m.SetUpdatedAt(v)
  7051. return nil
  7052. case contact.FieldStatus:
  7053. v, ok := value.(uint8)
  7054. if !ok {
  7055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7056. }
  7057. m.SetStatus(v)
  7058. return nil
  7059. case contact.FieldDeletedAt:
  7060. v, ok := value.(time.Time)
  7061. if !ok {
  7062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7063. }
  7064. m.SetDeletedAt(v)
  7065. return nil
  7066. case contact.FieldWxWxid:
  7067. v, ok := value.(string)
  7068. if !ok {
  7069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7070. }
  7071. m.SetWxWxid(v)
  7072. return nil
  7073. case contact.FieldType:
  7074. v, ok := value.(int)
  7075. if !ok {
  7076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7077. }
  7078. m.SetType(v)
  7079. return nil
  7080. case contact.FieldWxid:
  7081. v, ok := value.(string)
  7082. if !ok {
  7083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7084. }
  7085. m.SetWxid(v)
  7086. return nil
  7087. case contact.FieldAccount:
  7088. v, ok := value.(string)
  7089. if !ok {
  7090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7091. }
  7092. m.SetAccount(v)
  7093. return nil
  7094. case contact.FieldNickname:
  7095. v, ok := value.(string)
  7096. if !ok {
  7097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7098. }
  7099. m.SetNickname(v)
  7100. return nil
  7101. case contact.FieldMarkname:
  7102. v, ok := value.(string)
  7103. if !ok {
  7104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7105. }
  7106. m.SetMarkname(v)
  7107. return nil
  7108. case contact.FieldHeadimg:
  7109. v, ok := value.(string)
  7110. if !ok {
  7111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7112. }
  7113. m.SetHeadimg(v)
  7114. return nil
  7115. case contact.FieldSex:
  7116. v, ok := value.(int)
  7117. if !ok {
  7118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7119. }
  7120. m.SetSex(v)
  7121. return nil
  7122. case contact.FieldStarrole:
  7123. v, ok := value.(string)
  7124. if !ok {
  7125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7126. }
  7127. m.SetStarrole(v)
  7128. return nil
  7129. case contact.FieldDontseeit:
  7130. v, ok := value.(int)
  7131. if !ok {
  7132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7133. }
  7134. m.SetDontseeit(v)
  7135. return nil
  7136. case contact.FieldDontseeme:
  7137. v, ok := value.(int)
  7138. if !ok {
  7139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7140. }
  7141. m.SetDontseeme(v)
  7142. return nil
  7143. case contact.FieldLag:
  7144. v, ok := value.(string)
  7145. if !ok {
  7146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7147. }
  7148. m.SetLag(v)
  7149. return nil
  7150. case contact.FieldGid:
  7151. v, ok := value.(string)
  7152. if !ok {
  7153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7154. }
  7155. m.SetGid(v)
  7156. return nil
  7157. case contact.FieldGname:
  7158. v, ok := value.(string)
  7159. if !ok {
  7160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7161. }
  7162. m.SetGname(v)
  7163. return nil
  7164. case contact.FieldV3:
  7165. v, ok := value.(string)
  7166. if !ok {
  7167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7168. }
  7169. m.SetV3(v)
  7170. return nil
  7171. case contact.FieldOrganizationID:
  7172. v, ok := value.(uint64)
  7173. if !ok {
  7174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7175. }
  7176. m.SetOrganizationID(v)
  7177. return nil
  7178. }
  7179. return fmt.Errorf("unknown Contact field %s", name)
  7180. }
  7181. // AddedFields returns all numeric fields that were incremented/decremented during
  7182. // this mutation.
  7183. func (m *ContactMutation) AddedFields() []string {
  7184. var fields []string
  7185. if m.addstatus != nil {
  7186. fields = append(fields, contact.FieldStatus)
  7187. }
  7188. if m.add_type != nil {
  7189. fields = append(fields, contact.FieldType)
  7190. }
  7191. if m.addsex != nil {
  7192. fields = append(fields, contact.FieldSex)
  7193. }
  7194. if m.adddontseeit != nil {
  7195. fields = append(fields, contact.FieldDontseeit)
  7196. }
  7197. if m.adddontseeme != nil {
  7198. fields = append(fields, contact.FieldDontseeme)
  7199. }
  7200. if m.addorganization_id != nil {
  7201. fields = append(fields, contact.FieldOrganizationID)
  7202. }
  7203. return fields
  7204. }
  7205. // AddedField returns the numeric value that was incremented/decremented on a field
  7206. // with the given name. The second boolean return value indicates that this field
  7207. // was not set, or was not defined in the schema.
  7208. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  7209. switch name {
  7210. case contact.FieldStatus:
  7211. return m.AddedStatus()
  7212. case contact.FieldType:
  7213. return m.AddedType()
  7214. case contact.FieldSex:
  7215. return m.AddedSex()
  7216. case contact.FieldDontseeit:
  7217. return m.AddedDontseeit()
  7218. case contact.FieldDontseeme:
  7219. return m.AddedDontseeme()
  7220. case contact.FieldOrganizationID:
  7221. return m.AddedOrganizationID()
  7222. }
  7223. return nil, false
  7224. }
  7225. // AddField adds the value to the field with the given name. It returns an error if
  7226. // the field is not defined in the schema, or if the type mismatched the field
  7227. // type.
  7228. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  7229. switch name {
  7230. case contact.FieldStatus:
  7231. v, ok := value.(int8)
  7232. if !ok {
  7233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7234. }
  7235. m.AddStatus(v)
  7236. return nil
  7237. case contact.FieldType:
  7238. v, ok := value.(int)
  7239. if !ok {
  7240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7241. }
  7242. m.AddType(v)
  7243. return nil
  7244. case contact.FieldSex:
  7245. v, ok := value.(int)
  7246. if !ok {
  7247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7248. }
  7249. m.AddSex(v)
  7250. return nil
  7251. case contact.FieldDontseeit:
  7252. v, ok := value.(int)
  7253. if !ok {
  7254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7255. }
  7256. m.AddDontseeit(v)
  7257. return nil
  7258. case contact.FieldDontseeme:
  7259. v, ok := value.(int)
  7260. if !ok {
  7261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7262. }
  7263. m.AddDontseeme(v)
  7264. return nil
  7265. case contact.FieldOrganizationID:
  7266. v, ok := value.(int64)
  7267. if !ok {
  7268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7269. }
  7270. m.AddOrganizationID(v)
  7271. return nil
  7272. }
  7273. return fmt.Errorf("unknown Contact numeric field %s", name)
  7274. }
  7275. // ClearedFields returns all nullable fields that were cleared during this
  7276. // mutation.
  7277. func (m *ContactMutation) ClearedFields() []string {
  7278. var fields []string
  7279. if m.FieldCleared(contact.FieldStatus) {
  7280. fields = append(fields, contact.FieldStatus)
  7281. }
  7282. if m.FieldCleared(contact.FieldDeletedAt) {
  7283. fields = append(fields, contact.FieldDeletedAt)
  7284. }
  7285. if m.FieldCleared(contact.FieldWxWxid) {
  7286. fields = append(fields, contact.FieldWxWxid)
  7287. }
  7288. if m.FieldCleared(contact.FieldType) {
  7289. fields = append(fields, contact.FieldType)
  7290. }
  7291. if m.FieldCleared(contact.FieldOrganizationID) {
  7292. fields = append(fields, contact.FieldOrganizationID)
  7293. }
  7294. return fields
  7295. }
  7296. // FieldCleared returns a boolean indicating if a field with the given name was
  7297. // cleared in this mutation.
  7298. func (m *ContactMutation) FieldCleared(name string) bool {
  7299. _, ok := m.clearedFields[name]
  7300. return ok
  7301. }
  7302. // ClearField clears the value of the field with the given name. It returns an
  7303. // error if the field is not defined in the schema.
  7304. func (m *ContactMutation) ClearField(name string) error {
  7305. switch name {
  7306. case contact.FieldStatus:
  7307. m.ClearStatus()
  7308. return nil
  7309. case contact.FieldDeletedAt:
  7310. m.ClearDeletedAt()
  7311. return nil
  7312. case contact.FieldWxWxid:
  7313. m.ClearWxWxid()
  7314. return nil
  7315. case contact.FieldType:
  7316. m.ClearType()
  7317. return nil
  7318. case contact.FieldOrganizationID:
  7319. m.ClearOrganizationID()
  7320. return nil
  7321. }
  7322. return fmt.Errorf("unknown Contact nullable field %s", name)
  7323. }
  7324. // ResetField resets all changes in the mutation for the field with the given name.
  7325. // It returns an error if the field is not defined in the schema.
  7326. func (m *ContactMutation) ResetField(name string) error {
  7327. switch name {
  7328. case contact.FieldCreatedAt:
  7329. m.ResetCreatedAt()
  7330. return nil
  7331. case contact.FieldUpdatedAt:
  7332. m.ResetUpdatedAt()
  7333. return nil
  7334. case contact.FieldStatus:
  7335. m.ResetStatus()
  7336. return nil
  7337. case contact.FieldDeletedAt:
  7338. m.ResetDeletedAt()
  7339. return nil
  7340. case contact.FieldWxWxid:
  7341. m.ResetWxWxid()
  7342. return nil
  7343. case contact.FieldType:
  7344. m.ResetType()
  7345. return nil
  7346. case contact.FieldWxid:
  7347. m.ResetWxid()
  7348. return nil
  7349. case contact.FieldAccount:
  7350. m.ResetAccount()
  7351. return nil
  7352. case contact.FieldNickname:
  7353. m.ResetNickname()
  7354. return nil
  7355. case contact.FieldMarkname:
  7356. m.ResetMarkname()
  7357. return nil
  7358. case contact.FieldHeadimg:
  7359. m.ResetHeadimg()
  7360. return nil
  7361. case contact.FieldSex:
  7362. m.ResetSex()
  7363. return nil
  7364. case contact.FieldStarrole:
  7365. m.ResetStarrole()
  7366. return nil
  7367. case contact.FieldDontseeit:
  7368. m.ResetDontseeit()
  7369. return nil
  7370. case contact.FieldDontseeme:
  7371. m.ResetDontseeme()
  7372. return nil
  7373. case contact.FieldLag:
  7374. m.ResetLag()
  7375. return nil
  7376. case contact.FieldGid:
  7377. m.ResetGid()
  7378. return nil
  7379. case contact.FieldGname:
  7380. m.ResetGname()
  7381. return nil
  7382. case contact.FieldV3:
  7383. m.ResetV3()
  7384. return nil
  7385. case contact.FieldOrganizationID:
  7386. m.ResetOrganizationID()
  7387. return nil
  7388. }
  7389. return fmt.Errorf("unknown Contact field %s", name)
  7390. }
  7391. // AddedEdges returns all edge names that were set/added in this mutation.
  7392. func (m *ContactMutation) AddedEdges() []string {
  7393. edges := make([]string, 0, 2)
  7394. if m.contact_relationships != nil {
  7395. edges = append(edges, contact.EdgeContactRelationships)
  7396. }
  7397. if m.contact_messages != nil {
  7398. edges = append(edges, contact.EdgeContactMessages)
  7399. }
  7400. return edges
  7401. }
  7402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7403. // name in this mutation.
  7404. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  7405. switch name {
  7406. case contact.EdgeContactRelationships:
  7407. ids := make([]ent.Value, 0, len(m.contact_relationships))
  7408. for id := range m.contact_relationships {
  7409. ids = append(ids, id)
  7410. }
  7411. return ids
  7412. case contact.EdgeContactMessages:
  7413. ids := make([]ent.Value, 0, len(m.contact_messages))
  7414. for id := range m.contact_messages {
  7415. ids = append(ids, id)
  7416. }
  7417. return ids
  7418. }
  7419. return nil
  7420. }
  7421. // RemovedEdges returns all edge names that were removed in this mutation.
  7422. func (m *ContactMutation) RemovedEdges() []string {
  7423. edges := make([]string, 0, 2)
  7424. if m.removedcontact_relationships != nil {
  7425. edges = append(edges, contact.EdgeContactRelationships)
  7426. }
  7427. if m.removedcontact_messages != nil {
  7428. edges = append(edges, contact.EdgeContactMessages)
  7429. }
  7430. return edges
  7431. }
  7432. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7433. // the given name in this mutation.
  7434. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  7435. switch name {
  7436. case contact.EdgeContactRelationships:
  7437. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  7438. for id := range m.removedcontact_relationships {
  7439. ids = append(ids, id)
  7440. }
  7441. return ids
  7442. case contact.EdgeContactMessages:
  7443. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  7444. for id := range m.removedcontact_messages {
  7445. ids = append(ids, id)
  7446. }
  7447. return ids
  7448. }
  7449. return nil
  7450. }
  7451. // ClearedEdges returns all edge names that were cleared in this mutation.
  7452. func (m *ContactMutation) ClearedEdges() []string {
  7453. edges := make([]string, 0, 2)
  7454. if m.clearedcontact_relationships {
  7455. edges = append(edges, contact.EdgeContactRelationships)
  7456. }
  7457. if m.clearedcontact_messages {
  7458. edges = append(edges, contact.EdgeContactMessages)
  7459. }
  7460. return edges
  7461. }
  7462. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7463. // was cleared in this mutation.
  7464. func (m *ContactMutation) EdgeCleared(name string) bool {
  7465. switch name {
  7466. case contact.EdgeContactRelationships:
  7467. return m.clearedcontact_relationships
  7468. case contact.EdgeContactMessages:
  7469. return m.clearedcontact_messages
  7470. }
  7471. return false
  7472. }
  7473. // ClearEdge clears the value of the edge with the given name. It returns an error
  7474. // if that edge is not defined in the schema.
  7475. func (m *ContactMutation) ClearEdge(name string) error {
  7476. switch name {
  7477. }
  7478. return fmt.Errorf("unknown Contact unique edge %s", name)
  7479. }
  7480. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7481. // It returns an error if the edge is not defined in the schema.
  7482. func (m *ContactMutation) ResetEdge(name string) error {
  7483. switch name {
  7484. case contact.EdgeContactRelationships:
  7485. m.ResetContactRelationships()
  7486. return nil
  7487. case contact.EdgeContactMessages:
  7488. m.ResetContactMessages()
  7489. return nil
  7490. }
  7491. return fmt.Errorf("unknown Contact edge %s", name)
  7492. }
  7493. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  7494. type EmployeeMutation struct {
  7495. config
  7496. op Op
  7497. typ string
  7498. id *uint64
  7499. created_at *time.Time
  7500. updated_at *time.Time
  7501. deleted_at *time.Time
  7502. title *string
  7503. avatar *string
  7504. tags *string
  7505. hire_count *int
  7506. addhire_count *int
  7507. service_count *int
  7508. addservice_count *int
  7509. achievement_count *int
  7510. addachievement_count *int
  7511. intro *string
  7512. estimate *string
  7513. skill *string
  7514. ability_type *string
  7515. scene *string
  7516. switch_in *string
  7517. video_url *string
  7518. organization_id *uint64
  7519. addorganization_id *int64
  7520. category_id *uint64
  7521. addcategory_id *int64
  7522. api_base *string
  7523. api_key *string
  7524. clearedFields map[string]struct{}
  7525. em_work_experiences map[uint64]struct{}
  7526. removedem_work_experiences map[uint64]struct{}
  7527. clearedem_work_experiences bool
  7528. em_tutorial map[uint64]struct{}
  7529. removedem_tutorial map[uint64]struct{}
  7530. clearedem_tutorial bool
  7531. done bool
  7532. oldValue func(context.Context) (*Employee, error)
  7533. predicates []predicate.Employee
  7534. }
  7535. var _ ent.Mutation = (*EmployeeMutation)(nil)
  7536. // employeeOption allows management of the mutation configuration using functional options.
  7537. type employeeOption func(*EmployeeMutation)
  7538. // newEmployeeMutation creates new mutation for the Employee entity.
  7539. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  7540. m := &EmployeeMutation{
  7541. config: c,
  7542. op: op,
  7543. typ: TypeEmployee,
  7544. clearedFields: make(map[string]struct{}),
  7545. }
  7546. for _, opt := range opts {
  7547. opt(m)
  7548. }
  7549. return m
  7550. }
  7551. // withEmployeeID sets the ID field of the mutation.
  7552. func withEmployeeID(id uint64) employeeOption {
  7553. return func(m *EmployeeMutation) {
  7554. var (
  7555. err error
  7556. once sync.Once
  7557. value *Employee
  7558. )
  7559. m.oldValue = func(ctx context.Context) (*Employee, error) {
  7560. once.Do(func() {
  7561. if m.done {
  7562. err = errors.New("querying old values post mutation is not allowed")
  7563. } else {
  7564. value, err = m.Client().Employee.Get(ctx, id)
  7565. }
  7566. })
  7567. return value, err
  7568. }
  7569. m.id = &id
  7570. }
  7571. }
  7572. // withEmployee sets the old Employee of the mutation.
  7573. func withEmployee(node *Employee) employeeOption {
  7574. return func(m *EmployeeMutation) {
  7575. m.oldValue = func(context.Context) (*Employee, error) {
  7576. return node, nil
  7577. }
  7578. m.id = &node.ID
  7579. }
  7580. }
  7581. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7582. // executed in a transaction (ent.Tx), a transactional client is returned.
  7583. func (m EmployeeMutation) Client() *Client {
  7584. client := &Client{config: m.config}
  7585. client.init()
  7586. return client
  7587. }
  7588. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7589. // it returns an error otherwise.
  7590. func (m EmployeeMutation) Tx() (*Tx, error) {
  7591. if _, ok := m.driver.(*txDriver); !ok {
  7592. return nil, errors.New("ent: mutation is not running in a transaction")
  7593. }
  7594. tx := &Tx{config: m.config}
  7595. tx.init()
  7596. return tx, nil
  7597. }
  7598. // SetID sets the value of the id field. Note that this
  7599. // operation is only accepted on creation of Employee entities.
  7600. func (m *EmployeeMutation) SetID(id uint64) {
  7601. m.id = &id
  7602. }
  7603. // ID returns the ID value in the mutation. Note that the ID is only available
  7604. // if it was provided to the builder or after it was returned from the database.
  7605. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  7606. if m.id == nil {
  7607. return
  7608. }
  7609. return *m.id, true
  7610. }
  7611. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7612. // That means, if the mutation is applied within a transaction with an isolation level such
  7613. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7614. // or updated by the mutation.
  7615. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  7616. switch {
  7617. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7618. id, exists := m.ID()
  7619. if exists {
  7620. return []uint64{id}, nil
  7621. }
  7622. fallthrough
  7623. case m.op.Is(OpUpdate | OpDelete):
  7624. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  7625. default:
  7626. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7627. }
  7628. }
  7629. // SetCreatedAt sets the "created_at" field.
  7630. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  7631. m.created_at = &t
  7632. }
  7633. // CreatedAt returns the value of the "created_at" field in the mutation.
  7634. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  7635. v := m.created_at
  7636. if v == nil {
  7637. return
  7638. }
  7639. return *v, true
  7640. }
  7641. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  7642. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7644. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7645. if !m.op.Is(OpUpdateOne) {
  7646. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7647. }
  7648. if m.id == nil || m.oldValue == nil {
  7649. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7650. }
  7651. oldValue, err := m.oldValue(ctx)
  7652. if err != nil {
  7653. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7654. }
  7655. return oldValue.CreatedAt, nil
  7656. }
  7657. // ResetCreatedAt resets all changes to the "created_at" field.
  7658. func (m *EmployeeMutation) ResetCreatedAt() {
  7659. m.created_at = nil
  7660. }
  7661. // SetUpdatedAt sets the "updated_at" field.
  7662. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  7663. m.updated_at = &t
  7664. }
  7665. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7666. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  7667. v := m.updated_at
  7668. if v == nil {
  7669. return
  7670. }
  7671. return *v, true
  7672. }
  7673. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  7674. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7676. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7677. if !m.op.Is(OpUpdateOne) {
  7678. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7679. }
  7680. if m.id == nil || m.oldValue == nil {
  7681. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7682. }
  7683. oldValue, err := m.oldValue(ctx)
  7684. if err != nil {
  7685. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7686. }
  7687. return oldValue.UpdatedAt, nil
  7688. }
  7689. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7690. func (m *EmployeeMutation) ResetUpdatedAt() {
  7691. m.updated_at = nil
  7692. }
  7693. // SetDeletedAt sets the "deleted_at" field.
  7694. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  7695. m.deleted_at = &t
  7696. }
  7697. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7698. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  7699. v := m.deleted_at
  7700. if v == nil {
  7701. return
  7702. }
  7703. return *v, true
  7704. }
  7705. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  7706. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7708. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7709. if !m.op.Is(OpUpdateOne) {
  7710. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7711. }
  7712. if m.id == nil || m.oldValue == nil {
  7713. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7714. }
  7715. oldValue, err := m.oldValue(ctx)
  7716. if err != nil {
  7717. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7718. }
  7719. return oldValue.DeletedAt, nil
  7720. }
  7721. // ClearDeletedAt clears the value of the "deleted_at" field.
  7722. func (m *EmployeeMutation) ClearDeletedAt() {
  7723. m.deleted_at = nil
  7724. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  7725. }
  7726. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7727. func (m *EmployeeMutation) DeletedAtCleared() bool {
  7728. _, ok := m.clearedFields[employee.FieldDeletedAt]
  7729. return ok
  7730. }
  7731. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7732. func (m *EmployeeMutation) ResetDeletedAt() {
  7733. m.deleted_at = nil
  7734. delete(m.clearedFields, employee.FieldDeletedAt)
  7735. }
  7736. // SetTitle sets the "title" field.
  7737. func (m *EmployeeMutation) SetTitle(s string) {
  7738. m.title = &s
  7739. }
  7740. // Title returns the value of the "title" field in the mutation.
  7741. func (m *EmployeeMutation) Title() (r string, exists bool) {
  7742. v := m.title
  7743. if v == nil {
  7744. return
  7745. }
  7746. return *v, true
  7747. }
  7748. // OldTitle returns the old "title" field's value of the Employee entity.
  7749. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7751. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  7752. if !m.op.Is(OpUpdateOne) {
  7753. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  7754. }
  7755. if m.id == nil || m.oldValue == nil {
  7756. return v, errors.New("OldTitle requires an ID field in the mutation")
  7757. }
  7758. oldValue, err := m.oldValue(ctx)
  7759. if err != nil {
  7760. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  7761. }
  7762. return oldValue.Title, nil
  7763. }
  7764. // ResetTitle resets all changes to the "title" field.
  7765. func (m *EmployeeMutation) ResetTitle() {
  7766. m.title = nil
  7767. }
  7768. // SetAvatar sets the "avatar" field.
  7769. func (m *EmployeeMutation) SetAvatar(s string) {
  7770. m.avatar = &s
  7771. }
  7772. // Avatar returns the value of the "avatar" field in the mutation.
  7773. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  7774. v := m.avatar
  7775. if v == nil {
  7776. return
  7777. }
  7778. return *v, true
  7779. }
  7780. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  7781. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7783. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  7784. if !m.op.Is(OpUpdateOne) {
  7785. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  7786. }
  7787. if m.id == nil || m.oldValue == nil {
  7788. return v, errors.New("OldAvatar requires an ID field in the mutation")
  7789. }
  7790. oldValue, err := m.oldValue(ctx)
  7791. if err != nil {
  7792. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  7793. }
  7794. return oldValue.Avatar, nil
  7795. }
  7796. // ResetAvatar resets all changes to the "avatar" field.
  7797. func (m *EmployeeMutation) ResetAvatar() {
  7798. m.avatar = nil
  7799. }
  7800. // SetTags sets the "tags" field.
  7801. func (m *EmployeeMutation) SetTags(s string) {
  7802. m.tags = &s
  7803. }
  7804. // Tags returns the value of the "tags" field in the mutation.
  7805. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  7806. v := m.tags
  7807. if v == nil {
  7808. return
  7809. }
  7810. return *v, true
  7811. }
  7812. // OldTags returns the old "tags" field's value of the Employee entity.
  7813. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7815. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  7816. if !m.op.Is(OpUpdateOne) {
  7817. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  7818. }
  7819. if m.id == nil || m.oldValue == nil {
  7820. return v, errors.New("OldTags requires an ID field in the mutation")
  7821. }
  7822. oldValue, err := m.oldValue(ctx)
  7823. if err != nil {
  7824. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  7825. }
  7826. return oldValue.Tags, nil
  7827. }
  7828. // ResetTags resets all changes to the "tags" field.
  7829. func (m *EmployeeMutation) ResetTags() {
  7830. m.tags = nil
  7831. }
  7832. // SetHireCount sets the "hire_count" field.
  7833. func (m *EmployeeMutation) SetHireCount(i int) {
  7834. m.hire_count = &i
  7835. m.addhire_count = nil
  7836. }
  7837. // HireCount returns the value of the "hire_count" field in the mutation.
  7838. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  7839. v := m.hire_count
  7840. if v == nil {
  7841. return
  7842. }
  7843. return *v, true
  7844. }
  7845. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  7846. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7848. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  7849. if !m.op.Is(OpUpdateOne) {
  7850. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  7851. }
  7852. if m.id == nil || m.oldValue == nil {
  7853. return v, errors.New("OldHireCount requires an ID field in the mutation")
  7854. }
  7855. oldValue, err := m.oldValue(ctx)
  7856. if err != nil {
  7857. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  7858. }
  7859. return oldValue.HireCount, nil
  7860. }
  7861. // AddHireCount adds i to the "hire_count" field.
  7862. func (m *EmployeeMutation) AddHireCount(i int) {
  7863. if m.addhire_count != nil {
  7864. *m.addhire_count += i
  7865. } else {
  7866. m.addhire_count = &i
  7867. }
  7868. }
  7869. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  7870. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  7871. v := m.addhire_count
  7872. if v == nil {
  7873. return
  7874. }
  7875. return *v, true
  7876. }
  7877. // ResetHireCount resets all changes to the "hire_count" field.
  7878. func (m *EmployeeMutation) ResetHireCount() {
  7879. m.hire_count = nil
  7880. m.addhire_count = nil
  7881. }
  7882. // SetServiceCount sets the "service_count" field.
  7883. func (m *EmployeeMutation) SetServiceCount(i int) {
  7884. m.service_count = &i
  7885. m.addservice_count = nil
  7886. }
  7887. // ServiceCount returns the value of the "service_count" field in the mutation.
  7888. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  7889. v := m.service_count
  7890. if v == nil {
  7891. return
  7892. }
  7893. return *v, true
  7894. }
  7895. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  7896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7898. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  7899. if !m.op.Is(OpUpdateOne) {
  7900. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  7901. }
  7902. if m.id == nil || m.oldValue == nil {
  7903. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  7904. }
  7905. oldValue, err := m.oldValue(ctx)
  7906. if err != nil {
  7907. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  7908. }
  7909. return oldValue.ServiceCount, nil
  7910. }
  7911. // AddServiceCount adds i to the "service_count" field.
  7912. func (m *EmployeeMutation) AddServiceCount(i int) {
  7913. if m.addservice_count != nil {
  7914. *m.addservice_count += i
  7915. } else {
  7916. m.addservice_count = &i
  7917. }
  7918. }
  7919. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  7920. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  7921. v := m.addservice_count
  7922. if v == nil {
  7923. return
  7924. }
  7925. return *v, true
  7926. }
  7927. // ResetServiceCount resets all changes to the "service_count" field.
  7928. func (m *EmployeeMutation) ResetServiceCount() {
  7929. m.service_count = nil
  7930. m.addservice_count = nil
  7931. }
  7932. // SetAchievementCount sets the "achievement_count" field.
  7933. func (m *EmployeeMutation) SetAchievementCount(i int) {
  7934. m.achievement_count = &i
  7935. m.addachievement_count = nil
  7936. }
  7937. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  7938. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  7939. v := m.achievement_count
  7940. if v == nil {
  7941. return
  7942. }
  7943. return *v, true
  7944. }
  7945. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  7946. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7948. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  7949. if !m.op.Is(OpUpdateOne) {
  7950. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  7951. }
  7952. if m.id == nil || m.oldValue == nil {
  7953. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  7954. }
  7955. oldValue, err := m.oldValue(ctx)
  7956. if err != nil {
  7957. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  7958. }
  7959. return oldValue.AchievementCount, nil
  7960. }
  7961. // AddAchievementCount adds i to the "achievement_count" field.
  7962. func (m *EmployeeMutation) AddAchievementCount(i int) {
  7963. if m.addachievement_count != nil {
  7964. *m.addachievement_count += i
  7965. } else {
  7966. m.addachievement_count = &i
  7967. }
  7968. }
  7969. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  7970. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  7971. v := m.addachievement_count
  7972. if v == nil {
  7973. return
  7974. }
  7975. return *v, true
  7976. }
  7977. // ResetAchievementCount resets all changes to the "achievement_count" field.
  7978. func (m *EmployeeMutation) ResetAchievementCount() {
  7979. m.achievement_count = nil
  7980. m.addachievement_count = nil
  7981. }
  7982. // SetIntro sets the "intro" field.
  7983. func (m *EmployeeMutation) SetIntro(s string) {
  7984. m.intro = &s
  7985. }
  7986. // Intro returns the value of the "intro" field in the mutation.
  7987. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  7988. v := m.intro
  7989. if v == nil {
  7990. return
  7991. }
  7992. return *v, true
  7993. }
  7994. // OldIntro returns the old "intro" field's value of the Employee entity.
  7995. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  7996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7997. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  7998. if !m.op.Is(OpUpdateOne) {
  7999. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  8000. }
  8001. if m.id == nil || m.oldValue == nil {
  8002. return v, errors.New("OldIntro requires an ID field in the mutation")
  8003. }
  8004. oldValue, err := m.oldValue(ctx)
  8005. if err != nil {
  8006. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  8007. }
  8008. return oldValue.Intro, nil
  8009. }
  8010. // ResetIntro resets all changes to the "intro" field.
  8011. func (m *EmployeeMutation) ResetIntro() {
  8012. m.intro = nil
  8013. }
  8014. // SetEstimate sets the "estimate" field.
  8015. func (m *EmployeeMutation) SetEstimate(s string) {
  8016. m.estimate = &s
  8017. }
  8018. // Estimate returns the value of the "estimate" field in the mutation.
  8019. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  8020. v := m.estimate
  8021. if v == nil {
  8022. return
  8023. }
  8024. return *v, true
  8025. }
  8026. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  8027. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8029. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  8030. if !m.op.Is(OpUpdateOne) {
  8031. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  8032. }
  8033. if m.id == nil || m.oldValue == nil {
  8034. return v, errors.New("OldEstimate requires an ID field in the mutation")
  8035. }
  8036. oldValue, err := m.oldValue(ctx)
  8037. if err != nil {
  8038. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  8039. }
  8040. return oldValue.Estimate, nil
  8041. }
  8042. // ResetEstimate resets all changes to the "estimate" field.
  8043. func (m *EmployeeMutation) ResetEstimate() {
  8044. m.estimate = nil
  8045. }
  8046. // SetSkill sets the "skill" field.
  8047. func (m *EmployeeMutation) SetSkill(s string) {
  8048. m.skill = &s
  8049. }
  8050. // Skill returns the value of the "skill" field in the mutation.
  8051. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  8052. v := m.skill
  8053. if v == nil {
  8054. return
  8055. }
  8056. return *v, true
  8057. }
  8058. // OldSkill returns the old "skill" field's value of the Employee entity.
  8059. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8061. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  8062. if !m.op.Is(OpUpdateOne) {
  8063. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  8064. }
  8065. if m.id == nil || m.oldValue == nil {
  8066. return v, errors.New("OldSkill requires an ID field in the mutation")
  8067. }
  8068. oldValue, err := m.oldValue(ctx)
  8069. if err != nil {
  8070. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  8071. }
  8072. return oldValue.Skill, nil
  8073. }
  8074. // ResetSkill resets all changes to the "skill" field.
  8075. func (m *EmployeeMutation) ResetSkill() {
  8076. m.skill = nil
  8077. }
  8078. // SetAbilityType sets the "ability_type" field.
  8079. func (m *EmployeeMutation) SetAbilityType(s string) {
  8080. m.ability_type = &s
  8081. }
  8082. // AbilityType returns the value of the "ability_type" field in the mutation.
  8083. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  8084. v := m.ability_type
  8085. if v == nil {
  8086. return
  8087. }
  8088. return *v, true
  8089. }
  8090. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  8091. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8093. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  8094. if !m.op.Is(OpUpdateOne) {
  8095. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  8096. }
  8097. if m.id == nil || m.oldValue == nil {
  8098. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  8099. }
  8100. oldValue, err := m.oldValue(ctx)
  8101. if err != nil {
  8102. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  8103. }
  8104. return oldValue.AbilityType, nil
  8105. }
  8106. // ResetAbilityType resets all changes to the "ability_type" field.
  8107. func (m *EmployeeMutation) ResetAbilityType() {
  8108. m.ability_type = nil
  8109. }
  8110. // SetScene sets the "scene" field.
  8111. func (m *EmployeeMutation) SetScene(s string) {
  8112. m.scene = &s
  8113. }
  8114. // Scene returns the value of the "scene" field in the mutation.
  8115. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  8116. v := m.scene
  8117. if v == nil {
  8118. return
  8119. }
  8120. return *v, true
  8121. }
  8122. // OldScene returns the old "scene" field's value of the Employee entity.
  8123. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8125. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  8126. if !m.op.Is(OpUpdateOne) {
  8127. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  8128. }
  8129. if m.id == nil || m.oldValue == nil {
  8130. return v, errors.New("OldScene requires an ID field in the mutation")
  8131. }
  8132. oldValue, err := m.oldValue(ctx)
  8133. if err != nil {
  8134. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  8135. }
  8136. return oldValue.Scene, nil
  8137. }
  8138. // ResetScene resets all changes to the "scene" field.
  8139. func (m *EmployeeMutation) ResetScene() {
  8140. m.scene = nil
  8141. }
  8142. // SetSwitchIn sets the "switch_in" field.
  8143. func (m *EmployeeMutation) SetSwitchIn(s string) {
  8144. m.switch_in = &s
  8145. }
  8146. // SwitchIn returns the value of the "switch_in" field in the mutation.
  8147. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  8148. v := m.switch_in
  8149. if v == nil {
  8150. return
  8151. }
  8152. return *v, true
  8153. }
  8154. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  8155. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8157. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  8158. if !m.op.Is(OpUpdateOne) {
  8159. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  8160. }
  8161. if m.id == nil || m.oldValue == nil {
  8162. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  8163. }
  8164. oldValue, err := m.oldValue(ctx)
  8165. if err != nil {
  8166. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  8167. }
  8168. return oldValue.SwitchIn, nil
  8169. }
  8170. // ResetSwitchIn resets all changes to the "switch_in" field.
  8171. func (m *EmployeeMutation) ResetSwitchIn() {
  8172. m.switch_in = nil
  8173. }
  8174. // SetVideoURL sets the "video_url" field.
  8175. func (m *EmployeeMutation) SetVideoURL(s string) {
  8176. m.video_url = &s
  8177. }
  8178. // VideoURL returns the value of the "video_url" field in the mutation.
  8179. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  8180. v := m.video_url
  8181. if v == nil {
  8182. return
  8183. }
  8184. return *v, true
  8185. }
  8186. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  8187. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8189. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  8190. if !m.op.Is(OpUpdateOne) {
  8191. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  8192. }
  8193. if m.id == nil || m.oldValue == nil {
  8194. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  8195. }
  8196. oldValue, err := m.oldValue(ctx)
  8197. if err != nil {
  8198. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  8199. }
  8200. return oldValue.VideoURL, nil
  8201. }
  8202. // ResetVideoURL resets all changes to the "video_url" field.
  8203. func (m *EmployeeMutation) ResetVideoURL() {
  8204. m.video_url = nil
  8205. }
  8206. // SetOrganizationID sets the "organization_id" field.
  8207. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  8208. m.organization_id = &u
  8209. m.addorganization_id = nil
  8210. }
  8211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8212. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  8213. v := m.organization_id
  8214. if v == nil {
  8215. return
  8216. }
  8217. return *v, true
  8218. }
  8219. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  8220. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8222. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8223. if !m.op.Is(OpUpdateOne) {
  8224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8225. }
  8226. if m.id == nil || m.oldValue == nil {
  8227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8228. }
  8229. oldValue, err := m.oldValue(ctx)
  8230. if err != nil {
  8231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8232. }
  8233. return oldValue.OrganizationID, nil
  8234. }
  8235. // AddOrganizationID adds u to the "organization_id" field.
  8236. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  8237. if m.addorganization_id != nil {
  8238. *m.addorganization_id += u
  8239. } else {
  8240. m.addorganization_id = &u
  8241. }
  8242. }
  8243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8244. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  8245. v := m.addorganization_id
  8246. if v == nil {
  8247. return
  8248. }
  8249. return *v, true
  8250. }
  8251. // ResetOrganizationID resets all changes to the "organization_id" field.
  8252. func (m *EmployeeMutation) ResetOrganizationID() {
  8253. m.organization_id = nil
  8254. m.addorganization_id = nil
  8255. }
  8256. // SetCategoryID sets the "category_id" field.
  8257. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  8258. m.category_id = &u
  8259. m.addcategory_id = nil
  8260. }
  8261. // CategoryID returns the value of the "category_id" field in the mutation.
  8262. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  8263. v := m.category_id
  8264. if v == nil {
  8265. return
  8266. }
  8267. return *v, true
  8268. }
  8269. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  8270. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8272. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  8273. if !m.op.Is(OpUpdateOne) {
  8274. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  8275. }
  8276. if m.id == nil || m.oldValue == nil {
  8277. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  8278. }
  8279. oldValue, err := m.oldValue(ctx)
  8280. if err != nil {
  8281. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  8282. }
  8283. return oldValue.CategoryID, nil
  8284. }
  8285. // AddCategoryID adds u to the "category_id" field.
  8286. func (m *EmployeeMutation) AddCategoryID(u int64) {
  8287. if m.addcategory_id != nil {
  8288. *m.addcategory_id += u
  8289. } else {
  8290. m.addcategory_id = &u
  8291. }
  8292. }
  8293. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  8294. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  8295. v := m.addcategory_id
  8296. if v == nil {
  8297. return
  8298. }
  8299. return *v, true
  8300. }
  8301. // ResetCategoryID resets all changes to the "category_id" field.
  8302. func (m *EmployeeMutation) ResetCategoryID() {
  8303. m.category_id = nil
  8304. m.addcategory_id = nil
  8305. }
  8306. // SetAPIBase sets the "api_base" field.
  8307. func (m *EmployeeMutation) SetAPIBase(s string) {
  8308. m.api_base = &s
  8309. }
  8310. // APIBase returns the value of the "api_base" field in the mutation.
  8311. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  8312. v := m.api_base
  8313. if v == nil {
  8314. return
  8315. }
  8316. return *v, true
  8317. }
  8318. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  8319. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8321. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  8322. if !m.op.Is(OpUpdateOne) {
  8323. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  8324. }
  8325. if m.id == nil || m.oldValue == nil {
  8326. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  8327. }
  8328. oldValue, err := m.oldValue(ctx)
  8329. if err != nil {
  8330. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  8331. }
  8332. return oldValue.APIBase, nil
  8333. }
  8334. // ResetAPIBase resets all changes to the "api_base" field.
  8335. func (m *EmployeeMutation) ResetAPIBase() {
  8336. m.api_base = nil
  8337. }
  8338. // SetAPIKey sets the "api_key" field.
  8339. func (m *EmployeeMutation) SetAPIKey(s string) {
  8340. m.api_key = &s
  8341. }
  8342. // APIKey returns the value of the "api_key" field in the mutation.
  8343. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  8344. v := m.api_key
  8345. if v == nil {
  8346. return
  8347. }
  8348. return *v, true
  8349. }
  8350. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  8351. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8353. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  8354. if !m.op.Is(OpUpdateOne) {
  8355. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  8356. }
  8357. if m.id == nil || m.oldValue == nil {
  8358. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  8359. }
  8360. oldValue, err := m.oldValue(ctx)
  8361. if err != nil {
  8362. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  8363. }
  8364. return oldValue.APIKey, nil
  8365. }
  8366. // ResetAPIKey resets all changes to the "api_key" field.
  8367. func (m *EmployeeMutation) ResetAPIKey() {
  8368. m.api_key = nil
  8369. }
  8370. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  8371. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  8372. if m.em_work_experiences == nil {
  8373. m.em_work_experiences = make(map[uint64]struct{})
  8374. }
  8375. for i := range ids {
  8376. m.em_work_experiences[ids[i]] = struct{}{}
  8377. }
  8378. }
  8379. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  8380. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  8381. m.clearedem_work_experiences = true
  8382. }
  8383. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  8384. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  8385. return m.clearedem_work_experiences
  8386. }
  8387. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  8388. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  8389. if m.removedem_work_experiences == nil {
  8390. m.removedem_work_experiences = make(map[uint64]struct{})
  8391. }
  8392. for i := range ids {
  8393. delete(m.em_work_experiences, ids[i])
  8394. m.removedem_work_experiences[ids[i]] = struct{}{}
  8395. }
  8396. }
  8397. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  8398. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  8399. for id := range m.removedem_work_experiences {
  8400. ids = append(ids, id)
  8401. }
  8402. return
  8403. }
  8404. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  8405. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  8406. for id := range m.em_work_experiences {
  8407. ids = append(ids, id)
  8408. }
  8409. return
  8410. }
  8411. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  8412. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  8413. m.em_work_experiences = nil
  8414. m.clearedem_work_experiences = false
  8415. m.removedem_work_experiences = nil
  8416. }
  8417. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  8418. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  8419. if m.em_tutorial == nil {
  8420. m.em_tutorial = make(map[uint64]struct{})
  8421. }
  8422. for i := range ids {
  8423. m.em_tutorial[ids[i]] = struct{}{}
  8424. }
  8425. }
  8426. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  8427. func (m *EmployeeMutation) ClearEmTutorial() {
  8428. m.clearedem_tutorial = true
  8429. }
  8430. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  8431. func (m *EmployeeMutation) EmTutorialCleared() bool {
  8432. return m.clearedem_tutorial
  8433. }
  8434. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  8435. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  8436. if m.removedem_tutorial == nil {
  8437. m.removedem_tutorial = make(map[uint64]struct{})
  8438. }
  8439. for i := range ids {
  8440. delete(m.em_tutorial, ids[i])
  8441. m.removedem_tutorial[ids[i]] = struct{}{}
  8442. }
  8443. }
  8444. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  8445. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  8446. for id := range m.removedem_tutorial {
  8447. ids = append(ids, id)
  8448. }
  8449. return
  8450. }
  8451. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  8452. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  8453. for id := range m.em_tutorial {
  8454. ids = append(ids, id)
  8455. }
  8456. return
  8457. }
  8458. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  8459. func (m *EmployeeMutation) ResetEmTutorial() {
  8460. m.em_tutorial = nil
  8461. m.clearedem_tutorial = false
  8462. m.removedem_tutorial = nil
  8463. }
  8464. // Where appends a list predicates to the EmployeeMutation builder.
  8465. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  8466. m.predicates = append(m.predicates, ps...)
  8467. }
  8468. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  8469. // users can use type-assertion to append predicates that do not depend on any generated package.
  8470. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  8471. p := make([]predicate.Employee, len(ps))
  8472. for i := range ps {
  8473. p[i] = ps[i]
  8474. }
  8475. m.Where(p...)
  8476. }
  8477. // Op returns the operation name.
  8478. func (m *EmployeeMutation) Op() Op {
  8479. return m.op
  8480. }
  8481. // SetOp allows setting the mutation operation.
  8482. func (m *EmployeeMutation) SetOp(op Op) {
  8483. m.op = op
  8484. }
  8485. // Type returns the node type of this mutation (Employee).
  8486. func (m *EmployeeMutation) Type() string {
  8487. return m.typ
  8488. }
  8489. // Fields returns all fields that were changed during this mutation. Note that in
  8490. // order to get all numeric fields that were incremented/decremented, call
  8491. // AddedFields().
  8492. func (m *EmployeeMutation) Fields() []string {
  8493. fields := make([]string, 0, 20)
  8494. if m.created_at != nil {
  8495. fields = append(fields, employee.FieldCreatedAt)
  8496. }
  8497. if m.updated_at != nil {
  8498. fields = append(fields, employee.FieldUpdatedAt)
  8499. }
  8500. if m.deleted_at != nil {
  8501. fields = append(fields, employee.FieldDeletedAt)
  8502. }
  8503. if m.title != nil {
  8504. fields = append(fields, employee.FieldTitle)
  8505. }
  8506. if m.avatar != nil {
  8507. fields = append(fields, employee.FieldAvatar)
  8508. }
  8509. if m.tags != nil {
  8510. fields = append(fields, employee.FieldTags)
  8511. }
  8512. if m.hire_count != nil {
  8513. fields = append(fields, employee.FieldHireCount)
  8514. }
  8515. if m.service_count != nil {
  8516. fields = append(fields, employee.FieldServiceCount)
  8517. }
  8518. if m.achievement_count != nil {
  8519. fields = append(fields, employee.FieldAchievementCount)
  8520. }
  8521. if m.intro != nil {
  8522. fields = append(fields, employee.FieldIntro)
  8523. }
  8524. if m.estimate != nil {
  8525. fields = append(fields, employee.FieldEstimate)
  8526. }
  8527. if m.skill != nil {
  8528. fields = append(fields, employee.FieldSkill)
  8529. }
  8530. if m.ability_type != nil {
  8531. fields = append(fields, employee.FieldAbilityType)
  8532. }
  8533. if m.scene != nil {
  8534. fields = append(fields, employee.FieldScene)
  8535. }
  8536. if m.switch_in != nil {
  8537. fields = append(fields, employee.FieldSwitchIn)
  8538. }
  8539. if m.video_url != nil {
  8540. fields = append(fields, employee.FieldVideoURL)
  8541. }
  8542. if m.organization_id != nil {
  8543. fields = append(fields, employee.FieldOrganizationID)
  8544. }
  8545. if m.category_id != nil {
  8546. fields = append(fields, employee.FieldCategoryID)
  8547. }
  8548. if m.api_base != nil {
  8549. fields = append(fields, employee.FieldAPIBase)
  8550. }
  8551. if m.api_key != nil {
  8552. fields = append(fields, employee.FieldAPIKey)
  8553. }
  8554. return fields
  8555. }
  8556. // Field returns the value of a field with the given name. The second boolean
  8557. // return value indicates that this field was not set, or was not defined in the
  8558. // schema.
  8559. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  8560. switch name {
  8561. case employee.FieldCreatedAt:
  8562. return m.CreatedAt()
  8563. case employee.FieldUpdatedAt:
  8564. return m.UpdatedAt()
  8565. case employee.FieldDeletedAt:
  8566. return m.DeletedAt()
  8567. case employee.FieldTitle:
  8568. return m.Title()
  8569. case employee.FieldAvatar:
  8570. return m.Avatar()
  8571. case employee.FieldTags:
  8572. return m.Tags()
  8573. case employee.FieldHireCount:
  8574. return m.HireCount()
  8575. case employee.FieldServiceCount:
  8576. return m.ServiceCount()
  8577. case employee.FieldAchievementCount:
  8578. return m.AchievementCount()
  8579. case employee.FieldIntro:
  8580. return m.Intro()
  8581. case employee.FieldEstimate:
  8582. return m.Estimate()
  8583. case employee.FieldSkill:
  8584. return m.Skill()
  8585. case employee.FieldAbilityType:
  8586. return m.AbilityType()
  8587. case employee.FieldScene:
  8588. return m.Scene()
  8589. case employee.FieldSwitchIn:
  8590. return m.SwitchIn()
  8591. case employee.FieldVideoURL:
  8592. return m.VideoURL()
  8593. case employee.FieldOrganizationID:
  8594. return m.OrganizationID()
  8595. case employee.FieldCategoryID:
  8596. return m.CategoryID()
  8597. case employee.FieldAPIBase:
  8598. return m.APIBase()
  8599. case employee.FieldAPIKey:
  8600. return m.APIKey()
  8601. }
  8602. return nil, false
  8603. }
  8604. // OldField returns the old value of the field from the database. An error is
  8605. // returned if the mutation operation is not UpdateOne, or the query to the
  8606. // database failed.
  8607. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8608. switch name {
  8609. case employee.FieldCreatedAt:
  8610. return m.OldCreatedAt(ctx)
  8611. case employee.FieldUpdatedAt:
  8612. return m.OldUpdatedAt(ctx)
  8613. case employee.FieldDeletedAt:
  8614. return m.OldDeletedAt(ctx)
  8615. case employee.FieldTitle:
  8616. return m.OldTitle(ctx)
  8617. case employee.FieldAvatar:
  8618. return m.OldAvatar(ctx)
  8619. case employee.FieldTags:
  8620. return m.OldTags(ctx)
  8621. case employee.FieldHireCount:
  8622. return m.OldHireCount(ctx)
  8623. case employee.FieldServiceCount:
  8624. return m.OldServiceCount(ctx)
  8625. case employee.FieldAchievementCount:
  8626. return m.OldAchievementCount(ctx)
  8627. case employee.FieldIntro:
  8628. return m.OldIntro(ctx)
  8629. case employee.FieldEstimate:
  8630. return m.OldEstimate(ctx)
  8631. case employee.FieldSkill:
  8632. return m.OldSkill(ctx)
  8633. case employee.FieldAbilityType:
  8634. return m.OldAbilityType(ctx)
  8635. case employee.FieldScene:
  8636. return m.OldScene(ctx)
  8637. case employee.FieldSwitchIn:
  8638. return m.OldSwitchIn(ctx)
  8639. case employee.FieldVideoURL:
  8640. return m.OldVideoURL(ctx)
  8641. case employee.FieldOrganizationID:
  8642. return m.OldOrganizationID(ctx)
  8643. case employee.FieldCategoryID:
  8644. return m.OldCategoryID(ctx)
  8645. case employee.FieldAPIBase:
  8646. return m.OldAPIBase(ctx)
  8647. case employee.FieldAPIKey:
  8648. return m.OldAPIKey(ctx)
  8649. }
  8650. return nil, fmt.Errorf("unknown Employee field %s", name)
  8651. }
  8652. // SetField sets the value of a field with the given name. It returns an error if
  8653. // the field is not defined in the schema, or if the type mismatched the field
  8654. // type.
  8655. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  8656. switch name {
  8657. case employee.FieldCreatedAt:
  8658. v, ok := value.(time.Time)
  8659. if !ok {
  8660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8661. }
  8662. m.SetCreatedAt(v)
  8663. return nil
  8664. case employee.FieldUpdatedAt:
  8665. v, ok := value.(time.Time)
  8666. if !ok {
  8667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8668. }
  8669. m.SetUpdatedAt(v)
  8670. return nil
  8671. case employee.FieldDeletedAt:
  8672. v, ok := value.(time.Time)
  8673. if !ok {
  8674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8675. }
  8676. m.SetDeletedAt(v)
  8677. return nil
  8678. case employee.FieldTitle:
  8679. v, ok := value.(string)
  8680. if !ok {
  8681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8682. }
  8683. m.SetTitle(v)
  8684. return nil
  8685. case employee.FieldAvatar:
  8686. v, ok := value.(string)
  8687. if !ok {
  8688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8689. }
  8690. m.SetAvatar(v)
  8691. return nil
  8692. case employee.FieldTags:
  8693. v, ok := value.(string)
  8694. if !ok {
  8695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8696. }
  8697. m.SetTags(v)
  8698. return nil
  8699. case employee.FieldHireCount:
  8700. v, ok := value.(int)
  8701. if !ok {
  8702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8703. }
  8704. m.SetHireCount(v)
  8705. return nil
  8706. case employee.FieldServiceCount:
  8707. v, ok := value.(int)
  8708. if !ok {
  8709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8710. }
  8711. m.SetServiceCount(v)
  8712. return nil
  8713. case employee.FieldAchievementCount:
  8714. v, ok := value.(int)
  8715. if !ok {
  8716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8717. }
  8718. m.SetAchievementCount(v)
  8719. return nil
  8720. case employee.FieldIntro:
  8721. v, ok := value.(string)
  8722. if !ok {
  8723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8724. }
  8725. m.SetIntro(v)
  8726. return nil
  8727. case employee.FieldEstimate:
  8728. v, ok := value.(string)
  8729. if !ok {
  8730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8731. }
  8732. m.SetEstimate(v)
  8733. return nil
  8734. case employee.FieldSkill:
  8735. v, ok := value.(string)
  8736. if !ok {
  8737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8738. }
  8739. m.SetSkill(v)
  8740. return nil
  8741. case employee.FieldAbilityType:
  8742. v, ok := value.(string)
  8743. if !ok {
  8744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8745. }
  8746. m.SetAbilityType(v)
  8747. return nil
  8748. case employee.FieldScene:
  8749. v, ok := value.(string)
  8750. if !ok {
  8751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8752. }
  8753. m.SetScene(v)
  8754. return nil
  8755. case employee.FieldSwitchIn:
  8756. v, ok := value.(string)
  8757. if !ok {
  8758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8759. }
  8760. m.SetSwitchIn(v)
  8761. return nil
  8762. case employee.FieldVideoURL:
  8763. v, ok := value.(string)
  8764. if !ok {
  8765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8766. }
  8767. m.SetVideoURL(v)
  8768. return nil
  8769. case employee.FieldOrganizationID:
  8770. v, ok := value.(uint64)
  8771. if !ok {
  8772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8773. }
  8774. m.SetOrganizationID(v)
  8775. return nil
  8776. case employee.FieldCategoryID:
  8777. v, ok := value.(uint64)
  8778. if !ok {
  8779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8780. }
  8781. m.SetCategoryID(v)
  8782. return nil
  8783. case employee.FieldAPIBase:
  8784. v, ok := value.(string)
  8785. if !ok {
  8786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8787. }
  8788. m.SetAPIBase(v)
  8789. return nil
  8790. case employee.FieldAPIKey:
  8791. v, ok := value.(string)
  8792. if !ok {
  8793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8794. }
  8795. m.SetAPIKey(v)
  8796. return nil
  8797. }
  8798. return fmt.Errorf("unknown Employee field %s", name)
  8799. }
  8800. // AddedFields returns all numeric fields that were incremented/decremented during
  8801. // this mutation.
  8802. func (m *EmployeeMutation) AddedFields() []string {
  8803. var fields []string
  8804. if m.addhire_count != nil {
  8805. fields = append(fields, employee.FieldHireCount)
  8806. }
  8807. if m.addservice_count != nil {
  8808. fields = append(fields, employee.FieldServiceCount)
  8809. }
  8810. if m.addachievement_count != nil {
  8811. fields = append(fields, employee.FieldAchievementCount)
  8812. }
  8813. if m.addorganization_id != nil {
  8814. fields = append(fields, employee.FieldOrganizationID)
  8815. }
  8816. if m.addcategory_id != nil {
  8817. fields = append(fields, employee.FieldCategoryID)
  8818. }
  8819. return fields
  8820. }
  8821. // AddedField returns the numeric value that was incremented/decremented on a field
  8822. // with the given name. The second boolean return value indicates that this field
  8823. // was not set, or was not defined in the schema.
  8824. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  8825. switch name {
  8826. case employee.FieldHireCount:
  8827. return m.AddedHireCount()
  8828. case employee.FieldServiceCount:
  8829. return m.AddedServiceCount()
  8830. case employee.FieldAchievementCount:
  8831. return m.AddedAchievementCount()
  8832. case employee.FieldOrganizationID:
  8833. return m.AddedOrganizationID()
  8834. case employee.FieldCategoryID:
  8835. return m.AddedCategoryID()
  8836. }
  8837. return nil, false
  8838. }
  8839. // AddField adds the value to the field with the given name. It returns an error if
  8840. // the field is not defined in the schema, or if the type mismatched the field
  8841. // type.
  8842. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  8843. switch name {
  8844. case employee.FieldHireCount:
  8845. v, ok := value.(int)
  8846. if !ok {
  8847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8848. }
  8849. m.AddHireCount(v)
  8850. return nil
  8851. case employee.FieldServiceCount:
  8852. v, ok := value.(int)
  8853. if !ok {
  8854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8855. }
  8856. m.AddServiceCount(v)
  8857. return nil
  8858. case employee.FieldAchievementCount:
  8859. v, ok := value.(int)
  8860. if !ok {
  8861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8862. }
  8863. m.AddAchievementCount(v)
  8864. return nil
  8865. case employee.FieldOrganizationID:
  8866. v, ok := value.(int64)
  8867. if !ok {
  8868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8869. }
  8870. m.AddOrganizationID(v)
  8871. return nil
  8872. case employee.FieldCategoryID:
  8873. v, ok := value.(int64)
  8874. if !ok {
  8875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8876. }
  8877. m.AddCategoryID(v)
  8878. return nil
  8879. }
  8880. return fmt.Errorf("unknown Employee numeric field %s", name)
  8881. }
  8882. // ClearedFields returns all nullable fields that were cleared during this
  8883. // mutation.
  8884. func (m *EmployeeMutation) ClearedFields() []string {
  8885. var fields []string
  8886. if m.FieldCleared(employee.FieldDeletedAt) {
  8887. fields = append(fields, employee.FieldDeletedAt)
  8888. }
  8889. return fields
  8890. }
  8891. // FieldCleared returns a boolean indicating if a field with the given name was
  8892. // cleared in this mutation.
  8893. func (m *EmployeeMutation) FieldCleared(name string) bool {
  8894. _, ok := m.clearedFields[name]
  8895. return ok
  8896. }
  8897. // ClearField clears the value of the field with the given name. It returns an
  8898. // error if the field is not defined in the schema.
  8899. func (m *EmployeeMutation) ClearField(name string) error {
  8900. switch name {
  8901. case employee.FieldDeletedAt:
  8902. m.ClearDeletedAt()
  8903. return nil
  8904. }
  8905. return fmt.Errorf("unknown Employee nullable field %s", name)
  8906. }
  8907. // ResetField resets all changes in the mutation for the field with the given name.
  8908. // It returns an error if the field is not defined in the schema.
  8909. func (m *EmployeeMutation) ResetField(name string) error {
  8910. switch name {
  8911. case employee.FieldCreatedAt:
  8912. m.ResetCreatedAt()
  8913. return nil
  8914. case employee.FieldUpdatedAt:
  8915. m.ResetUpdatedAt()
  8916. return nil
  8917. case employee.FieldDeletedAt:
  8918. m.ResetDeletedAt()
  8919. return nil
  8920. case employee.FieldTitle:
  8921. m.ResetTitle()
  8922. return nil
  8923. case employee.FieldAvatar:
  8924. m.ResetAvatar()
  8925. return nil
  8926. case employee.FieldTags:
  8927. m.ResetTags()
  8928. return nil
  8929. case employee.FieldHireCount:
  8930. m.ResetHireCount()
  8931. return nil
  8932. case employee.FieldServiceCount:
  8933. m.ResetServiceCount()
  8934. return nil
  8935. case employee.FieldAchievementCount:
  8936. m.ResetAchievementCount()
  8937. return nil
  8938. case employee.FieldIntro:
  8939. m.ResetIntro()
  8940. return nil
  8941. case employee.FieldEstimate:
  8942. m.ResetEstimate()
  8943. return nil
  8944. case employee.FieldSkill:
  8945. m.ResetSkill()
  8946. return nil
  8947. case employee.FieldAbilityType:
  8948. m.ResetAbilityType()
  8949. return nil
  8950. case employee.FieldScene:
  8951. m.ResetScene()
  8952. return nil
  8953. case employee.FieldSwitchIn:
  8954. m.ResetSwitchIn()
  8955. return nil
  8956. case employee.FieldVideoURL:
  8957. m.ResetVideoURL()
  8958. return nil
  8959. case employee.FieldOrganizationID:
  8960. m.ResetOrganizationID()
  8961. return nil
  8962. case employee.FieldCategoryID:
  8963. m.ResetCategoryID()
  8964. return nil
  8965. case employee.FieldAPIBase:
  8966. m.ResetAPIBase()
  8967. return nil
  8968. case employee.FieldAPIKey:
  8969. m.ResetAPIKey()
  8970. return nil
  8971. }
  8972. return fmt.Errorf("unknown Employee field %s", name)
  8973. }
  8974. // AddedEdges returns all edge names that were set/added in this mutation.
  8975. func (m *EmployeeMutation) AddedEdges() []string {
  8976. edges := make([]string, 0, 2)
  8977. if m.em_work_experiences != nil {
  8978. edges = append(edges, employee.EdgeEmWorkExperiences)
  8979. }
  8980. if m.em_tutorial != nil {
  8981. edges = append(edges, employee.EdgeEmTutorial)
  8982. }
  8983. return edges
  8984. }
  8985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8986. // name in this mutation.
  8987. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  8988. switch name {
  8989. case employee.EdgeEmWorkExperiences:
  8990. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  8991. for id := range m.em_work_experiences {
  8992. ids = append(ids, id)
  8993. }
  8994. return ids
  8995. case employee.EdgeEmTutorial:
  8996. ids := make([]ent.Value, 0, len(m.em_tutorial))
  8997. for id := range m.em_tutorial {
  8998. ids = append(ids, id)
  8999. }
  9000. return ids
  9001. }
  9002. return nil
  9003. }
  9004. // RemovedEdges returns all edge names that were removed in this mutation.
  9005. func (m *EmployeeMutation) RemovedEdges() []string {
  9006. edges := make([]string, 0, 2)
  9007. if m.removedem_work_experiences != nil {
  9008. edges = append(edges, employee.EdgeEmWorkExperiences)
  9009. }
  9010. if m.removedem_tutorial != nil {
  9011. edges = append(edges, employee.EdgeEmTutorial)
  9012. }
  9013. return edges
  9014. }
  9015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9016. // the given name in this mutation.
  9017. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  9018. switch name {
  9019. case employee.EdgeEmWorkExperiences:
  9020. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  9021. for id := range m.removedem_work_experiences {
  9022. ids = append(ids, id)
  9023. }
  9024. return ids
  9025. case employee.EdgeEmTutorial:
  9026. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  9027. for id := range m.removedem_tutorial {
  9028. ids = append(ids, id)
  9029. }
  9030. return ids
  9031. }
  9032. return nil
  9033. }
  9034. // ClearedEdges returns all edge names that were cleared in this mutation.
  9035. func (m *EmployeeMutation) ClearedEdges() []string {
  9036. edges := make([]string, 0, 2)
  9037. if m.clearedem_work_experiences {
  9038. edges = append(edges, employee.EdgeEmWorkExperiences)
  9039. }
  9040. if m.clearedem_tutorial {
  9041. edges = append(edges, employee.EdgeEmTutorial)
  9042. }
  9043. return edges
  9044. }
  9045. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9046. // was cleared in this mutation.
  9047. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  9048. switch name {
  9049. case employee.EdgeEmWorkExperiences:
  9050. return m.clearedem_work_experiences
  9051. case employee.EdgeEmTutorial:
  9052. return m.clearedem_tutorial
  9053. }
  9054. return false
  9055. }
  9056. // ClearEdge clears the value of the edge with the given name. It returns an error
  9057. // if that edge is not defined in the schema.
  9058. func (m *EmployeeMutation) ClearEdge(name string) error {
  9059. switch name {
  9060. }
  9061. return fmt.Errorf("unknown Employee unique edge %s", name)
  9062. }
  9063. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9064. // It returns an error if the edge is not defined in the schema.
  9065. func (m *EmployeeMutation) ResetEdge(name string) error {
  9066. switch name {
  9067. case employee.EdgeEmWorkExperiences:
  9068. m.ResetEmWorkExperiences()
  9069. return nil
  9070. case employee.EdgeEmTutorial:
  9071. m.ResetEmTutorial()
  9072. return nil
  9073. }
  9074. return fmt.Errorf("unknown Employee edge %s", name)
  9075. }
  9076. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  9077. type EmployeeConfigMutation struct {
  9078. config
  9079. op Op
  9080. typ string
  9081. id *uint64
  9082. created_at *time.Time
  9083. updated_at *time.Time
  9084. deleted_at *time.Time
  9085. stype *string
  9086. title *string
  9087. photo *string
  9088. organization_id *uint64
  9089. addorganization_id *int64
  9090. clearedFields map[string]struct{}
  9091. done bool
  9092. oldValue func(context.Context) (*EmployeeConfig, error)
  9093. predicates []predicate.EmployeeConfig
  9094. }
  9095. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  9096. // employeeconfigOption allows management of the mutation configuration using functional options.
  9097. type employeeconfigOption func(*EmployeeConfigMutation)
  9098. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  9099. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  9100. m := &EmployeeConfigMutation{
  9101. config: c,
  9102. op: op,
  9103. typ: TypeEmployeeConfig,
  9104. clearedFields: make(map[string]struct{}),
  9105. }
  9106. for _, opt := range opts {
  9107. opt(m)
  9108. }
  9109. return m
  9110. }
  9111. // withEmployeeConfigID sets the ID field of the mutation.
  9112. func withEmployeeConfigID(id uint64) employeeconfigOption {
  9113. return func(m *EmployeeConfigMutation) {
  9114. var (
  9115. err error
  9116. once sync.Once
  9117. value *EmployeeConfig
  9118. )
  9119. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  9120. once.Do(func() {
  9121. if m.done {
  9122. err = errors.New("querying old values post mutation is not allowed")
  9123. } else {
  9124. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  9125. }
  9126. })
  9127. return value, err
  9128. }
  9129. m.id = &id
  9130. }
  9131. }
  9132. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  9133. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  9134. return func(m *EmployeeConfigMutation) {
  9135. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  9136. return node, nil
  9137. }
  9138. m.id = &node.ID
  9139. }
  9140. }
  9141. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9142. // executed in a transaction (ent.Tx), a transactional client is returned.
  9143. func (m EmployeeConfigMutation) Client() *Client {
  9144. client := &Client{config: m.config}
  9145. client.init()
  9146. return client
  9147. }
  9148. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9149. // it returns an error otherwise.
  9150. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  9151. if _, ok := m.driver.(*txDriver); !ok {
  9152. return nil, errors.New("ent: mutation is not running in a transaction")
  9153. }
  9154. tx := &Tx{config: m.config}
  9155. tx.init()
  9156. return tx, nil
  9157. }
  9158. // SetID sets the value of the id field. Note that this
  9159. // operation is only accepted on creation of EmployeeConfig entities.
  9160. func (m *EmployeeConfigMutation) SetID(id uint64) {
  9161. m.id = &id
  9162. }
  9163. // ID returns the ID value in the mutation. Note that the ID is only available
  9164. // if it was provided to the builder or after it was returned from the database.
  9165. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  9166. if m.id == nil {
  9167. return
  9168. }
  9169. return *m.id, true
  9170. }
  9171. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9172. // That means, if the mutation is applied within a transaction with an isolation level such
  9173. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9174. // or updated by the mutation.
  9175. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  9176. switch {
  9177. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9178. id, exists := m.ID()
  9179. if exists {
  9180. return []uint64{id}, nil
  9181. }
  9182. fallthrough
  9183. case m.op.Is(OpUpdate | OpDelete):
  9184. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  9185. default:
  9186. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9187. }
  9188. }
  9189. // SetCreatedAt sets the "created_at" field.
  9190. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  9191. m.created_at = &t
  9192. }
  9193. // CreatedAt returns the value of the "created_at" field in the mutation.
  9194. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  9195. v := m.created_at
  9196. if v == nil {
  9197. return
  9198. }
  9199. return *v, true
  9200. }
  9201. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  9202. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9204. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9205. if !m.op.Is(OpUpdateOne) {
  9206. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9207. }
  9208. if m.id == nil || m.oldValue == nil {
  9209. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9210. }
  9211. oldValue, err := m.oldValue(ctx)
  9212. if err != nil {
  9213. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9214. }
  9215. return oldValue.CreatedAt, nil
  9216. }
  9217. // ResetCreatedAt resets all changes to the "created_at" field.
  9218. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  9219. m.created_at = nil
  9220. }
  9221. // SetUpdatedAt sets the "updated_at" field.
  9222. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  9223. m.updated_at = &t
  9224. }
  9225. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9226. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  9227. v := m.updated_at
  9228. if v == nil {
  9229. return
  9230. }
  9231. return *v, true
  9232. }
  9233. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  9234. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9236. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9237. if !m.op.Is(OpUpdateOne) {
  9238. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9239. }
  9240. if m.id == nil || m.oldValue == nil {
  9241. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9242. }
  9243. oldValue, err := m.oldValue(ctx)
  9244. if err != nil {
  9245. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9246. }
  9247. return oldValue.UpdatedAt, nil
  9248. }
  9249. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9250. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  9251. m.updated_at = nil
  9252. }
  9253. // SetDeletedAt sets the "deleted_at" field.
  9254. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  9255. m.deleted_at = &t
  9256. }
  9257. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9258. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  9259. v := m.deleted_at
  9260. if v == nil {
  9261. return
  9262. }
  9263. return *v, true
  9264. }
  9265. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  9266. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9268. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9269. if !m.op.Is(OpUpdateOne) {
  9270. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9271. }
  9272. if m.id == nil || m.oldValue == nil {
  9273. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9274. }
  9275. oldValue, err := m.oldValue(ctx)
  9276. if err != nil {
  9277. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9278. }
  9279. return oldValue.DeletedAt, nil
  9280. }
  9281. // ClearDeletedAt clears the value of the "deleted_at" field.
  9282. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  9283. m.deleted_at = nil
  9284. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  9285. }
  9286. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9287. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  9288. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  9289. return ok
  9290. }
  9291. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9292. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  9293. m.deleted_at = nil
  9294. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  9295. }
  9296. // SetStype sets the "stype" field.
  9297. func (m *EmployeeConfigMutation) SetStype(s string) {
  9298. m.stype = &s
  9299. }
  9300. // Stype returns the value of the "stype" field in the mutation.
  9301. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  9302. v := m.stype
  9303. if v == nil {
  9304. return
  9305. }
  9306. return *v, true
  9307. }
  9308. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  9309. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9311. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  9312. if !m.op.Is(OpUpdateOne) {
  9313. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  9314. }
  9315. if m.id == nil || m.oldValue == nil {
  9316. return v, errors.New("OldStype requires an ID field in the mutation")
  9317. }
  9318. oldValue, err := m.oldValue(ctx)
  9319. if err != nil {
  9320. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  9321. }
  9322. return oldValue.Stype, nil
  9323. }
  9324. // ResetStype resets all changes to the "stype" field.
  9325. func (m *EmployeeConfigMutation) ResetStype() {
  9326. m.stype = nil
  9327. }
  9328. // SetTitle sets the "title" field.
  9329. func (m *EmployeeConfigMutation) SetTitle(s string) {
  9330. m.title = &s
  9331. }
  9332. // Title returns the value of the "title" field in the mutation.
  9333. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  9334. v := m.title
  9335. if v == nil {
  9336. return
  9337. }
  9338. return *v, true
  9339. }
  9340. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  9341. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9343. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  9344. if !m.op.Is(OpUpdateOne) {
  9345. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9346. }
  9347. if m.id == nil || m.oldValue == nil {
  9348. return v, errors.New("OldTitle requires an ID field in the mutation")
  9349. }
  9350. oldValue, err := m.oldValue(ctx)
  9351. if err != nil {
  9352. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9353. }
  9354. return oldValue.Title, nil
  9355. }
  9356. // ResetTitle resets all changes to the "title" field.
  9357. func (m *EmployeeConfigMutation) ResetTitle() {
  9358. m.title = nil
  9359. }
  9360. // SetPhoto sets the "photo" field.
  9361. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  9362. m.photo = &s
  9363. }
  9364. // Photo returns the value of the "photo" field in the mutation.
  9365. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  9366. v := m.photo
  9367. if v == nil {
  9368. return
  9369. }
  9370. return *v, true
  9371. }
  9372. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  9373. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9375. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  9376. if !m.op.Is(OpUpdateOne) {
  9377. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  9378. }
  9379. if m.id == nil || m.oldValue == nil {
  9380. return v, errors.New("OldPhoto requires an ID field in the mutation")
  9381. }
  9382. oldValue, err := m.oldValue(ctx)
  9383. if err != nil {
  9384. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  9385. }
  9386. return oldValue.Photo, nil
  9387. }
  9388. // ResetPhoto resets all changes to the "photo" field.
  9389. func (m *EmployeeConfigMutation) ResetPhoto() {
  9390. m.photo = nil
  9391. }
  9392. // SetOrganizationID sets the "organization_id" field.
  9393. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  9394. m.organization_id = &u
  9395. m.addorganization_id = nil
  9396. }
  9397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9398. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  9399. v := m.organization_id
  9400. if v == nil {
  9401. return
  9402. }
  9403. return *v, true
  9404. }
  9405. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  9406. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  9407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9408. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9409. if !m.op.Is(OpUpdateOne) {
  9410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9411. }
  9412. if m.id == nil || m.oldValue == nil {
  9413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9414. }
  9415. oldValue, err := m.oldValue(ctx)
  9416. if err != nil {
  9417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9418. }
  9419. return oldValue.OrganizationID, nil
  9420. }
  9421. // AddOrganizationID adds u to the "organization_id" field.
  9422. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  9423. if m.addorganization_id != nil {
  9424. *m.addorganization_id += u
  9425. } else {
  9426. m.addorganization_id = &u
  9427. }
  9428. }
  9429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9430. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  9431. v := m.addorganization_id
  9432. if v == nil {
  9433. return
  9434. }
  9435. return *v, true
  9436. }
  9437. // ClearOrganizationID clears the value of the "organization_id" field.
  9438. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  9439. m.organization_id = nil
  9440. m.addorganization_id = nil
  9441. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  9442. }
  9443. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9444. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  9445. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  9446. return ok
  9447. }
  9448. // ResetOrganizationID resets all changes to the "organization_id" field.
  9449. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  9450. m.organization_id = nil
  9451. m.addorganization_id = nil
  9452. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  9453. }
  9454. // Where appends a list predicates to the EmployeeConfigMutation builder.
  9455. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  9456. m.predicates = append(m.predicates, ps...)
  9457. }
  9458. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  9459. // users can use type-assertion to append predicates that do not depend on any generated package.
  9460. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  9461. p := make([]predicate.EmployeeConfig, len(ps))
  9462. for i := range ps {
  9463. p[i] = ps[i]
  9464. }
  9465. m.Where(p...)
  9466. }
  9467. // Op returns the operation name.
  9468. func (m *EmployeeConfigMutation) Op() Op {
  9469. return m.op
  9470. }
  9471. // SetOp allows setting the mutation operation.
  9472. func (m *EmployeeConfigMutation) SetOp(op Op) {
  9473. m.op = op
  9474. }
  9475. // Type returns the node type of this mutation (EmployeeConfig).
  9476. func (m *EmployeeConfigMutation) Type() string {
  9477. return m.typ
  9478. }
  9479. // Fields returns all fields that were changed during this mutation. Note that in
  9480. // order to get all numeric fields that were incremented/decremented, call
  9481. // AddedFields().
  9482. func (m *EmployeeConfigMutation) Fields() []string {
  9483. fields := make([]string, 0, 7)
  9484. if m.created_at != nil {
  9485. fields = append(fields, employeeconfig.FieldCreatedAt)
  9486. }
  9487. if m.updated_at != nil {
  9488. fields = append(fields, employeeconfig.FieldUpdatedAt)
  9489. }
  9490. if m.deleted_at != nil {
  9491. fields = append(fields, employeeconfig.FieldDeletedAt)
  9492. }
  9493. if m.stype != nil {
  9494. fields = append(fields, employeeconfig.FieldStype)
  9495. }
  9496. if m.title != nil {
  9497. fields = append(fields, employeeconfig.FieldTitle)
  9498. }
  9499. if m.photo != nil {
  9500. fields = append(fields, employeeconfig.FieldPhoto)
  9501. }
  9502. if m.organization_id != nil {
  9503. fields = append(fields, employeeconfig.FieldOrganizationID)
  9504. }
  9505. return fields
  9506. }
  9507. // Field returns the value of a field with the given name. The second boolean
  9508. // return value indicates that this field was not set, or was not defined in the
  9509. // schema.
  9510. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  9511. switch name {
  9512. case employeeconfig.FieldCreatedAt:
  9513. return m.CreatedAt()
  9514. case employeeconfig.FieldUpdatedAt:
  9515. return m.UpdatedAt()
  9516. case employeeconfig.FieldDeletedAt:
  9517. return m.DeletedAt()
  9518. case employeeconfig.FieldStype:
  9519. return m.Stype()
  9520. case employeeconfig.FieldTitle:
  9521. return m.Title()
  9522. case employeeconfig.FieldPhoto:
  9523. return m.Photo()
  9524. case employeeconfig.FieldOrganizationID:
  9525. return m.OrganizationID()
  9526. }
  9527. return nil, false
  9528. }
  9529. // OldField returns the old value of the field from the database. An error is
  9530. // returned if the mutation operation is not UpdateOne, or the query to the
  9531. // database failed.
  9532. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9533. switch name {
  9534. case employeeconfig.FieldCreatedAt:
  9535. return m.OldCreatedAt(ctx)
  9536. case employeeconfig.FieldUpdatedAt:
  9537. return m.OldUpdatedAt(ctx)
  9538. case employeeconfig.FieldDeletedAt:
  9539. return m.OldDeletedAt(ctx)
  9540. case employeeconfig.FieldStype:
  9541. return m.OldStype(ctx)
  9542. case employeeconfig.FieldTitle:
  9543. return m.OldTitle(ctx)
  9544. case employeeconfig.FieldPhoto:
  9545. return m.OldPhoto(ctx)
  9546. case employeeconfig.FieldOrganizationID:
  9547. return m.OldOrganizationID(ctx)
  9548. }
  9549. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  9550. }
  9551. // SetField sets the value of a field with the given name. It returns an error if
  9552. // the field is not defined in the schema, or if the type mismatched the field
  9553. // type.
  9554. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  9555. switch name {
  9556. case employeeconfig.FieldCreatedAt:
  9557. v, ok := value.(time.Time)
  9558. if !ok {
  9559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9560. }
  9561. m.SetCreatedAt(v)
  9562. return nil
  9563. case employeeconfig.FieldUpdatedAt:
  9564. v, ok := value.(time.Time)
  9565. if !ok {
  9566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9567. }
  9568. m.SetUpdatedAt(v)
  9569. return nil
  9570. case employeeconfig.FieldDeletedAt:
  9571. v, ok := value.(time.Time)
  9572. if !ok {
  9573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9574. }
  9575. m.SetDeletedAt(v)
  9576. return nil
  9577. case employeeconfig.FieldStype:
  9578. v, ok := value.(string)
  9579. if !ok {
  9580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9581. }
  9582. m.SetStype(v)
  9583. return nil
  9584. case employeeconfig.FieldTitle:
  9585. v, ok := value.(string)
  9586. if !ok {
  9587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9588. }
  9589. m.SetTitle(v)
  9590. return nil
  9591. case employeeconfig.FieldPhoto:
  9592. v, ok := value.(string)
  9593. if !ok {
  9594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9595. }
  9596. m.SetPhoto(v)
  9597. return nil
  9598. case employeeconfig.FieldOrganizationID:
  9599. v, ok := value.(uint64)
  9600. if !ok {
  9601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9602. }
  9603. m.SetOrganizationID(v)
  9604. return nil
  9605. }
  9606. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9607. }
  9608. // AddedFields returns all numeric fields that were incremented/decremented during
  9609. // this mutation.
  9610. func (m *EmployeeConfigMutation) AddedFields() []string {
  9611. var fields []string
  9612. if m.addorganization_id != nil {
  9613. fields = append(fields, employeeconfig.FieldOrganizationID)
  9614. }
  9615. return fields
  9616. }
  9617. // AddedField returns the numeric value that was incremented/decremented on a field
  9618. // with the given name. The second boolean return value indicates that this field
  9619. // was not set, or was not defined in the schema.
  9620. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  9621. switch name {
  9622. case employeeconfig.FieldOrganizationID:
  9623. return m.AddedOrganizationID()
  9624. }
  9625. return nil, false
  9626. }
  9627. // AddField adds the value to the field with the given name. It returns an error if
  9628. // the field is not defined in the schema, or if the type mismatched the field
  9629. // type.
  9630. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  9631. switch name {
  9632. case employeeconfig.FieldOrganizationID:
  9633. v, ok := value.(int64)
  9634. if !ok {
  9635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9636. }
  9637. m.AddOrganizationID(v)
  9638. return nil
  9639. }
  9640. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  9641. }
  9642. // ClearedFields returns all nullable fields that were cleared during this
  9643. // mutation.
  9644. func (m *EmployeeConfigMutation) ClearedFields() []string {
  9645. var fields []string
  9646. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  9647. fields = append(fields, employeeconfig.FieldDeletedAt)
  9648. }
  9649. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  9650. fields = append(fields, employeeconfig.FieldOrganizationID)
  9651. }
  9652. return fields
  9653. }
  9654. // FieldCleared returns a boolean indicating if a field with the given name was
  9655. // cleared in this mutation.
  9656. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  9657. _, ok := m.clearedFields[name]
  9658. return ok
  9659. }
  9660. // ClearField clears the value of the field with the given name. It returns an
  9661. // error if the field is not defined in the schema.
  9662. func (m *EmployeeConfigMutation) ClearField(name string) error {
  9663. switch name {
  9664. case employeeconfig.FieldDeletedAt:
  9665. m.ClearDeletedAt()
  9666. return nil
  9667. case employeeconfig.FieldOrganizationID:
  9668. m.ClearOrganizationID()
  9669. return nil
  9670. }
  9671. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  9672. }
  9673. // ResetField resets all changes in the mutation for the field with the given name.
  9674. // It returns an error if the field is not defined in the schema.
  9675. func (m *EmployeeConfigMutation) ResetField(name string) error {
  9676. switch name {
  9677. case employeeconfig.FieldCreatedAt:
  9678. m.ResetCreatedAt()
  9679. return nil
  9680. case employeeconfig.FieldUpdatedAt:
  9681. m.ResetUpdatedAt()
  9682. return nil
  9683. case employeeconfig.FieldDeletedAt:
  9684. m.ResetDeletedAt()
  9685. return nil
  9686. case employeeconfig.FieldStype:
  9687. m.ResetStype()
  9688. return nil
  9689. case employeeconfig.FieldTitle:
  9690. m.ResetTitle()
  9691. return nil
  9692. case employeeconfig.FieldPhoto:
  9693. m.ResetPhoto()
  9694. return nil
  9695. case employeeconfig.FieldOrganizationID:
  9696. m.ResetOrganizationID()
  9697. return nil
  9698. }
  9699. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  9700. }
  9701. // AddedEdges returns all edge names that were set/added in this mutation.
  9702. func (m *EmployeeConfigMutation) AddedEdges() []string {
  9703. edges := make([]string, 0, 0)
  9704. return edges
  9705. }
  9706. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9707. // name in this mutation.
  9708. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  9709. return nil
  9710. }
  9711. // RemovedEdges returns all edge names that were removed in this mutation.
  9712. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  9713. edges := make([]string, 0, 0)
  9714. return edges
  9715. }
  9716. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9717. // the given name in this mutation.
  9718. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  9719. return nil
  9720. }
  9721. // ClearedEdges returns all edge names that were cleared in this mutation.
  9722. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  9723. edges := make([]string, 0, 0)
  9724. return edges
  9725. }
  9726. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9727. // was cleared in this mutation.
  9728. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  9729. return false
  9730. }
  9731. // ClearEdge clears the value of the edge with the given name. It returns an error
  9732. // if that edge is not defined in the schema.
  9733. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  9734. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  9735. }
  9736. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9737. // It returns an error if the edge is not defined in the schema.
  9738. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  9739. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  9740. }
  9741. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  9742. type LabelMutation struct {
  9743. config
  9744. op Op
  9745. typ string
  9746. id *uint64
  9747. created_at *time.Time
  9748. updated_at *time.Time
  9749. status *uint8
  9750. addstatus *int8
  9751. _type *int
  9752. add_type *int
  9753. name *string
  9754. from *int
  9755. addfrom *int
  9756. mode *int
  9757. addmode *int
  9758. conditions *string
  9759. organization_id *uint64
  9760. addorganization_id *int64
  9761. clearedFields map[string]struct{}
  9762. label_relationships map[uint64]struct{}
  9763. removedlabel_relationships map[uint64]struct{}
  9764. clearedlabel_relationships bool
  9765. done bool
  9766. oldValue func(context.Context) (*Label, error)
  9767. predicates []predicate.Label
  9768. }
  9769. var _ ent.Mutation = (*LabelMutation)(nil)
  9770. // labelOption allows management of the mutation configuration using functional options.
  9771. type labelOption func(*LabelMutation)
  9772. // newLabelMutation creates new mutation for the Label entity.
  9773. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  9774. m := &LabelMutation{
  9775. config: c,
  9776. op: op,
  9777. typ: TypeLabel,
  9778. clearedFields: make(map[string]struct{}),
  9779. }
  9780. for _, opt := range opts {
  9781. opt(m)
  9782. }
  9783. return m
  9784. }
  9785. // withLabelID sets the ID field of the mutation.
  9786. func withLabelID(id uint64) labelOption {
  9787. return func(m *LabelMutation) {
  9788. var (
  9789. err error
  9790. once sync.Once
  9791. value *Label
  9792. )
  9793. m.oldValue = func(ctx context.Context) (*Label, error) {
  9794. once.Do(func() {
  9795. if m.done {
  9796. err = errors.New("querying old values post mutation is not allowed")
  9797. } else {
  9798. value, err = m.Client().Label.Get(ctx, id)
  9799. }
  9800. })
  9801. return value, err
  9802. }
  9803. m.id = &id
  9804. }
  9805. }
  9806. // withLabel sets the old Label of the mutation.
  9807. func withLabel(node *Label) labelOption {
  9808. return func(m *LabelMutation) {
  9809. m.oldValue = func(context.Context) (*Label, error) {
  9810. return node, nil
  9811. }
  9812. m.id = &node.ID
  9813. }
  9814. }
  9815. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9816. // executed in a transaction (ent.Tx), a transactional client is returned.
  9817. func (m LabelMutation) Client() *Client {
  9818. client := &Client{config: m.config}
  9819. client.init()
  9820. return client
  9821. }
  9822. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9823. // it returns an error otherwise.
  9824. func (m LabelMutation) Tx() (*Tx, error) {
  9825. if _, ok := m.driver.(*txDriver); !ok {
  9826. return nil, errors.New("ent: mutation is not running in a transaction")
  9827. }
  9828. tx := &Tx{config: m.config}
  9829. tx.init()
  9830. return tx, nil
  9831. }
  9832. // SetID sets the value of the id field. Note that this
  9833. // operation is only accepted on creation of Label entities.
  9834. func (m *LabelMutation) SetID(id uint64) {
  9835. m.id = &id
  9836. }
  9837. // ID returns the ID value in the mutation. Note that the ID is only available
  9838. // if it was provided to the builder or after it was returned from the database.
  9839. func (m *LabelMutation) ID() (id uint64, exists bool) {
  9840. if m.id == nil {
  9841. return
  9842. }
  9843. return *m.id, true
  9844. }
  9845. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9846. // That means, if the mutation is applied within a transaction with an isolation level such
  9847. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9848. // or updated by the mutation.
  9849. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  9850. switch {
  9851. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9852. id, exists := m.ID()
  9853. if exists {
  9854. return []uint64{id}, nil
  9855. }
  9856. fallthrough
  9857. case m.op.Is(OpUpdate | OpDelete):
  9858. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  9859. default:
  9860. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9861. }
  9862. }
  9863. // SetCreatedAt sets the "created_at" field.
  9864. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  9865. m.created_at = &t
  9866. }
  9867. // CreatedAt returns the value of the "created_at" field in the mutation.
  9868. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  9869. v := m.created_at
  9870. if v == nil {
  9871. return
  9872. }
  9873. return *v, true
  9874. }
  9875. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  9876. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  9877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9878. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9879. if !m.op.Is(OpUpdateOne) {
  9880. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9881. }
  9882. if m.id == nil || m.oldValue == nil {
  9883. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9884. }
  9885. oldValue, err := m.oldValue(ctx)
  9886. if err != nil {
  9887. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9888. }
  9889. return oldValue.CreatedAt, nil
  9890. }
  9891. // ResetCreatedAt resets all changes to the "created_at" field.
  9892. func (m *LabelMutation) ResetCreatedAt() {
  9893. m.created_at = nil
  9894. }
  9895. // SetUpdatedAt sets the "updated_at" field.
  9896. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  9897. m.updated_at = &t
  9898. }
  9899. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9900. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  9901. v := m.updated_at
  9902. if v == nil {
  9903. return
  9904. }
  9905. return *v, true
  9906. }
  9907. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  9908. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  9909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9910. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9911. if !m.op.Is(OpUpdateOne) {
  9912. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9913. }
  9914. if m.id == nil || m.oldValue == nil {
  9915. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9916. }
  9917. oldValue, err := m.oldValue(ctx)
  9918. if err != nil {
  9919. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9920. }
  9921. return oldValue.UpdatedAt, nil
  9922. }
  9923. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9924. func (m *LabelMutation) ResetUpdatedAt() {
  9925. m.updated_at = nil
  9926. }
  9927. // SetStatus sets the "status" field.
  9928. func (m *LabelMutation) SetStatus(u uint8) {
  9929. m.status = &u
  9930. m.addstatus = nil
  9931. }
  9932. // Status returns the value of the "status" field in the mutation.
  9933. func (m *LabelMutation) Status() (r uint8, exists bool) {
  9934. v := m.status
  9935. if v == nil {
  9936. return
  9937. }
  9938. return *v, true
  9939. }
  9940. // OldStatus returns the old "status" field's value of the Label entity.
  9941. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  9942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9943. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9944. if !m.op.Is(OpUpdateOne) {
  9945. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9946. }
  9947. if m.id == nil || m.oldValue == nil {
  9948. return v, errors.New("OldStatus requires an ID field in the mutation")
  9949. }
  9950. oldValue, err := m.oldValue(ctx)
  9951. if err != nil {
  9952. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9953. }
  9954. return oldValue.Status, nil
  9955. }
  9956. // AddStatus adds u to the "status" field.
  9957. func (m *LabelMutation) AddStatus(u int8) {
  9958. if m.addstatus != nil {
  9959. *m.addstatus += u
  9960. } else {
  9961. m.addstatus = &u
  9962. }
  9963. }
  9964. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9965. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  9966. v := m.addstatus
  9967. if v == nil {
  9968. return
  9969. }
  9970. return *v, true
  9971. }
  9972. // ClearStatus clears the value of the "status" field.
  9973. func (m *LabelMutation) ClearStatus() {
  9974. m.status = nil
  9975. m.addstatus = nil
  9976. m.clearedFields[label.FieldStatus] = struct{}{}
  9977. }
  9978. // StatusCleared returns if the "status" field was cleared in this mutation.
  9979. func (m *LabelMutation) StatusCleared() bool {
  9980. _, ok := m.clearedFields[label.FieldStatus]
  9981. return ok
  9982. }
  9983. // ResetStatus resets all changes to the "status" field.
  9984. func (m *LabelMutation) ResetStatus() {
  9985. m.status = nil
  9986. m.addstatus = nil
  9987. delete(m.clearedFields, label.FieldStatus)
  9988. }
  9989. // SetType sets the "type" field.
  9990. func (m *LabelMutation) SetType(i int) {
  9991. m._type = &i
  9992. m.add_type = nil
  9993. }
  9994. // GetType returns the value of the "type" field in the mutation.
  9995. func (m *LabelMutation) GetType() (r int, exists bool) {
  9996. v := m._type
  9997. if v == nil {
  9998. return
  9999. }
  10000. return *v, true
  10001. }
  10002. // OldType returns the old "type" field's value of the Label entity.
  10003. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10005. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  10006. if !m.op.Is(OpUpdateOne) {
  10007. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10008. }
  10009. if m.id == nil || m.oldValue == nil {
  10010. return v, errors.New("OldType requires an ID field in the mutation")
  10011. }
  10012. oldValue, err := m.oldValue(ctx)
  10013. if err != nil {
  10014. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10015. }
  10016. return oldValue.Type, nil
  10017. }
  10018. // AddType adds i to the "type" field.
  10019. func (m *LabelMutation) AddType(i int) {
  10020. if m.add_type != nil {
  10021. *m.add_type += i
  10022. } else {
  10023. m.add_type = &i
  10024. }
  10025. }
  10026. // AddedType returns the value that was added to the "type" field in this mutation.
  10027. func (m *LabelMutation) AddedType() (r int, exists bool) {
  10028. v := m.add_type
  10029. if v == nil {
  10030. return
  10031. }
  10032. return *v, true
  10033. }
  10034. // ResetType resets all changes to the "type" field.
  10035. func (m *LabelMutation) ResetType() {
  10036. m._type = nil
  10037. m.add_type = nil
  10038. }
  10039. // SetName sets the "name" field.
  10040. func (m *LabelMutation) SetName(s string) {
  10041. m.name = &s
  10042. }
  10043. // Name returns the value of the "name" field in the mutation.
  10044. func (m *LabelMutation) Name() (r string, exists bool) {
  10045. v := m.name
  10046. if v == nil {
  10047. return
  10048. }
  10049. return *v, true
  10050. }
  10051. // OldName returns the old "name" field's value of the Label entity.
  10052. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10054. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  10055. if !m.op.Is(OpUpdateOne) {
  10056. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10057. }
  10058. if m.id == nil || m.oldValue == nil {
  10059. return v, errors.New("OldName requires an ID field in the mutation")
  10060. }
  10061. oldValue, err := m.oldValue(ctx)
  10062. if err != nil {
  10063. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10064. }
  10065. return oldValue.Name, nil
  10066. }
  10067. // ResetName resets all changes to the "name" field.
  10068. func (m *LabelMutation) ResetName() {
  10069. m.name = nil
  10070. }
  10071. // SetFrom sets the "from" field.
  10072. func (m *LabelMutation) SetFrom(i int) {
  10073. m.from = &i
  10074. m.addfrom = nil
  10075. }
  10076. // From returns the value of the "from" field in the mutation.
  10077. func (m *LabelMutation) From() (r int, exists bool) {
  10078. v := m.from
  10079. if v == nil {
  10080. return
  10081. }
  10082. return *v, true
  10083. }
  10084. // OldFrom returns the old "from" field's value of the Label entity.
  10085. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10087. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  10088. if !m.op.Is(OpUpdateOne) {
  10089. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  10090. }
  10091. if m.id == nil || m.oldValue == nil {
  10092. return v, errors.New("OldFrom requires an ID field in the mutation")
  10093. }
  10094. oldValue, err := m.oldValue(ctx)
  10095. if err != nil {
  10096. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  10097. }
  10098. return oldValue.From, nil
  10099. }
  10100. // AddFrom adds i to the "from" field.
  10101. func (m *LabelMutation) AddFrom(i int) {
  10102. if m.addfrom != nil {
  10103. *m.addfrom += i
  10104. } else {
  10105. m.addfrom = &i
  10106. }
  10107. }
  10108. // AddedFrom returns the value that was added to the "from" field in this mutation.
  10109. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  10110. v := m.addfrom
  10111. if v == nil {
  10112. return
  10113. }
  10114. return *v, true
  10115. }
  10116. // ResetFrom resets all changes to the "from" field.
  10117. func (m *LabelMutation) ResetFrom() {
  10118. m.from = nil
  10119. m.addfrom = nil
  10120. }
  10121. // SetMode sets the "mode" field.
  10122. func (m *LabelMutation) SetMode(i int) {
  10123. m.mode = &i
  10124. m.addmode = nil
  10125. }
  10126. // Mode returns the value of the "mode" field in the mutation.
  10127. func (m *LabelMutation) Mode() (r int, exists bool) {
  10128. v := m.mode
  10129. if v == nil {
  10130. return
  10131. }
  10132. return *v, true
  10133. }
  10134. // OldMode returns the old "mode" field's value of the Label entity.
  10135. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10137. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  10138. if !m.op.Is(OpUpdateOne) {
  10139. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  10140. }
  10141. if m.id == nil || m.oldValue == nil {
  10142. return v, errors.New("OldMode requires an ID field in the mutation")
  10143. }
  10144. oldValue, err := m.oldValue(ctx)
  10145. if err != nil {
  10146. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  10147. }
  10148. return oldValue.Mode, nil
  10149. }
  10150. // AddMode adds i to the "mode" field.
  10151. func (m *LabelMutation) AddMode(i int) {
  10152. if m.addmode != nil {
  10153. *m.addmode += i
  10154. } else {
  10155. m.addmode = &i
  10156. }
  10157. }
  10158. // AddedMode returns the value that was added to the "mode" field in this mutation.
  10159. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  10160. v := m.addmode
  10161. if v == nil {
  10162. return
  10163. }
  10164. return *v, true
  10165. }
  10166. // ResetMode resets all changes to the "mode" field.
  10167. func (m *LabelMutation) ResetMode() {
  10168. m.mode = nil
  10169. m.addmode = nil
  10170. }
  10171. // SetConditions sets the "conditions" field.
  10172. func (m *LabelMutation) SetConditions(s string) {
  10173. m.conditions = &s
  10174. }
  10175. // Conditions returns the value of the "conditions" field in the mutation.
  10176. func (m *LabelMutation) Conditions() (r string, exists bool) {
  10177. v := m.conditions
  10178. if v == nil {
  10179. return
  10180. }
  10181. return *v, true
  10182. }
  10183. // OldConditions returns the old "conditions" field's value of the Label entity.
  10184. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10186. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  10187. if !m.op.Is(OpUpdateOne) {
  10188. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  10189. }
  10190. if m.id == nil || m.oldValue == nil {
  10191. return v, errors.New("OldConditions requires an ID field in the mutation")
  10192. }
  10193. oldValue, err := m.oldValue(ctx)
  10194. if err != nil {
  10195. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  10196. }
  10197. return oldValue.Conditions, nil
  10198. }
  10199. // ClearConditions clears the value of the "conditions" field.
  10200. func (m *LabelMutation) ClearConditions() {
  10201. m.conditions = nil
  10202. m.clearedFields[label.FieldConditions] = struct{}{}
  10203. }
  10204. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  10205. func (m *LabelMutation) ConditionsCleared() bool {
  10206. _, ok := m.clearedFields[label.FieldConditions]
  10207. return ok
  10208. }
  10209. // ResetConditions resets all changes to the "conditions" field.
  10210. func (m *LabelMutation) ResetConditions() {
  10211. m.conditions = nil
  10212. delete(m.clearedFields, label.FieldConditions)
  10213. }
  10214. // SetOrganizationID sets the "organization_id" field.
  10215. func (m *LabelMutation) SetOrganizationID(u uint64) {
  10216. m.organization_id = &u
  10217. m.addorganization_id = nil
  10218. }
  10219. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10220. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  10221. v := m.organization_id
  10222. if v == nil {
  10223. return
  10224. }
  10225. return *v, true
  10226. }
  10227. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  10228. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10230. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10231. if !m.op.Is(OpUpdateOne) {
  10232. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10233. }
  10234. if m.id == nil || m.oldValue == nil {
  10235. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10236. }
  10237. oldValue, err := m.oldValue(ctx)
  10238. if err != nil {
  10239. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10240. }
  10241. return oldValue.OrganizationID, nil
  10242. }
  10243. // AddOrganizationID adds u to the "organization_id" field.
  10244. func (m *LabelMutation) AddOrganizationID(u int64) {
  10245. if m.addorganization_id != nil {
  10246. *m.addorganization_id += u
  10247. } else {
  10248. m.addorganization_id = &u
  10249. }
  10250. }
  10251. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10252. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  10253. v := m.addorganization_id
  10254. if v == nil {
  10255. return
  10256. }
  10257. return *v, true
  10258. }
  10259. // ClearOrganizationID clears the value of the "organization_id" field.
  10260. func (m *LabelMutation) ClearOrganizationID() {
  10261. m.organization_id = nil
  10262. m.addorganization_id = nil
  10263. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  10264. }
  10265. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10266. func (m *LabelMutation) OrganizationIDCleared() bool {
  10267. _, ok := m.clearedFields[label.FieldOrganizationID]
  10268. return ok
  10269. }
  10270. // ResetOrganizationID resets all changes to the "organization_id" field.
  10271. func (m *LabelMutation) ResetOrganizationID() {
  10272. m.organization_id = nil
  10273. m.addorganization_id = nil
  10274. delete(m.clearedFields, label.FieldOrganizationID)
  10275. }
  10276. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  10277. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  10278. if m.label_relationships == nil {
  10279. m.label_relationships = make(map[uint64]struct{})
  10280. }
  10281. for i := range ids {
  10282. m.label_relationships[ids[i]] = struct{}{}
  10283. }
  10284. }
  10285. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  10286. func (m *LabelMutation) ClearLabelRelationships() {
  10287. m.clearedlabel_relationships = true
  10288. }
  10289. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  10290. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  10291. return m.clearedlabel_relationships
  10292. }
  10293. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  10294. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  10295. if m.removedlabel_relationships == nil {
  10296. m.removedlabel_relationships = make(map[uint64]struct{})
  10297. }
  10298. for i := range ids {
  10299. delete(m.label_relationships, ids[i])
  10300. m.removedlabel_relationships[ids[i]] = struct{}{}
  10301. }
  10302. }
  10303. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  10304. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  10305. for id := range m.removedlabel_relationships {
  10306. ids = append(ids, id)
  10307. }
  10308. return
  10309. }
  10310. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  10311. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  10312. for id := range m.label_relationships {
  10313. ids = append(ids, id)
  10314. }
  10315. return
  10316. }
  10317. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  10318. func (m *LabelMutation) ResetLabelRelationships() {
  10319. m.label_relationships = nil
  10320. m.clearedlabel_relationships = false
  10321. m.removedlabel_relationships = nil
  10322. }
  10323. // Where appends a list predicates to the LabelMutation builder.
  10324. func (m *LabelMutation) Where(ps ...predicate.Label) {
  10325. m.predicates = append(m.predicates, ps...)
  10326. }
  10327. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  10328. // users can use type-assertion to append predicates that do not depend on any generated package.
  10329. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  10330. p := make([]predicate.Label, len(ps))
  10331. for i := range ps {
  10332. p[i] = ps[i]
  10333. }
  10334. m.Where(p...)
  10335. }
  10336. // Op returns the operation name.
  10337. func (m *LabelMutation) Op() Op {
  10338. return m.op
  10339. }
  10340. // SetOp allows setting the mutation operation.
  10341. func (m *LabelMutation) SetOp(op Op) {
  10342. m.op = op
  10343. }
  10344. // Type returns the node type of this mutation (Label).
  10345. func (m *LabelMutation) Type() string {
  10346. return m.typ
  10347. }
  10348. // Fields returns all fields that were changed during this mutation. Note that in
  10349. // order to get all numeric fields that were incremented/decremented, call
  10350. // AddedFields().
  10351. func (m *LabelMutation) Fields() []string {
  10352. fields := make([]string, 0, 9)
  10353. if m.created_at != nil {
  10354. fields = append(fields, label.FieldCreatedAt)
  10355. }
  10356. if m.updated_at != nil {
  10357. fields = append(fields, label.FieldUpdatedAt)
  10358. }
  10359. if m.status != nil {
  10360. fields = append(fields, label.FieldStatus)
  10361. }
  10362. if m._type != nil {
  10363. fields = append(fields, label.FieldType)
  10364. }
  10365. if m.name != nil {
  10366. fields = append(fields, label.FieldName)
  10367. }
  10368. if m.from != nil {
  10369. fields = append(fields, label.FieldFrom)
  10370. }
  10371. if m.mode != nil {
  10372. fields = append(fields, label.FieldMode)
  10373. }
  10374. if m.conditions != nil {
  10375. fields = append(fields, label.FieldConditions)
  10376. }
  10377. if m.organization_id != nil {
  10378. fields = append(fields, label.FieldOrganizationID)
  10379. }
  10380. return fields
  10381. }
  10382. // Field returns the value of a field with the given name. The second boolean
  10383. // return value indicates that this field was not set, or was not defined in the
  10384. // schema.
  10385. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  10386. switch name {
  10387. case label.FieldCreatedAt:
  10388. return m.CreatedAt()
  10389. case label.FieldUpdatedAt:
  10390. return m.UpdatedAt()
  10391. case label.FieldStatus:
  10392. return m.Status()
  10393. case label.FieldType:
  10394. return m.GetType()
  10395. case label.FieldName:
  10396. return m.Name()
  10397. case label.FieldFrom:
  10398. return m.From()
  10399. case label.FieldMode:
  10400. return m.Mode()
  10401. case label.FieldConditions:
  10402. return m.Conditions()
  10403. case label.FieldOrganizationID:
  10404. return m.OrganizationID()
  10405. }
  10406. return nil, false
  10407. }
  10408. // OldField returns the old value of the field from the database. An error is
  10409. // returned if the mutation operation is not UpdateOne, or the query to the
  10410. // database failed.
  10411. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10412. switch name {
  10413. case label.FieldCreatedAt:
  10414. return m.OldCreatedAt(ctx)
  10415. case label.FieldUpdatedAt:
  10416. return m.OldUpdatedAt(ctx)
  10417. case label.FieldStatus:
  10418. return m.OldStatus(ctx)
  10419. case label.FieldType:
  10420. return m.OldType(ctx)
  10421. case label.FieldName:
  10422. return m.OldName(ctx)
  10423. case label.FieldFrom:
  10424. return m.OldFrom(ctx)
  10425. case label.FieldMode:
  10426. return m.OldMode(ctx)
  10427. case label.FieldConditions:
  10428. return m.OldConditions(ctx)
  10429. case label.FieldOrganizationID:
  10430. return m.OldOrganizationID(ctx)
  10431. }
  10432. return nil, fmt.Errorf("unknown Label field %s", name)
  10433. }
  10434. // SetField sets the value of a field with the given name. It returns an error if
  10435. // the field is not defined in the schema, or if the type mismatched the field
  10436. // type.
  10437. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  10438. switch name {
  10439. case label.FieldCreatedAt:
  10440. v, ok := value.(time.Time)
  10441. if !ok {
  10442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10443. }
  10444. m.SetCreatedAt(v)
  10445. return nil
  10446. case label.FieldUpdatedAt:
  10447. v, ok := value.(time.Time)
  10448. if !ok {
  10449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10450. }
  10451. m.SetUpdatedAt(v)
  10452. return nil
  10453. case label.FieldStatus:
  10454. v, ok := value.(uint8)
  10455. if !ok {
  10456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10457. }
  10458. m.SetStatus(v)
  10459. return nil
  10460. case label.FieldType:
  10461. v, ok := value.(int)
  10462. if !ok {
  10463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10464. }
  10465. m.SetType(v)
  10466. return nil
  10467. case label.FieldName:
  10468. v, ok := value.(string)
  10469. if !ok {
  10470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10471. }
  10472. m.SetName(v)
  10473. return nil
  10474. case label.FieldFrom:
  10475. v, ok := value.(int)
  10476. if !ok {
  10477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10478. }
  10479. m.SetFrom(v)
  10480. return nil
  10481. case label.FieldMode:
  10482. v, ok := value.(int)
  10483. if !ok {
  10484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10485. }
  10486. m.SetMode(v)
  10487. return nil
  10488. case label.FieldConditions:
  10489. v, ok := value.(string)
  10490. if !ok {
  10491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10492. }
  10493. m.SetConditions(v)
  10494. return nil
  10495. case label.FieldOrganizationID:
  10496. v, ok := value.(uint64)
  10497. if !ok {
  10498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10499. }
  10500. m.SetOrganizationID(v)
  10501. return nil
  10502. }
  10503. return fmt.Errorf("unknown Label field %s", name)
  10504. }
  10505. // AddedFields returns all numeric fields that were incremented/decremented during
  10506. // this mutation.
  10507. func (m *LabelMutation) AddedFields() []string {
  10508. var fields []string
  10509. if m.addstatus != nil {
  10510. fields = append(fields, label.FieldStatus)
  10511. }
  10512. if m.add_type != nil {
  10513. fields = append(fields, label.FieldType)
  10514. }
  10515. if m.addfrom != nil {
  10516. fields = append(fields, label.FieldFrom)
  10517. }
  10518. if m.addmode != nil {
  10519. fields = append(fields, label.FieldMode)
  10520. }
  10521. if m.addorganization_id != nil {
  10522. fields = append(fields, label.FieldOrganizationID)
  10523. }
  10524. return fields
  10525. }
  10526. // AddedField returns the numeric value that was incremented/decremented on a field
  10527. // with the given name. The second boolean return value indicates that this field
  10528. // was not set, or was not defined in the schema.
  10529. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  10530. switch name {
  10531. case label.FieldStatus:
  10532. return m.AddedStatus()
  10533. case label.FieldType:
  10534. return m.AddedType()
  10535. case label.FieldFrom:
  10536. return m.AddedFrom()
  10537. case label.FieldMode:
  10538. return m.AddedMode()
  10539. case label.FieldOrganizationID:
  10540. return m.AddedOrganizationID()
  10541. }
  10542. return nil, false
  10543. }
  10544. // AddField adds the value to the field with the given name. It returns an error if
  10545. // the field is not defined in the schema, or if the type mismatched the field
  10546. // type.
  10547. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  10548. switch name {
  10549. case label.FieldStatus:
  10550. v, ok := value.(int8)
  10551. if !ok {
  10552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10553. }
  10554. m.AddStatus(v)
  10555. return nil
  10556. case label.FieldType:
  10557. v, ok := value.(int)
  10558. if !ok {
  10559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10560. }
  10561. m.AddType(v)
  10562. return nil
  10563. case label.FieldFrom:
  10564. v, ok := value.(int)
  10565. if !ok {
  10566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10567. }
  10568. m.AddFrom(v)
  10569. return nil
  10570. case label.FieldMode:
  10571. v, ok := value.(int)
  10572. if !ok {
  10573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10574. }
  10575. m.AddMode(v)
  10576. return nil
  10577. case label.FieldOrganizationID:
  10578. v, ok := value.(int64)
  10579. if !ok {
  10580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10581. }
  10582. m.AddOrganizationID(v)
  10583. return nil
  10584. }
  10585. return fmt.Errorf("unknown Label numeric field %s", name)
  10586. }
  10587. // ClearedFields returns all nullable fields that were cleared during this
  10588. // mutation.
  10589. func (m *LabelMutation) ClearedFields() []string {
  10590. var fields []string
  10591. if m.FieldCleared(label.FieldStatus) {
  10592. fields = append(fields, label.FieldStatus)
  10593. }
  10594. if m.FieldCleared(label.FieldConditions) {
  10595. fields = append(fields, label.FieldConditions)
  10596. }
  10597. if m.FieldCleared(label.FieldOrganizationID) {
  10598. fields = append(fields, label.FieldOrganizationID)
  10599. }
  10600. return fields
  10601. }
  10602. // FieldCleared returns a boolean indicating if a field with the given name was
  10603. // cleared in this mutation.
  10604. func (m *LabelMutation) FieldCleared(name string) bool {
  10605. _, ok := m.clearedFields[name]
  10606. return ok
  10607. }
  10608. // ClearField clears the value of the field with the given name. It returns an
  10609. // error if the field is not defined in the schema.
  10610. func (m *LabelMutation) ClearField(name string) error {
  10611. switch name {
  10612. case label.FieldStatus:
  10613. m.ClearStatus()
  10614. return nil
  10615. case label.FieldConditions:
  10616. m.ClearConditions()
  10617. return nil
  10618. case label.FieldOrganizationID:
  10619. m.ClearOrganizationID()
  10620. return nil
  10621. }
  10622. return fmt.Errorf("unknown Label nullable field %s", name)
  10623. }
  10624. // ResetField resets all changes in the mutation for the field with the given name.
  10625. // It returns an error if the field is not defined in the schema.
  10626. func (m *LabelMutation) ResetField(name string) error {
  10627. switch name {
  10628. case label.FieldCreatedAt:
  10629. m.ResetCreatedAt()
  10630. return nil
  10631. case label.FieldUpdatedAt:
  10632. m.ResetUpdatedAt()
  10633. return nil
  10634. case label.FieldStatus:
  10635. m.ResetStatus()
  10636. return nil
  10637. case label.FieldType:
  10638. m.ResetType()
  10639. return nil
  10640. case label.FieldName:
  10641. m.ResetName()
  10642. return nil
  10643. case label.FieldFrom:
  10644. m.ResetFrom()
  10645. return nil
  10646. case label.FieldMode:
  10647. m.ResetMode()
  10648. return nil
  10649. case label.FieldConditions:
  10650. m.ResetConditions()
  10651. return nil
  10652. case label.FieldOrganizationID:
  10653. m.ResetOrganizationID()
  10654. return nil
  10655. }
  10656. return fmt.Errorf("unknown Label field %s", name)
  10657. }
  10658. // AddedEdges returns all edge names that were set/added in this mutation.
  10659. func (m *LabelMutation) AddedEdges() []string {
  10660. edges := make([]string, 0, 1)
  10661. if m.label_relationships != nil {
  10662. edges = append(edges, label.EdgeLabelRelationships)
  10663. }
  10664. return edges
  10665. }
  10666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10667. // name in this mutation.
  10668. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  10669. switch name {
  10670. case label.EdgeLabelRelationships:
  10671. ids := make([]ent.Value, 0, len(m.label_relationships))
  10672. for id := range m.label_relationships {
  10673. ids = append(ids, id)
  10674. }
  10675. return ids
  10676. }
  10677. return nil
  10678. }
  10679. // RemovedEdges returns all edge names that were removed in this mutation.
  10680. func (m *LabelMutation) RemovedEdges() []string {
  10681. edges := make([]string, 0, 1)
  10682. if m.removedlabel_relationships != nil {
  10683. edges = append(edges, label.EdgeLabelRelationships)
  10684. }
  10685. return edges
  10686. }
  10687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10688. // the given name in this mutation.
  10689. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  10690. switch name {
  10691. case label.EdgeLabelRelationships:
  10692. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  10693. for id := range m.removedlabel_relationships {
  10694. ids = append(ids, id)
  10695. }
  10696. return ids
  10697. }
  10698. return nil
  10699. }
  10700. // ClearedEdges returns all edge names that were cleared in this mutation.
  10701. func (m *LabelMutation) ClearedEdges() []string {
  10702. edges := make([]string, 0, 1)
  10703. if m.clearedlabel_relationships {
  10704. edges = append(edges, label.EdgeLabelRelationships)
  10705. }
  10706. return edges
  10707. }
  10708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10709. // was cleared in this mutation.
  10710. func (m *LabelMutation) EdgeCleared(name string) bool {
  10711. switch name {
  10712. case label.EdgeLabelRelationships:
  10713. return m.clearedlabel_relationships
  10714. }
  10715. return false
  10716. }
  10717. // ClearEdge clears the value of the edge with the given name. It returns an error
  10718. // if that edge is not defined in the schema.
  10719. func (m *LabelMutation) ClearEdge(name string) error {
  10720. switch name {
  10721. }
  10722. return fmt.Errorf("unknown Label unique edge %s", name)
  10723. }
  10724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10725. // It returns an error if the edge is not defined in the schema.
  10726. func (m *LabelMutation) ResetEdge(name string) error {
  10727. switch name {
  10728. case label.EdgeLabelRelationships:
  10729. m.ResetLabelRelationships()
  10730. return nil
  10731. }
  10732. return fmt.Errorf("unknown Label edge %s", name)
  10733. }
  10734. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  10735. type LabelRelationshipMutation struct {
  10736. config
  10737. op Op
  10738. typ string
  10739. id *uint64
  10740. created_at *time.Time
  10741. updated_at *time.Time
  10742. status *uint8
  10743. addstatus *int8
  10744. deleted_at *time.Time
  10745. organization_id *uint64
  10746. addorganization_id *int64
  10747. clearedFields map[string]struct{}
  10748. contacts *uint64
  10749. clearedcontacts bool
  10750. labels *uint64
  10751. clearedlabels bool
  10752. done bool
  10753. oldValue func(context.Context) (*LabelRelationship, error)
  10754. predicates []predicate.LabelRelationship
  10755. }
  10756. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  10757. // labelrelationshipOption allows management of the mutation configuration using functional options.
  10758. type labelrelationshipOption func(*LabelRelationshipMutation)
  10759. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  10760. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  10761. m := &LabelRelationshipMutation{
  10762. config: c,
  10763. op: op,
  10764. typ: TypeLabelRelationship,
  10765. clearedFields: make(map[string]struct{}),
  10766. }
  10767. for _, opt := range opts {
  10768. opt(m)
  10769. }
  10770. return m
  10771. }
  10772. // withLabelRelationshipID sets the ID field of the mutation.
  10773. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  10774. return func(m *LabelRelationshipMutation) {
  10775. var (
  10776. err error
  10777. once sync.Once
  10778. value *LabelRelationship
  10779. )
  10780. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  10781. once.Do(func() {
  10782. if m.done {
  10783. err = errors.New("querying old values post mutation is not allowed")
  10784. } else {
  10785. value, err = m.Client().LabelRelationship.Get(ctx, id)
  10786. }
  10787. })
  10788. return value, err
  10789. }
  10790. m.id = &id
  10791. }
  10792. }
  10793. // withLabelRelationship sets the old LabelRelationship of the mutation.
  10794. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  10795. return func(m *LabelRelationshipMutation) {
  10796. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  10797. return node, nil
  10798. }
  10799. m.id = &node.ID
  10800. }
  10801. }
  10802. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10803. // executed in a transaction (ent.Tx), a transactional client is returned.
  10804. func (m LabelRelationshipMutation) Client() *Client {
  10805. client := &Client{config: m.config}
  10806. client.init()
  10807. return client
  10808. }
  10809. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10810. // it returns an error otherwise.
  10811. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  10812. if _, ok := m.driver.(*txDriver); !ok {
  10813. return nil, errors.New("ent: mutation is not running in a transaction")
  10814. }
  10815. tx := &Tx{config: m.config}
  10816. tx.init()
  10817. return tx, nil
  10818. }
  10819. // SetID sets the value of the id field. Note that this
  10820. // operation is only accepted on creation of LabelRelationship entities.
  10821. func (m *LabelRelationshipMutation) SetID(id uint64) {
  10822. m.id = &id
  10823. }
  10824. // ID returns the ID value in the mutation. Note that the ID is only available
  10825. // if it was provided to the builder or after it was returned from the database.
  10826. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  10827. if m.id == nil {
  10828. return
  10829. }
  10830. return *m.id, true
  10831. }
  10832. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10833. // That means, if the mutation is applied within a transaction with an isolation level such
  10834. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10835. // or updated by the mutation.
  10836. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  10837. switch {
  10838. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10839. id, exists := m.ID()
  10840. if exists {
  10841. return []uint64{id}, nil
  10842. }
  10843. fallthrough
  10844. case m.op.Is(OpUpdate | OpDelete):
  10845. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  10846. default:
  10847. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10848. }
  10849. }
  10850. // SetCreatedAt sets the "created_at" field.
  10851. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  10852. m.created_at = &t
  10853. }
  10854. // CreatedAt returns the value of the "created_at" field in the mutation.
  10855. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  10856. v := m.created_at
  10857. if v == nil {
  10858. return
  10859. }
  10860. return *v, true
  10861. }
  10862. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  10863. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  10864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10865. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10866. if !m.op.Is(OpUpdateOne) {
  10867. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10868. }
  10869. if m.id == nil || m.oldValue == nil {
  10870. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10871. }
  10872. oldValue, err := m.oldValue(ctx)
  10873. if err != nil {
  10874. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10875. }
  10876. return oldValue.CreatedAt, nil
  10877. }
  10878. // ResetCreatedAt resets all changes to the "created_at" field.
  10879. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  10880. m.created_at = nil
  10881. }
  10882. // SetUpdatedAt sets the "updated_at" field.
  10883. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  10884. m.updated_at = &t
  10885. }
  10886. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10887. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  10888. v := m.updated_at
  10889. if v == nil {
  10890. return
  10891. }
  10892. return *v, true
  10893. }
  10894. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  10895. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  10896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10897. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10898. if !m.op.Is(OpUpdateOne) {
  10899. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10900. }
  10901. if m.id == nil || m.oldValue == nil {
  10902. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10903. }
  10904. oldValue, err := m.oldValue(ctx)
  10905. if err != nil {
  10906. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10907. }
  10908. return oldValue.UpdatedAt, nil
  10909. }
  10910. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10911. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  10912. m.updated_at = nil
  10913. }
  10914. // SetStatus sets the "status" field.
  10915. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  10916. m.status = &u
  10917. m.addstatus = nil
  10918. }
  10919. // Status returns the value of the "status" field in the mutation.
  10920. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  10921. v := m.status
  10922. if v == nil {
  10923. return
  10924. }
  10925. return *v, true
  10926. }
  10927. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  10928. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  10929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10930. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10931. if !m.op.Is(OpUpdateOne) {
  10932. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10933. }
  10934. if m.id == nil || m.oldValue == nil {
  10935. return v, errors.New("OldStatus requires an ID field in the mutation")
  10936. }
  10937. oldValue, err := m.oldValue(ctx)
  10938. if err != nil {
  10939. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10940. }
  10941. return oldValue.Status, nil
  10942. }
  10943. // AddStatus adds u to the "status" field.
  10944. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  10945. if m.addstatus != nil {
  10946. *m.addstatus += u
  10947. } else {
  10948. m.addstatus = &u
  10949. }
  10950. }
  10951. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10952. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  10953. v := m.addstatus
  10954. if v == nil {
  10955. return
  10956. }
  10957. return *v, true
  10958. }
  10959. // ClearStatus clears the value of the "status" field.
  10960. func (m *LabelRelationshipMutation) ClearStatus() {
  10961. m.status = nil
  10962. m.addstatus = nil
  10963. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  10964. }
  10965. // StatusCleared returns if the "status" field was cleared in this mutation.
  10966. func (m *LabelRelationshipMutation) StatusCleared() bool {
  10967. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  10968. return ok
  10969. }
  10970. // ResetStatus resets all changes to the "status" field.
  10971. func (m *LabelRelationshipMutation) ResetStatus() {
  10972. m.status = nil
  10973. m.addstatus = nil
  10974. delete(m.clearedFields, labelrelationship.FieldStatus)
  10975. }
  10976. // SetDeletedAt sets the "deleted_at" field.
  10977. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  10978. m.deleted_at = &t
  10979. }
  10980. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10981. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  10982. v := m.deleted_at
  10983. if v == nil {
  10984. return
  10985. }
  10986. return *v, true
  10987. }
  10988. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  10989. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  10990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10991. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10992. if !m.op.Is(OpUpdateOne) {
  10993. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10994. }
  10995. if m.id == nil || m.oldValue == nil {
  10996. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10997. }
  10998. oldValue, err := m.oldValue(ctx)
  10999. if err != nil {
  11000. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11001. }
  11002. return oldValue.DeletedAt, nil
  11003. }
  11004. // ClearDeletedAt clears the value of the "deleted_at" field.
  11005. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  11006. m.deleted_at = nil
  11007. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  11008. }
  11009. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11010. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  11011. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  11012. return ok
  11013. }
  11014. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11015. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  11016. m.deleted_at = nil
  11017. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  11018. }
  11019. // SetLabelID sets the "label_id" field.
  11020. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  11021. m.labels = &u
  11022. }
  11023. // LabelID returns the value of the "label_id" field in the mutation.
  11024. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  11025. v := m.labels
  11026. if v == nil {
  11027. return
  11028. }
  11029. return *v, true
  11030. }
  11031. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  11032. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11034. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  11035. if !m.op.Is(OpUpdateOne) {
  11036. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  11037. }
  11038. if m.id == nil || m.oldValue == nil {
  11039. return v, errors.New("OldLabelID requires an ID field in the mutation")
  11040. }
  11041. oldValue, err := m.oldValue(ctx)
  11042. if err != nil {
  11043. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  11044. }
  11045. return oldValue.LabelID, nil
  11046. }
  11047. // ResetLabelID resets all changes to the "label_id" field.
  11048. func (m *LabelRelationshipMutation) ResetLabelID() {
  11049. m.labels = nil
  11050. }
  11051. // SetContactID sets the "contact_id" field.
  11052. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  11053. m.contacts = &u
  11054. }
  11055. // ContactID returns the value of the "contact_id" field in the mutation.
  11056. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  11057. v := m.contacts
  11058. if v == nil {
  11059. return
  11060. }
  11061. return *v, true
  11062. }
  11063. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  11064. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11066. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  11067. if !m.op.Is(OpUpdateOne) {
  11068. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  11069. }
  11070. if m.id == nil || m.oldValue == nil {
  11071. return v, errors.New("OldContactID requires an ID field in the mutation")
  11072. }
  11073. oldValue, err := m.oldValue(ctx)
  11074. if err != nil {
  11075. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  11076. }
  11077. return oldValue.ContactID, nil
  11078. }
  11079. // ResetContactID resets all changes to the "contact_id" field.
  11080. func (m *LabelRelationshipMutation) ResetContactID() {
  11081. m.contacts = nil
  11082. }
  11083. // SetOrganizationID sets the "organization_id" field.
  11084. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  11085. m.organization_id = &u
  11086. m.addorganization_id = nil
  11087. }
  11088. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11089. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  11090. v := m.organization_id
  11091. if v == nil {
  11092. return
  11093. }
  11094. return *v, true
  11095. }
  11096. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  11097. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11099. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11100. if !m.op.Is(OpUpdateOne) {
  11101. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11102. }
  11103. if m.id == nil || m.oldValue == nil {
  11104. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11105. }
  11106. oldValue, err := m.oldValue(ctx)
  11107. if err != nil {
  11108. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11109. }
  11110. return oldValue.OrganizationID, nil
  11111. }
  11112. // AddOrganizationID adds u to the "organization_id" field.
  11113. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  11114. if m.addorganization_id != nil {
  11115. *m.addorganization_id += u
  11116. } else {
  11117. m.addorganization_id = &u
  11118. }
  11119. }
  11120. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11121. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  11122. v := m.addorganization_id
  11123. if v == nil {
  11124. return
  11125. }
  11126. return *v, true
  11127. }
  11128. // ClearOrganizationID clears the value of the "organization_id" field.
  11129. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  11130. m.organization_id = nil
  11131. m.addorganization_id = nil
  11132. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  11133. }
  11134. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11135. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  11136. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  11137. return ok
  11138. }
  11139. // ResetOrganizationID resets all changes to the "organization_id" field.
  11140. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  11141. m.organization_id = nil
  11142. m.addorganization_id = nil
  11143. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  11144. }
  11145. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  11146. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  11147. m.contacts = &id
  11148. }
  11149. // ClearContacts clears the "contacts" edge to the Contact entity.
  11150. func (m *LabelRelationshipMutation) ClearContacts() {
  11151. m.clearedcontacts = true
  11152. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  11153. }
  11154. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  11155. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  11156. return m.clearedcontacts
  11157. }
  11158. // ContactsID returns the "contacts" edge ID in the mutation.
  11159. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  11160. if m.contacts != nil {
  11161. return *m.contacts, true
  11162. }
  11163. return
  11164. }
  11165. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  11166. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11167. // ContactsID instead. It exists only for internal usage by the builders.
  11168. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  11169. if id := m.contacts; id != nil {
  11170. ids = append(ids, *id)
  11171. }
  11172. return
  11173. }
  11174. // ResetContacts resets all changes to the "contacts" edge.
  11175. func (m *LabelRelationshipMutation) ResetContacts() {
  11176. m.contacts = nil
  11177. m.clearedcontacts = false
  11178. }
  11179. // SetLabelsID sets the "labels" edge to the Label entity by id.
  11180. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  11181. m.labels = &id
  11182. }
  11183. // ClearLabels clears the "labels" edge to the Label entity.
  11184. func (m *LabelRelationshipMutation) ClearLabels() {
  11185. m.clearedlabels = true
  11186. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  11187. }
  11188. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  11189. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  11190. return m.clearedlabels
  11191. }
  11192. // LabelsID returns the "labels" edge ID in the mutation.
  11193. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  11194. if m.labels != nil {
  11195. return *m.labels, true
  11196. }
  11197. return
  11198. }
  11199. // LabelsIDs returns the "labels" edge IDs in the mutation.
  11200. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11201. // LabelsID instead. It exists only for internal usage by the builders.
  11202. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  11203. if id := m.labels; id != nil {
  11204. ids = append(ids, *id)
  11205. }
  11206. return
  11207. }
  11208. // ResetLabels resets all changes to the "labels" edge.
  11209. func (m *LabelRelationshipMutation) ResetLabels() {
  11210. m.labels = nil
  11211. m.clearedlabels = false
  11212. }
  11213. // Where appends a list predicates to the LabelRelationshipMutation builder.
  11214. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  11215. m.predicates = append(m.predicates, ps...)
  11216. }
  11217. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  11218. // users can use type-assertion to append predicates that do not depend on any generated package.
  11219. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  11220. p := make([]predicate.LabelRelationship, len(ps))
  11221. for i := range ps {
  11222. p[i] = ps[i]
  11223. }
  11224. m.Where(p...)
  11225. }
  11226. // Op returns the operation name.
  11227. func (m *LabelRelationshipMutation) Op() Op {
  11228. return m.op
  11229. }
  11230. // SetOp allows setting the mutation operation.
  11231. func (m *LabelRelationshipMutation) SetOp(op Op) {
  11232. m.op = op
  11233. }
  11234. // Type returns the node type of this mutation (LabelRelationship).
  11235. func (m *LabelRelationshipMutation) Type() string {
  11236. return m.typ
  11237. }
  11238. // Fields returns all fields that were changed during this mutation. Note that in
  11239. // order to get all numeric fields that were incremented/decremented, call
  11240. // AddedFields().
  11241. func (m *LabelRelationshipMutation) Fields() []string {
  11242. fields := make([]string, 0, 7)
  11243. if m.created_at != nil {
  11244. fields = append(fields, labelrelationship.FieldCreatedAt)
  11245. }
  11246. if m.updated_at != nil {
  11247. fields = append(fields, labelrelationship.FieldUpdatedAt)
  11248. }
  11249. if m.status != nil {
  11250. fields = append(fields, labelrelationship.FieldStatus)
  11251. }
  11252. if m.deleted_at != nil {
  11253. fields = append(fields, labelrelationship.FieldDeletedAt)
  11254. }
  11255. if m.labels != nil {
  11256. fields = append(fields, labelrelationship.FieldLabelID)
  11257. }
  11258. if m.contacts != nil {
  11259. fields = append(fields, labelrelationship.FieldContactID)
  11260. }
  11261. if m.organization_id != nil {
  11262. fields = append(fields, labelrelationship.FieldOrganizationID)
  11263. }
  11264. return fields
  11265. }
  11266. // Field returns the value of a field with the given name. The second boolean
  11267. // return value indicates that this field was not set, or was not defined in the
  11268. // schema.
  11269. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  11270. switch name {
  11271. case labelrelationship.FieldCreatedAt:
  11272. return m.CreatedAt()
  11273. case labelrelationship.FieldUpdatedAt:
  11274. return m.UpdatedAt()
  11275. case labelrelationship.FieldStatus:
  11276. return m.Status()
  11277. case labelrelationship.FieldDeletedAt:
  11278. return m.DeletedAt()
  11279. case labelrelationship.FieldLabelID:
  11280. return m.LabelID()
  11281. case labelrelationship.FieldContactID:
  11282. return m.ContactID()
  11283. case labelrelationship.FieldOrganizationID:
  11284. return m.OrganizationID()
  11285. }
  11286. return nil, false
  11287. }
  11288. // OldField returns the old value of the field from the database. An error is
  11289. // returned if the mutation operation is not UpdateOne, or the query to the
  11290. // database failed.
  11291. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11292. switch name {
  11293. case labelrelationship.FieldCreatedAt:
  11294. return m.OldCreatedAt(ctx)
  11295. case labelrelationship.FieldUpdatedAt:
  11296. return m.OldUpdatedAt(ctx)
  11297. case labelrelationship.FieldStatus:
  11298. return m.OldStatus(ctx)
  11299. case labelrelationship.FieldDeletedAt:
  11300. return m.OldDeletedAt(ctx)
  11301. case labelrelationship.FieldLabelID:
  11302. return m.OldLabelID(ctx)
  11303. case labelrelationship.FieldContactID:
  11304. return m.OldContactID(ctx)
  11305. case labelrelationship.FieldOrganizationID:
  11306. return m.OldOrganizationID(ctx)
  11307. }
  11308. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  11309. }
  11310. // SetField sets the value of a field with the given name. It returns an error if
  11311. // the field is not defined in the schema, or if the type mismatched the field
  11312. // type.
  11313. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  11314. switch name {
  11315. case labelrelationship.FieldCreatedAt:
  11316. v, ok := value.(time.Time)
  11317. if !ok {
  11318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11319. }
  11320. m.SetCreatedAt(v)
  11321. return nil
  11322. case labelrelationship.FieldUpdatedAt:
  11323. v, ok := value.(time.Time)
  11324. if !ok {
  11325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11326. }
  11327. m.SetUpdatedAt(v)
  11328. return nil
  11329. case labelrelationship.FieldStatus:
  11330. v, ok := value.(uint8)
  11331. if !ok {
  11332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11333. }
  11334. m.SetStatus(v)
  11335. return nil
  11336. case labelrelationship.FieldDeletedAt:
  11337. v, ok := value.(time.Time)
  11338. if !ok {
  11339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11340. }
  11341. m.SetDeletedAt(v)
  11342. return nil
  11343. case labelrelationship.FieldLabelID:
  11344. v, ok := value.(uint64)
  11345. if !ok {
  11346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11347. }
  11348. m.SetLabelID(v)
  11349. return nil
  11350. case labelrelationship.FieldContactID:
  11351. v, ok := value.(uint64)
  11352. if !ok {
  11353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11354. }
  11355. m.SetContactID(v)
  11356. return nil
  11357. case labelrelationship.FieldOrganizationID:
  11358. v, ok := value.(uint64)
  11359. if !ok {
  11360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11361. }
  11362. m.SetOrganizationID(v)
  11363. return nil
  11364. }
  11365. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11366. }
  11367. // AddedFields returns all numeric fields that were incremented/decremented during
  11368. // this mutation.
  11369. func (m *LabelRelationshipMutation) AddedFields() []string {
  11370. var fields []string
  11371. if m.addstatus != nil {
  11372. fields = append(fields, labelrelationship.FieldStatus)
  11373. }
  11374. if m.addorganization_id != nil {
  11375. fields = append(fields, labelrelationship.FieldOrganizationID)
  11376. }
  11377. return fields
  11378. }
  11379. // AddedField returns the numeric value that was incremented/decremented on a field
  11380. // with the given name. The second boolean return value indicates that this field
  11381. // was not set, or was not defined in the schema.
  11382. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  11383. switch name {
  11384. case labelrelationship.FieldStatus:
  11385. return m.AddedStatus()
  11386. case labelrelationship.FieldOrganizationID:
  11387. return m.AddedOrganizationID()
  11388. }
  11389. return nil, false
  11390. }
  11391. // AddField adds the value to the field with the given name. It returns an error if
  11392. // the field is not defined in the schema, or if the type mismatched the field
  11393. // type.
  11394. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  11395. switch name {
  11396. case labelrelationship.FieldStatus:
  11397. v, ok := value.(int8)
  11398. if !ok {
  11399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11400. }
  11401. m.AddStatus(v)
  11402. return nil
  11403. case labelrelationship.FieldOrganizationID:
  11404. v, ok := value.(int64)
  11405. if !ok {
  11406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11407. }
  11408. m.AddOrganizationID(v)
  11409. return nil
  11410. }
  11411. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  11412. }
  11413. // ClearedFields returns all nullable fields that were cleared during this
  11414. // mutation.
  11415. func (m *LabelRelationshipMutation) ClearedFields() []string {
  11416. var fields []string
  11417. if m.FieldCleared(labelrelationship.FieldStatus) {
  11418. fields = append(fields, labelrelationship.FieldStatus)
  11419. }
  11420. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  11421. fields = append(fields, labelrelationship.FieldDeletedAt)
  11422. }
  11423. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  11424. fields = append(fields, labelrelationship.FieldOrganizationID)
  11425. }
  11426. return fields
  11427. }
  11428. // FieldCleared returns a boolean indicating if a field with the given name was
  11429. // cleared in this mutation.
  11430. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  11431. _, ok := m.clearedFields[name]
  11432. return ok
  11433. }
  11434. // ClearField clears the value of the field with the given name. It returns an
  11435. // error if the field is not defined in the schema.
  11436. func (m *LabelRelationshipMutation) ClearField(name string) error {
  11437. switch name {
  11438. case labelrelationship.FieldStatus:
  11439. m.ClearStatus()
  11440. return nil
  11441. case labelrelationship.FieldDeletedAt:
  11442. m.ClearDeletedAt()
  11443. return nil
  11444. case labelrelationship.FieldOrganizationID:
  11445. m.ClearOrganizationID()
  11446. return nil
  11447. }
  11448. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  11449. }
  11450. // ResetField resets all changes in the mutation for the field with the given name.
  11451. // It returns an error if the field is not defined in the schema.
  11452. func (m *LabelRelationshipMutation) ResetField(name string) error {
  11453. switch name {
  11454. case labelrelationship.FieldCreatedAt:
  11455. m.ResetCreatedAt()
  11456. return nil
  11457. case labelrelationship.FieldUpdatedAt:
  11458. m.ResetUpdatedAt()
  11459. return nil
  11460. case labelrelationship.FieldStatus:
  11461. m.ResetStatus()
  11462. return nil
  11463. case labelrelationship.FieldDeletedAt:
  11464. m.ResetDeletedAt()
  11465. return nil
  11466. case labelrelationship.FieldLabelID:
  11467. m.ResetLabelID()
  11468. return nil
  11469. case labelrelationship.FieldContactID:
  11470. m.ResetContactID()
  11471. return nil
  11472. case labelrelationship.FieldOrganizationID:
  11473. m.ResetOrganizationID()
  11474. return nil
  11475. }
  11476. return fmt.Errorf("unknown LabelRelationship field %s", name)
  11477. }
  11478. // AddedEdges returns all edge names that were set/added in this mutation.
  11479. func (m *LabelRelationshipMutation) AddedEdges() []string {
  11480. edges := make([]string, 0, 2)
  11481. if m.contacts != nil {
  11482. edges = append(edges, labelrelationship.EdgeContacts)
  11483. }
  11484. if m.labels != nil {
  11485. edges = append(edges, labelrelationship.EdgeLabels)
  11486. }
  11487. return edges
  11488. }
  11489. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11490. // name in this mutation.
  11491. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  11492. switch name {
  11493. case labelrelationship.EdgeContacts:
  11494. if id := m.contacts; id != nil {
  11495. return []ent.Value{*id}
  11496. }
  11497. case labelrelationship.EdgeLabels:
  11498. if id := m.labels; id != nil {
  11499. return []ent.Value{*id}
  11500. }
  11501. }
  11502. return nil
  11503. }
  11504. // RemovedEdges returns all edge names that were removed in this mutation.
  11505. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  11506. edges := make([]string, 0, 2)
  11507. return edges
  11508. }
  11509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11510. // the given name in this mutation.
  11511. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  11512. return nil
  11513. }
  11514. // ClearedEdges returns all edge names that were cleared in this mutation.
  11515. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  11516. edges := make([]string, 0, 2)
  11517. if m.clearedcontacts {
  11518. edges = append(edges, labelrelationship.EdgeContacts)
  11519. }
  11520. if m.clearedlabels {
  11521. edges = append(edges, labelrelationship.EdgeLabels)
  11522. }
  11523. return edges
  11524. }
  11525. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11526. // was cleared in this mutation.
  11527. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  11528. switch name {
  11529. case labelrelationship.EdgeContacts:
  11530. return m.clearedcontacts
  11531. case labelrelationship.EdgeLabels:
  11532. return m.clearedlabels
  11533. }
  11534. return false
  11535. }
  11536. // ClearEdge clears the value of the edge with the given name. It returns an error
  11537. // if that edge is not defined in the schema.
  11538. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  11539. switch name {
  11540. case labelrelationship.EdgeContacts:
  11541. m.ClearContacts()
  11542. return nil
  11543. case labelrelationship.EdgeLabels:
  11544. m.ClearLabels()
  11545. return nil
  11546. }
  11547. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  11548. }
  11549. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11550. // It returns an error if the edge is not defined in the schema.
  11551. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  11552. switch name {
  11553. case labelrelationship.EdgeContacts:
  11554. m.ResetContacts()
  11555. return nil
  11556. case labelrelationship.EdgeLabels:
  11557. m.ResetLabels()
  11558. return nil
  11559. }
  11560. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  11561. }
  11562. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  11563. type MessageMutation struct {
  11564. config
  11565. op Op
  11566. typ string
  11567. id *int
  11568. wx_wxid *string
  11569. wxid *string
  11570. content *string
  11571. clearedFields map[string]struct{}
  11572. done bool
  11573. oldValue func(context.Context) (*Message, error)
  11574. predicates []predicate.Message
  11575. }
  11576. var _ ent.Mutation = (*MessageMutation)(nil)
  11577. // messageOption allows management of the mutation configuration using functional options.
  11578. type messageOption func(*MessageMutation)
  11579. // newMessageMutation creates new mutation for the Message entity.
  11580. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  11581. m := &MessageMutation{
  11582. config: c,
  11583. op: op,
  11584. typ: TypeMessage,
  11585. clearedFields: make(map[string]struct{}),
  11586. }
  11587. for _, opt := range opts {
  11588. opt(m)
  11589. }
  11590. return m
  11591. }
  11592. // withMessageID sets the ID field of the mutation.
  11593. func withMessageID(id int) messageOption {
  11594. return func(m *MessageMutation) {
  11595. var (
  11596. err error
  11597. once sync.Once
  11598. value *Message
  11599. )
  11600. m.oldValue = func(ctx context.Context) (*Message, error) {
  11601. once.Do(func() {
  11602. if m.done {
  11603. err = errors.New("querying old values post mutation is not allowed")
  11604. } else {
  11605. value, err = m.Client().Message.Get(ctx, id)
  11606. }
  11607. })
  11608. return value, err
  11609. }
  11610. m.id = &id
  11611. }
  11612. }
  11613. // withMessage sets the old Message of the mutation.
  11614. func withMessage(node *Message) messageOption {
  11615. return func(m *MessageMutation) {
  11616. m.oldValue = func(context.Context) (*Message, error) {
  11617. return node, nil
  11618. }
  11619. m.id = &node.ID
  11620. }
  11621. }
  11622. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11623. // executed in a transaction (ent.Tx), a transactional client is returned.
  11624. func (m MessageMutation) Client() *Client {
  11625. client := &Client{config: m.config}
  11626. client.init()
  11627. return client
  11628. }
  11629. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11630. // it returns an error otherwise.
  11631. func (m MessageMutation) Tx() (*Tx, error) {
  11632. if _, ok := m.driver.(*txDriver); !ok {
  11633. return nil, errors.New("ent: mutation is not running in a transaction")
  11634. }
  11635. tx := &Tx{config: m.config}
  11636. tx.init()
  11637. return tx, nil
  11638. }
  11639. // ID returns the ID value in the mutation. Note that the ID is only available
  11640. // if it was provided to the builder or after it was returned from the database.
  11641. func (m *MessageMutation) ID() (id int, exists bool) {
  11642. if m.id == nil {
  11643. return
  11644. }
  11645. return *m.id, true
  11646. }
  11647. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11648. // That means, if the mutation is applied within a transaction with an isolation level such
  11649. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11650. // or updated by the mutation.
  11651. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  11652. switch {
  11653. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11654. id, exists := m.ID()
  11655. if exists {
  11656. return []int{id}, nil
  11657. }
  11658. fallthrough
  11659. case m.op.Is(OpUpdate | OpDelete):
  11660. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  11661. default:
  11662. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11663. }
  11664. }
  11665. // SetWxWxid sets the "wx_wxid" field.
  11666. func (m *MessageMutation) SetWxWxid(s string) {
  11667. m.wx_wxid = &s
  11668. }
  11669. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11670. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  11671. v := m.wx_wxid
  11672. if v == nil {
  11673. return
  11674. }
  11675. return *v, true
  11676. }
  11677. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  11678. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11680. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11681. if !m.op.Is(OpUpdateOne) {
  11682. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11683. }
  11684. if m.id == nil || m.oldValue == nil {
  11685. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11686. }
  11687. oldValue, err := m.oldValue(ctx)
  11688. if err != nil {
  11689. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11690. }
  11691. return oldValue.WxWxid, nil
  11692. }
  11693. // ClearWxWxid clears the value of the "wx_wxid" field.
  11694. func (m *MessageMutation) ClearWxWxid() {
  11695. m.wx_wxid = nil
  11696. m.clearedFields[message.FieldWxWxid] = struct{}{}
  11697. }
  11698. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  11699. func (m *MessageMutation) WxWxidCleared() bool {
  11700. _, ok := m.clearedFields[message.FieldWxWxid]
  11701. return ok
  11702. }
  11703. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11704. func (m *MessageMutation) ResetWxWxid() {
  11705. m.wx_wxid = nil
  11706. delete(m.clearedFields, message.FieldWxWxid)
  11707. }
  11708. // SetWxid sets the "wxid" field.
  11709. func (m *MessageMutation) SetWxid(s string) {
  11710. m.wxid = &s
  11711. }
  11712. // Wxid returns the value of the "wxid" field in the mutation.
  11713. func (m *MessageMutation) Wxid() (r string, exists bool) {
  11714. v := m.wxid
  11715. if v == nil {
  11716. return
  11717. }
  11718. return *v, true
  11719. }
  11720. // OldWxid returns the old "wxid" field's value of the Message entity.
  11721. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11723. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  11724. if !m.op.Is(OpUpdateOne) {
  11725. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11726. }
  11727. if m.id == nil || m.oldValue == nil {
  11728. return v, errors.New("OldWxid requires an ID field in the mutation")
  11729. }
  11730. oldValue, err := m.oldValue(ctx)
  11731. if err != nil {
  11732. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11733. }
  11734. return oldValue.Wxid, nil
  11735. }
  11736. // ResetWxid resets all changes to the "wxid" field.
  11737. func (m *MessageMutation) ResetWxid() {
  11738. m.wxid = nil
  11739. }
  11740. // SetContent sets the "content" field.
  11741. func (m *MessageMutation) SetContent(s string) {
  11742. m.content = &s
  11743. }
  11744. // Content returns the value of the "content" field in the mutation.
  11745. func (m *MessageMutation) Content() (r string, exists bool) {
  11746. v := m.content
  11747. if v == nil {
  11748. return
  11749. }
  11750. return *v, true
  11751. }
  11752. // OldContent returns the old "content" field's value of the Message entity.
  11753. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  11754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11755. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  11756. if !m.op.Is(OpUpdateOne) {
  11757. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  11758. }
  11759. if m.id == nil || m.oldValue == nil {
  11760. return v, errors.New("OldContent requires an ID field in the mutation")
  11761. }
  11762. oldValue, err := m.oldValue(ctx)
  11763. if err != nil {
  11764. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  11765. }
  11766. return oldValue.Content, nil
  11767. }
  11768. // ResetContent resets all changes to the "content" field.
  11769. func (m *MessageMutation) ResetContent() {
  11770. m.content = nil
  11771. }
  11772. // Where appends a list predicates to the MessageMutation builder.
  11773. func (m *MessageMutation) Where(ps ...predicate.Message) {
  11774. m.predicates = append(m.predicates, ps...)
  11775. }
  11776. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  11777. // users can use type-assertion to append predicates that do not depend on any generated package.
  11778. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  11779. p := make([]predicate.Message, len(ps))
  11780. for i := range ps {
  11781. p[i] = ps[i]
  11782. }
  11783. m.Where(p...)
  11784. }
  11785. // Op returns the operation name.
  11786. func (m *MessageMutation) Op() Op {
  11787. return m.op
  11788. }
  11789. // SetOp allows setting the mutation operation.
  11790. func (m *MessageMutation) SetOp(op Op) {
  11791. m.op = op
  11792. }
  11793. // Type returns the node type of this mutation (Message).
  11794. func (m *MessageMutation) Type() string {
  11795. return m.typ
  11796. }
  11797. // Fields returns all fields that were changed during this mutation. Note that in
  11798. // order to get all numeric fields that were incremented/decremented, call
  11799. // AddedFields().
  11800. func (m *MessageMutation) Fields() []string {
  11801. fields := make([]string, 0, 3)
  11802. if m.wx_wxid != nil {
  11803. fields = append(fields, message.FieldWxWxid)
  11804. }
  11805. if m.wxid != nil {
  11806. fields = append(fields, message.FieldWxid)
  11807. }
  11808. if m.content != nil {
  11809. fields = append(fields, message.FieldContent)
  11810. }
  11811. return fields
  11812. }
  11813. // Field returns the value of a field with the given name. The second boolean
  11814. // return value indicates that this field was not set, or was not defined in the
  11815. // schema.
  11816. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  11817. switch name {
  11818. case message.FieldWxWxid:
  11819. return m.WxWxid()
  11820. case message.FieldWxid:
  11821. return m.Wxid()
  11822. case message.FieldContent:
  11823. return m.Content()
  11824. }
  11825. return nil, false
  11826. }
  11827. // OldField returns the old value of the field from the database. An error is
  11828. // returned if the mutation operation is not UpdateOne, or the query to the
  11829. // database failed.
  11830. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11831. switch name {
  11832. case message.FieldWxWxid:
  11833. return m.OldWxWxid(ctx)
  11834. case message.FieldWxid:
  11835. return m.OldWxid(ctx)
  11836. case message.FieldContent:
  11837. return m.OldContent(ctx)
  11838. }
  11839. return nil, fmt.Errorf("unknown Message field %s", name)
  11840. }
  11841. // SetField sets the value of a field with the given name. It returns an error if
  11842. // the field is not defined in the schema, or if the type mismatched the field
  11843. // type.
  11844. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  11845. switch name {
  11846. case message.FieldWxWxid:
  11847. v, ok := value.(string)
  11848. if !ok {
  11849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11850. }
  11851. m.SetWxWxid(v)
  11852. return nil
  11853. case message.FieldWxid:
  11854. v, ok := value.(string)
  11855. if !ok {
  11856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11857. }
  11858. m.SetWxid(v)
  11859. return nil
  11860. case message.FieldContent:
  11861. v, ok := value.(string)
  11862. if !ok {
  11863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11864. }
  11865. m.SetContent(v)
  11866. return nil
  11867. }
  11868. return fmt.Errorf("unknown Message field %s", name)
  11869. }
  11870. // AddedFields returns all numeric fields that were incremented/decremented during
  11871. // this mutation.
  11872. func (m *MessageMutation) AddedFields() []string {
  11873. return nil
  11874. }
  11875. // AddedField returns the numeric value that was incremented/decremented on a field
  11876. // with the given name. The second boolean return value indicates that this field
  11877. // was not set, or was not defined in the schema.
  11878. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  11879. return nil, false
  11880. }
  11881. // AddField adds the value to the field with the given name. It returns an error if
  11882. // the field is not defined in the schema, or if the type mismatched the field
  11883. // type.
  11884. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  11885. switch name {
  11886. }
  11887. return fmt.Errorf("unknown Message numeric field %s", name)
  11888. }
  11889. // ClearedFields returns all nullable fields that were cleared during this
  11890. // mutation.
  11891. func (m *MessageMutation) ClearedFields() []string {
  11892. var fields []string
  11893. if m.FieldCleared(message.FieldWxWxid) {
  11894. fields = append(fields, message.FieldWxWxid)
  11895. }
  11896. return fields
  11897. }
  11898. // FieldCleared returns a boolean indicating if a field with the given name was
  11899. // cleared in this mutation.
  11900. func (m *MessageMutation) FieldCleared(name string) bool {
  11901. _, ok := m.clearedFields[name]
  11902. return ok
  11903. }
  11904. // ClearField clears the value of the field with the given name. It returns an
  11905. // error if the field is not defined in the schema.
  11906. func (m *MessageMutation) ClearField(name string) error {
  11907. switch name {
  11908. case message.FieldWxWxid:
  11909. m.ClearWxWxid()
  11910. return nil
  11911. }
  11912. return fmt.Errorf("unknown Message nullable field %s", name)
  11913. }
  11914. // ResetField resets all changes in the mutation for the field with the given name.
  11915. // It returns an error if the field is not defined in the schema.
  11916. func (m *MessageMutation) ResetField(name string) error {
  11917. switch name {
  11918. case message.FieldWxWxid:
  11919. m.ResetWxWxid()
  11920. return nil
  11921. case message.FieldWxid:
  11922. m.ResetWxid()
  11923. return nil
  11924. case message.FieldContent:
  11925. m.ResetContent()
  11926. return nil
  11927. }
  11928. return fmt.Errorf("unknown Message field %s", name)
  11929. }
  11930. // AddedEdges returns all edge names that were set/added in this mutation.
  11931. func (m *MessageMutation) AddedEdges() []string {
  11932. edges := make([]string, 0, 0)
  11933. return edges
  11934. }
  11935. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11936. // name in this mutation.
  11937. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  11938. return nil
  11939. }
  11940. // RemovedEdges returns all edge names that were removed in this mutation.
  11941. func (m *MessageMutation) RemovedEdges() []string {
  11942. edges := make([]string, 0, 0)
  11943. return edges
  11944. }
  11945. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11946. // the given name in this mutation.
  11947. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  11948. return nil
  11949. }
  11950. // ClearedEdges returns all edge names that were cleared in this mutation.
  11951. func (m *MessageMutation) ClearedEdges() []string {
  11952. edges := make([]string, 0, 0)
  11953. return edges
  11954. }
  11955. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11956. // was cleared in this mutation.
  11957. func (m *MessageMutation) EdgeCleared(name string) bool {
  11958. return false
  11959. }
  11960. // ClearEdge clears the value of the edge with the given name. It returns an error
  11961. // if that edge is not defined in the schema.
  11962. func (m *MessageMutation) ClearEdge(name string) error {
  11963. return fmt.Errorf("unknown Message unique edge %s", name)
  11964. }
  11965. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11966. // It returns an error if the edge is not defined in the schema.
  11967. func (m *MessageMutation) ResetEdge(name string) error {
  11968. return fmt.Errorf("unknown Message edge %s", name)
  11969. }
  11970. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  11971. type MessageRecordsMutation struct {
  11972. config
  11973. op Op
  11974. typ string
  11975. id *uint64
  11976. created_at *time.Time
  11977. updated_at *time.Time
  11978. status *uint8
  11979. addstatus *int8
  11980. bot_wxid *string
  11981. contact_type *int
  11982. addcontact_type *int
  11983. contact_wxid *string
  11984. content_type *int
  11985. addcontent_type *int
  11986. content *string
  11987. meta *custom_types.Meta
  11988. error_detail *string
  11989. send_time *time.Time
  11990. source_type *int
  11991. addsource_type *int
  11992. organization_id *uint64
  11993. addorganization_id *int64
  11994. clearedFields map[string]struct{}
  11995. sop_stage *uint64
  11996. clearedsop_stage bool
  11997. sop_node *uint64
  11998. clearedsop_node bool
  11999. message_contact *uint64
  12000. clearedmessage_contact bool
  12001. done bool
  12002. oldValue func(context.Context) (*MessageRecords, error)
  12003. predicates []predicate.MessageRecords
  12004. }
  12005. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  12006. // messagerecordsOption allows management of the mutation configuration using functional options.
  12007. type messagerecordsOption func(*MessageRecordsMutation)
  12008. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  12009. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  12010. m := &MessageRecordsMutation{
  12011. config: c,
  12012. op: op,
  12013. typ: TypeMessageRecords,
  12014. clearedFields: make(map[string]struct{}),
  12015. }
  12016. for _, opt := range opts {
  12017. opt(m)
  12018. }
  12019. return m
  12020. }
  12021. // withMessageRecordsID sets the ID field of the mutation.
  12022. func withMessageRecordsID(id uint64) messagerecordsOption {
  12023. return func(m *MessageRecordsMutation) {
  12024. var (
  12025. err error
  12026. once sync.Once
  12027. value *MessageRecords
  12028. )
  12029. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  12030. once.Do(func() {
  12031. if m.done {
  12032. err = errors.New("querying old values post mutation is not allowed")
  12033. } else {
  12034. value, err = m.Client().MessageRecords.Get(ctx, id)
  12035. }
  12036. })
  12037. return value, err
  12038. }
  12039. m.id = &id
  12040. }
  12041. }
  12042. // withMessageRecords sets the old MessageRecords of the mutation.
  12043. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  12044. return func(m *MessageRecordsMutation) {
  12045. m.oldValue = func(context.Context) (*MessageRecords, error) {
  12046. return node, nil
  12047. }
  12048. m.id = &node.ID
  12049. }
  12050. }
  12051. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12052. // executed in a transaction (ent.Tx), a transactional client is returned.
  12053. func (m MessageRecordsMutation) Client() *Client {
  12054. client := &Client{config: m.config}
  12055. client.init()
  12056. return client
  12057. }
  12058. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12059. // it returns an error otherwise.
  12060. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  12061. if _, ok := m.driver.(*txDriver); !ok {
  12062. return nil, errors.New("ent: mutation is not running in a transaction")
  12063. }
  12064. tx := &Tx{config: m.config}
  12065. tx.init()
  12066. return tx, nil
  12067. }
  12068. // SetID sets the value of the id field. Note that this
  12069. // operation is only accepted on creation of MessageRecords entities.
  12070. func (m *MessageRecordsMutation) SetID(id uint64) {
  12071. m.id = &id
  12072. }
  12073. // ID returns the ID value in the mutation. Note that the ID is only available
  12074. // if it was provided to the builder or after it was returned from the database.
  12075. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  12076. if m.id == nil {
  12077. return
  12078. }
  12079. return *m.id, true
  12080. }
  12081. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12082. // That means, if the mutation is applied within a transaction with an isolation level such
  12083. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12084. // or updated by the mutation.
  12085. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  12086. switch {
  12087. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12088. id, exists := m.ID()
  12089. if exists {
  12090. return []uint64{id}, nil
  12091. }
  12092. fallthrough
  12093. case m.op.Is(OpUpdate | OpDelete):
  12094. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  12095. default:
  12096. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12097. }
  12098. }
  12099. // SetCreatedAt sets the "created_at" field.
  12100. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  12101. m.created_at = &t
  12102. }
  12103. // CreatedAt returns the value of the "created_at" field in the mutation.
  12104. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  12105. v := m.created_at
  12106. if v == nil {
  12107. return
  12108. }
  12109. return *v, true
  12110. }
  12111. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  12112. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12114. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12115. if !m.op.Is(OpUpdateOne) {
  12116. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12117. }
  12118. if m.id == nil || m.oldValue == nil {
  12119. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12120. }
  12121. oldValue, err := m.oldValue(ctx)
  12122. if err != nil {
  12123. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12124. }
  12125. return oldValue.CreatedAt, nil
  12126. }
  12127. // ResetCreatedAt resets all changes to the "created_at" field.
  12128. func (m *MessageRecordsMutation) ResetCreatedAt() {
  12129. m.created_at = nil
  12130. }
  12131. // SetUpdatedAt sets the "updated_at" field.
  12132. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  12133. m.updated_at = &t
  12134. }
  12135. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12136. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  12137. v := m.updated_at
  12138. if v == nil {
  12139. return
  12140. }
  12141. return *v, true
  12142. }
  12143. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  12144. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12146. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12147. if !m.op.Is(OpUpdateOne) {
  12148. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12149. }
  12150. if m.id == nil || m.oldValue == nil {
  12151. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12152. }
  12153. oldValue, err := m.oldValue(ctx)
  12154. if err != nil {
  12155. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12156. }
  12157. return oldValue.UpdatedAt, nil
  12158. }
  12159. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12160. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  12161. m.updated_at = nil
  12162. }
  12163. // SetStatus sets the "status" field.
  12164. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  12165. m.status = &u
  12166. m.addstatus = nil
  12167. }
  12168. // Status returns the value of the "status" field in the mutation.
  12169. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  12170. v := m.status
  12171. if v == nil {
  12172. return
  12173. }
  12174. return *v, true
  12175. }
  12176. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  12177. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12179. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12180. if !m.op.Is(OpUpdateOne) {
  12181. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12182. }
  12183. if m.id == nil || m.oldValue == nil {
  12184. return v, errors.New("OldStatus requires an ID field in the mutation")
  12185. }
  12186. oldValue, err := m.oldValue(ctx)
  12187. if err != nil {
  12188. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12189. }
  12190. return oldValue.Status, nil
  12191. }
  12192. // AddStatus adds u to the "status" field.
  12193. func (m *MessageRecordsMutation) AddStatus(u int8) {
  12194. if m.addstatus != nil {
  12195. *m.addstatus += u
  12196. } else {
  12197. m.addstatus = &u
  12198. }
  12199. }
  12200. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12201. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  12202. v := m.addstatus
  12203. if v == nil {
  12204. return
  12205. }
  12206. return *v, true
  12207. }
  12208. // ClearStatus clears the value of the "status" field.
  12209. func (m *MessageRecordsMutation) ClearStatus() {
  12210. m.status = nil
  12211. m.addstatus = nil
  12212. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  12213. }
  12214. // StatusCleared returns if the "status" field was cleared in this mutation.
  12215. func (m *MessageRecordsMutation) StatusCleared() bool {
  12216. _, ok := m.clearedFields[messagerecords.FieldStatus]
  12217. return ok
  12218. }
  12219. // ResetStatus resets all changes to the "status" field.
  12220. func (m *MessageRecordsMutation) ResetStatus() {
  12221. m.status = nil
  12222. m.addstatus = nil
  12223. delete(m.clearedFields, messagerecords.FieldStatus)
  12224. }
  12225. // SetBotWxid sets the "bot_wxid" field.
  12226. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  12227. m.bot_wxid = &s
  12228. }
  12229. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  12230. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  12231. v := m.bot_wxid
  12232. if v == nil {
  12233. return
  12234. }
  12235. return *v, true
  12236. }
  12237. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  12238. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12240. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  12241. if !m.op.Is(OpUpdateOne) {
  12242. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  12243. }
  12244. if m.id == nil || m.oldValue == nil {
  12245. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  12246. }
  12247. oldValue, err := m.oldValue(ctx)
  12248. if err != nil {
  12249. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  12250. }
  12251. return oldValue.BotWxid, nil
  12252. }
  12253. // ResetBotWxid resets all changes to the "bot_wxid" field.
  12254. func (m *MessageRecordsMutation) ResetBotWxid() {
  12255. m.bot_wxid = nil
  12256. }
  12257. // SetContactID sets the "contact_id" field.
  12258. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  12259. m.message_contact = &u
  12260. }
  12261. // ContactID returns the value of the "contact_id" field in the mutation.
  12262. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  12263. v := m.message_contact
  12264. if v == nil {
  12265. return
  12266. }
  12267. return *v, true
  12268. }
  12269. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  12270. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12272. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12273. if !m.op.Is(OpUpdateOne) {
  12274. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12275. }
  12276. if m.id == nil || m.oldValue == nil {
  12277. return v, errors.New("OldContactID requires an ID field in the mutation")
  12278. }
  12279. oldValue, err := m.oldValue(ctx)
  12280. if err != nil {
  12281. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12282. }
  12283. return oldValue.ContactID, nil
  12284. }
  12285. // ClearContactID clears the value of the "contact_id" field.
  12286. func (m *MessageRecordsMutation) ClearContactID() {
  12287. m.message_contact = nil
  12288. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  12289. }
  12290. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  12291. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  12292. _, ok := m.clearedFields[messagerecords.FieldContactID]
  12293. return ok
  12294. }
  12295. // ResetContactID resets all changes to the "contact_id" field.
  12296. func (m *MessageRecordsMutation) ResetContactID() {
  12297. m.message_contact = nil
  12298. delete(m.clearedFields, messagerecords.FieldContactID)
  12299. }
  12300. // SetContactType sets the "contact_type" field.
  12301. func (m *MessageRecordsMutation) SetContactType(i int) {
  12302. m.contact_type = &i
  12303. m.addcontact_type = nil
  12304. }
  12305. // ContactType returns the value of the "contact_type" field in the mutation.
  12306. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  12307. v := m.contact_type
  12308. if v == nil {
  12309. return
  12310. }
  12311. return *v, true
  12312. }
  12313. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  12314. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12316. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  12317. if !m.op.Is(OpUpdateOne) {
  12318. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  12319. }
  12320. if m.id == nil || m.oldValue == nil {
  12321. return v, errors.New("OldContactType requires an ID field in the mutation")
  12322. }
  12323. oldValue, err := m.oldValue(ctx)
  12324. if err != nil {
  12325. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  12326. }
  12327. return oldValue.ContactType, nil
  12328. }
  12329. // AddContactType adds i to the "contact_type" field.
  12330. func (m *MessageRecordsMutation) AddContactType(i int) {
  12331. if m.addcontact_type != nil {
  12332. *m.addcontact_type += i
  12333. } else {
  12334. m.addcontact_type = &i
  12335. }
  12336. }
  12337. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  12338. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  12339. v := m.addcontact_type
  12340. if v == nil {
  12341. return
  12342. }
  12343. return *v, true
  12344. }
  12345. // ResetContactType resets all changes to the "contact_type" field.
  12346. func (m *MessageRecordsMutation) ResetContactType() {
  12347. m.contact_type = nil
  12348. m.addcontact_type = nil
  12349. }
  12350. // SetContactWxid sets the "contact_wxid" field.
  12351. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  12352. m.contact_wxid = &s
  12353. }
  12354. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  12355. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  12356. v := m.contact_wxid
  12357. if v == nil {
  12358. return
  12359. }
  12360. return *v, true
  12361. }
  12362. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  12363. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12365. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  12366. if !m.op.Is(OpUpdateOne) {
  12367. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  12368. }
  12369. if m.id == nil || m.oldValue == nil {
  12370. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  12371. }
  12372. oldValue, err := m.oldValue(ctx)
  12373. if err != nil {
  12374. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  12375. }
  12376. return oldValue.ContactWxid, nil
  12377. }
  12378. // ResetContactWxid resets all changes to the "contact_wxid" field.
  12379. func (m *MessageRecordsMutation) ResetContactWxid() {
  12380. m.contact_wxid = nil
  12381. }
  12382. // SetContentType sets the "content_type" field.
  12383. func (m *MessageRecordsMutation) SetContentType(i int) {
  12384. m.content_type = &i
  12385. m.addcontent_type = nil
  12386. }
  12387. // ContentType returns the value of the "content_type" field in the mutation.
  12388. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  12389. v := m.content_type
  12390. if v == nil {
  12391. return
  12392. }
  12393. return *v, true
  12394. }
  12395. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  12396. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12398. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  12399. if !m.op.Is(OpUpdateOne) {
  12400. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  12401. }
  12402. if m.id == nil || m.oldValue == nil {
  12403. return v, errors.New("OldContentType requires an ID field in the mutation")
  12404. }
  12405. oldValue, err := m.oldValue(ctx)
  12406. if err != nil {
  12407. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  12408. }
  12409. return oldValue.ContentType, nil
  12410. }
  12411. // AddContentType adds i to the "content_type" field.
  12412. func (m *MessageRecordsMutation) AddContentType(i int) {
  12413. if m.addcontent_type != nil {
  12414. *m.addcontent_type += i
  12415. } else {
  12416. m.addcontent_type = &i
  12417. }
  12418. }
  12419. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  12420. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  12421. v := m.addcontent_type
  12422. if v == nil {
  12423. return
  12424. }
  12425. return *v, true
  12426. }
  12427. // ResetContentType resets all changes to the "content_type" field.
  12428. func (m *MessageRecordsMutation) ResetContentType() {
  12429. m.content_type = nil
  12430. m.addcontent_type = nil
  12431. }
  12432. // SetContent sets the "content" field.
  12433. func (m *MessageRecordsMutation) SetContent(s string) {
  12434. m.content = &s
  12435. }
  12436. // Content returns the value of the "content" field in the mutation.
  12437. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  12438. v := m.content
  12439. if v == nil {
  12440. return
  12441. }
  12442. return *v, true
  12443. }
  12444. // OldContent returns the old "content" field's value of the MessageRecords entity.
  12445. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12447. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  12448. if !m.op.Is(OpUpdateOne) {
  12449. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12450. }
  12451. if m.id == nil || m.oldValue == nil {
  12452. return v, errors.New("OldContent requires an ID field in the mutation")
  12453. }
  12454. oldValue, err := m.oldValue(ctx)
  12455. if err != nil {
  12456. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12457. }
  12458. return oldValue.Content, nil
  12459. }
  12460. // ResetContent resets all changes to the "content" field.
  12461. func (m *MessageRecordsMutation) ResetContent() {
  12462. m.content = nil
  12463. }
  12464. // SetMeta sets the "meta" field.
  12465. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  12466. m.meta = &ct
  12467. }
  12468. // Meta returns the value of the "meta" field in the mutation.
  12469. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  12470. v := m.meta
  12471. if v == nil {
  12472. return
  12473. }
  12474. return *v, true
  12475. }
  12476. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  12477. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12479. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  12480. if !m.op.Is(OpUpdateOne) {
  12481. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  12482. }
  12483. if m.id == nil || m.oldValue == nil {
  12484. return v, errors.New("OldMeta requires an ID field in the mutation")
  12485. }
  12486. oldValue, err := m.oldValue(ctx)
  12487. if err != nil {
  12488. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  12489. }
  12490. return oldValue.Meta, nil
  12491. }
  12492. // ClearMeta clears the value of the "meta" field.
  12493. func (m *MessageRecordsMutation) ClearMeta() {
  12494. m.meta = nil
  12495. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  12496. }
  12497. // MetaCleared returns if the "meta" field was cleared in this mutation.
  12498. func (m *MessageRecordsMutation) MetaCleared() bool {
  12499. _, ok := m.clearedFields[messagerecords.FieldMeta]
  12500. return ok
  12501. }
  12502. // ResetMeta resets all changes to the "meta" field.
  12503. func (m *MessageRecordsMutation) ResetMeta() {
  12504. m.meta = nil
  12505. delete(m.clearedFields, messagerecords.FieldMeta)
  12506. }
  12507. // SetErrorDetail sets the "error_detail" field.
  12508. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  12509. m.error_detail = &s
  12510. }
  12511. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  12512. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  12513. v := m.error_detail
  12514. if v == nil {
  12515. return
  12516. }
  12517. return *v, true
  12518. }
  12519. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  12520. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12522. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  12523. if !m.op.Is(OpUpdateOne) {
  12524. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  12525. }
  12526. if m.id == nil || m.oldValue == nil {
  12527. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  12528. }
  12529. oldValue, err := m.oldValue(ctx)
  12530. if err != nil {
  12531. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  12532. }
  12533. return oldValue.ErrorDetail, nil
  12534. }
  12535. // ResetErrorDetail resets all changes to the "error_detail" field.
  12536. func (m *MessageRecordsMutation) ResetErrorDetail() {
  12537. m.error_detail = nil
  12538. }
  12539. // SetSendTime sets the "send_time" field.
  12540. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  12541. m.send_time = &t
  12542. }
  12543. // SendTime returns the value of the "send_time" field in the mutation.
  12544. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  12545. v := m.send_time
  12546. if v == nil {
  12547. return
  12548. }
  12549. return *v, true
  12550. }
  12551. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  12552. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12554. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  12555. if !m.op.Is(OpUpdateOne) {
  12556. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  12557. }
  12558. if m.id == nil || m.oldValue == nil {
  12559. return v, errors.New("OldSendTime requires an ID field in the mutation")
  12560. }
  12561. oldValue, err := m.oldValue(ctx)
  12562. if err != nil {
  12563. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  12564. }
  12565. return oldValue.SendTime, nil
  12566. }
  12567. // ClearSendTime clears the value of the "send_time" field.
  12568. func (m *MessageRecordsMutation) ClearSendTime() {
  12569. m.send_time = nil
  12570. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  12571. }
  12572. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  12573. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  12574. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  12575. return ok
  12576. }
  12577. // ResetSendTime resets all changes to the "send_time" field.
  12578. func (m *MessageRecordsMutation) ResetSendTime() {
  12579. m.send_time = nil
  12580. delete(m.clearedFields, messagerecords.FieldSendTime)
  12581. }
  12582. // SetSourceType sets the "source_type" field.
  12583. func (m *MessageRecordsMutation) SetSourceType(i int) {
  12584. m.source_type = &i
  12585. m.addsource_type = nil
  12586. }
  12587. // SourceType returns the value of the "source_type" field in the mutation.
  12588. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  12589. v := m.source_type
  12590. if v == nil {
  12591. return
  12592. }
  12593. return *v, true
  12594. }
  12595. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  12596. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12598. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  12599. if !m.op.Is(OpUpdateOne) {
  12600. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  12601. }
  12602. if m.id == nil || m.oldValue == nil {
  12603. return v, errors.New("OldSourceType requires an ID field in the mutation")
  12604. }
  12605. oldValue, err := m.oldValue(ctx)
  12606. if err != nil {
  12607. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  12608. }
  12609. return oldValue.SourceType, nil
  12610. }
  12611. // AddSourceType adds i to the "source_type" field.
  12612. func (m *MessageRecordsMutation) AddSourceType(i int) {
  12613. if m.addsource_type != nil {
  12614. *m.addsource_type += i
  12615. } else {
  12616. m.addsource_type = &i
  12617. }
  12618. }
  12619. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  12620. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  12621. v := m.addsource_type
  12622. if v == nil {
  12623. return
  12624. }
  12625. return *v, true
  12626. }
  12627. // ResetSourceType resets all changes to the "source_type" field.
  12628. func (m *MessageRecordsMutation) ResetSourceType() {
  12629. m.source_type = nil
  12630. m.addsource_type = nil
  12631. }
  12632. // SetSourceID sets the "source_id" field.
  12633. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  12634. m.sop_stage = &u
  12635. }
  12636. // SourceID returns the value of the "source_id" field in the mutation.
  12637. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  12638. v := m.sop_stage
  12639. if v == nil {
  12640. return
  12641. }
  12642. return *v, true
  12643. }
  12644. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  12645. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12647. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  12648. if !m.op.Is(OpUpdateOne) {
  12649. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  12650. }
  12651. if m.id == nil || m.oldValue == nil {
  12652. return v, errors.New("OldSourceID requires an ID field in the mutation")
  12653. }
  12654. oldValue, err := m.oldValue(ctx)
  12655. if err != nil {
  12656. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  12657. }
  12658. return oldValue.SourceID, nil
  12659. }
  12660. // ClearSourceID clears the value of the "source_id" field.
  12661. func (m *MessageRecordsMutation) ClearSourceID() {
  12662. m.sop_stage = nil
  12663. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12664. }
  12665. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  12666. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  12667. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  12668. return ok
  12669. }
  12670. // ResetSourceID resets all changes to the "source_id" field.
  12671. func (m *MessageRecordsMutation) ResetSourceID() {
  12672. m.sop_stage = nil
  12673. delete(m.clearedFields, messagerecords.FieldSourceID)
  12674. }
  12675. // SetSubSourceID sets the "sub_source_id" field.
  12676. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  12677. m.sop_node = &u
  12678. }
  12679. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  12680. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  12681. v := m.sop_node
  12682. if v == nil {
  12683. return
  12684. }
  12685. return *v, true
  12686. }
  12687. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  12688. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12690. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  12691. if !m.op.Is(OpUpdateOne) {
  12692. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  12693. }
  12694. if m.id == nil || m.oldValue == nil {
  12695. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  12696. }
  12697. oldValue, err := m.oldValue(ctx)
  12698. if err != nil {
  12699. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  12700. }
  12701. return oldValue.SubSourceID, nil
  12702. }
  12703. // ClearSubSourceID clears the value of the "sub_source_id" field.
  12704. func (m *MessageRecordsMutation) ClearSubSourceID() {
  12705. m.sop_node = nil
  12706. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12707. }
  12708. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  12709. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  12710. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  12711. return ok
  12712. }
  12713. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  12714. func (m *MessageRecordsMutation) ResetSubSourceID() {
  12715. m.sop_node = nil
  12716. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  12717. }
  12718. // SetOrganizationID sets the "organization_id" field.
  12719. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  12720. m.organization_id = &u
  12721. m.addorganization_id = nil
  12722. }
  12723. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12724. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  12725. v := m.organization_id
  12726. if v == nil {
  12727. return
  12728. }
  12729. return *v, true
  12730. }
  12731. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  12732. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  12733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12734. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12735. if !m.op.Is(OpUpdateOne) {
  12736. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12737. }
  12738. if m.id == nil || m.oldValue == nil {
  12739. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12740. }
  12741. oldValue, err := m.oldValue(ctx)
  12742. if err != nil {
  12743. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12744. }
  12745. return oldValue.OrganizationID, nil
  12746. }
  12747. // AddOrganizationID adds u to the "organization_id" field.
  12748. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  12749. if m.addorganization_id != nil {
  12750. *m.addorganization_id += u
  12751. } else {
  12752. m.addorganization_id = &u
  12753. }
  12754. }
  12755. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12756. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  12757. v := m.addorganization_id
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // ClearOrganizationID clears the value of the "organization_id" field.
  12764. func (m *MessageRecordsMutation) ClearOrganizationID() {
  12765. m.organization_id = nil
  12766. m.addorganization_id = nil
  12767. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  12768. }
  12769. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12770. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  12771. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  12772. return ok
  12773. }
  12774. // ResetOrganizationID resets all changes to the "organization_id" field.
  12775. func (m *MessageRecordsMutation) ResetOrganizationID() {
  12776. m.organization_id = nil
  12777. m.addorganization_id = nil
  12778. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  12779. }
  12780. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12781. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  12782. m.sop_stage = &id
  12783. }
  12784. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12785. func (m *MessageRecordsMutation) ClearSopStage() {
  12786. m.clearedsop_stage = true
  12787. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  12788. }
  12789. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12790. func (m *MessageRecordsMutation) SopStageCleared() bool {
  12791. return m.SourceIDCleared() || m.clearedsop_stage
  12792. }
  12793. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12794. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  12795. if m.sop_stage != nil {
  12796. return *m.sop_stage, true
  12797. }
  12798. return
  12799. }
  12800. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12801. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12802. // SopStageID instead. It exists only for internal usage by the builders.
  12803. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  12804. if id := m.sop_stage; id != nil {
  12805. ids = append(ids, *id)
  12806. }
  12807. return
  12808. }
  12809. // ResetSopStage resets all changes to the "sop_stage" edge.
  12810. func (m *MessageRecordsMutation) ResetSopStage() {
  12811. m.sop_stage = nil
  12812. m.clearedsop_stage = false
  12813. }
  12814. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  12815. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  12816. m.sop_node = &id
  12817. }
  12818. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  12819. func (m *MessageRecordsMutation) ClearSopNode() {
  12820. m.clearedsop_node = true
  12821. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  12822. }
  12823. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  12824. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  12825. return m.SubSourceIDCleared() || m.clearedsop_node
  12826. }
  12827. // SopNodeID returns the "sop_node" edge ID in the mutation.
  12828. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  12829. if m.sop_node != nil {
  12830. return *m.sop_node, true
  12831. }
  12832. return
  12833. }
  12834. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  12835. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12836. // SopNodeID instead. It exists only for internal usage by the builders.
  12837. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  12838. if id := m.sop_node; id != nil {
  12839. ids = append(ids, *id)
  12840. }
  12841. return
  12842. }
  12843. // ResetSopNode resets all changes to the "sop_node" edge.
  12844. func (m *MessageRecordsMutation) ResetSopNode() {
  12845. m.sop_node = nil
  12846. m.clearedsop_node = false
  12847. }
  12848. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  12849. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  12850. m.message_contact = &id
  12851. }
  12852. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  12853. func (m *MessageRecordsMutation) ClearMessageContact() {
  12854. m.clearedmessage_contact = true
  12855. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  12856. }
  12857. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  12858. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  12859. return m.ContactIDCleared() || m.clearedmessage_contact
  12860. }
  12861. // MessageContactID returns the "message_contact" edge ID in the mutation.
  12862. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  12863. if m.message_contact != nil {
  12864. return *m.message_contact, true
  12865. }
  12866. return
  12867. }
  12868. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  12869. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12870. // MessageContactID instead. It exists only for internal usage by the builders.
  12871. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  12872. if id := m.message_contact; id != nil {
  12873. ids = append(ids, *id)
  12874. }
  12875. return
  12876. }
  12877. // ResetMessageContact resets all changes to the "message_contact" edge.
  12878. func (m *MessageRecordsMutation) ResetMessageContact() {
  12879. m.message_contact = nil
  12880. m.clearedmessage_contact = false
  12881. }
  12882. // Where appends a list predicates to the MessageRecordsMutation builder.
  12883. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  12884. m.predicates = append(m.predicates, ps...)
  12885. }
  12886. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  12887. // users can use type-assertion to append predicates that do not depend on any generated package.
  12888. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  12889. p := make([]predicate.MessageRecords, len(ps))
  12890. for i := range ps {
  12891. p[i] = ps[i]
  12892. }
  12893. m.Where(p...)
  12894. }
  12895. // Op returns the operation name.
  12896. func (m *MessageRecordsMutation) Op() Op {
  12897. return m.op
  12898. }
  12899. // SetOp allows setting the mutation operation.
  12900. func (m *MessageRecordsMutation) SetOp(op Op) {
  12901. m.op = op
  12902. }
  12903. // Type returns the node type of this mutation (MessageRecords).
  12904. func (m *MessageRecordsMutation) Type() string {
  12905. return m.typ
  12906. }
  12907. // Fields returns all fields that were changed during this mutation. Note that in
  12908. // order to get all numeric fields that were incremented/decremented, call
  12909. // AddedFields().
  12910. func (m *MessageRecordsMutation) Fields() []string {
  12911. fields := make([]string, 0, 16)
  12912. if m.created_at != nil {
  12913. fields = append(fields, messagerecords.FieldCreatedAt)
  12914. }
  12915. if m.updated_at != nil {
  12916. fields = append(fields, messagerecords.FieldUpdatedAt)
  12917. }
  12918. if m.status != nil {
  12919. fields = append(fields, messagerecords.FieldStatus)
  12920. }
  12921. if m.bot_wxid != nil {
  12922. fields = append(fields, messagerecords.FieldBotWxid)
  12923. }
  12924. if m.message_contact != nil {
  12925. fields = append(fields, messagerecords.FieldContactID)
  12926. }
  12927. if m.contact_type != nil {
  12928. fields = append(fields, messagerecords.FieldContactType)
  12929. }
  12930. if m.contact_wxid != nil {
  12931. fields = append(fields, messagerecords.FieldContactWxid)
  12932. }
  12933. if m.content_type != nil {
  12934. fields = append(fields, messagerecords.FieldContentType)
  12935. }
  12936. if m.content != nil {
  12937. fields = append(fields, messagerecords.FieldContent)
  12938. }
  12939. if m.meta != nil {
  12940. fields = append(fields, messagerecords.FieldMeta)
  12941. }
  12942. if m.error_detail != nil {
  12943. fields = append(fields, messagerecords.FieldErrorDetail)
  12944. }
  12945. if m.send_time != nil {
  12946. fields = append(fields, messagerecords.FieldSendTime)
  12947. }
  12948. if m.source_type != nil {
  12949. fields = append(fields, messagerecords.FieldSourceType)
  12950. }
  12951. if m.sop_stage != nil {
  12952. fields = append(fields, messagerecords.FieldSourceID)
  12953. }
  12954. if m.sop_node != nil {
  12955. fields = append(fields, messagerecords.FieldSubSourceID)
  12956. }
  12957. if m.organization_id != nil {
  12958. fields = append(fields, messagerecords.FieldOrganizationID)
  12959. }
  12960. return fields
  12961. }
  12962. // Field returns the value of a field with the given name. The second boolean
  12963. // return value indicates that this field was not set, or was not defined in the
  12964. // schema.
  12965. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  12966. switch name {
  12967. case messagerecords.FieldCreatedAt:
  12968. return m.CreatedAt()
  12969. case messagerecords.FieldUpdatedAt:
  12970. return m.UpdatedAt()
  12971. case messagerecords.FieldStatus:
  12972. return m.Status()
  12973. case messagerecords.FieldBotWxid:
  12974. return m.BotWxid()
  12975. case messagerecords.FieldContactID:
  12976. return m.ContactID()
  12977. case messagerecords.FieldContactType:
  12978. return m.ContactType()
  12979. case messagerecords.FieldContactWxid:
  12980. return m.ContactWxid()
  12981. case messagerecords.FieldContentType:
  12982. return m.ContentType()
  12983. case messagerecords.FieldContent:
  12984. return m.Content()
  12985. case messagerecords.FieldMeta:
  12986. return m.Meta()
  12987. case messagerecords.FieldErrorDetail:
  12988. return m.ErrorDetail()
  12989. case messagerecords.FieldSendTime:
  12990. return m.SendTime()
  12991. case messagerecords.FieldSourceType:
  12992. return m.SourceType()
  12993. case messagerecords.FieldSourceID:
  12994. return m.SourceID()
  12995. case messagerecords.FieldSubSourceID:
  12996. return m.SubSourceID()
  12997. case messagerecords.FieldOrganizationID:
  12998. return m.OrganizationID()
  12999. }
  13000. return nil, false
  13001. }
  13002. // OldField returns the old value of the field from the database. An error is
  13003. // returned if the mutation operation is not UpdateOne, or the query to the
  13004. // database failed.
  13005. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13006. switch name {
  13007. case messagerecords.FieldCreatedAt:
  13008. return m.OldCreatedAt(ctx)
  13009. case messagerecords.FieldUpdatedAt:
  13010. return m.OldUpdatedAt(ctx)
  13011. case messagerecords.FieldStatus:
  13012. return m.OldStatus(ctx)
  13013. case messagerecords.FieldBotWxid:
  13014. return m.OldBotWxid(ctx)
  13015. case messagerecords.FieldContactID:
  13016. return m.OldContactID(ctx)
  13017. case messagerecords.FieldContactType:
  13018. return m.OldContactType(ctx)
  13019. case messagerecords.FieldContactWxid:
  13020. return m.OldContactWxid(ctx)
  13021. case messagerecords.FieldContentType:
  13022. return m.OldContentType(ctx)
  13023. case messagerecords.FieldContent:
  13024. return m.OldContent(ctx)
  13025. case messagerecords.FieldMeta:
  13026. return m.OldMeta(ctx)
  13027. case messagerecords.FieldErrorDetail:
  13028. return m.OldErrorDetail(ctx)
  13029. case messagerecords.FieldSendTime:
  13030. return m.OldSendTime(ctx)
  13031. case messagerecords.FieldSourceType:
  13032. return m.OldSourceType(ctx)
  13033. case messagerecords.FieldSourceID:
  13034. return m.OldSourceID(ctx)
  13035. case messagerecords.FieldSubSourceID:
  13036. return m.OldSubSourceID(ctx)
  13037. case messagerecords.FieldOrganizationID:
  13038. return m.OldOrganizationID(ctx)
  13039. }
  13040. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  13041. }
  13042. // SetField sets the value of a field with the given name. It returns an error if
  13043. // the field is not defined in the schema, or if the type mismatched the field
  13044. // type.
  13045. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  13046. switch name {
  13047. case messagerecords.FieldCreatedAt:
  13048. v, ok := value.(time.Time)
  13049. if !ok {
  13050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13051. }
  13052. m.SetCreatedAt(v)
  13053. return nil
  13054. case messagerecords.FieldUpdatedAt:
  13055. v, ok := value.(time.Time)
  13056. if !ok {
  13057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13058. }
  13059. m.SetUpdatedAt(v)
  13060. return nil
  13061. case messagerecords.FieldStatus:
  13062. v, ok := value.(uint8)
  13063. if !ok {
  13064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13065. }
  13066. m.SetStatus(v)
  13067. return nil
  13068. case messagerecords.FieldBotWxid:
  13069. v, ok := value.(string)
  13070. if !ok {
  13071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13072. }
  13073. m.SetBotWxid(v)
  13074. return nil
  13075. case messagerecords.FieldContactID:
  13076. v, ok := value.(uint64)
  13077. if !ok {
  13078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13079. }
  13080. m.SetContactID(v)
  13081. return nil
  13082. case messagerecords.FieldContactType:
  13083. v, ok := value.(int)
  13084. if !ok {
  13085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13086. }
  13087. m.SetContactType(v)
  13088. return nil
  13089. case messagerecords.FieldContactWxid:
  13090. v, ok := value.(string)
  13091. if !ok {
  13092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13093. }
  13094. m.SetContactWxid(v)
  13095. return nil
  13096. case messagerecords.FieldContentType:
  13097. v, ok := value.(int)
  13098. if !ok {
  13099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13100. }
  13101. m.SetContentType(v)
  13102. return nil
  13103. case messagerecords.FieldContent:
  13104. v, ok := value.(string)
  13105. if !ok {
  13106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13107. }
  13108. m.SetContent(v)
  13109. return nil
  13110. case messagerecords.FieldMeta:
  13111. v, ok := value.(custom_types.Meta)
  13112. if !ok {
  13113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13114. }
  13115. m.SetMeta(v)
  13116. return nil
  13117. case messagerecords.FieldErrorDetail:
  13118. v, ok := value.(string)
  13119. if !ok {
  13120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13121. }
  13122. m.SetErrorDetail(v)
  13123. return nil
  13124. case messagerecords.FieldSendTime:
  13125. v, ok := value.(time.Time)
  13126. if !ok {
  13127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13128. }
  13129. m.SetSendTime(v)
  13130. return nil
  13131. case messagerecords.FieldSourceType:
  13132. v, ok := value.(int)
  13133. if !ok {
  13134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13135. }
  13136. m.SetSourceType(v)
  13137. return nil
  13138. case messagerecords.FieldSourceID:
  13139. v, ok := value.(uint64)
  13140. if !ok {
  13141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13142. }
  13143. m.SetSourceID(v)
  13144. return nil
  13145. case messagerecords.FieldSubSourceID:
  13146. v, ok := value.(uint64)
  13147. if !ok {
  13148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13149. }
  13150. m.SetSubSourceID(v)
  13151. return nil
  13152. case messagerecords.FieldOrganizationID:
  13153. v, ok := value.(uint64)
  13154. if !ok {
  13155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13156. }
  13157. m.SetOrganizationID(v)
  13158. return nil
  13159. }
  13160. return fmt.Errorf("unknown MessageRecords field %s", name)
  13161. }
  13162. // AddedFields returns all numeric fields that were incremented/decremented during
  13163. // this mutation.
  13164. func (m *MessageRecordsMutation) AddedFields() []string {
  13165. var fields []string
  13166. if m.addstatus != nil {
  13167. fields = append(fields, messagerecords.FieldStatus)
  13168. }
  13169. if m.addcontact_type != nil {
  13170. fields = append(fields, messagerecords.FieldContactType)
  13171. }
  13172. if m.addcontent_type != nil {
  13173. fields = append(fields, messagerecords.FieldContentType)
  13174. }
  13175. if m.addsource_type != nil {
  13176. fields = append(fields, messagerecords.FieldSourceType)
  13177. }
  13178. if m.addorganization_id != nil {
  13179. fields = append(fields, messagerecords.FieldOrganizationID)
  13180. }
  13181. return fields
  13182. }
  13183. // AddedField returns the numeric value that was incremented/decremented on a field
  13184. // with the given name. The second boolean return value indicates that this field
  13185. // was not set, or was not defined in the schema.
  13186. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  13187. switch name {
  13188. case messagerecords.FieldStatus:
  13189. return m.AddedStatus()
  13190. case messagerecords.FieldContactType:
  13191. return m.AddedContactType()
  13192. case messagerecords.FieldContentType:
  13193. return m.AddedContentType()
  13194. case messagerecords.FieldSourceType:
  13195. return m.AddedSourceType()
  13196. case messagerecords.FieldOrganizationID:
  13197. return m.AddedOrganizationID()
  13198. }
  13199. return nil, false
  13200. }
  13201. // AddField adds the value to the field with the given name. It returns an error if
  13202. // the field is not defined in the schema, or if the type mismatched the field
  13203. // type.
  13204. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  13205. switch name {
  13206. case messagerecords.FieldStatus:
  13207. v, ok := value.(int8)
  13208. if !ok {
  13209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13210. }
  13211. m.AddStatus(v)
  13212. return nil
  13213. case messagerecords.FieldContactType:
  13214. v, ok := value.(int)
  13215. if !ok {
  13216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13217. }
  13218. m.AddContactType(v)
  13219. return nil
  13220. case messagerecords.FieldContentType:
  13221. v, ok := value.(int)
  13222. if !ok {
  13223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13224. }
  13225. m.AddContentType(v)
  13226. return nil
  13227. case messagerecords.FieldSourceType:
  13228. v, ok := value.(int)
  13229. if !ok {
  13230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13231. }
  13232. m.AddSourceType(v)
  13233. return nil
  13234. case messagerecords.FieldOrganizationID:
  13235. v, ok := value.(int64)
  13236. if !ok {
  13237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13238. }
  13239. m.AddOrganizationID(v)
  13240. return nil
  13241. }
  13242. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  13243. }
  13244. // ClearedFields returns all nullable fields that were cleared during this
  13245. // mutation.
  13246. func (m *MessageRecordsMutation) ClearedFields() []string {
  13247. var fields []string
  13248. if m.FieldCleared(messagerecords.FieldStatus) {
  13249. fields = append(fields, messagerecords.FieldStatus)
  13250. }
  13251. if m.FieldCleared(messagerecords.FieldContactID) {
  13252. fields = append(fields, messagerecords.FieldContactID)
  13253. }
  13254. if m.FieldCleared(messagerecords.FieldMeta) {
  13255. fields = append(fields, messagerecords.FieldMeta)
  13256. }
  13257. if m.FieldCleared(messagerecords.FieldSendTime) {
  13258. fields = append(fields, messagerecords.FieldSendTime)
  13259. }
  13260. if m.FieldCleared(messagerecords.FieldSourceID) {
  13261. fields = append(fields, messagerecords.FieldSourceID)
  13262. }
  13263. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  13264. fields = append(fields, messagerecords.FieldSubSourceID)
  13265. }
  13266. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  13267. fields = append(fields, messagerecords.FieldOrganizationID)
  13268. }
  13269. return fields
  13270. }
  13271. // FieldCleared returns a boolean indicating if a field with the given name was
  13272. // cleared in this mutation.
  13273. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  13274. _, ok := m.clearedFields[name]
  13275. return ok
  13276. }
  13277. // ClearField clears the value of the field with the given name. It returns an
  13278. // error if the field is not defined in the schema.
  13279. func (m *MessageRecordsMutation) ClearField(name string) error {
  13280. switch name {
  13281. case messagerecords.FieldStatus:
  13282. m.ClearStatus()
  13283. return nil
  13284. case messagerecords.FieldContactID:
  13285. m.ClearContactID()
  13286. return nil
  13287. case messagerecords.FieldMeta:
  13288. m.ClearMeta()
  13289. return nil
  13290. case messagerecords.FieldSendTime:
  13291. m.ClearSendTime()
  13292. return nil
  13293. case messagerecords.FieldSourceID:
  13294. m.ClearSourceID()
  13295. return nil
  13296. case messagerecords.FieldSubSourceID:
  13297. m.ClearSubSourceID()
  13298. return nil
  13299. case messagerecords.FieldOrganizationID:
  13300. m.ClearOrganizationID()
  13301. return nil
  13302. }
  13303. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  13304. }
  13305. // ResetField resets all changes in the mutation for the field with the given name.
  13306. // It returns an error if the field is not defined in the schema.
  13307. func (m *MessageRecordsMutation) ResetField(name string) error {
  13308. switch name {
  13309. case messagerecords.FieldCreatedAt:
  13310. m.ResetCreatedAt()
  13311. return nil
  13312. case messagerecords.FieldUpdatedAt:
  13313. m.ResetUpdatedAt()
  13314. return nil
  13315. case messagerecords.FieldStatus:
  13316. m.ResetStatus()
  13317. return nil
  13318. case messagerecords.FieldBotWxid:
  13319. m.ResetBotWxid()
  13320. return nil
  13321. case messagerecords.FieldContactID:
  13322. m.ResetContactID()
  13323. return nil
  13324. case messagerecords.FieldContactType:
  13325. m.ResetContactType()
  13326. return nil
  13327. case messagerecords.FieldContactWxid:
  13328. m.ResetContactWxid()
  13329. return nil
  13330. case messagerecords.FieldContentType:
  13331. m.ResetContentType()
  13332. return nil
  13333. case messagerecords.FieldContent:
  13334. m.ResetContent()
  13335. return nil
  13336. case messagerecords.FieldMeta:
  13337. m.ResetMeta()
  13338. return nil
  13339. case messagerecords.FieldErrorDetail:
  13340. m.ResetErrorDetail()
  13341. return nil
  13342. case messagerecords.FieldSendTime:
  13343. m.ResetSendTime()
  13344. return nil
  13345. case messagerecords.FieldSourceType:
  13346. m.ResetSourceType()
  13347. return nil
  13348. case messagerecords.FieldSourceID:
  13349. m.ResetSourceID()
  13350. return nil
  13351. case messagerecords.FieldSubSourceID:
  13352. m.ResetSubSourceID()
  13353. return nil
  13354. case messagerecords.FieldOrganizationID:
  13355. m.ResetOrganizationID()
  13356. return nil
  13357. }
  13358. return fmt.Errorf("unknown MessageRecords field %s", name)
  13359. }
  13360. // AddedEdges returns all edge names that were set/added in this mutation.
  13361. func (m *MessageRecordsMutation) AddedEdges() []string {
  13362. edges := make([]string, 0, 3)
  13363. if m.sop_stage != nil {
  13364. edges = append(edges, messagerecords.EdgeSopStage)
  13365. }
  13366. if m.sop_node != nil {
  13367. edges = append(edges, messagerecords.EdgeSopNode)
  13368. }
  13369. if m.message_contact != nil {
  13370. edges = append(edges, messagerecords.EdgeMessageContact)
  13371. }
  13372. return edges
  13373. }
  13374. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13375. // name in this mutation.
  13376. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  13377. switch name {
  13378. case messagerecords.EdgeSopStage:
  13379. if id := m.sop_stage; id != nil {
  13380. return []ent.Value{*id}
  13381. }
  13382. case messagerecords.EdgeSopNode:
  13383. if id := m.sop_node; id != nil {
  13384. return []ent.Value{*id}
  13385. }
  13386. case messagerecords.EdgeMessageContact:
  13387. if id := m.message_contact; id != nil {
  13388. return []ent.Value{*id}
  13389. }
  13390. }
  13391. return nil
  13392. }
  13393. // RemovedEdges returns all edge names that were removed in this mutation.
  13394. func (m *MessageRecordsMutation) RemovedEdges() []string {
  13395. edges := make([]string, 0, 3)
  13396. return edges
  13397. }
  13398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13399. // the given name in this mutation.
  13400. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  13401. return nil
  13402. }
  13403. // ClearedEdges returns all edge names that were cleared in this mutation.
  13404. func (m *MessageRecordsMutation) ClearedEdges() []string {
  13405. edges := make([]string, 0, 3)
  13406. if m.clearedsop_stage {
  13407. edges = append(edges, messagerecords.EdgeSopStage)
  13408. }
  13409. if m.clearedsop_node {
  13410. edges = append(edges, messagerecords.EdgeSopNode)
  13411. }
  13412. if m.clearedmessage_contact {
  13413. edges = append(edges, messagerecords.EdgeMessageContact)
  13414. }
  13415. return edges
  13416. }
  13417. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13418. // was cleared in this mutation.
  13419. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  13420. switch name {
  13421. case messagerecords.EdgeSopStage:
  13422. return m.clearedsop_stage
  13423. case messagerecords.EdgeSopNode:
  13424. return m.clearedsop_node
  13425. case messagerecords.EdgeMessageContact:
  13426. return m.clearedmessage_contact
  13427. }
  13428. return false
  13429. }
  13430. // ClearEdge clears the value of the edge with the given name. It returns an error
  13431. // if that edge is not defined in the schema.
  13432. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  13433. switch name {
  13434. case messagerecords.EdgeSopStage:
  13435. m.ClearSopStage()
  13436. return nil
  13437. case messagerecords.EdgeSopNode:
  13438. m.ClearSopNode()
  13439. return nil
  13440. case messagerecords.EdgeMessageContact:
  13441. m.ClearMessageContact()
  13442. return nil
  13443. }
  13444. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  13445. }
  13446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13447. // It returns an error if the edge is not defined in the schema.
  13448. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  13449. switch name {
  13450. case messagerecords.EdgeSopStage:
  13451. m.ResetSopStage()
  13452. return nil
  13453. case messagerecords.EdgeSopNode:
  13454. m.ResetSopNode()
  13455. return nil
  13456. case messagerecords.EdgeMessageContact:
  13457. m.ResetMessageContact()
  13458. return nil
  13459. }
  13460. return fmt.Errorf("unknown MessageRecords edge %s", name)
  13461. }
  13462. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  13463. type MsgMutation struct {
  13464. config
  13465. op Op
  13466. typ string
  13467. id *uint64
  13468. created_at *time.Time
  13469. updated_at *time.Time
  13470. deleted_at *time.Time
  13471. status *uint8
  13472. addstatus *int8
  13473. fromwxid *string
  13474. toid *string
  13475. msgtype *int32
  13476. addmsgtype *int32
  13477. msg *string
  13478. batch_no *string
  13479. clearedFields map[string]struct{}
  13480. done bool
  13481. oldValue func(context.Context) (*Msg, error)
  13482. predicates []predicate.Msg
  13483. }
  13484. var _ ent.Mutation = (*MsgMutation)(nil)
  13485. // msgOption allows management of the mutation configuration using functional options.
  13486. type msgOption func(*MsgMutation)
  13487. // newMsgMutation creates new mutation for the Msg entity.
  13488. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  13489. m := &MsgMutation{
  13490. config: c,
  13491. op: op,
  13492. typ: TypeMsg,
  13493. clearedFields: make(map[string]struct{}),
  13494. }
  13495. for _, opt := range opts {
  13496. opt(m)
  13497. }
  13498. return m
  13499. }
  13500. // withMsgID sets the ID field of the mutation.
  13501. func withMsgID(id uint64) msgOption {
  13502. return func(m *MsgMutation) {
  13503. var (
  13504. err error
  13505. once sync.Once
  13506. value *Msg
  13507. )
  13508. m.oldValue = func(ctx context.Context) (*Msg, error) {
  13509. once.Do(func() {
  13510. if m.done {
  13511. err = errors.New("querying old values post mutation is not allowed")
  13512. } else {
  13513. value, err = m.Client().Msg.Get(ctx, id)
  13514. }
  13515. })
  13516. return value, err
  13517. }
  13518. m.id = &id
  13519. }
  13520. }
  13521. // withMsg sets the old Msg of the mutation.
  13522. func withMsg(node *Msg) msgOption {
  13523. return func(m *MsgMutation) {
  13524. m.oldValue = func(context.Context) (*Msg, error) {
  13525. return node, nil
  13526. }
  13527. m.id = &node.ID
  13528. }
  13529. }
  13530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13531. // executed in a transaction (ent.Tx), a transactional client is returned.
  13532. func (m MsgMutation) Client() *Client {
  13533. client := &Client{config: m.config}
  13534. client.init()
  13535. return client
  13536. }
  13537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13538. // it returns an error otherwise.
  13539. func (m MsgMutation) Tx() (*Tx, error) {
  13540. if _, ok := m.driver.(*txDriver); !ok {
  13541. return nil, errors.New("ent: mutation is not running in a transaction")
  13542. }
  13543. tx := &Tx{config: m.config}
  13544. tx.init()
  13545. return tx, nil
  13546. }
  13547. // SetID sets the value of the id field. Note that this
  13548. // operation is only accepted on creation of Msg entities.
  13549. func (m *MsgMutation) SetID(id uint64) {
  13550. m.id = &id
  13551. }
  13552. // ID returns the ID value in the mutation. Note that the ID is only available
  13553. // if it was provided to the builder or after it was returned from the database.
  13554. func (m *MsgMutation) ID() (id uint64, exists bool) {
  13555. if m.id == nil {
  13556. return
  13557. }
  13558. return *m.id, true
  13559. }
  13560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13561. // That means, if the mutation is applied within a transaction with an isolation level such
  13562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13563. // or updated by the mutation.
  13564. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  13565. switch {
  13566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13567. id, exists := m.ID()
  13568. if exists {
  13569. return []uint64{id}, nil
  13570. }
  13571. fallthrough
  13572. case m.op.Is(OpUpdate | OpDelete):
  13573. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  13574. default:
  13575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13576. }
  13577. }
  13578. // SetCreatedAt sets the "created_at" field.
  13579. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  13580. m.created_at = &t
  13581. }
  13582. // CreatedAt returns the value of the "created_at" field in the mutation.
  13583. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  13584. v := m.created_at
  13585. if v == nil {
  13586. return
  13587. }
  13588. return *v, true
  13589. }
  13590. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  13591. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13593. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13594. if !m.op.Is(OpUpdateOne) {
  13595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13596. }
  13597. if m.id == nil || m.oldValue == nil {
  13598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13599. }
  13600. oldValue, err := m.oldValue(ctx)
  13601. if err != nil {
  13602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13603. }
  13604. return oldValue.CreatedAt, nil
  13605. }
  13606. // ResetCreatedAt resets all changes to the "created_at" field.
  13607. func (m *MsgMutation) ResetCreatedAt() {
  13608. m.created_at = nil
  13609. }
  13610. // SetUpdatedAt sets the "updated_at" field.
  13611. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  13612. m.updated_at = &t
  13613. }
  13614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13615. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  13616. v := m.updated_at
  13617. if v == nil {
  13618. return
  13619. }
  13620. return *v, true
  13621. }
  13622. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  13623. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13625. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13626. if !m.op.Is(OpUpdateOne) {
  13627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13628. }
  13629. if m.id == nil || m.oldValue == nil {
  13630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13631. }
  13632. oldValue, err := m.oldValue(ctx)
  13633. if err != nil {
  13634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13635. }
  13636. return oldValue.UpdatedAt, nil
  13637. }
  13638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13639. func (m *MsgMutation) ResetUpdatedAt() {
  13640. m.updated_at = nil
  13641. }
  13642. // SetDeletedAt sets the "deleted_at" field.
  13643. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  13644. m.deleted_at = &t
  13645. }
  13646. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13647. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  13648. v := m.deleted_at
  13649. if v == nil {
  13650. return
  13651. }
  13652. return *v, true
  13653. }
  13654. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  13655. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13657. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13658. if !m.op.Is(OpUpdateOne) {
  13659. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13660. }
  13661. if m.id == nil || m.oldValue == nil {
  13662. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13663. }
  13664. oldValue, err := m.oldValue(ctx)
  13665. if err != nil {
  13666. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13667. }
  13668. return oldValue.DeletedAt, nil
  13669. }
  13670. // ClearDeletedAt clears the value of the "deleted_at" field.
  13671. func (m *MsgMutation) ClearDeletedAt() {
  13672. m.deleted_at = nil
  13673. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  13674. }
  13675. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13676. func (m *MsgMutation) DeletedAtCleared() bool {
  13677. _, ok := m.clearedFields[msg.FieldDeletedAt]
  13678. return ok
  13679. }
  13680. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13681. func (m *MsgMutation) ResetDeletedAt() {
  13682. m.deleted_at = nil
  13683. delete(m.clearedFields, msg.FieldDeletedAt)
  13684. }
  13685. // SetStatus sets the "status" field.
  13686. func (m *MsgMutation) SetStatus(u uint8) {
  13687. m.status = &u
  13688. m.addstatus = nil
  13689. }
  13690. // Status returns the value of the "status" field in the mutation.
  13691. func (m *MsgMutation) Status() (r uint8, exists bool) {
  13692. v := m.status
  13693. if v == nil {
  13694. return
  13695. }
  13696. return *v, true
  13697. }
  13698. // OldStatus returns the old "status" field's value of the Msg entity.
  13699. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13701. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13702. if !m.op.Is(OpUpdateOne) {
  13703. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13704. }
  13705. if m.id == nil || m.oldValue == nil {
  13706. return v, errors.New("OldStatus requires an ID field in the mutation")
  13707. }
  13708. oldValue, err := m.oldValue(ctx)
  13709. if err != nil {
  13710. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13711. }
  13712. return oldValue.Status, nil
  13713. }
  13714. // AddStatus adds u to the "status" field.
  13715. func (m *MsgMutation) AddStatus(u int8) {
  13716. if m.addstatus != nil {
  13717. *m.addstatus += u
  13718. } else {
  13719. m.addstatus = &u
  13720. }
  13721. }
  13722. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13723. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  13724. v := m.addstatus
  13725. if v == nil {
  13726. return
  13727. }
  13728. return *v, true
  13729. }
  13730. // ClearStatus clears the value of the "status" field.
  13731. func (m *MsgMutation) ClearStatus() {
  13732. m.status = nil
  13733. m.addstatus = nil
  13734. m.clearedFields[msg.FieldStatus] = struct{}{}
  13735. }
  13736. // StatusCleared returns if the "status" field was cleared in this mutation.
  13737. func (m *MsgMutation) StatusCleared() bool {
  13738. _, ok := m.clearedFields[msg.FieldStatus]
  13739. return ok
  13740. }
  13741. // ResetStatus resets all changes to the "status" field.
  13742. func (m *MsgMutation) ResetStatus() {
  13743. m.status = nil
  13744. m.addstatus = nil
  13745. delete(m.clearedFields, msg.FieldStatus)
  13746. }
  13747. // SetFromwxid sets the "fromwxid" field.
  13748. func (m *MsgMutation) SetFromwxid(s string) {
  13749. m.fromwxid = &s
  13750. }
  13751. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  13752. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  13753. v := m.fromwxid
  13754. if v == nil {
  13755. return
  13756. }
  13757. return *v, true
  13758. }
  13759. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  13760. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13762. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  13763. if !m.op.Is(OpUpdateOne) {
  13764. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  13765. }
  13766. if m.id == nil || m.oldValue == nil {
  13767. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  13768. }
  13769. oldValue, err := m.oldValue(ctx)
  13770. if err != nil {
  13771. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  13772. }
  13773. return oldValue.Fromwxid, nil
  13774. }
  13775. // ClearFromwxid clears the value of the "fromwxid" field.
  13776. func (m *MsgMutation) ClearFromwxid() {
  13777. m.fromwxid = nil
  13778. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  13779. }
  13780. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  13781. func (m *MsgMutation) FromwxidCleared() bool {
  13782. _, ok := m.clearedFields[msg.FieldFromwxid]
  13783. return ok
  13784. }
  13785. // ResetFromwxid resets all changes to the "fromwxid" field.
  13786. func (m *MsgMutation) ResetFromwxid() {
  13787. m.fromwxid = nil
  13788. delete(m.clearedFields, msg.FieldFromwxid)
  13789. }
  13790. // SetToid sets the "toid" field.
  13791. func (m *MsgMutation) SetToid(s string) {
  13792. m.toid = &s
  13793. }
  13794. // Toid returns the value of the "toid" field in the mutation.
  13795. func (m *MsgMutation) Toid() (r string, exists bool) {
  13796. v := m.toid
  13797. if v == nil {
  13798. return
  13799. }
  13800. return *v, true
  13801. }
  13802. // OldToid returns the old "toid" field's value of the Msg entity.
  13803. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13805. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  13806. if !m.op.Is(OpUpdateOne) {
  13807. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  13808. }
  13809. if m.id == nil || m.oldValue == nil {
  13810. return v, errors.New("OldToid requires an ID field in the mutation")
  13811. }
  13812. oldValue, err := m.oldValue(ctx)
  13813. if err != nil {
  13814. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  13815. }
  13816. return oldValue.Toid, nil
  13817. }
  13818. // ClearToid clears the value of the "toid" field.
  13819. func (m *MsgMutation) ClearToid() {
  13820. m.toid = nil
  13821. m.clearedFields[msg.FieldToid] = struct{}{}
  13822. }
  13823. // ToidCleared returns if the "toid" field was cleared in this mutation.
  13824. func (m *MsgMutation) ToidCleared() bool {
  13825. _, ok := m.clearedFields[msg.FieldToid]
  13826. return ok
  13827. }
  13828. // ResetToid resets all changes to the "toid" field.
  13829. func (m *MsgMutation) ResetToid() {
  13830. m.toid = nil
  13831. delete(m.clearedFields, msg.FieldToid)
  13832. }
  13833. // SetMsgtype sets the "msgtype" field.
  13834. func (m *MsgMutation) SetMsgtype(i int32) {
  13835. m.msgtype = &i
  13836. m.addmsgtype = nil
  13837. }
  13838. // Msgtype returns the value of the "msgtype" field in the mutation.
  13839. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  13840. v := m.msgtype
  13841. if v == nil {
  13842. return
  13843. }
  13844. return *v, true
  13845. }
  13846. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  13847. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13849. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  13850. if !m.op.Is(OpUpdateOne) {
  13851. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  13852. }
  13853. if m.id == nil || m.oldValue == nil {
  13854. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  13855. }
  13856. oldValue, err := m.oldValue(ctx)
  13857. if err != nil {
  13858. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  13859. }
  13860. return oldValue.Msgtype, nil
  13861. }
  13862. // AddMsgtype adds i to the "msgtype" field.
  13863. func (m *MsgMutation) AddMsgtype(i int32) {
  13864. if m.addmsgtype != nil {
  13865. *m.addmsgtype += i
  13866. } else {
  13867. m.addmsgtype = &i
  13868. }
  13869. }
  13870. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  13871. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  13872. v := m.addmsgtype
  13873. if v == nil {
  13874. return
  13875. }
  13876. return *v, true
  13877. }
  13878. // ClearMsgtype clears the value of the "msgtype" field.
  13879. func (m *MsgMutation) ClearMsgtype() {
  13880. m.msgtype = nil
  13881. m.addmsgtype = nil
  13882. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  13883. }
  13884. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  13885. func (m *MsgMutation) MsgtypeCleared() bool {
  13886. _, ok := m.clearedFields[msg.FieldMsgtype]
  13887. return ok
  13888. }
  13889. // ResetMsgtype resets all changes to the "msgtype" field.
  13890. func (m *MsgMutation) ResetMsgtype() {
  13891. m.msgtype = nil
  13892. m.addmsgtype = nil
  13893. delete(m.clearedFields, msg.FieldMsgtype)
  13894. }
  13895. // SetMsg sets the "msg" field.
  13896. func (m *MsgMutation) SetMsg(s string) {
  13897. m.msg = &s
  13898. }
  13899. // Msg returns the value of the "msg" field in the mutation.
  13900. func (m *MsgMutation) Msg() (r string, exists bool) {
  13901. v := m.msg
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // OldMsg returns the old "msg" field's value of the Msg entity.
  13908. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13910. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  13911. if !m.op.Is(OpUpdateOne) {
  13912. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  13913. }
  13914. if m.id == nil || m.oldValue == nil {
  13915. return v, errors.New("OldMsg requires an ID field in the mutation")
  13916. }
  13917. oldValue, err := m.oldValue(ctx)
  13918. if err != nil {
  13919. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  13920. }
  13921. return oldValue.Msg, nil
  13922. }
  13923. // ClearMsg clears the value of the "msg" field.
  13924. func (m *MsgMutation) ClearMsg() {
  13925. m.msg = nil
  13926. m.clearedFields[msg.FieldMsg] = struct{}{}
  13927. }
  13928. // MsgCleared returns if the "msg" field was cleared in this mutation.
  13929. func (m *MsgMutation) MsgCleared() bool {
  13930. _, ok := m.clearedFields[msg.FieldMsg]
  13931. return ok
  13932. }
  13933. // ResetMsg resets all changes to the "msg" field.
  13934. func (m *MsgMutation) ResetMsg() {
  13935. m.msg = nil
  13936. delete(m.clearedFields, msg.FieldMsg)
  13937. }
  13938. // SetBatchNo sets the "batch_no" field.
  13939. func (m *MsgMutation) SetBatchNo(s string) {
  13940. m.batch_no = &s
  13941. }
  13942. // BatchNo returns the value of the "batch_no" field in the mutation.
  13943. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  13944. v := m.batch_no
  13945. if v == nil {
  13946. return
  13947. }
  13948. return *v, true
  13949. }
  13950. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  13951. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  13952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13953. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  13954. if !m.op.Is(OpUpdateOne) {
  13955. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  13956. }
  13957. if m.id == nil || m.oldValue == nil {
  13958. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  13959. }
  13960. oldValue, err := m.oldValue(ctx)
  13961. if err != nil {
  13962. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  13963. }
  13964. return oldValue.BatchNo, nil
  13965. }
  13966. // ClearBatchNo clears the value of the "batch_no" field.
  13967. func (m *MsgMutation) ClearBatchNo() {
  13968. m.batch_no = nil
  13969. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  13970. }
  13971. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  13972. func (m *MsgMutation) BatchNoCleared() bool {
  13973. _, ok := m.clearedFields[msg.FieldBatchNo]
  13974. return ok
  13975. }
  13976. // ResetBatchNo resets all changes to the "batch_no" field.
  13977. func (m *MsgMutation) ResetBatchNo() {
  13978. m.batch_no = nil
  13979. delete(m.clearedFields, msg.FieldBatchNo)
  13980. }
  13981. // Where appends a list predicates to the MsgMutation builder.
  13982. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  13983. m.predicates = append(m.predicates, ps...)
  13984. }
  13985. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  13986. // users can use type-assertion to append predicates that do not depend on any generated package.
  13987. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  13988. p := make([]predicate.Msg, len(ps))
  13989. for i := range ps {
  13990. p[i] = ps[i]
  13991. }
  13992. m.Where(p...)
  13993. }
  13994. // Op returns the operation name.
  13995. func (m *MsgMutation) Op() Op {
  13996. return m.op
  13997. }
  13998. // SetOp allows setting the mutation operation.
  13999. func (m *MsgMutation) SetOp(op Op) {
  14000. m.op = op
  14001. }
  14002. // Type returns the node type of this mutation (Msg).
  14003. func (m *MsgMutation) Type() string {
  14004. return m.typ
  14005. }
  14006. // Fields returns all fields that were changed during this mutation. Note that in
  14007. // order to get all numeric fields that were incremented/decremented, call
  14008. // AddedFields().
  14009. func (m *MsgMutation) Fields() []string {
  14010. fields := make([]string, 0, 9)
  14011. if m.created_at != nil {
  14012. fields = append(fields, msg.FieldCreatedAt)
  14013. }
  14014. if m.updated_at != nil {
  14015. fields = append(fields, msg.FieldUpdatedAt)
  14016. }
  14017. if m.deleted_at != nil {
  14018. fields = append(fields, msg.FieldDeletedAt)
  14019. }
  14020. if m.status != nil {
  14021. fields = append(fields, msg.FieldStatus)
  14022. }
  14023. if m.fromwxid != nil {
  14024. fields = append(fields, msg.FieldFromwxid)
  14025. }
  14026. if m.toid != nil {
  14027. fields = append(fields, msg.FieldToid)
  14028. }
  14029. if m.msgtype != nil {
  14030. fields = append(fields, msg.FieldMsgtype)
  14031. }
  14032. if m.msg != nil {
  14033. fields = append(fields, msg.FieldMsg)
  14034. }
  14035. if m.batch_no != nil {
  14036. fields = append(fields, msg.FieldBatchNo)
  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 *MsgMutation) Field(name string) (ent.Value, bool) {
  14044. switch name {
  14045. case msg.FieldCreatedAt:
  14046. return m.CreatedAt()
  14047. case msg.FieldUpdatedAt:
  14048. return m.UpdatedAt()
  14049. case msg.FieldDeletedAt:
  14050. return m.DeletedAt()
  14051. case msg.FieldStatus:
  14052. return m.Status()
  14053. case msg.FieldFromwxid:
  14054. return m.Fromwxid()
  14055. case msg.FieldToid:
  14056. return m.Toid()
  14057. case msg.FieldMsgtype:
  14058. return m.Msgtype()
  14059. case msg.FieldMsg:
  14060. return m.Msg()
  14061. case msg.FieldBatchNo:
  14062. return m.BatchNo()
  14063. }
  14064. return nil, false
  14065. }
  14066. // OldField returns the old value of the field from the database. An error is
  14067. // returned if the mutation operation is not UpdateOne, or the query to the
  14068. // database failed.
  14069. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14070. switch name {
  14071. case msg.FieldCreatedAt:
  14072. return m.OldCreatedAt(ctx)
  14073. case msg.FieldUpdatedAt:
  14074. return m.OldUpdatedAt(ctx)
  14075. case msg.FieldDeletedAt:
  14076. return m.OldDeletedAt(ctx)
  14077. case msg.FieldStatus:
  14078. return m.OldStatus(ctx)
  14079. case msg.FieldFromwxid:
  14080. return m.OldFromwxid(ctx)
  14081. case msg.FieldToid:
  14082. return m.OldToid(ctx)
  14083. case msg.FieldMsgtype:
  14084. return m.OldMsgtype(ctx)
  14085. case msg.FieldMsg:
  14086. return m.OldMsg(ctx)
  14087. case msg.FieldBatchNo:
  14088. return m.OldBatchNo(ctx)
  14089. }
  14090. return nil, fmt.Errorf("unknown Msg field %s", name)
  14091. }
  14092. // SetField sets the value of a field with the given name. It returns an error if
  14093. // the field is not defined in the schema, or if the type mismatched the field
  14094. // type.
  14095. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  14096. switch name {
  14097. case msg.FieldCreatedAt:
  14098. v, ok := value.(time.Time)
  14099. if !ok {
  14100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14101. }
  14102. m.SetCreatedAt(v)
  14103. return nil
  14104. case msg.FieldUpdatedAt:
  14105. v, ok := value.(time.Time)
  14106. if !ok {
  14107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14108. }
  14109. m.SetUpdatedAt(v)
  14110. return nil
  14111. case msg.FieldDeletedAt:
  14112. v, ok := value.(time.Time)
  14113. if !ok {
  14114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14115. }
  14116. m.SetDeletedAt(v)
  14117. return nil
  14118. case msg.FieldStatus:
  14119. v, ok := value.(uint8)
  14120. if !ok {
  14121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14122. }
  14123. m.SetStatus(v)
  14124. return nil
  14125. case msg.FieldFromwxid:
  14126. v, ok := value.(string)
  14127. if !ok {
  14128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14129. }
  14130. m.SetFromwxid(v)
  14131. return nil
  14132. case msg.FieldToid:
  14133. v, ok := value.(string)
  14134. if !ok {
  14135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14136. }
  14137. m.SetToid(v)
  14138. return nil
  14139. case msg.FieldMsgtype:
  14140. v, ok := value.(int32)
  14141. if !ok {
  14142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14143. }
  14144. m.SetMsgtype(v)
  14145. return nil
  14146. case msg.FieldMsg:
  14147. v, ok := value.(string)
  14148. if !ok {
  14149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14150. }
  14151. m.SetMsg(v)
  14152. return nil
  14153. case msg.FieldBatchNo:
  14154. v, ok := value.(string)
  14155. if !ok {
  14156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14157. }
  14158. m.SetBatchNo(v)
  14159. return nil
  14160. }
  14161. return fmt.Errorf("unknown Msg field %s", name)
  14162. }
  14163. // AddedFields returns all numeric fields that were incremented/decremented during
  14164. // this mutation.
  14165. func (m *MsgMutation) AddedFields() []string {
  14166. var fields []string
  14167. if m.addstatus != nil {
  14168. fields = append(fields, msg.FieldStatus)
  14169. }
  14170. if m.addmsgtype != nil {
  14171. fields = append(fields, msg.FieldMsgtype)
  14172. }
  14173. return fields
  14174. }
  14175. // AddedField returns the numeric value that was incremented/decremented on a field
  14176. // with the given name. The second boolean return value indicates that this field
  14177. // was not set, or was not defined in the schema.
  14178. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  14179. switch name {
  14180. case msg.FieldStatus:
  14181. return m.AddedStatus()
  14182. case msg.FieldMsgtype:
  14183. return m.AddedMsgtype()
  14184. }
  14185. return nil, false
  14186. }
  14187. // AddField adds the value to the field with the given name. It returns an error if
  14188. // the field is not defined in the schema, or if the type mismatched the field
  14189. // type.
  14190. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  14191. switch name {
  14192. case msg.FieldStatus:
  14193. v, ok := value.(int8)
  14194. if !ok {
  14195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14196. }
  14197. m.AddStatus(v)
  14198. return nil
  14199. case msg.FieldMsgtype:
  14200. v, ok := value.(int32)
  14201. if !ok {
  14202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14203. }
  14204. m.AddMsgtype(v)
  14205. return nil
  14206. }
  14207. return fmt.Errorf("unknown Msg numeric field %s", name)
  14208. }
  14209. // ClearedFields returns all nullable fields that were cleared during this
  14210. // mutation.
  14211. func (m *MsgMutation) ClearedFields() []string {
  14212. var fields []string
  14213. if m.FieldCleared(msg.FieldDeletedAt) {
  14214. fields = append(fields, msg.FieldDeletedAt)
  14215. }
  14216. if m.FieldCleared(msg.FieldStatus) {
  14217. fields = append(fields, msg.FieldStatus)
  14218. }
  14219. if m.FieldCleared(msg.FieldFromwxid) {
  14220. fields = append(fields, msg.FieldFromwxid)
  14221. }
  14222. if m.FieldCleared(msg.FieldToid) {
  14223. fields = append(fields, msg.FieldToid)
  14224. }
  14225. if m.FieldCleared(msg.FieldMsgtype) {
  14226. fields = append(fields, msg.FieldMsgtype)
  14227. }
  14228. if m.FieldCleared(msg.FieldMsg) {
  14229. fields = append(fields, msg.FieldMsg)
  14230. }
  14231. if m.FieldCleared(msg.FieldBatchNo) {
  14232. fields = append(fields, msg.FieldBatchNo)
  14233. }
  14234. return fields
  14235. }
  14236. // FieldCleared returns a boolean indicating if a field with the given name was
  14237. // cleared in this mutation.
  14238. func (m *MsgMutation) FieldCleared(name string) bool {
  14239. _, ok := m.clearedFields[name]
  14240. return ok
  14241. }
  14242. // ClearField clears the value of the field with the given name. It returns an
  14243. // error if the field is not defined in the schema.
  14244. func (m *MsgMutation) ClearField(name string) error {
  14245. switch name {
  14246. case msg.FieldDeletedAt:
  14247. m.ClearDeletedAt()
  14248. return nil
  14249. case msg.FieldStatus:
  14250. m.ClearStatus()
  14251. return nil
  14252. case msg.FieldFromwxid:
  14253. m.ClearFromwxid()
  14254. return nil
  14255. case msg.FieldToid:
  14256. m.ClearToid()
  14257. return nil
  14258. case msg.FieldMsgtype:
  14259. m.ClearMsgtype()
  14260. return nil
  14261. case msg.FieldMsg:
  14262. m.ClearMsg()
  14263. return nil
  14264. case msg.FieldBatchNo:
  14265. m.ClearBatchNo()
  14266. return nil
  14267. }
  14268. return fmt.Errorf("unknown Msg nullable field %s", name)
  14269. }
  14270. // ResetField resets all changes in the mutation for the field with the given name.
  14271. // It returns an error if the field is not defined in the schema.
  14272. func (m *MsgMutation) ResetField(name string) error {
  14273. switch name {
  14274. case msg.FieldCreatedAt:
  14275. m.ResetCreatedAt()
  14276. return nil
  14277. case msg.FieldUpdatedAt:
  14278. m.ResetUpdatedAt()
  14279. return nil
  14280. case msg.FieldDeletedAt:
  14281. m.ResetDeletedAt()
  14282. return nil
  14283. case msg.FieldStatus:
  14284. m.ResetStatus()
  14285. return nil
  14286. case msg.FieldFromwxid:
  14287. m.ResetFromwxid()
  14288. return nil
  14289. case msg.FieldToid:
  14290. m.ResetToid()
  14291. return nil
  14292. case msg.FieldMsgtype:
  14293. m.ResetMsgtype()
  14294. return nil
  14295. case msg.FieldMsg:
  14296. m.ResetMsg()
  14297. return nil
  14298. case msg.FieldBatchNo:
  14299. m.ResetBatchNo()
  14300. return nil
  14301. }
  14302. return fmt.Errorf("unknown Msg field %s", name)
  14303. }
  14304. // AddedEdges returns all edge names that were set/added in this mutation.
  14305. func (m *MsgMutation) AddedEdges() []string {
  14306. edges := make([]string, 0, 0)
  14307. return edges
  14308. }
  14309. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14310. // name in this mutation.
  14311. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  14312. return nil
  14313. }
  14314. // RemovedEdges returns all edge names that were removed in this mutation.
  14315. func (m *MsgMutation) RemovedEdges() []string {
  14316. edges := make([]string, 0, 0)
  14317. return edges
  14318. }
  14319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14320. // the given name in this mutation.
  14321. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  14322. return nil
  14323. }
  14324. // ClearedEdges returns all edge names that were cleared in this mutation.
  14325. func (m *MsgMutation) ClearedEdges() []string {
  14326. edges := make([]string, 0, 0)
  14327. return edges
  14328. }
  14329. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14330. // was cleared in this mutation.
  14331. func (m *MsgMutation) EdgeCleared(name string) bool {
  14332. return false
  14333. }
  14334. // ClearEdge clears the value of the edge with the given name. It returns an error
  14335. // if that edge is not defined in the schema.
  14336. func (m *MsgMutation) ClearEdge(name string) error {
  14337. return fmt.Errorf("unknown Msg unique edge %s", name)
  14338. }
  14339. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14340. // It returns an error if the edge is not defined in the schema.
  14341. func (m *MsgMutation) ResetEdge(name string) error {
  14342. return fmt.Errorf("unknown Msg edge %s", name)
  14343. }
  14344. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  14345. type ServerMutation struct {
  14346. config
  14347. op Op
  14348. typ string
  14349. id *uint64
  14350. created_at *time.Time
  14351. updated_at *time.Time
  14352. status *uint8
  14353. addstatus *int8
  14354. deleted_at *time.Time
  14355. name *string
  14356. public_ip *string
  14357. private_ip *string
  14358. admin_port *string
  14359. clearedFields map[string]struct{}
  14360. wxs map[uint64]struct{}
  14361. removedwxs map[uint64]struct{}
  14362. clearedwxs bool
  14363. done bool
  14364. oldValue func(context.Context) (*Server, error)
  14365. predicates []predicate.Server
  14366. }
  14367. var _ ent.Mutation = (*ServerMutation)(nil)
  14368. // serverOption allows management of the mutation configuration using functional options.
  14369. type serverOption func(*ServerMutation)
  14370. // newServerMutation creates new mutation for the Server entity.
  14371. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  14372. m := &ServerMutation{
  14373. config: c,
  14374. op: op,
  14375. typ: TypeServer,
  14376. clearedFields: make(map[string]struct{}),
  14377. }
  14378. for _, opt := range opts {
  14379. opt(m)
  14380. }
  14381. return m
  14382. }
  14383. // withServerID sets the ID field of the mutation.
  14384. func withServerID(id uint64) serverOption {
  14385. return func(m *ServerMutation) {
  14386. var (
  14387. err error
  14388. once sync.Once
  14389. value *Server
  14390. )
  14391. m.oldValue = func(ctx context.Context) (*Server, error) {
  14392. once.Do(func() {
  14393. if m.done {
  14394. err = errors.New("querying old values post mutation is not allowed")
  14395. } else {
  14396. value, err = m.Client().Server.Get(ctx, id)
  14397. }
  14398. })
  14399. return value, err
  14400. }
  14401. m.id = &id
  14402. }
  14403. }
  14404. // withServer sets the old Server of the mutation.
  14405. func withServer(node *Server) serverOption {
  14406. return func(m *ServerMutation) {
  14407. m.oldValue = func(context.Context) (*Server, error) {
  14408. return node, nil
  14409. }
  14410. m.id = &node.ID
  14411. }
  14412. }
  14413. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14414. // executed in a transaction (ent.Tx), a transactional client is returned.
  14415. func (m ServerMutation) Client() *Client {
  14416. client := &Client{config: m.config}
  14417. client.init()
  14418. return client
  14419. }
  14420. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14421. // it returns an error otherwise.
  14422. func (m ServerMutation) Tx() (*Tx, error) {
  14423. if _, ok := m.driver.(*txDriver); !ok {
  14424. return nil, errors.New("ent: mutation is not running in a transaction")
  14425. }
  14426. tx := &Tx{config: m.config}
  14427. tx.init()
  14428. return tx, nil
  14429. }
  14430. // SetID sets the value of the id field. Note that this
  14431. // operation is only accepted on creation of Server entities.
  14432. func (m *ServerMutation) SetID(id uint64) {
  14433. m.id = &id
  14434. }
  14435. // ID returns the ID value in the mutation. Note that the ID is only available
  14436. // if it was provided to the builder or after it was returned from the database.
  14437. func (m *ServerMutation) ID() (id uint64, exists bool) {
  14438. if m.id == nil {
  14439. return
  14440. }
  14441. return *m.id, true
  14442. }
  14443. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14444. // That means, if the mutation is applied within a transaction with an isolation level such
  14445. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14446. // or updated by the mutation.
  14447. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  14448. switch {
  14449. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14450. id, exists := m.ID()
  14451. if exists {
  14452. return []uint64{id}, nil
  14453. }
  14454. fallthrough
  14455. case m.op.Is(OpUpdate | OpDelete):
  14456. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  14457. default:
  14458. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14459. }
  14460. }
  14461. // SetCreatedAt sets the "created_at" field.
  14462. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  14463. m.created_at = &t
  14464. }
  14465. // CreatedAt returns the value of the "created_at" field in the mutation.
  14466. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  14467. v := m.created_at
  14468. if v == nil {
  14469. return
  14470. }
  14471. return *v, true
  14472. }
  14473. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  14474. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14476. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14477. if !m.op.Is(OpUpdateOne) {
  14478. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14479. }
  14480. if m.id == nil || m.oldValue == nil {
  14481. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14482. }
  14483. oldValue, err := m.oldValue(ctx)
  14484. if err != nil {
  14485. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14486. }
  14487. return oldValue.CreatedAt, nil
  14488. }
  14489. // ResetCreatedAt resets all changes to the "created_at" field.
  14490. func (m *ServerMutation) ResetCreatedAt() {
  14491. m.created_at = nil
  14492. }
  14493. // SetUpdatedAt sets the "updated_at" field.
  14494. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  14495. m.updated_at = &t
  14496. }
  14497. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14498. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  14499. v := m.updated_at
  14500. if v == nil {
  14501. return
  14502. }
  14503. return *v, true
  14504. }
  14505. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  14506. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14508. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14509. if !m.op.Is(OpUpdateOne) {
  14510. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14511. }
  14512. if m.id == nil || m.oldValue == nil {
  14513. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14514. }
  14515. oldValue, err := m.oldValue(ctx)
  14516. if err != nil {
  14517. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14518. }
  14519. return oldValue.UpdatedAt, nil
  14520. }
  14521. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14522. func (m *ServerMutation) ResetUpdatedAt() {
  14523. m.updated_at = nil
  14524. }
  14525. // SetStatus sets the "status" field.
  14526. func (m *ServerMutation) SetStatus(u uint8) {
  14527. m.status = &u
  14528. m.addstatus = nil
  14529. }
  14530. // Status returns the value of the "status" field in the mutation.
  14531. func (m *ServerMutation) Status() (r uint8, exists bool) {
  14532. v := m.status
  14533. if v == nil {
  14534. return
  14535. }
  14536. return *v, true
  14537. }
  14538. // OldStatus returns the old "status" field's value of the Server entity.
  14539. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14541. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14542. if !m.op.Is(OpUpdateOne) {
  14543. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14544. }
  14545. if m.id == nil || m.oldValue == nil {
  14546. return v, errors.New("OldStatus requires an ID field in the mutation")
  14547. }
  14548. oldValue, err := m.oldValue(ctx)
  14549. if err != nil {
  14550. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14551. }
  14552. return oldValue.Status, nil
  14553. }
  14554. // AddStatus adds u to the "status" field.
  14555. func (m *ServerMutation) AddStatus(u int8) {
  14556. if m.addstatus != nil {
  14557. *m.addstatus += u
  14558. } else {
  14559. m.addstatus = &u
  14560. }
  14561. }
  14562. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14563. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  14564. v := m.addstatus
  14565. if v == nil {
  14566. return
  14567. }
  14568. return *v, true
  14569. }
  14570. // ClearStatus clears the value of the "status" field.
  14571. func (m *ServerMutation) ClearStatus() {
  14572. m.status = nil
  14573. m.addstatus = nil
  14574. m.clearedFields[server.FieldStatus] = struct{}{}
  14575. }
  14576. // StatusCleared returns if the "status" field was cleared in this mutation.
  14577. func (m *ServerMutation) StatusCleared() bool {
  14578. _, ok := m.clearedFields[server.FieldStatus]
  14579. return ok
  14580. }
  14581. // ResetStatus resets all changes to the "status" field.
  14582. func (m *ServerMutation) ResetStatus() {
  14583. m.status = nil
  14584. m.addstatus = nil
  14585. delete(m.clearedFields, server.FieldStatus)
  14586. }
  14587. // SetDeletedAt sets the "deleted_at" field.
  14588. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  14589. m.deleted_at = &t
  14590. }
  14591. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14592. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  14593. v := m.deleted_at
  14594. if v == nil {
  14595. return
  14596. }
  14597. return *v, true
  14598. }
  14599. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  14600. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14602. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14603. if !m.op.Is(OpUpdateOne) {
  14604. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14605. }
  14606. if m.id == nil || m.oldValue == nil {
  14607. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14608. }
  14609. oldValue, err := m.oldValue(ctx)
  14610. if err != nil {
  14611. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14612. }
  14613. return oldValue.DeletedAt, nil
  14614. }
  14615. // ClearDeletedAt clears the value of the "deleted_at" field.
  14616. func (m *ServerMutation) ClearDeletedAt() {
  14617. m.deleted_at = nil
  14618. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  14619. }
  14620. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14621. func (m *ServerMutation) DeletedAtCleared() bool {
  14622. _, ok := m.clearedFields[server.FieldDeletedAt]
  14623. return ok
  14624. }
  14625. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14626. func (m *ServerMutation) ResetDeletedAt() {
  14627. m.deleted_at = nil
  14628. delete(m.clearedFields, server.FieldDeletedAt)
  14629. }
  14630. // SetName sets the "name" field.
  14631. func (m *ServerMutation) SetName(s string) {
  14632. m.name = &s
  14633. }
  14634. // Name returns the value of the "name" field in the mutation.
  14635. func (m *ServerMutation) Name() (r string, exists bool) {
  14636. v := m.name
  14637. if v == nil {
  14638. return
  14639. }
  14640. return *v, true
  14641. }
  14642. // OldName returns the old "name" field's value of the Server entity.
  14643. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14645. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  14646. if !m.op.Is(OpUpdateOne) {
  14647. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14648. }
  14649. if m.id == nil || m.oldValue == nil {
  14650. return v, errors.New("OldName requires an ID field in the mutation")
  14651. }
  14652. oldValue, err := m.oldValue(ctx)
  14653. if err != nil {
  14654. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14655. }
  14656. return oldValue.Name, nil
  14657. }
  14658. // ResetName resets all changes to the "name" field.
  14659. func (m *ServerMutation) ResetName() {
  14660. m.name = nil
  14661. }
  14662. // SetPublicIP sets the "public_ip" field.
  14663. func (m *ServerMutation) SetPublicIP(s string) {
  14664. m.public_ip = &s
  14665. }
  14666. // PublicIP returns the value of the "public_ip" field in the mutation.
  14667. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  14668. v := m.public_ip
  14669. if v == nil {
  14670. return
  14671. }
  14672. return *v, true
  14673. }
  14674. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  14675. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14677. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  14678. if !m.op.Is(OpUpdateOne) {
  14679. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  14680. }
  14681. if m.id == nil || m.oldValue == nil {
  14682. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  14683. }
  14684. oldValue, err := m.oldValue(ctx)
  14685. if err != nil {
  14686. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  14687. }
  14688. return oldValue.PublicIP, nil
  14689. }
  14690. // ResetPublicIP resets all changes to the "public_ip" field.
  14691. func (m *ServerMutation) ResetPublicIP() {
  14692. m.public_ip = nil
  14693. }
  14694. // SetPrivateIP sets the "private_ip" field.
  14695. func (m *ServerMutation) SetPrivateIP(s string) {
  14696. m.private_ip = &s
  14697. }
  14698. // PrivateIP returns the value of the "private_ip" field in the mutation.
  14699. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  14700. v := m.private_ip
  14701. if v == nil {
  14702. return
  14703. }
  14704. return *v, true
  14705. }
  14706. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  14707. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14709. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  14710. if !m.op.Is(OpUpdateOne) {
  14711. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  14712. }
  14713. if m.id == nil || m.oldValue == nil {
  14714. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  14715. }
  14716. oldValue, err := m.oldValue(ctx)
  14717. if err != nil {
  14718. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  14719. }
  14720. return oldValue.PrivateIP, nil
  14721. }
  14722. // ResetPrivateIP resets all changes to the "private_ip" field.
  14723. func (m *ServerMutation) ResetPrivateIP() {
  14724. m.private_ip = nil
  14725. }
  14726. // SetAdminPort sets the "admin_port" field.
  14727. func (m *ServerMutation) SetAdminPort(s string) {
  14728. m.admin_port = &s
  14729. }
  14730. // AdminPort returns the value of the "admin_port" field in the mutation.
  14731. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  14732. v := m.admin_port
  14733. if v == nil {
  14734. return
  14735. }
  14736. return *v, true
  14737. }
  14738. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  14739. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  14740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14741. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  14742. if !m.op.Is(OpUpdateOne) {
  14743. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  14744. }
  14745. if m.id == nil || m.oldValue == nil {
  14746. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  14747. }
  14748. oldValue, err := m.oldValue(ctx)
  14749. if err != nil {
  14750. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  14751. }
  14752. return oldValue.AdminPort, nil
  14753. }
  14754. // ResetAdminPort resets all changes to the "admin_port" field.
  14755. func (m *ServerMutation) ResetAdminPort() {
  14756. m.admin_port = nil
  14757. }
  14758. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  14759. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  14760. if m.wxs == nil {
  14761. m.wxs = make(map[uint64]struct{})
  14762. }
  14763. for i := range ids {
  14764. m.wxs[ids[i]] = struct{}{}
  14765. }
  14766. }
  14767. // ClearWxs clears the "wxs" edge to the Wx entity.
  14768. func (m *ServerMutation) ClearWxs() {
  14769. m.clearedwxs = true
  14770. }
  14771. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  14772. func (m *ServerMutation) WxsCleared() bool {
  14773. return m.clearedwxs
  14774. }
  14775. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  14776. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  14777. if m.removedwxs == nil {
  14778. m.removedwxs = make(map[uint64]struct{})
  14779. }
  14780. for i := range ids {
  14781. delete(m.wxs, ids[i])
  14782. m.removedwxs[ids[i]] = struct{}{}
  14783. }
  14784. }
  14785. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  14786. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  14787. for id := range m.removedwxs {
  14788. ids = append(ids, id)
  14789. }
  14790. return
  14791. }
  14792. // WxsIDs returns the "wxs" edge IDs in the mutation.
  14793. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  14794. for id := range m.wxs {
  14795. ids = append(ids, id)
  14796. }
  14797. return
  14798. }
  14799. // ResetWxs resets all changes to the "wxs" edge.
  14800. func (m *ServerMutation) ResetWxs() {
  14801. m.wxs = nil
  14802. m.clearedwxs = false
  14803. m.removedwxs = nil
  14804. }
  14805. // Where appends a list predicates to the ServerMutation builder.
  14806. func (m *ServerMutation) Where(ps ...predicate.Server) {
  14807. m.predicates = append(m.predicates, ps...)
  14808. }
  14809. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  14810. // users can use type-assertion to append predicates that do not depend on any generated package.
  14811. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  14812. p := make([]predicate.Server, len(ps))
  14813. for i := range ps {
  14814. p[i] = ps[i]
  14815. }
  14816. m.Where(p...)
  14817. }
  14818. // Op returns the operation name.
  14819. func (m *ServerMutation) Op() Op {
  14820. return m.op
  14821. }
  14822. // SetOp allows setting the mutation operation.
  14823. func (m *ServerMutation) SetOp(op Op) {
  14824. m.op = op
  14825. }
  14826. // Type returns the node type of this mutation (Server).
  14827. func (m *ServerMutation) Type() string {
  14828. return m.typ
  14829. }
  14830. // Fields returns all fields that were changed during this mutation. Note that in
  14831. // order to get all numeric fields that were incremented/decremented, call
  14832. // AddedFields().
  14833. func (m *ServerMutation) Fields() []string {
  14834. fields := make([]string, 0, 8)
  14835. if m.created_at != nil {
  14836. fields = append(fields, server.FieldCreatedAt)
  14837. }
  14838. if m.updated_at != nil {
  14839. fields = append(fields, server.FieldUpdatedAt)
  14840. }
  14841. if m.status != nil {
  14842. fields = append(fields, server.FieldStatus)
  14843. }
  14844. if m.deleted_at != nil {
  14845. fields = append(fields, server.FieldDeletedAt)
  14846. }
  14847. if m.name != nil {
  14848. fields = append(fields, server.FieldName)
  14849. }
  14850. if m.public_ip != nil {
  14851. fields = append(fields, server.FieldPublicIP)
  14852. }
  14853. if m.private_ip != nil {
  14854. fields = append(fields, server.FieldPrivateIP)
  14855. }
  14856. if m.admin_port != nil {
  14857. fields = append(fields, server.FieldAdminPort)
  14858. }
  14859. return fields
  14860. }
  14861. // Field returns the value of a field with the given name. The second boolean
  14862. // return value indicates that this field was not set, or was not defined in the
  14863. // schema.
  14864. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  14865. switch name {
  14866. case server.FieldCreatedAt:
  14867. return m.CreatedAt()
  14868. case server.FieldUpdatedAt:
  14869. return m.UpdatedAt()
  14870. case server.FieldStatus:
  14871. return m.Status()
  14872. case server.FieldDeletedAt:
  14873. return m.DeletedAt()
  14874. case server.FieldName:
  14875. return m.Name()
  14876. case server.FieldPublicIP:
  14877. return m.PublicIP()
  14878. case server.FieldPrivateIP:
  14879. return m.PrivateIP()
  14880. case server.FieldAdminPort:
  14881. return m.AdminPort()
  14882. }
  14883. return nil, false
  14884. }
  14885. // OldField returns the old value of the field from the database. An error is
  14886. // returned if the mutation operation is not UpdateOne, or the query to the
  14887. // database failed.
  14888. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14889. switch name {
  14890. case server.FieldCreatedAt:
  14891. return m.OldCreatedAt(ctx)
  14892. case server.FieldUpdatedAt:
  14893. return m.OldUpdatedAt(ctx)
  14894. case server.FieldStatus:
  14895. return m.OldStatus(ctx)
  14896. case server.FieldDeletedAt:
  14897. return m.OldDeletedAt(ctx)
  14898. case server.FieldName:
  14899. return m.OldName(ctx)
  14900. case server.FieldPublicIP:
  14901. return m.OldPublicIP(ctx)
  14902. case server.FieldPrivateIP:
  14903. return m.OldPrivateIP(ctx)
  14904. case server.FieldAdminPort:
  14905. return m.OldAdminPort(ctx)
  14906. }
  14907. return nil, fmt.Errorf("unknown Server field %s", name)
  14908. }
  14909. // SetField sets the value of a field with the given name. It returns an error if
  14910. // the field is not defined in the schema, or if the type mismatched the field
  14911. // type.
  14912. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  14913. switch name {
  14914. case server.FieldCreatedAt:
  14915. v, ok := value.(time.Time)
  14916. if !ok {
  14917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14918. }
  14919. m.SetCreatedAt(v)
  14920. return nil
  14921. case server.FieldUpdatedAt:
  14922. v, ok := value.(time.Time)
  14923. if !ok {
  14924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14925. }
  14926. m.SetUpdatedAt(v)
  14927. return nil
  14928. case server.FieldStatus:
  14929. v, ok := value.(uint8)
  14930. if !ok {
  14931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14932. }
  14933. m.SetStatus(v)
  14934. return nil
  14935. case server.FieldDeletedAt:
  14936. v, ok := value.(time.Time)
  14937. if !ok {
  14938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14939. }
  14940. m.SetDeletedAt(v)
  14941. return nil
  14942. case server.FieldName:
  14943. v, ok := value.(string)
  14944. if !ok {
  14945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14946. }
  14947. m.SetName(v)
  14948. return nil
  14949. case server.FieldPublicIP:
  14950. v, ok := value.(string)
  14951. if !ok {
  14952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14953. }
  14954. m.SetPublicIP(v)
  14955. return nil
  14956. case server.FieldPrivateIP:
  14957. v, ok := value.(string)
  14958. if !ok {
  14959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14960. }
  14961. m.SetPrivateIP(v)
  14962. return nil
  14963. case server.FieldAdminPort:
  14964. v, ok := value.(string)
  14965. if !ok {
  14966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14967. }
  14968. m.SetAdminPort(v)
  14969. return nil
  14970. }
  14971. return fmt.Errorf("unknown Server field %s", name)
  14972. }
  14973. // AddedFields returns all numeric fields that were incremented/decremented during
  14974. // this mutation.
  14975. func (m *ServerMutation) AddedFields() []string {
  14976. var fields []string
  14977. if m.addstatus != nil {
  14978. fields = append(fields, server.FieldStatus)
  14979. }
  14980. return fields
  14981. }
  14982. // AddedField returns the numeric value that was incremented/decremented on a field
  14983. // with the given name. The second boolean return value indicates that this field
  14984. // was not set, or was not defined in the schema.
  14985. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  14986. switch name {
  14987. case server.FieldStatus:
  14988. return m.AddedStatus()
  14989. }
  14990. return nil, false
  14991. }
  14992. // AddField adds the value to the field with the given name. It returns an error if
  14993. // the field is not defined in the schema, or if the type mismatched the field
  14994. // type.
  14995. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  14996. switch name {
  14997. case server.FieldStatus:
  14998. v, ok := value.(int8)
  14999. if !ok {
  15000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15001. }
  15002. m.AddStatus(v)
  15003. return nil
  15004. }
  15005. return fmt.Errorf("unknown Server numeric field %s", name)
  15006. }
  15007. // ClearedFields returns all nullable fields that were cleared during this
  15008. // mutation.
  15009. func (m *ServerMutation) ClearedFields() []string {
  15010. var fields []string
  15011. if m.FieldCleared(server.FieldStatus) {
  15012. fields = append(fields, server.FieldStatus)
  15013. }
  15014. if m.FieldCleared(server.FieldDeletedAt) {
  15015. fields = append(fields, server.FieldDeletedAt)
  15016. }
  15017. return fields
  15018. }
  15019. // FieldCleared returns a boolean indicating if a field with the given name was
  15020. // cleared in this mutation.
  15021. func (m *ServerMutation) FieldCleared(name string) bool {
  15022. _, ok := m.clearedFields[name]
  15023. return ok
  15024. }
  15025. // ClearField clears the value of the field with the given name. It returns an
  15026. // error if the field is not defined in the schema.
  15027. func (m *ServerMutation) ClearField(name string) error {
  15028. switch name {
  15029. case server.FieldStatus:
  15030. m.ClearStatus()
  15031. return nil
  15032. case server.FieldDeletedAt:
  15033. m.ClearDeletedAt()
  15034. return nil
  15035. }
  15036. return fmt.Errorf("unknown Server nullable field %s", name)
  15037. }
  15038. // ResetField resets all changes in the mutation for the field with the given name.
  15039. // It returns an error if the field is not defined in the schema.
  15040. func (m *ServerMutation) ResetField(name string) error {
  15041. switch name {
  15042. case server.FieldCreatedAt:
  15043. m.ResetCreatedAt()
  15044. return nil
  15045. case server.FieldUpdatedAt:
  15046. m.ResetUpdatedAt()
  15047. return nil
  15048. case server.FieldStatus:
  15049. m.ResetStatus()
  15050. return nil
  15051. case server.FieldDeletedAt:
  15052. m.ResetDeletedAt()
  15053. return nil
  15054. case server.FieldName:
  15055. m.ResetName()
  15056. return nil
  15057. case server.FieldPublicIP:
  15058. m.ResetPublicIP()
  15059. return nil
  15060. case server.FieldPrivateIP:
  15061. m.ResetPrivateIP()
  15062. return nil
  15063. case server.FieldAdminPort:
  15064. m.ResetAdminPort()
  15065. return nil
  15066. }
  15067. return fmt.Errorf("unknown Server field %s", name)
  15068. }
  15069. // AddedEdges returns all edge names that were set/added in this mutation.
  15070. func (m *ServerMutation) AddedEdges() []string {
  15071. edges := make([]string, 0, 1)
  15072. if m.wxs != nil {
  15073. edges = append(edges, server.EdgeWxs)
  15074. }
  15075. return edges
  15076. }
  15077. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15078. // name in this mutation.
  15079. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  15080. switch name {
  15081. case server.EdgeWxs:
  15082. ids := make([]ent.Value, 0, len(m.wxs))
  15083. for id := range m.wxs {
  15084. ids = append(ids, id)
  15085. }
  15086. return ids
  15087. }
  15088. return nil
  15089. }
  15090. // RemovedEdges returns all edge names that were removed in this mutation.
  15091. func (m *ServerMutation) RemovedEdges() []string {
  15092. edges := make([]string, 0, 1)
  15093. if m.removedwxs != nil {
  15094. edges = append(edges, server.EdgeWxs)
  15095. }
  15096. return edges
  15097. }
  15098. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15099. // the given name in this mutation.
  15100. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  15101. switch name {
  15102. case server.EdgeWxs:
  15103. ids := make([]ent.Value, 0, len(m.removedwxs))
  15104. for id := range m.removedwxs {
  15105. ids = append(ids, id)
  15106. }
  15107. return ids
  15108. }
  15109. return nil
  15110. }
  15111. // ClearedEdges returns all edge names that were cleared in this mutation.
  15112. func (m *ServerMutation) ClearedEdges() []string {
  15113. edges := make([]string, 0, 1)
  15114. if m.clearedwxs {
  15115. edges = append(edges, server.EdgeWxs)
  15116. }
  15117. return edges
  15118. }
  15119. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15120. // was cleared in this mutation.
  15121. func (m *ServerMutation) EdgeCleared(name string) bool {
  15122. switch name {
  15123. case server.EdgeWxs:
  15124. return m.clearedwxs
  15125. }
  15126. return false
  15127. }
  15128. // ClearEdge clears the value of the edge with the given name. It returns an error
  15129. // if that edge is not defined in the schema.
  15130. func (m *ServerMutation) ClearEdge(name string) error {
  15131. switch name {
  15132. }
  15133. return fmt.Errorf("unknown Server unique edge %s", name)
  15134. }
  15135. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15136. // It returns an error if the edge is not defined in the schema.
  15137. func (m *ServerMutation) ResetEdge(name string) error {
  15138. switch name {
  15139. case server.EdgeWxs:
  15140. m.ResetWxs()
  15141. return nil
  15142. }
  15143. return fmt.Errorf("unknown Server edge %s", name)
  15144. }
  15145. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  15146. type SopNodeMutation struct {
  15147. config
  15148. op Op
  15149. typ string
  15150. id *uint64
  15151. created_at *time.Time
  15152. updated_at *time.Time
  15153. status *uint8
  15154. addstatus *int8
  15155. deleted_at *time.Time
  15156. parent_id *uint64
  15157. addparent_id *int64
  15158. name *string
  15159. condition_type *int
  15160. addcondition_type *int
  15161. condition_list *[]string
  15162. appendcondition_list []string
  15163. no_reply_condition *uint64
  15164. addno_reply_condition *int64
  15165. no_reply_unit *string
  15166. action_message *[]custom_types.Action
  15167. appendaction_message []custom_types.Action
  15168. action_label_add *[]uint64
  15169. appendaction_label_add []uint64
  15170. action_label_del *[]uint64
  15171. appendaction_label_del []uint64
  15172. action_forward **custom_types.ActionForward
  15173. clearedFields map[string]struct{}
  15174. sop_stage *uint64
  15175. clearedsop_stage bool
  15176. node_messages map[uint64]struct{}
  15177. removednode_messages map[uint64]struct{}
  15178. clearednode_messages bool
  15179. done bool
  15180. oldValue func(context.Context) (*SopNode, error)
  15181. predicates []predicate.SopNode
  15182. }
  15183. var _ ent.Mutation = (*SopNodeMutation)(nil)
  15184. // sopnodeOption allows management of the mutation configuration using functional options.
  15185. type sopnodeOption func(*SopNodeMutation)
  15186. // newSopNodeMutation creates new mutation for the SopNode entity.
  15187. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  15188. m := &SopNodeMutation{
  15189. config: c,
  15190. op: op,
  15191. typ: TypeSopNode,
  15192. clearedFields: make(map[string]struct{}),
  15193. }
  15194. for _, opt := range opts {
  15195. opt(m)
  15196. }
  15197. return m
  15198. }
  15199. // withSopNodeID sets the ID field of the mutation.
  15200. func withSopNodeID(id uint64) sopnodeOption {
  15201. return func(m *SopNodeMutation) {
  15202. var (
  15203. err error
  15204. once sync.Once
  15205. value *SopNode
  15206. )
  15207. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  15208. once.Do(func() {
  15209. if m.done {
  15210. err = errors.New("querying old values post mutation is not allowed")
  15211. } else {
  15212. value, err = m.Client().SopNode.Get(ctx, id)
  15213. }
  15214. })
  15215. return value, err
  15216. }
  15217. m.id = &id
  15218. }
  15219. }
  15220. // withSopNode sets the old SopNode of the mutation.
  15221. func withSopNode(node *SopNode) sopnodeOption {
  15222. return func(m *SopNodeMutation) {
  15223. m.oldValue = func(context.Context) (*SopNode, error) {
  15224. return node, nil
  15225. }
  15226. m.id = &node.ID
  15227. }
  15228. }
  15229. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15230. // executed in a transaction (ent.Tx), a transactional client is returned.
  15231. func (m SopNodeMutation) Client() *Client {
  15232. client := &Client{config: m.config}
  15233. client.init()
  15234. return client
  15235. }
  15236. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15237. // it returns an error otherwise.
  15238. func (m SopNodeMutation) Tx() (*Tx, error) {
  15239. if _, ok := m.driver.(*txDriver); !ok {
  15240. return nil, errors.New("ent: mutation is not running in a transaction")
  15241. }
  15242. tx := &Tx{config: m.config}
  15243. tx.init()
  15244. return tx, nil
  15245. }
  15246. // SetID sets the value of the id field. Note that this
  15247. // operation is only accepted on creation of SopNode entities.
  15248. func (m *SopNodeMutation) SetID(id uint64) {
  15249. m.id = &id
  15250. }
  15251. // ID returns the ID value in the mutation. Note that the ID is only available
  15252. // if it was provided to the builder or after it was returned from the database.
  15253. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  15254. if m.id == nil {
  15255. return
  15256. }
  15257. return *m.id, true
  15258. }
  15259. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15260. // That means, if the mutation is applied within a transaction with an isolation level such
  15261. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15262. // or updated by the mutation.
  15263. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15264. switch {
  15265. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15266. id, exists := m.ID()
  15267. if exists {
  15268. return []uint64{id}, nil
  15269. }
  15270. fallthrough
  15271. case m.op.Is(OpUpdate | OpDelete):
  15272. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  15273. default:
  15274. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15275. }
  15276. }
  15277. // SetCreatedAt sets the "created_at" field.
  15278. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  15279. m.created_at = &t
  15280. }
  15281. // CreatedAt returns the value of the "created_at" field in the mutation.
  15282. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  15283. v := m.created_at
  15284. if v == nil {
  15285. return
  15286. }
  15287. return *v, true
  15288. }
  15289. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  15290. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15292. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15293. if !m.op.Is(OpUpdateOne) {
  15294. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15295. }
  15296. if m.id == nil || m.oldValue == nil {
  15297. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15298. }
  15299. oldValue, err := m.oldValue(ctx)
  15300. if err != nil {
  15301. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15302. }
  15303. return oldValue.CreatedAt, nil
  15304. }
  15305. // ResetCreatedAt resets all changes to the "created_at" field.
  15306. func (m *SopNodeMutation) ResetCreatedAt() {
  15307. m.created_at = nil
  15308. }
  15309. // SetUpdatedAt sets the "updated_at" field.
  15310. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  15311. m.updated_at = &t
  15312. }
  15313. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15314. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  15315. v := m.updated_at
  15316. if v == nil {
  15317. return
  15318. }
  15319. return *v, true
  15320. }
  15321. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  15322. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15324. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15325. if !m.op.Is(OpUpdateOne) {
  15326. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15327. }
  15328. if m.id == nil || m.oldValue == nil {
  15329. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15330. }
  15331. oldValue, err := m.oldValue(ctx)
  15332. if err != nil {
  15333. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15334. }
  15335. return oldValue.UpdatedAt, nil
  15336. }
  15337. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15338. func (m *SopNodeMutation) ResetUpdatedAt() {
  15339. m.updated_at = nil
  15340. }
  15341. // SetStatus sets the "status" field.
  15342. func (m *SopNodeMutation) SetStatus(u uint8) {
  15343. m.status = &u
  15344. m.addstatus = nil
  15345. }
  15346. // Status returns the value of the "status" field in the mutation.
  15347. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  15348. v := m.status
  15349. if v == nil {
  15350. return
  15351. }
  15352. return *v, true
  15353. }
  15354. // OldStatus returns the old "status" field's value of the SopNode entity.
  15355. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15357. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15358. if !m.op.Is(OpUpdateOne) {
  15359. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15360. }
  15361. if m.id == nil || m.oldValue == nil {
  15362. return v, errors.New("OldStatus requires an ID field in the mutation")
  15363. }
  15364. oldValue, err := m.oldValue(ctx)
  15365. if err != nil {
  15366. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15367. }
  15368. return oldValue.Status, nil
  15369. }
  15370. // AddStatus adds u to the "status" field.
  15371. func (m *SopNodeMutation) AddStatus(u int8) {
  15372. if m.addstatus != nil {
  15373. *m.addstatus += u
  15374. } else {
  15375. m.addstatus = &u
  15376. }
  15377. }
  15378. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15379. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  15380. v := m.addstatus
  15381. if v == nil {
  15382. return
  15383. }
  15384. return *v, true
  15385. }
  15386. // ClearStatus clears the value of the "status" field.
  15387. func (m *SopNodeMutation) ClearStatus() {
  15388. m.status = nil
  15389. m.addstatus = nil
  15390. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  15391. }
  15392. // StatusCleared returns if the "status" field was cleared in this mutation.
  15393. func (m *SopNodeMutation) StatusCleared() bool {
  15394. _, ok := m.clearedFields[sopnode.FieldStatus]
  15395. return ok
  15396. }
  15397. // ResetStatus resets all changes to the "status" field.
  15398. func (m *SopNodeMutation) ResetStatus() {
  15399. m.status = nil
  15400. m.addstatus = nil
  15401. delete(m.clearedFields, sopnode.FieldStatus)
  15402. }
  15403. // SetDeletedAt sets the "deleted_at" field.
  15404. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  15405. m.deleted_at = &t
  15406. }
  15407. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15408. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  15409. v := m.deleted_at
  15410. if v == nil {
  15411. return
  15412. }
  15413. return *v, true
  15414. }
  15415. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  15416. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15418. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15419. if !m.op.Is(OpUpdateOne) {
  15420. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15421. }
  15422. if m.id == nil || m.oldValue == nil {
  15423. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15424. }
  15425. oldValue, err := m.oldValue(ctx)
  15426. if err != nil {
  15427. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15428. }
  15429. return oldValue.DeletedAt, nil
  15430. }
  15431. // ClearDeletedAt clears the value of the "deleted_at" field.
  15432. func (m *SopNodeMutation) ClearDeletedAt() {
  15433. m.deleted_at = nil
  15434. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  15435. }
  15436. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15437. func (m *SopNodeMutation) DeletedAtCleared() bool {
  15438. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  15439. return ok
  15440. }
  15441. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15442. func (m *SopNodeMutation) ResetDeletedAt() {
  15443. m.deleted_at = nil
  15444. delete(m.clearedFields, sopnode.FieldDeletedAt)
  15445. }
  15446. // SetStageID sets the "stage_id" field.
  15447. func (m *SopNodeMutation) SetStageID(u uint64) {
  15448. m.sop_stage = &u
  15449. }
  15450. // StageID returns the value of the "stage_id" field in the mutation.
  15451. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  15452. v := m.sop_stage
  15453. if v == nil {
  15454. return
  15455. }
  15456. return *v, true
  15457. }
  15458. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  15459. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15461. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  15462. if !m.op.Is(OpUpdateOne) {
  15463. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  15464. }
  15465. if m.id == nil || m.oldValue == nil {
  15466. return v, errors.New("OldStageID requires an ID field in the mutation")
  15467. }
  15468. oldValue, err := m.oldValue(ctx)
  15469. if err != nil {
  15470. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  15471. }
  15472. return oldValue.StageID, nil
  15473. }
  15474. // ResetStageID resets all changes to the "stage_id" field.
  15475. func (m *SopNodeMutation) ResetStageID() {
  15476. m.sop_stage = nil
  15477. }
  15478. // SetParentID sets the "parent_id" field.
  15479. func (m *SopNodeMutation) SetParentID(u uint64) {
  15480. m.parent_id = &u
  15481. m.addparent_id = nil
  15482. }
  15483. // ParentID returns the value of the "parent_id" field in the mutation.
  15484. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  15485. v := m.parent_id
  15486. if v == nil {
  15487. return
  15488. }
  15489. return *v, true
  15490. }
  15491. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  15492. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15494. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  15495. if !m.op.Is(OpUpdateOne) {
  15496. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  15497. }
  15498. if m.id == nil || m.oldValue == nil {
  15499. return v, errors.New("OldParentID requires an ID field in the mutation")
  15500. }
  15501. oldValue, err := m.oldValue(ctx)
  15502. if err != nil {
  15503. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  15504. }
  15505. return oldValue.ParentID, nil
  15506. }
  15507. // AddParentID adds u to the "parent_id" field.
  15508. func (m *SopNodeMutation) AddParentID(u int64) {
  15509. if m.addparent_id != nil {
  15510. *m.addparent_id += u
  15511. } else {
  15512. m.addparent_id = &u
  15513. }
  15514. }
  15515. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  15516. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  15517. v := m.addparent_id
  15518. if v == nil {
  15519. return
  15520. }
  15521. return *v, true
  15522. }
  15523. // ResetParentID resets all changes to the "parent_id" field.
  15524. func (m *SopNodeMutation) ResetParentID() {
  15525. m.parent_id = nil
  15526. m.addparent_id = nil
  15527. }
  15528. // SetName sets the "name" field.
  15529. func (m *SopNodeMutation) SetName(s string) {
  15530. m.name = &s
  15531. }
  15532. // Name returns the value of the "name" field in the mutation.
  15533. func (m *SopNodeMutation) Name() (r string, exists bool) {
  15534. v := m.name
  15535. if v == nil {
  15536. return
  15537. }
  15538. return *v, true
  15539. }
  15540. // OldName returns the old "name" field's value of the SopNode entity.
  15541. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15543. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  15544. if !m.op.Is(OpUpdateOne) {
  15545. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15546. }
  15547. if m.id == nil || m.oldValue == nil {
  15548. return v, errors.New("OldName requires an ID field in the mutation")
  15549. }
  15550. oldValue, err := m.oldValue(ctx)
  15551. if err != nil {
  15552. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15553. }
  15554. return oldValue.Name, nil
  15555. }
  15556. // ResetName resets all changes to the "name" field.
  15557. func (m *SopNodeMutation) ResetName() {
  15558. m.name = nil
  15559. }
  15560. // SetConditionType sets the "condition_type" field.
  15561. func (m *SopNodeMutation) SetConditionType(i int) {
  15562. m.condition_type = &i
  15563. m.addcondition_type = nil
  15564. }
  15565. // ConditionType returns the value of the "condition_type" field in the mutation.
  15566. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  15567. v := m.condition_type
  15568. if v == nil {
  15569. return
  15570. }
  15571. return *v, true
  15572. }
  15573. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  15574. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15576. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  15577. if !m.op.Is(OpUpdateOne) {
  15578. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  15579. }
  15580. if m.id == nil || m.oldValue == nil {
  15581. return v, errors.New("OldConditionType requires an ID field in the mutation")
  15582. }
  15583. oldValue, err := m.oldValue(ctx)
  15584. if err != nil {
  15585. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  15586. }
  15587. return oldValue.ConditionType, nil
  15588. }
  15589. // AddConditionType adds i to the "condition_type" field.
  15590. func (m *SopNodeMutation) AddConditionType(i int) {
  15591. if m.addcondition_type != nil {
  15592. *m.addcondition_type += i
  15593. } else {
  15594. m.addcondition_type = &i
  15595. }
  15596. }
  15597. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  15598. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  15599. v := m.addcondition_type
  15600. if v == nil {
  15601. return
  15602. }
  15603. return *v, true
  15604. }
  15605. // ResetConditionType resets all changes to the "condition_type" field.
  15606. func (m *SopNodeMutation) ResetConditionType() {
  15607. m.condition_type = nil
  15608. m.addcondition_type = nil
  15609. }
  15610. // SetConditionList sets the "condition_list" field.
  15611. func (m *SopNodeMutation) SetConditionList(s []string) {
  15612. m.condition_list = &s
  15613. m.appendcondition_list = nil
  15614. }
  15615. // ConditionList returns the value of the "condition_list" field in the mutation.
  15616. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  15617. v := m.condition_list
  15618. if v == nil {
  15619. return
  15620. }
  15621. return *v, true
  15622. }
  15623. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  15624. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15626. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  15627. if !m.op.Is(OpUpdateOne) {
  15628. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  15629. }
  15630. if m.id == nil || m.oldValue == nil {
  15631. return v, errors.New("OldConditionList requires an ID field in the mutation")
  15632. }
  15633. oldValue, err := m.oldValue(ctx)
  15634. if err != nil {
  15635. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  15636. }
  15637. return oldValue.ConditionList, nil
  15638. }
  15639. // AppendConditionList adds s to the "condition_list" field.
  15640. func (m *SopNodeMutation) AppendConditionList(s []string) {
  15641. m.appendcondition_list = append(m.appendcondition_list, s...)
  15642. }
  15643. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  15644. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  15645. if len(m.appendcondition_list) == 0 {
  15646. return nil, false
  15647. }
  15648. return m.appendcondition_list, true
  15649. }
  15650. // ClearConditionList clears the value of the "condition_list" field.
  15651. func (m *SopNodeMutation) ClearConditionList() {
  15652. m.condition_list = nil
  15653. m.appendcondition_list = nil
  15654. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  15655. }
  15656. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  15657. func (m *SopNodeMutation) ConditionListCleared() bool {
  15658. _, ok := m.clearedFields[sopnode.FieldConditionList]
  15659. return ok
  15660. }
  15661. // ResetConditionList resets all changes to the "condition_list" field.
  15662. func (m *SopNodeMutation) ResetConditionList() {
  15663. m.condition_list = nil
  15664. m.appendcondition_list = nil
  15665. delete(m.clearedFields, sopnode.FieldConditionList)
  15666. }
  15667. // SetNoReplyCondition sets the "no_reply_condition" field.
  15668. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  15669. m.no_reply_condition = &u
  15670. m.addno_reply_condition = nil
  15671. }
  15672. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  15673. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  15674. v := m.no_reply_condition
  15675. if v == nil {
  15676. return
  15677. }
  15678. return *v, true
  15679. }
  15680. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  15681. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15683. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  15684. if !m.op.Is(OpUpdateOne) {
  15685. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  15686. }
  15687. if m.id == nil || m.oldValue == nil {
  15688. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  15689. }
  15690. oldValue, err := m.oldValue(ctx)
  15691. if err != nil {
  15692. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  15693. }
  15694. return oldValue.NoReplyCondition, nil
  15695. }
  15696. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  15697. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  15698. if m.addno_reply_condition != nil {
  15699. *m.addno_reply_condition += u
  15700. } else {
  15701. m.addno_reply_condition = &u
  15702. }
  15703. }
  15704. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  15705. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  15706. v := m.addno_reply_condition
  15707. if v == nil {
  15708. return
  15709. }
  15710. return *v, true
  15711. }
  15712. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  15713. func (m *SopNodeMutation) ResetNoReplyCondition() {
  15714. m.no_reply_condition = nil
  15715. m.addno_reply_condition = nil
  15716. }
  15717. // SetNoReplyUnit sets the "no_reply_unit" field.
  15718. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  15719. m.no_reply_unit = &s
  15720. }
  15721. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  15722. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  15723. v := m.no_reply_unit
  15724. if v == nil {
  15725. return
  15726. }
  15727. return *v, true
  15728. }
  15729. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  15730. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15732. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  15733. if !m.op.Is(OpUpdateOne) {
  15734. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  15735. }
  15736. if m.id == nil || m.oldValue == nil {
  15737. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  15738. }
  15739. oldValue, err := m.oldValue(ctx)
  15740. if err != nil {
  15741. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  15742. }
  15743. return oldValue.NoReplyUnit, nil
  15744. }
  15745. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  15746. func (m *SopNodeMutation) ResetNoReplyUnit() {
  15747. m.no_reply_unit = nil
  15748. }
  15749. // SetActionMessage sets the "action_message" field.
  15750. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  15751. m.action_message = &ct
  15752. m.appendaction_message = nil
  15753. }
  15754. // ActionMessage returns the value of the "action_message" field in the mutation.
  15755. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  15756. v := m.action_message
  15757. if v == nil {
  15758. return
  15759. }
  15760. return *v, true
  15761. }
  15762. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  15763. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15765. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  15766. if !m.op.Is(OpUpdateOne) {
  15767. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  15768. }
  15769. if m.id == nil || m.oldValue == nil {
  15770. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  15771. }
  15772. oldValue, err := m.oldValue(ctx)
  15773. if err != nil {
  15774. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  15775. }
  15776. return oldValue.ActionMessage, nil
  15777. }
  15778. // AppendActionMessage adds ct to the "action_message" field.
  15779. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  15780. m.appendaction_message = append(m.appendaction_message, ct...)
  15781. }
  15782. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  15783. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  15784. if len(m.appendaction_message) == 0 {
  15785. return nil, false
  15786. }
  15787. return m.appendaction_message, true
  15788. }
  15789. // ClearActionMessage clears the value of the "action_message" field.
  15790. func (m *SopNodeMutation) ClearActionMessage() {
  15791. m.action_message = nil
  15792. m.appendaction_message = nil
  15793. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  15794. }
  15795. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  15796. func (m *SopNodeMutation) ActionMessageCleared() bool {
  15797. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  15798. return ok
  15799. }
  15800. // ResetActionMessage resets all changes to the "action_message" field.
  15801. func (m *SopNodeMutation) ResetActionMessage() {
  15802. m.action_message = nil
  15803. m.appendaction_message = nil
  15804. delete(m.clearedFields, sopnode.FieldActionMessage)
  15805. }
  15806. // SetActionLabelAdd sets the "action_label_add" field.
  15807. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  15808. m.action_label_add = &u
  15809. m.appendaction_label_add = nil
  15810. }
  15811. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15812. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15813. v := m.action_label_add
  15814. if v == nil {
  15815. return
  15816. }
  15817. return *v, true
  15818. }
  15819. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  15820. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15822. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15823. if !m.op.Is(OpUpdateOne) {
  15824. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15825. }
  15826. if m.id == nil || m.oldValue == nil {
  15827. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15828. }
  15829. oldValue, err := m.oldValue(ctx)
  15830. if err != nil {
  15831. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15832. }
  15833. return oldValue.ActionLabelAdd, nil
  15834. }
  15835. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15836. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  15837. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15838. }
  15839. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15840. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15841. if len(m.appendaction_label_add) == 0 {
  15842. return nil, false
  15843. }
  15844. return m.appendaction_label_add, true
  15845. }
  15846. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15847. func (m *SopNodeMutation) ClearActionLabelAdd() {
  15848. m.action_label_add = nil
  15849. m.appendaction_label_add = nil
  15850. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  15851. }
  15852. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15853. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  15854. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  15855. return ok
  15856. }
  15857. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15858. func (m *SopNodeMutation) ResetActionLabelAdd() {
  15859. m.action_label_add = nil
  15860. m.appendaction_label_add = nil
  15861. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  15862. }
  15863. // SetActionLabelDel sets the "action_label_del" field.
  15864. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  15865. m.action_label_del = &u
  15866. m.appendaction_label_del = nil
  15867. }
  15868. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15869. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  15870. v := m.action_label_del
  15871. if v == nil {
  15872. return
  15873. }
  15874. return *v, true
  15875. }
  15876. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  15877. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15879. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15880. if !m.op.Is(OpUpdateOne) {
  15881. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15882. }
  15883. if m.id == nil || m.oldValue == nil {
  15884. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15885. }
  15886. oldValue, err := m.oldValue(ctx)
  15887. if err != nil {
  15888. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15889. }
  15890. return oldValue.ActionLabelDel, nil
  15891. }
  15892. // AppendActionLabelDel adds u to the "action_label_del" field.
  15893. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  15894. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15895. }
  15896. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15897. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15898. if len(m.appendaction_label_del) == 0 {
  15899. return nil, false
  15900. }
  15901. return m.appendaction_label_del, true
  15902. }
  15903. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15904. func (m *SopNodeMutation) ClearActionLabelDel() {
  15905. m.action_label_del = nil
  15906. m.appendaction_label_del = nil
  15907. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  15908. }
  15909. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15910. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  15911. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  15912. return ok
  15913. }
  15914. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15915. func (m *SopNodeMutation) ResetActionLabelDel() {
  15916. m.action_label_del = nil
  15917. m.appendaction_label_del = nil
  15918. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  15919. }
  15920. // SetActionForward sets the "action_forward" field.
  15921. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  15922. m.action_forward = &ctf
  15923. }
  15924. // ActionForward returns the value of the "action_forward" field in the mutation.
  15925. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  15926. v := m.action_forward
  15927. if v == nil {
  15928. return
  15929. }
  15930. return *v, true
  15931. }
  15932. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  15933. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  15934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15935. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  15936. if !m.op.Is(OpUpdateOne) {
  15937. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  15938. }
  15939. if m.id == nil || m.oldValue == nil {
  15940. return v, errors.New("OldActionForward requires an ID field in the mutation")
  15941. }
  15942. oldValue, err := m.oldValue(ctx)
  15943. if err != nil {
  15944. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  15945. }
  15946. return oldValue.ActionForward, nil
  15947. }
  15948. // ClearActionForward clears the value of the "action_forward" field.
  15949. func (m *SopNodeMutation) ClearActionForward() {
  15950. m.action_forward = nil
  15951. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  15952. }
  15953. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  15954. func (m *SopNodeMutation) ActionForwardCleared() bool {
  15955. _, ok := m.clearedFields[sopnode.FieldActionForward]
  15956. return ok
  15957. }
  15958. // ResetActionForward resets all changes to the "action_forward" field.
  15959. func (m *SopNodeMutation) ResetActionForward() {
  15960. m.action_forward = nil
  15961. delete(m.clearedFields, sopnode.FieldActionForward)
  15962. }
  15963. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  15964. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  15965. m.sop_stage = &id
  15966. }
  15967. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  15968. func (m *SopNodeMutation) ClearSopStage() {
  15969. m.clearedsop_stage = true
  15970. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  15971. }
  15972. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  15973. func (m *SopNodeMutation) SopStageCleared() bool {
  15974. return m.clearedsop_stage
  15975. }
  15976. // SopStageID returns the "sop_stage" edge ID in the mutation.
  15977. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  15978. if m.sop_stage != nil {
  15979. return *m.sop_stage, true
  15980. }
  15981. return
  15982. }
  15983. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  15984. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15985. // SopStageID instead. It exists only for internal usage by the builders.
  15986. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  15987. if id := m.sop_stage; id != nil {
  15988. ids = append(ids, *id)
  15989. }
  15990. return
  15991. }
  15992. // ResetSopStage resets all changes to the "sop_stage" edge.
  15993. func (m *SopNodeMutation) ResetSopStage() {
  15994. m.sop_stage = nil
  15995. m.clearedsop_stage = false
  15996. }
  15997. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  15998. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  15999. if m.node_messages == nil {
  16000. m.node_messages = make(map[uint64]struct{})
  16001. }
  16002. for i := range ids {
  16003. m.node_messages[ids[i]] = struct{}{}
  16004. }
  16005. }
  16006. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  16007. func (m *SopNodeMutation) ClearNodeMessages() {
  16008. m.clearednode_messages = true
  16009. }
  16010. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  16011. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  16012. return m.clearednode_messages
  16013. }
  16014. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  16015. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  16016. if m.removednode_messages == nil {
  16017. m.removednode_messages = make(map[uint64]struct{})
  16018. }
  16019. for i := range ids {
  16020. delete(m.node_messages, ids[i])
  16021. m.removednode_messages[ids[i]] = struct{}{}
  16022. }
  16023. }
  16024. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  16025. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  16026. for id := range m.removednode_messages {
  16027. ids = append(ids, id)
  16028. }
  16029. return
  16030. }
  16031. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  16032. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  16033. for id := range m.node_messages {
  16034. ids = append(ids, id)
  16035. }
  16036. return
  16037. }
  16038. // ResetNodeMessages resets all changes to the "node_messages" edge.
  16039. func (m *SopNodeMutation) ResetNodeMessages() {
  16040. m.node_messages = nil
  16041. m.clearednode_messages = false
  16042. m.removednode_messages = nil
  16043. }
  16044. // Where appends a list predicates to the SopNodeMutation builder.
  16045. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  16046. m.predicates = append(m.predicates, ps...)
  16047. }
  16048. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  16049. // users can use type-assertion to append predicates that do not depend on any generated package.
  16050. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  16051. p := make([]predicate.SopNode, len(ps))
  16052. for i := range ps {
  16053. p[i] = ps[i]
  16054. }
  16055. m.Where(p...)
  16056. }
  16057. // Op returns the operation name.
  16058. func (m *SopNodeMutation) Op() Op {
  16059. return m.op
  16060. }
  16061. // SetOp allows setting the mutation operation.
  16062. func (m *SopNodeMutation) SetOp(op Op) {
  16063. m.op = op
  16064. }
  16065. // Type returns the node type of this mutation (SopNode).
  16066. func (m *SopNodeMutation) Type() string {
  16067. return m.typ
  16068. }
  16069. // Fields returns all fields that were changed during this mutation. Note that in
  16070. // order to get all numeric fields that were incremented/decremented, call
  16071. // AddedFields().
  16072. func (m *SopNodeMutation) Fields() []string {
  16073. fields := make([]string, 0, 15)
  16074. if m.created_at != nil {
  16075. fields = append(fields, sopnode.FieldCreatedAt)
  16076. }
  16077. if m.updated_at != nil {
  16078. fields = append(fields, sopnode.FieldUpdatedAt)
  16079. }
  16080. if m.status != nil {
  16081. fields = append(fields, sopnode.FieldStatus)
  16082. }
  16083. if m.deleted_at != nil {
  16084. fields = append(fields, sopnode.FieldDeletedAt)
  16085. }
  16086. if m.sop_stage != nil {
  16087. fields = append(fields, sopnode.FieldStageID)
  16088. }
  16089. if m.parent_id != nil {
  16090. fields = append(fields, sopnode.FieldParentID)
  16091. }
  16092. if m.name != nil {
  16093. fields = append(fields, sopnode.FieldName)
  16094. }
  16095. if m.condition_type != nil {
  16096. fields = append(fields, sopnode.FieldConditionType)
  16097. }
  16098. if m.condition_list != nil {
  16099. fields = append(fields, sopnode.FieldConditionList)
  16100. }
  16101. if m.no_reply_condition != nil {
  16102. fields = append(fields, sopnode.FieldNoReplyCondition)
  16103. }
  16104. if m.no_reply_unit != nil {
  16105. fields = append(fields, sopnode.FieldNoReplyUnit)
  16106. }
  16107. if m.action_message != nil {
  16108. fields = append(fields, sopnode.FieldActionMessage)
  16109. }
  16110. if m.action_label_add != nil {
  16111. fields = append(fields, sopnode.FieldActionLabelAdd)
  16112. }
  16113. if m.action_label_del != nil {
  16114. fields = append(fields, sopnode.FieldActionLabelDel)
  16115. }
  16116. if m.action_forward != nil {
  16117. fields = append(fields, sopnode.FieldActionForward)
  16118. }
  16119. return fields
  16120. }
  16121. // Field returns the value of a field with the given name. The second boolean
  16122. // return value indicates that this field was not set, or was not defined in the
  16123. // schema.
  16124. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  16125. switch name {
  16126. case sopnode.FieldCreatedAt:
  16127. return m.CreatedAt()
  16128. case sopnode.FieldUpdatedAt:
  16129. return m.UpdatedAt()
  16130. case sopnode.FieldStatus:
  16131. return m.Status()
  16132. case sopnode.FieldDeletedAt:
  16133. return m.DeletedAt()
  16134. case sopnode.FieldStageID:
  16135. return m.StageID()
  16136. case sopnode.FieldParentID:
  16137. return m.ParentID()
  16138. case sopnode.FieldName:
  16139. return m.Name()
  16140. case sopnode.FieldConditionType:
  16141. return m.ConditionType()
  16142. case sopnode.FieldConditionList:
  16143. return m.ConditionList()
  16144. case sopnode.FieldNoReplyCondition:
  16145. return m.NoReplyCondition()
  16146. case sopnode.FieldNoReplyUnit:
  16147. return m.NoReplyUnit()
  16148. case sopnode.FieldActionMessage:
  16149. return m.ActionMessage()
  16150. case sopnode.FieldActionLabelAdd:
  16151. return m.ActionLabelAdd()
  16152. case sopnode.FieldActionLabelDel:
  16153. return m.ActionLabelDel()
  16154. case sopnode.FieldActionForward:
  16155. return m.ActionForward()
  16156. }
  16157. return nil, false
  16158. }
  16159. // OldField returns the old value of the field from the database. An error is
  16160. // returned if the mutation operation is not UpdateOne, or the query to the
  16161. // database failed.
  16162. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16163. switch name {
  16164. case sopnode.FieldCreatedAt:
  16165. return m.OldCreatedAt(ctx)
  16166. case sopnode.FieldUpdatedAt:
  16167. return m.OldUpdatedAt(ctx)
  16168. case sopnode.FieldStatus:
  16169. return m.OldStatus(ctx)
  16170. case sopnode.FieldDeletedAt:
  16171. return m.OldDeletedAt(ctx)
  16172. case sopnode.FieldStageID:
  16173. return m.OldStageID(ctx)
  16174. case sopnode.FieldParentID:
  16175. return m.OldParentID(ctx)
  16176. case sopnode.FieldName:
  16177. return m.OldName(ctx)
  16178. case sopnode.FieldConditionType:
  16179. return m.OldConditionType(ctx)
  16180. case sopnode.FieldConditionList:
  16181. return m.OldConditionList(ctx)
  16182. case sopnode.FieldNoReplyCondition:
  16183. return m.OldNoReplyCondition(ctx)
  16184. case sopnode.FieldNoReplyUnit:
  16185. return m.OldNoReplyUnit(ctx)
  16186. case sopnode.FieldActionMessage:
  16187. return m.OldActionMessage(ctx)
  16188. case sopnode.FieldActionLabelAdd:
  16189. return m.OldActionLabelAdd(ctx)
  16190. case sopnode.FieldActionLabelDel:
  16191. return m.OldActionLabelDel(ctx)
  16192. case sopnode.FieldActionForward:
  16193. return m.OldActionForward(ctx)
  16194. }
  16195. return nil, fmt.Errorf("unknown SopNode field %s", name)
  16196. }
  16197. // SetField sets the value of a field with the given name. It returns an error if
  16198. // the field is not defined in the schema, or if the type mismatched the field
  16199. // type.
  16200. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  16201. switch name {
  16202. case sopnode.FieldCreatedAt:
  16203. v, ok := value.(time.Time)
  16204. if !ok {
  16205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16206. }
  16207. m.SetCreatedAt(v)
  16208. return nil
  16209. case sopnode.FieldUpdatedAt:
  16210. v, ok := value.(time.Time)
  16211. if !ok {
  16212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16213. }
  16214. m.SetUpdatedAt(v)
  16215. return nil
  16216. case sopnode.FieldStatus:
  16217. v, ok := value.(uint8)
  16218. if !ok {
  16219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16220. }
  16221. m.SetStatus(v)
  16222. return nil
  16223. case sopnode.FieldDeletedAt:
  16224. v, ok := value.(time.Time)
  16225. if !ok {
  16226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16227. }
  16228. m.SetDeletedAt(v)
  16229. return nil
  16230. case sopnode.FieldStageID:
  16231. v, ok := value.(uint64)
  16232. if !ok {
  16233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16234. }
  16235. m.SetStageID(v)
  16236. return nil
  16237. case sopnode.FieldParentID:
  16238. v, ok := value.(uint64)
  16239. if !ok {
  16240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16241. }
  16242. m.SetParentID(v)
  16243. return nil
  16244. case sopnode.FieldName:
  16245. v, ok := value.(string)
  16246. if !ok {
  16247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16248. }
  16249. m.SetName(v)
  16250. return nil
  16251. case sopnode.FieldConditionType:
  16252. v, ok := value.(int)
  16253. if !ok {
  16254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16255. }
  16256. m.SetConditionType(v)
  16257. return nil
  16258. case sopnode.FieldConditionList:
  16259. v, ok := value.([]string)
  16260. if !ok {
  16261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16262. }
  16263. m.SetConditionList(v)
  16264. return nil
  16265. case sopnode.FieldNoReplyCondition:
  16266. v, ok := value.(uint64)
  16267. if !ok {
  16268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16269. }
  16270. m.SetNoReplyCondition(v)
  16271. return nil
  16272. case sopnode.FieldNoReplyUnit:
  16273. v, ok := value.(string)
  16274. if !ok {
  16275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16276. }
  16277. m.SetNoReplyUnit(v)
  16278. return nil
  16279. case sopnode.FieldActionMessage:
  16280. v, ok := value.([]custom_types.Action)
  16281. if !ok {
  16282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16283. }
  16284. m.SetActionMessage(v)
  16285. return nil
  16286. case sopnode.FieldActionLabelAdd:
  16287. v, ok := value.([]uint64)
  16288. if !ok {
  16289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16290. }
  16291. m.SetActionLabelAdd(v)
  16292. return nil
  16293. case sopnode.FieldActionLabelDel:
  16294. v, ok := value.([]uint64)
  16295. if !ok {
  16296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16297. }
  16298. m.SetActionLabelDel(v)
  16299. return nil
  16300. case sopnode.FieldActionForward:
  16301. v, ok := value.(*custom_types.ActionForward)
  16302. if !ok {
  16303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16304. }
  16305. m.SetActionForward(v)
  16306. return nil
  16307. }
  16308. return fmt.Errorf("unknown SopNode field %s", name)
  16309. }
  16310. // AddedFields returns all numeric fields that were incremented/decremented during
  16311. // this mutation.
  16312. func (m *SopNodeMutation) AddedFields() []string {
  16313. var fields []string
  16314. if m.addstatus != nil {
  16315. fields = append(fields, sopnode.FieldStatus)
  16316. }
  16317. if m.addparent_id != nil {
  16318. fields = append(fields, sopnode.FieldParentID)
  16319. }
  16320. if m.addcondition_type != nil {
  16321. fields = append(fields, sopnode.FieldConditionType)
  16322. }
  16323. if m.addno_reply_condition != nil {
  16324. fields = append(fields, sopnode.FieldNoReplyCondition)
  16325. }
  16326. return fields
  16327. }
  16328. // AddedField returns the numeric value that was incremented/decremented on a field
  16329. // with the given name. The second boolean return value indicates that this field
  16330. // was not set, or was not defined in the schema.
  16331. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  16332. switch name {
  16333. case sopnode.FieldStatus:
  16334. return m.AddedStatus()
  16335. case sopnode.FieldParentID:
  16336. return m.AddedParentID()
  16337. case sopnode.FieldConditionType:
  16338. return m.AddedConditionType()
  16339. case sopnode.FieldNoReplyCondition:
  16340. return m.AddedNoReplyCondition()
  16341. }
  16342. return nil, false
  16343. }
  16344. // AddField adds the value to the field with the given name. It returns an error if
  16345. // the field is not defined in the schema, or if the type mismatched the field
  16346. // type.
  16347. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  16348. switch name {
  16349. case sopnode.FieldStatus:
  16350. v, ok := value.(int8)
  16351. if !ok {
  16352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16353. }
  16354. m.AddStatus(v)
  16355. return nil
  16356. case sopnode.FieldParentID:
  16357. v, ok := value.(int64)
  16358. if !ok {
  16359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16360. }
  16361. m.AddParentID(v)
  16362. return nil
  16363. case sopnode.FieldConditionType:
  16364. v, ok := value.(int)
  16365. if !ok {
  16366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16367. }
  16368. m.AddConditionType(v)
  16369. return nil
  16370. case sopnode.FieldNoReplyCondition:
  16371. v, ok := value.(int64)
  16372. if !ok {
  16373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16374. }
  16375. m.AddNoReplyCondition(v)
  16376. return nil
  16377. }
  16378. return fmt.Errorf("unknown SopNode numeric field %s", name)
  16379. }
  16380. // ClearedFields returns all nullable fields that were cleared during this
  16381. // mutation.
  16382. func (m *SopNodeMutation) ClearedFields() []string {
  16383. var fields []string
  16384. if m.FieldCleared(sopnode.FieldStatus) {
  16385. fields = append(fields, sopnode.FieldStatus)
  16386. }
  16387. if m.FieldCleared(sopnode.FieldDeletedAt) {
  16388. fields = append(fields, sopnode.FieldDeletedAt)
  16389. }
  16390. if m.FieldCleared(sopnode.FieldConditionList) {
  16391. fields = append(fields, sopnode.FieldConditionList)
  16392. }
  16393. if m.FieldCleared(sopnode.FieldActionMessage) {
  16394. fields = append(fields, sopnode.FieldActionMessage)
  16395. }
  16396. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  16397. fields = append(fields, sopnode.FieldActionLabelAdd)
  16398. }
  16399. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  16400. fields = append(fields, sopnode.FieldActionLabelDel)
  16401. }
  16402. if m.FieldCleared(sopnode.FieldActionForward) {
  16403. fields = append(fields, sopnode.FieldActionForward)
  16404. }
  16405. return fields
  16406. }
  16407. // FieldCleared returns a boolean indicating if a field with the given name was
  16408. // cleared in this mutation.
  16409. func (m *SopNodeMutation) FieldCleared(name string) bool {
  16410. _, ok := m.clearedFields[name]
  16411. return ok
  16412. }
  16413. // ClearField clears the value of the field with the given name. It returns an
  16414. // error if the field is not defined in the schema.
  16415. func (m *SopNodeMutation) ClearField(name string) error {
  16416. switch name {
  16417. case sopnode.FieldStatus:
  16418. m.ClearStatus()
  16419. return nil
  16420. case sopnode.FieldDeletedAt:
  16421. m.ClearDeletedAt()
  16422. return nil
  16423. case sopnode.FieldConditionList:
  16424. m.ClearConditionList()
  16425. return nil
  16426. case sopnode.FieldActionMessage:
  16427. m.ClearActionMessage()
  16428. return nil
  16429. case sopnode.FieldActionLabelAdd:
  16430. m.ClearActionLabelAdd()
  16431. return nil
  16432. case sopnode.FieldActionLabelDel:
  16433. m.ClearActionLabelDel()
  16434. return nil
  16435. case sopnode.FieldActionForward:
  16436. m.ClearActionForward()
  16437. return nil
  16438. }
  16439. return fmt.Errorf("unknown SopNode nullable field %s", name)
  16440. }
  16441. // ResetField resets all changes in the mutation for the field with the given name.
  16442. // It returns an error if the field is not defined in the schema.
  16443. func (m *SopNodeMutation) ResetField(name string) error {
  16444. switch name {
  16445. case sopnode.FieldCreatedAt:
  16446. m.ResetCreatedAt()
  16447. return nil
  16448. case sopnode.FieldUpdatedAt:
  16449. m.ResetUpdatedAt()
  16450. return nil
  16451. case sopnode.FieldStatus:
  16452. m.ResetStatus()
  16453. return nil
  16454. case sopnode.FieldDeletedAt:
  16455. m.ResetDeletedAt()
  16456. return nil
  16457. case sopnode.FieldStageID:
  16458. m.ResetStageID()
  16459. return nil
  16460. case sopnode.FieldParentID:
  16461. m.ResetParentID()
  16462. return nil
  16463. case sopnode.FieldName:
  16464. m.ResetName()
  16465. return nil
  16466. case sopnode.FieldConditionType:
  16467. m.ResetConditionType()
  16468. return nil
  16469. case sopnode.FieldConditionList:
  16470. m.ResetConditionList()
  16471. return nil
  16472. case sopnode.FieldNoReplyCondition:
  16473. m.ResetNoReplyCondition()
  16474. return nil
  16475. case sopnode.FieldNoReplyUnit:
  16476. m.ResetNoReplyUnit()
  16477. return nil
  16478. case sopnode.FieldActionMessage:
  16479. m.ResetActionMessage()
  16480. return nil
  16481. case sopnode.FieldActionLabelAdd:
  16482. m.ResetActionLabelAdd()
  16483. return nil
  16484. case sopnode.FieldActionLabelDel:
  16485. m.ResetActionLabelDel()
  16486. return nil
  16487. case sopnode.FieldActionForward:
  16488. m.ResetActionForward()
  16489. return nil
  16490. }
  16491. return fmt.Errorf("unknown SopNode field %s", name)
  16492. }
  16493. // AddedEdges returns all edge names that were set/added in this mutation.
  16494. func (m *SopNodeMutation) AddedEdges() []string {
  16495. edges := make([]string, 0, 2)
  16496. if m.sop_stage != nil {
  16497. edges = append(edges, sopnode.EdgeSopStage)
  16498. }
  16499. if m.node_messages != nil {
  16500. edges = append(edges, sopnode.EdgeNodeMessages)
  16501. }
  16502. return edges
  16503. }
  16504. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16505. // name in this mutation.
  16506. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  16507. switch name {
  16508. case sopnode.EdgeSopStage:
  16509. if id := m.sop_stage; id != nil {
  16510. return []ent.Value{*id}
  16511. }
  16512. case sopnode.EdgeNodeMessages:
  16513. ids := make([]ent.Value, 0, len(m.node_messages))
  16514. for id := range m.node_messages {
  16515. ids = append(ids, id)
  16516. }
  16517. return ids
  16518. }
  16519. return nil
  16520. }
  16521. // RemovedEdges returns all edge names that were removed in this mutation.
  16522. func (m *SopNodeMutation) RemovedEdges() []string {
  16523. edges := make([]string, 0, 2)
  16524. if m.removednode_messages != nil {
  16525. edges = append(edges, sopnode.EdgeNodeMessages)
  16526. }
  16527. return edges
  16528. }
  16529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16530. // the given name in this mutation.
  16531. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  16532. switch name {
  16533. case sopnode.EdgeNodeMessages:
  16534. ids := make([]ent.Value, 0, len(m.removednode_messages))
  16535. for id := range m.removednode_messages {
  16536. ids = append(ids, id)
  16537. }
  16538. return ids
  16539. }
  16540. return nil
  16541. }
  16542. // ClearedEdges returns all edge names that were cleared in this mutation.
  16543. func (m *SopNodeMutation) ClearedEdges() []string {
  16544. edges := make([]string, 0, 2)
  16545. if m.clearedsop_stage {
  16546. edges = append(edges, sopnode.EdgeSopStage)
  16547. }
  16548. if m.clearednode_messages {
  16549. edges = append(edges, sopnode.EdgeNodeMessages)
  16550. }
  16551. return edges
  16552. }
  16553. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16554. // was cleared in this mutation.
  16555. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  16556. switch name {
  16557. case sopnode.EdgeSopStage:
  16558. return m.clearedsop_stage
  16559. case sopnode.EdgeNodeMessages:
  16560. return m.clearednode_messages
  16561. }
  16562. return false
  16563. }
  16564. // ClearEdge clears the value of the edge with the given name. It returns an error
  16565. // if that edge is not defined in the schema.
  16566. func (m *SopNodeMutation) ClearEdge(name string) error {
  16567. switch name {
  16568. case sopnode.EdgeSopStage:
  16569. m.ClearSopStage()
  16570. return nil
  16571. }
  16572. return fmt.Errorf("unknown SopNode unique edge %s", name)
  16573. }
  16574. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16575. // It returns an error if the edge is not defined in the schema.
  16576. func (m *SopNodeMutation) ResetEdge(name string) error {
  16577. switch name {
  16578. case sopnode.EdgeSopStage:
  16579. m.ResetSopStage()
  16580. return nil
  16581. case sopnode.EdgeNodeMessages:
  16582. m.ResetNodeMessages()
  16583. return nil
  16584. }
  16585. return fmt.Errorf("unknown SopNode edge %s", name)
  16586. }
  16587. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  16588. type SopStageMutation struct {
  16589. config
  16590. op Op
  16591. typ string
  16592. id *uint64
  16593. created_at *time.Time
  16594. updated_at *time.Time
  16595. status *uint8
  16596. addstatus *int8
  16597. deleted_at *time.Time
  16598. name *string
  16599. condition_type *int
  16600. addcondition_type *int
  16601. condition_operator *int
  16602. addcondition_operator *int
  16603. condition_list *[]custom_types.Condition
  16604. appendcondition_list []custom_types.Condition
  16605. action_message *[]custom_types.Action
  16606. appendaction_message []custom_types.Action
  16607. action_label_add *[]uint64
  16608. appendaction_label_add []uint64
  16609. action_label_del *[]uint64
  16610. appendaction_label_del []uint64
  16611. action_forward **custom_types.ActionForward
  16612. index_sort *int
  16613. addindex_sort *int
  16614. clearedFields map[string]struct{}
  16615. sop_task *uint64
  16616. clearedsop_task bool
  16617. stage_nodes map[uint64]struct{}
  16618. removedstage_nodes map[uint64]struct{}
  16619. clearedstage_nodes bool
  16620. stage_messages map[uint64]struct{}
  16621. removedstage_messages map[uint64]struct{}
  16622. clearedstage_messages bool
  16623. done bool
  16624. oldValue func(context.Context) (*SopStage, error)
  16625. predicates []predicate.SopStage
  16626. }
  16627. var _ ent.Mutation = (*SopStageMutation)(nil)
  16628. // sopstageOption allows management of the mutation configuration using functional options.
  16629. type sopstageOption func(*SopStageMutation)
  16630. // newSopStageMutation creates new mutation for the SopStage entity.
  16631. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  16632. m := &SopStageMutation{
  16633. config: c,
  16634. op: op,
  16635. typ: TypeSopStage,
  16636. clearedFields: make(map[string]struct{}),
  16637. }
  16638. for _, opt := range opts {
  16639. opt(m)
  16640. }
  16641. return m
  16642. }
  16643. // withSopStageID sets the ID field of the mutation.
  16644. func withSopStageID(id uint64) sopstageOption {
  16645. return func(m *SopStageMutation) {
  16646. var (
  16647. err error
  16648. once sync.Once
  16649. value *SopStage
  16650. )
  16651. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  16652. once.Do(func() {
  16653. if m.done {
  16654. err = errors.New("querying old values post mutation is not allowed")
  16655. } else {
  16656. value, err = m.Client().SopStage.Get(ctx, id)
  16657. }
  16658. })
  16659. return value, err
  16660. }
  16661. m.id = &id
  16662. }
  16663. }
  16664. // withSopStage sets the old SopStage of the mutation.
  16665. func withSopStage(node *SopStage) sopstageOption {
  16666. return func(m *SopStageMutation) {
  16667. m.oldValue = func(context.Context) (*SopStage, error) {
  16668. return node, nil
  16669. }
  16670. m.id = &node.ID
  16671. }
  16672. }
  16673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16674. // executed in a transaction (ent.Tx), a transactional client is returned.
  16675. func (m SopStageMutation) Client() *Client {
  16676. client := &Client{config: m.config}
  16677. client.init()
  16678. return client
  16679. }
  16680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16681. // it returns an error otherwise.
  16682. func (m SopStageMutation) Tx() (*Tx, error) {
  16683. if _, ok := m.driver.(*txDriver); !ok {
  16684. return nil, errors.New("ent: mutation is not running in a transaction")
  16685. }
  16686. tx := &Tx{config: m.config}
  16687. tx.init()
  16688. return tx, nil
  16689. }
  16690. // SetID sets the value of the id field. Note that this
  16691. // operation is only accepted on creation of SopStage entities.
  16692. func (m *SopStageMutation) SetID(id uint64) {
  16693. m.id = &id
  16694. }
  16695. // ID returns the ID value in the mutation. Note that the ID is only available
  16696. // if it was provided to the builder or after it was returned from the database.
  16697. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  16698. if m.id == nil {
  16699. return
  16700. }
  16701. return *m.id, true
  16702. }
  16703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16704. // That means, if the mutation is applied within a transaction with an isolation level such
  16705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16706. // or updated by the mutation.
  16707. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16708. switch {
  16709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16710. id, exists := m.ID()
  16711. if exists {
  16712. return []uint64{id}, nil
  16713. }
  16714. fallthrough
  16715. case m.op.Is(OpUpdate | OpDelete):
  16716. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  16717. default:
  16718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16719. }
  16720. }
  16721. // SetCreatedAt sets the "created_at" field.
  16722. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  16723. m.created_at = &t
  16724. }
  16725. // CreatedAt returns the value of the "created_at" field in the mutation.
  16726. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  16727. v := m.created_at
  16728. if v == nil {
  16729. return
  16730. }
  16731. return *v, true
  16732. }
  16733. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  16734. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16736. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16737. if !m.op.Is(OpUpdateOne) {
  16738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16739. }
  16740. if m.id == nil || m.oldValue == nil {
  16741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16742. }
  16743. oldValue, err := m.oldValue(ctx)
  16744. if err != nil {
  16745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16746. }
  16747. return oldValue.CreatedAt, nil
  16748. }
  16749. // ResetCreatedAt resets all changes to the "created_at" field.
  16750. func (m *SopStageMutation) ResetCreatedAt() {
  16751. m.created_at = nil
  16752. }
  16753. // SetUpdatedAt sets the "updated_at" field.
  16754. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  16755. m.updated_at = &t
  16756. }
  16757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16758. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  16759. v := m.updated_at
  16760. if v == nil {
  16761. return
  16762. }
  16763. return *v, true
  16764. }
  16765. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  16766. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16768. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16769. if !m.op.Is(OpUpdateOne) {
  16770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16771. }
  16772. if m.id == nil || m.oldValue == nil {
  16773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16774. }
  16775. oldValue, err := m.oldValue(ctx)
  16776. if err != nil {
  16777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16778. }
  16779. return oldValue.UpdatedAt, nil
  16780. }
  16781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16782. func (m *SopStageMutation) ResetUpdatedAt() {
  16783. m.updated_at = nil
  16784. }
  16785. // SetStatus sets the "status" field.
  16786. func (m *SopStageMutation) SetStatus(u uint8) {
  16787. m.status = &u
  16788. m.addstatus = nil
  16789. }
  16790. // Status returns the value of the "status" field in the mutation.
  16791. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  16792. v := m.status
  16793. if v == nil {
  16794. return
  16795. }
  16796. return *v, true
  16797. }
  16798. // OldStatus returns the old "status" field's value of the SopStage entity.
  16799. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16801. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16802. if !m.op.Is(OpUpdateOne) {
  16803. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16804. }
  16805. if m.id == nil || m.oldValue == nil {
  16806. return v, errors.New("OldStatus requires an ID field in the mutation")
  16807. }
  16808. oldValue, err := m.oldValue(ctx)
  16809. if err != nil {
  16810. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16811. }
  16812. return oldValue.Status, nil
  16813. }
  16814. // AddStatus adds u to the "status" field.
  16815. func (m *SopStageMutation) AddStatus(u int8) {
  16816. if m.addstatus != nil {
  16817. *m.addstatus += u
  16818. } else {
  16819. m.addstatus = &u
  16820. }
  16821. }
  16822. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16823. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  16824. v := m.addstatus
  16825. if v == nil {
  16826. return
  16827. }
  16828. return *v, true
  16829. }
  16830. // ClearStatus clears the value of the "status" field.
  16831. func (m *SopStageMutation) ClearStatus() {
  16832. m.status = nil
  16833. m.addstatus = nil
  16834. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  16835. }
  16836. // StatusCleared returns if the "status" field was cleared in this mutation.
  16837. func (m *SopStageMutation) StatusCleared() bool {
  16838. _, ok := m.clearedFields[sopstage.FieldStatus]
  16839. return ok
  16840. }
  16841. // ResetStatus resets all changes to the "status" field.
  16842. func (m *SopStageMutation) ResetStatus() {
  16843. m.status = nil
  16844. m.addstatus = nil
  16845. delete(m.clearedFields, sopstage.FieldStatus)
  16846. }
  16847. // SetDeletedAt sets the "deleted_at" field.
  16848. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  16849. m.deleted_at = &t
  16850. }
  16851. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16852. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  16853. v := m.deleted_at
  16854. if v == nil {
  16855. return
  16856. }
  16857. return *v, true
  16858. }
  16859. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  16860. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16862. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16863. if !m.op.Is(OpUpdateOne) {
  16864. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16865. }
  16866. if m.id == nil || m.oldValue == nil {
  16867. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16868. }
  16869. oldValue, err := m.oldValue(ctx)
  16870. if err != nil {
  16871. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16872. }
  16873. return oldValue.DeletedAt, nil
  16874. }
  16875. // ClearDeletedAt clears the value of the "deleted_at" field.
  16876. func (m *SopStageMutation) ClearDeletedAt() {
  16877. m.deleted_at = nil
  16878. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  16879. }
  16880. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16881. func (m *SopStageMutation) DeletedAtCleared() bool {
  16882. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  16883. return ok
  16884. }
  16885. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16886. func (m *SopStageMutation) ResetDeletedAt() {
  16887. m.deleted_at = nil
  16888. delete(m.clearedFields, sopstage.FieldDeletedAt)
  16889. }
  16890. // SetTaskID sets the "task_id" field.
  16891. func (m *SopStageMutation) SetTaskID(u uint64) {
  16892. m.sop_task = &u
  16893. }
  16894. // TaskID returns the value of the "task_id" field in the mutation.
  16895. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  16896. v := m.sop_task
  16897. if v == nil {
  16898. return
  16899. }
  16900. return *v, true
  16901. }
  16902. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  16903. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16905. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  16906. if !m.op.Is(OpUpdateOne) {
  16907. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  16908. }
  16909. if m.id == nil || m.oldValue == nil {
  16910. return v, errors.New("OldTaskID requires an ID field in the mutation")
  16911. }
  16912. oldValue, err := m.oldValue(ctx)
  16913. if err != nil {
  16914. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  16915. }
  16916. return oldValue.TaskID, nil
  16917. }
  16918. // ResetTaskID resets all changes to the "task_id" field.
  16919. func (m *SopStageMutation) ResetTaskID() {
  16920. m.sop_task = nil
  16921. }
  16922. // SetName sets the "name" field.
  16923. func (m *SopStageMutation) SetName(s string) {
  16924. m.name = &s
  16925. }
  16926. // Name returns the value of the "name" field in the mutation.
  16927. func (m *SopStageMutation) Name() (r string, exists bool) {
  16928. v := m.name
  16929. if v == nil {
  16930. return
  16931. }
  16932. return *v, true
  16933. }
  16934. // OldName returns the old "name" field's value of the SopStage entity.
  16935. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16937. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  16938. if !m.op.Is(OpUpdateOne) {
  16939. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16940. }
  16941. if m.id == nil || m.oldValue == nil {
  16942. return v, errors.New("OldName requires an ID field in the mutation")
  16943. }
  16944. oldValue, err := m.oldValue(ctx)
  16945. if err != nil {
  16946. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16947. }
  16948. return oldValue.Name, nil
  16949. }
  16950. // ResetName resets all changes to the "name" field.
  16951. func (m *SopStageMutation) ResetName() {
  16952. m.name = nil
  16953. }
  16954. // SetConditionType sets the "condition_type" field.
  16955. func (m *SopStageMutation) SetConditionType(i int) {
  16956. m.condition_type = &i
  16957. m.addcondition_type = nil
  16958. }
  16959. // ConditionType returns the value of the "condition_type" field in the mutation.
  16960. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  16961. v := m.condition_type
  16962. if v == nil {
  16963. return
  16964. }
  16965. return *v, true
  16966. }
  16967. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  16968. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  16969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16970. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16971. if !m.op.Is(OpUpdateOne) {
  16972. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16973. }
  16974. if m.id == nil || m.oldValue == nil {
  16975. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16976. }
  16977. oldValue, err := m.oldValue(ctx)
  16978. if err != nil {
  16979. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16980. }
  16981. return oldValue.ConditionType, nil
  16982. }
  16983. // AddConditionType adds i to the "condition_type" field.
  16984. func (m *SopStageMutation) AddConditionType(i int) {
  16985. if m.addcondition_type != nil {
  16986. *m.addcondition_type += i
  16987. } else {
  16988. m.addcondition_type = &i
  16989. }
  16990. }
  16991. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16992. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  16993. v := m.addcondition_type
  16994. if v == nil {
  16995. return
  16996. }
  16997. return *v, true
  16998. }
  16999. // ResetConditionType resets all changes to the "condition_type" field.
  17000. func (m *SopStageMutation) ResetConditionType() {
  17001. m.condition_type = nil
  17002. m.addcondition_type = nil
  17003. }
  17004. // SetConditionOperator sets the "condition_operator" field.
  17005. func (m *SopStageMutation) SetConditionOperator(i int) {
  17006. m.condition_operator = &i
  17007. m.addcondition_operator = nil
  17008. }
  17009. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  17010. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  17011. v := m.condition_operator
  17012. if v == nil {
  17013. return
  17014. }
  17015. return *v, true
  17016. }
  17017. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  17018. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17020. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  17021. if !m.op.Is(OpUpdateOne) {
  17022. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  17023. }
  17024. if m.id == nil || m.oldValue == nil {
  17025. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  17026. }
  17027. oldValue, err := m.oldValue(ctx)
  17028. if err != nil {
  17029. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  17030. }
  17031. return oldValue.ConditionOperator, nil
  17032. }
  17033. // AddConditionOperator adds i to the "condition_operator" field.
  17034. func (m *SopStageMutation) AddConditionOperator(i int) {
  17035. if m.addcondition_operator != nil {
  17036. *m.addcondition_operator += i
  17037. } else {
  17038. m.addcondition_operator = &i
  17039. }
  17040. }
  17041. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  17042. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  17043. v := m.addcondition_operator
  17044. if v == nil {
  17045. return
  17046. }
  17047. return *v, true
  17048. }
  17049. // ResetConditionOperator resets all changes to the "condition_operator" field.
  17050. func (m *SopStageMutation) ResetConditionOperator() {
  17051. m.condition_operator = nil
  17052. m.addcondition_operator = nil
  17053. }
  17054. // SetConditionList sets the "condition_list" field.
  17055. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  17056. m.condition_list = &ct
  17057. m.appendcondition_list = nil
  17058. }
  17059. // ConditionList returns the value of the "condition_list" field in the mutation.
  17060. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  17061. v := m.condition_list
  17062. if v == nil {
  17063. return
  17064. }
  17065. return *v, true
  17066. }
  17067. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  17068. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17070. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  17071. if !m.op.Is(OpUpdateOne) {
  17072. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17073. }
  17074. if m.id == nil || m.oldValue == nil {
  17075. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17076. }
  17077. oldValue, err := m.oldValue(ctx)
  17078. if err != nil {
  17079. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17080. }
  17081. return oldValue.ConditionList, nil
  17082. }
  17083. // AppendConditionList adds ct to the "condition_list" field.
  17084. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  17085. m.appendcondition_list = append(m.appendcondition_list, ct...)
  17086. }
  17087. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17088. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  17089. if len(m.appendcondition_list) == 0 {
  17090. return nil, false
  17091. }
  17092. return m.appendcondition_list, true
  17093. }
  17094. // ResetConditionList resets all changes to the "condition_list" field.
  17095. func (m *SopStageMutation) ResetConditionList() {
  17096. m.condition_list = nil
  17097. m.appendcondition_list = nil
  17098. }
  17099. // SetActionMessage sets the "action_message" field.
  17100. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  17101. m.action_message = &ct
  17102. m.appendaction_message = nil
  17103. }
  17104. // ActionMessage returns the value of the "action_message" field in the mutation.
  17105. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17106. v := m.action_message
  17107. if v == nil {
  17108. return
  17109. }
  17110. return *v, true
  17111. }
  17112. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  17113. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17115. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17116. if !m.op.Is(OpUpdateOne) {
  17117. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17118. }
  17119. if m.id == nil || m.oldValue == nil {
  17120. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17121. }
  17122. oldValue, err := m.oldValue(ctx)
  17123. if err != nil {
  17124. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17125. }
  17126. return oldValue.ActionMessage, nil
  17127. }
  17128. // AppendActionMessage adds ct to the "action_message" field.
  17129. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  17130. m.appendaction_message = append(m.appendaction_message, ct...)
  17131. }
  17132. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17133. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17134. if len(m.appendaction_message) == 0 {
  17135. return nil, false
  17136. }
  17137. return m.appendaction_message, true
  17138. }
  17139. // ClearActionMessage clears the value of the "action_message" field.
  17140. func (m *SopStageMutation) ClearActionMessage() {
  17141. m.action_message = nil
  17142. m.appendaction_message = nil
  17143. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  17144. }
  17145. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17146. func (m *SopStageMutation) ActionMessageCleared() bool {
  17147. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  17148. return ok
  17149. }
  17150. // ResetActionMessage resets all changes to the "action_message" field.
  17151. func (m *SopStageMutation) ResetActionMessage() {
  17152. m.action_message = nil
  17153. m.appendaction_message = nil
  17154. delete(m.clearedFields, sopstage.FieldActionMessage)
  17155. }
  17156. // SetActionLabelAdd sets the "action_label_add" field.
  17157. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  17158. m.action_label_add = &u
  17159. m.appendaction_label_add = nil
  17160. }
  17161. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17162. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17163. v := m.action_label_add
  17164. if v == nil {
  17165. return
  17166. }
  17167. return *v, true
  17168. }
  17169. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  17170. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17172. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17173. if !m.op.Is(OpUpdateOne) {
  17174. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17175. }
  17176. if m.id == nil || m.oldValue == nil {
  17177. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17178. }
  17179. oldValue, err := m.oldValue(ctx)
  17180. if err != nil {
  17181. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17182. }
  17183. return oldValue.ActionLabelAdd, nil
  17184. }
  17185. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17186. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  17187. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17188. }
  17189. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17190. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17191. if len(m.appendaction_label_add) == 0 {
  17192. return nil, false
  17193. }
  17194. return m.appendaction_label_add, true
  17195. }
  17196. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17197. func (m *SopStageMutation) ClearActionLabelAdd() {
  17198. m.action_label_add = nil
  17199. m.appendaction_label_add = nil
  17200. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  17201. }
  17202. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17203. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  17204. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  17205. return ok
  17206. }
  17207. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17208. func (m *SopStageMutation) ResetActionLabelAdd() {
  17209. m.action_label_add = nil
  17210. m.appendaction_label_add = nil
  17211. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  17212. }
  17213. // SetActionLabelDel sets the "action_label_del" field.
  17214. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  17215. m.action_label_del = &u
  17216. m.appendaction_label_del = nil
  17217. }
  17218. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17219. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  17220. v := m.action_label_del
  17221. if v == nil {
  17222. return
  17223. }
  17224. return *v, true
  17225. }
  17226. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  17227. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17229. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17230. if !m.op.Is(OpUpdateOne) {
  17231. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17232. }
  17233. if m.id == nil || m.oldValue == nil {
  17234. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17235. }
  17236. oldValue, err := m.oldValue(ctx)
  17237. if err != nil {
  17238. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17239. }
  17240. return oldValue.ActionLabelDel, nil
  17241. }
  17242. // AppendActionLabelDel adds u to the "action_label_del" field.
  17243. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  17244. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17245. }
  17246. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17247. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17248. if len(m.appendaction_label_del) == 0 {
  17249. return nil, false
  17250. }
  17251. return m.appendaction_label_del, true
  17252. }
  17253. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17254. func (m *SopStageMutation) ClearActionLabelDel() {
  17255. m.action_label_del = nil
  17256. m.appendaction_label_del = nil
  17257. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  17258. }
  17259. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17260. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  17261. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  17262. return ok
  17263. }
  17264. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17265. func (m *SopStageMutation) ResetActionLabelDel() {
  17266. m.action_label_del = nil
  17267. m.appendaction_label_del = nil
  17268. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  17269. }
  17270. // SetActionForward sets the "action_forward" field.
  17271. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17272. m.action_forward = &ctf
  17273. }
  17274. // ActionForward returns the value of the "action_forward" field in the mutation.
  17275. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17276. v := m.action_forward
  17277. if v == nil {
  17278. return
  17279. }
  17280. return *v, true
  17281. }
  17282. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  17283. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17285. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17286. if !m.op.Is(OpUpdateOne) {
  17287. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17288. }
  17289. if m.id == nil || m.oldValue == nil {
  17290. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17291. }
  17292. oldValue, err := m.oldValue(ctx)
  17293. if err != nil {
  17294. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17295. }
  17296. return oldValue.ActionForward, nil
  17297. }
  17298. // ClearActionForward clears the value of the "action_forward" field.
  17299. func (m *SopStageMutation) ClearActionForward() {
  17300. m.action_forward = nil
  17301. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  17302. }
  17303. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17304. func (m *SopStageMutation) ActionForwardCleared() bool {
  17305. _, ok := m.clearedFields[sopstage.FieldActionForward]
  17306. return ok
  17307. }
  17308. // ResetActionForward resets all changes to the "action_forward" field.
  17309. func (m *SopStageMutation) ResetActionForward() {
  17310. m.action_forward = nil
  17311. delete(m.clearedFields, sopstage.FieldActionForward)
  17312. }
  17313. // SetIndexSort sets the "index_sort" field.
  17314. func (m *SopStageMutation) SetIndexSort(i int) {
  17315. m.index_sort = &i
  17316. m.addindex_sort = nil
  17317. }
  17318. // IndexSort returns the value of the "index_sort" field in the mutation.
  17319. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  17320. v := m.index_sort
  17321. if v == nil {
  17322. return
  17323. }
  17324. return *v, true
  17325. }
  17326. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  17327. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17329. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  17330. if !m.op.Is(OpUpdateOne) {
  17331. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  17332. }
  17333. if m.id == nil || m.oldValue == nil {
  17334. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  17335. }
  17336. oldValue, err := m.oldValue(ctx)
  17337. if err != nil {
  17338. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  17339. }
  17340. return oldValue.IndexSort, nil
  17341. }
  17342. // AddIndexSort adds i to the "index_sort" field.
  17343. func (m *SopStageMutation) AddIndexSort(i int) {
  17344. if m.addindex_sort != nil {
  17345. *m.addindex_sort += i
  17346. } else {
  17347. m.addindex_sort = &i
  17348. }
  17349. }
  17350. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  17351. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  17352. v := m.addindex_sort
  17353. if v == nil {
  17354. return
  17355. }
  17356. return *v, true
  17357. }
  17358. // ClearIndexSort clears the value of the "index_sort" field.
  17359. func (m *SopStageMutation) ClearIndexSort() {
  17360. m.index_sort = nil
  17361. m.addindex_sort = nil
  17362. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  17363. }
  17364. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  17365. func (m *SopStageMutation) IndexSortCleared() bool {
  17366. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  17367. return ok
  17368. }
  17369. // ResetIndexSort resets all changes to the "index_sort" field.
  17370. func (m *SopStageMutation) ResetIndexSort() {
  17371. m.index_sort = nil
  17372. m.addindex_sort = nil
  17373. delete(m.clearedFields, sopstage.FieldIndexSort)
  17374. }
  17375. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  17376. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  17377. m.sop_task = &id
  17378. }
  17379. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  17380. func (m *SopStageMutation) ClearSopTask() {
  17381. m.clearedsop_task = true
  17382. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  17383. }
  17384. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  17385. func (m *SopStageMutation) SopTaskCleared() bool {
  17386. return m.clearedsop_task
  17387. }
  17388. // SopTaskID returns the "sop_task" edge ID in the mutation.
  17389. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  17390. if m.sop_task != nil {
  17391. return *m.sop_task, true
  17392. }
  17393. return
  17394. }
  17395. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  17396. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17397. // SopTaskID instead. It exists only for internal usage by the builders.
  17398. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  17399. if id := m.sop_task; id != nil {
  17400. ids = append(ids, *id)
  17401. }
  17402. return
  17403. }
  17404. // ResetSopTask resets all changes to the "sop_task" edge.
  17405. func (m *SopStageMutation) ResetSopTask() {
  17406. m.sop_task = nil
  17407. m.clearedsop_task = false
  17408. }
  17409. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  17410. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  17411. if m.stage_nodes == nil {
  17412. m.stage_nodes = make(map[uint64]struct{})
  17413. }
  17414. for i := range ids {
  17415. m.stage_nodes[ids[i]] = struct{}{}
  17416. }
  17417. }
  17418. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  17419. func (m *SopStageMutation) ClearStageNodes() {
  17420. m.clearedstage_nodes = true
  17421. }
  17422. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  17423. func (m *SopStageMutation) StageNodesCleared() bool {
  17424. return m.clearedstage_nodes
  17425. }
  17426. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  17427. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  17428. if m.removedstage_nodes == nil {
  17429. m.removedstage_nodes = make(map[uint64]struct{})
  17430. }
  17431. for i := range ids {
  17432. delete(m.stage_nodes, ids[i])
  17433. m.removedstage_nodes[ids[i]] = struct{}{}
  17434. }
  17435. }
  17436. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  17437. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  17438. for id := range m.removedstage_nodes {
  17439. ids = append(ids, id)
  17440. }
  17441. return
  17442. }
  17443. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  17444. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  17445. for id := range m.stage_nodes {
  17446. ids = append(ids, id)
  17447. }
  17448. return
  17449. }
  17450. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  17451. func (m *SopStageMutation) ResetStageNodes() {
  17452. m.stage_nodes = nil
  17453. m.clearedstage_nodes = false
  17454. m.removedstage_nodes = nil
  17455. }
  17456. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  17457. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  17458. if m.stage_messages == nil {
  17459. m.stage_messages = make(map[uint64]struct{})
  17460. }
  17461. for i := range ids {
  17462. m.stage_messages[ids[i]] = struct{}{}
  17463. }
  17464. }
  17465. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  17466. func (m *SopStageMutation) ClearStageMessages() {
  17467. m.clearedstage_messages = true
  17468. }
  17469. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  17470. func (m *SopStageMutation) StageMessagesCleared() bool {
  17471. return m.clearedstage_messages
  17472. }
  17473. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  17474. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  17475. if m.removedstage_messages == nil {
  17476. m.removedstage_messages = make(map[uint64]struct{})
  17477. }
  17478. for i := range ids {
  17479. delete(m.stage_messages, ids[i])
  17480. m.removedstage_messages[ids[i]] = struct{}{}
  17481. }
  17482. }
  17483. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  17484. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  17485. for id := range m.removedstage_messages {
  17486. ids = append(ids, id)
  17487. }
  17488. return
  17489. }
  17490. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  17491. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  17492. for id := range m.stage_messages {
  17493. ids = append(ids, id)
  17494. }
  17495. return
  17496. }
  17497. // ResetStageMessages resets all changes to the "stage_messages" edge.
  17498. func (m *SopStageMutation) ResetStageMessages() {
  17499. m.stage_messages = nil
  17500. m.clearedstage_messages = false
  17501. m.removedstage_messages = nil
  17502. }
  17503. // Where appends a list predicates to the SopStageMutation builder.
  17504. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  17505. m.predicates = append(m.predicates, ps...)
  17506. }
  17507. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  17508. // users can use type-assertion to append predicates that do not depend on any generated package.
  17509. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  17510. p := make([]predicate.SopStage, len(ps))
  17511. for i := range ps {
  17512. p[i] = ps[i]
  17513. }
  17514. m.Where(p...)
  17515. }
  17516. // Op returns the operation name.
  17517. func (m *SopStageMutation) Op() Op {
  17518. return m.op
  17519. }
  17520. // SetOp allows setting the mutation operation.
  17521. func (m *SopStageMutation) SetOp(op Op) {
  17522. m.op = op
  17523. }
  17524. // Type returns the node type of this mutation (SopStage).
  17525. func (m *SopStageMutation) Type() string {
  17526. return m.typ
  17527. }
  17528. // Fields returns all fields that were changed during this mutation. Note that in
  17529. // order to get all numeric fields that were incremented/decremented, call
  17530. // AddedFields().
  17531. func (m *SopStageMutation) Fields() []string {
  17532. fields := make([]string, 0, 14)
  17533. if m.created_at != nil {
  17534. fields = append(fields, sopstage.FieldCreatedAt)
  17535. }
  17536. if m.updated_at != nil {
  17537. fields = append(fields, sopstage.FieldUpdatedAt)
  17538. }
  17539. if m.status != nil {
  17540. fields = append(fields, sopstage.FieldStatus)
  17541. }
  17542. if m.deleted_at != nil {
  17543. fields = append(fields, sopstage.FieldDeletedAt)
  17544. }
  17545. if m.sop_task != nil {
  17546. fields = append(fields, sopstage.FieldTaskID)
  17547. }
  17548. if m.name != nil {
  17549. fields = append(fields, sopstage.FieldName)
  17550. }
  17551. if m.condition_type != nil {
  17552. fields = append(fields, sopstage.FieldConditionType)
  17553. }
  17554. if m.condition_operator != nil {
  17555. fields = append(fields, sopstage.FieldConditionOperator)
  17556. }
  17557. if m.condition_list != nil {
  17558. fields = append(fields, sopstage.FieldConditionList)
  17559. }
  17560. if m.action_message != nil {
  17561. fields = append(fields, sopstage.FieldActionMessage)
  17562. }
  17563. if m.action_label_add != nil {
  17564. fields = append(fields, sopstage.FieldActionLabelAdd)
  17565. }
  17566. if m.action_label_del != nil {
  17567. fields = append(fields, sopstage.FieldActionLabelDel)
  17568. }
  17569. if m.action_forward != nil {
  17570. fields = append(fields, sopstage.FieldActionForward)
  17571. }
  17572. if m.index_sort != nil {
  17573. fields = append(fields, sopstage.FieldIndexSort)
  17574. }
  17575. return fields
  17576. }
  17577. // Field returns the value of a field with the given name. The second boolean
  17578. // return value indicates that this field was not set, or was not defined in the
  17579. // schema.
  17580. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  17581. switch name {
  17582. case sopstage.FieldCreatedAt:
  17583. return m.CreatedAt()
  17584. case sopstage.FieldUpdatedAt:
  17585. return m.UpdatedAt()
  17586. case sopstage.FieldStatus:
  17587. return m.Status()
  17588. case sopstage.FieldDeletedAt:
  17589. return m.DeletedAt()
  17590. case sopstage.FieldTaskID:
  17591. return m.TaskID()
  17592. case sopstage.FieldName:
  17593. return m.Name()
  17594. case sopstage.FieldConditionType:
  17595. return m.ConditionType()
  17596. case sopstage.FieldConditionOperator:
  17597. return m.ConditionOperator()
  17598. case sopstage.FieldConditionList:
  17599. return m.ConditionList()
  17600. case sopstage.FieldActionMessage:
  17601. return m.ActionMessage()
  17602. case sopstage.FieldActionLabelAdd:
  17603. return m.ActionLabelAdd()
  17604. case sopstage.FieldActionLabelDel:
  17605. return m.ActionLabelDel()
  17606. case sopstage.FieldActionForward:
  17607. return m.ActionForward()
  17608. case sopstage.FieldIndexSort:
  17609. return m.IndexSort()
  17610. }
  17611. return nil, false
  17612. }
  17613. // OldField returns the old value of the field from the database. An error is
  17614. // returned if the mutation operation is not UpdateOne, or the query to the
  17615. // database failed.
  17616. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17617. switch name {
  17618. case sopstage.FieldCreatedAt:
  17619. return m.OldCreatedAt(ctx)
  17620. case sopstage.FieldUpdatedAt:
  17621. return m.OldUpdatedAt(ctx)
  17622. case sopstage.FieldStatus:
  17623. return m.OldStatus(ctx)
  17624. case sopstage.FieldDeletedAt:
  17625. return m.OldDeletedAt(ctx)
  17626. case sopstage.FieldTaskID:
  17627. return m.OldTaskID(ctx)
  17628. case sopstage.FieldName:
  17629. return m.OldName(ctx)
  17630. case sopstage.FieldConditionType:
  17631. return m.OldConditionType(ctx)
  17632. case sopstage.FieldConditionOperator:
  17633. return m.OldConditionOperator(ctx)
  17634. case sopstage.FieldConditionList:
  17635. return m.OldConditionList(ctx)
  17636. case sopstage.FieldActionMessage:
  17637. return m.OldActionMessage(ctx)
  17638. case sopstage.FieldActionLabelAdd:
  17639. return m.OldActionLabelAdd(ctx)
  17640. case sopstage.FieldActionLabelDel:
  17641. return m.OldActionLabelDel(ctx)
  17642. case sopstage.FieldActionForward:
  17643. return m.OldActionForward(ctx)
  17644. case sopstage.FieldIndexSort:
  17645. return m.OldIndexSort(ctx)
  17646. }
  17647. return nil, fmt.Errorf("unknown SopStage field %s", name)
  17648. }
  17649. // SetField sets the value of a field with the given name. It returns an error if
  17650. // the field is not defined in the schema, or if the type mismatched the field
  17651. // type.
  17652. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  17653. switch name {
  17654. case sopstage.FieldCreatedAt:
  17655. v, ok := value.(time.Time)
  17656. if !ok {
  17657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17658. }
  17659. m.SetCreatedAt(v)
  17660. return nil
  17661. case sopstage.FieldUpdatedAt:
  17662. v, ok := value.(time.Time)
  17663. if !ok {
  17664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17665. }
  17666. m.SetUpdatedAt(v)
  17667. return nil
  17668. case sopstage.FieldStatus:
  17669. v, ok := value.(uint8)
  17670. if !ok {
  17671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17672. }
  17673. m.SetStatus(v)
  17674. return nil
  17675. case sopstage.FieldDeletedAt:
  17676. v, ok := value.(time.Time)
  17677. if !ok {
  17678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17679. }
  17680. m.SetDeletedAt(v)
  17681. return nil
  17682. case sopstage.FieldTaskID:
  17683. v, ok := value.(uint64)
  17684. if !ok {
  17685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17686. }
  17687. m.SetTaskID(v)
  17688. return nil
  17689. case sopstage.FieldName:
  17690. v, ok := value.(string)
  17691. if !ok {
  17692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17693. }
  17694. m.SetName(v)
  17695. return nil
  17696. case sopstage.FieldConditionType:
  17697. v, ok := value.(int)
  17698. if !ok {
  17699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17700. }
  17701. m.SetConditionType(v)
  17702. return nil
  17703. case sopstage.FieldConditionOperator:
  17704. v, ok := value.(int)
  17705. if !ok {
  17706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17707. }
  17708. m.SetConditionOperator(v)
  17709. return nil
  17710. case sopstage.FieldConditionList:
  17711. v, ok := value.([]custom_types.Condition)
  17712. if !ok {
  17713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17714. }
  17715. m.SetConditionList(v)
  17716. return nil
  17717. case sopstage.FieldActionMessage:
  17718. v, ok := value.([]custom_types.Action)
  17719. if !ok {
  17720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17721. }
  17722. m.SetActionMessage(v)
  17723. return nil
  17724. case sopstage.FieldActionLabelAdd:
  17725. v, ok := value.([]uint64)
  17726. if !ok {
  17727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17728. }
  17729. m.SetActionLabelAdd(v)
  17730. return nil
  17731. case sopstage.FieldActionLabelDel:
  17732. v, ok := value.([]uint64)
  17733. if !ok {
  17734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17735. }
  17736. m.SetActionLabelDel(v)
  17737. return nil
  17738. case sopstage.FieldActionForward:
  17739. v, ok := value.(*custom_types.ActionForward)
  17740. if !ok {
  17741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17742. }
  17743. m.SetActionForward(v)
  17744. return nil
  17745. case sopstage.FieldIndexSort:
  17746. v, ok := value.(int)
  17747. if !ok {
  17748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17749. }
  17750. m.SetIndexSort(v)
  17751. return nil
  17752. }
  17753. return fmt.Errorf("unknown SopStage field %s", name)
  17754. }
  17755. // AddedFields returns all numeric fields that were incremented/decremented during
  17756. // this mutation.
  17757. func (m *SopStageMutation) AddedFields() []string {
  17758. var fields []string
  17759. if m.addstatus != nil {
  17760. fields = append(fields, sopstage.FieldStatus)
  17761. }
  17762. if m.addcondition_type != nil {
  17763. fields = append(fields, sopstage.FieldConditionType)
  17764. }
  17765. if m.addcondition_operator != nil {
  17766. fields = append(fields, sopstage.FieldConditionOperator)
  17767. }
  17768. if m.addindex_sort != nil {
  17769. fields = append(fields, sopstage.FieldIndexSort)
  17770. }
  17771. return fields
  17772. }
  17773. // AddedField returns the numeric value that was incremented/decremented on a field
  17774. // with the given name. The second boolean return value indicates that this field
  17775. // was not set, or was not defined in the schema.
  17776. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  17777. switch name {
  17778. case sopstage.FieldStatus:
  17779. return m.AddedStatus()
  17780. case sopstage.FieldConditionType:
  17781. return m.AddedConditionType()
  17782. case sopstage.FieldConditionOperator:
  17783. return m.AddedConditionOperator()
  17784. case sopstage.FieldIndexSort:
  17785. return m.AddedIndexSort()
  17786. }
  17787. return nil, false
  17788. }
  17789. // AddField adds the value to the field with the given name. It returns an error if
  17790. // the field is not defined in the schema, or if the type mismatched the field
  17791. // type.
  17792. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  17793. switch name {
  17794. case sopstage.FieldStatus:
  17795. v, ok := value.(int8)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.AddStatus(v)
  17800. return nil
  17801. case sopstage.FieldConditionType:
  17802. v, ok := value.(int)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.AddConditionType(v)
  17807. return nil
  17808. case sopstage.FieldConditionOperator:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.AddConditionOperator(v)
  17814. return nil
  17815. case sopstage.FieldIndexSort:
  17816. v, ok := value.(int)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.AddIndexSort(v)
  17821. return nil
  17822. }
  17823. return fmt.Errorf("unknown SopStage numeric field %s", name)
  17824. }
  17825. // ClearedFields returns all nullable fields that were cleared during this
  17826. // mutation.
  17827. func (m *SopStageMutation) ClearedFields() []string {
  17828. var fields []string
  17829. if m.FieldCleared(sopstage.FieldStatus) {
  17830. fields = append(fields, sopstage.FieldStatus)
  17831. }
  17832. if m.FieldCleared(sopstage.FieldDeletedAt) {
  17833. fields = append(fields, sopstage.FieldDeletedAt)
  17834. }
  17835. if m.FieldCleared(sopstage.FieldActionMessage) {
  17836. fields = append(fields, sopstage.FieldActionMessage)
  17837. }
  17838. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  17839. fields = append(fields, sopstage.FieldActionLabelAdd)
  17840. }
  17841. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  17842. fields = append(fields, sopstage.FieldActionLabelDel)
  17843. }
  17844. if m.FieldCleared(sopstage.FieldActionForward) {
  17845. fields = append(fields, sopstage.FieldActionForward)
  17846. }
  17847. if m.FieldCleared(sopstage.FieldIndexSort) {
  17848. fields = append(fields, sopstage.FieldIndexSort)
  17849. }
  17850. return fields
  17851. }
  17852. // FieldCleared returns a boolean indicating if a field with the given name was
  17853. // cleared in this mutation.
  17854. func (m *SopStageMutation) FieldCleared(name string) bool {
  17855. _, ok := m.clearedFields[name]
  17856. return ok
  17857. }
  17858. // ClearField clears the value of the field with the given name. It returns an
  17859. // error if the field is not defined in the schema.
  17860. func (m *SopStageMutation) ClearField(name string) error {
  17861. switch name {
  17862. case sopstage.FieldStatus:
  17863. m.ClearStatus()
  17864. return nil
  17865. case sopstage.FieldDeletedAt:
  17866. m.ClearDeletedAt()
  17867. return nil
  17868. case sopstage.FieldActionMessage:
  17869. m.ClearActionMessage()
  17870. return nil
  17871. case sopstage.FieldActionLabelAdd:
  17872. m.ClearActionLabelAdd()
  17873. return nil
  17874. case sopstage.FieldActionLabelDel:
  17875. m.ClearActionLabelDel()
  17876. return nil
  17877. case sopstage.FieldActionForward:
  17878. m.ClearActionForward()
  17879. return nil
  17880. case sopstage.FieldIndexSort:
  17881. m.ClearIndexSort()
  17882. return nil
  17883. }
  17884. return fmt.Errorf("unknown SopStage nullable field %s", name)
  17885. }
  17886. // ResetField resets all changes in the mutation for the field with the given name.
  17887. // It returns an error if the field is not defined in the schema.
  17888. func (m *SopStageMutation) ResetField(name string) error {
  17889. switch name {
  17890. case sopstage.FieldCreatedAt:
  17891. m.ResetCreatedAt()
  17892. return nil
  17893. case sopstage.FieldUpdatedAt:
  17894. m.ResetUpdatedAt()
  17895. return nil
  17896. case sopstage.FieldStatus:
  17897. m.ResetStatus()
  17898. return nil
  17899. case sopstage.FieldDeletedAt:
  17900. m.ResetDeletedAt()
  17901. return nil
  17902. case sopstage.FieldTaskID:
  17903. m.ResetTaskID()
  17904. return nil
  17905. case sopstage.FieldName:
  17906. m.ResetName()
  17907. return nil
  17908. case sopstage.FieldConditionType:
  17909. m.ResetConditionType()
  17910. return nil
  17911. case sopstage.FieldConditionOperator:
  17912. m.ResetConditionOperator()
  17913. return nil
  17914. case sopstage.FieldConditionList:
  17915. m.ResetConditionList()
  17916. return nil
  17917. case sopstage.FieldActionMessage:
  17918. m.ResetActionMessage()
  17919. return nil
  17920. case sopstage.FieldActionLabelAdd:
  17921. m.ResetActionLabelAdd()
  17922. return nil
  17923. case sopstage.FieldActionLabelDel:
  17924. m.ResetActionLabelDel()
  17925. return nil
  17926. case sopstage.FieldActionForward:
  17927. m.ResetActionForward()
  17928. return nil
  17929. case sopstage.FieldIndexSort:
  17930. m.ResetIndexSort()
  17931. return nil
  17932. }
  17933. return fmt.Errorf("unknown SopStage field %s", name)
  17934. }
  17935. // AddedEdges returns all edge names that were set/added in this mutation.
  17936. func (m *SopStageMutation) AddedEdges() []string {
  17937. edges := make([]string, 0, 3)
  17938. if m.sop_task != nil {
  17939. edges = append(edges, sopstage.EdgeSopTask)
  17940. }
  17941. if m.stage_nodes != nil {
  17942. edges = append(edges, sopstage.EdgeStageNodes)
  17943. }
  17944. if m.stage_messages != nil {
  17945. edges = append(edges, sopstage.EdgeStageMessages)
  17946. }
  17947. return edges
  17948. }
  17949. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17950. // name in this mutation.
  17951. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  17952. switch name {
  17953. case sopstage.EdgeSopTask:
  17954. if id := m.sop_task; id != nil {
  17955. return []ent.Value{*id}
  17956. }
  17957. case sopstage.EdgeStageNodes:
  17958. ids := make([]ent.Value, 0, len(m.stage_nodes))
  17959. for id := range m.stage_nodes {
  17960. ids = append(ids, id)
  17961. }
  17962. return ids
  17963. case sopstage.EdgeStageMessages:
  17964. ids := make([]ent.Value, 0, len(m.stage_messages))
  17965. for id := range m.stage_messages {
  17966. ids = append(ids, id)
  17967. }
  17968. return ids
  17969. }
  17970. return nil
  17971. }
  17972. // RemovedEdges returns all edge names that were removed in this mutation.
  17973. func (m *SopStageMutation) RemovedEdges() []string {
  17974. edges := make([]string, 0, 3)
  17975. if m.removedstage_nodes != nil {
  17976. edges = append(edges, sopstage.EdgeStageNodes)
  17977. }
  17978. if m.removedstage_messages != nil {
  17979. edges = append(edges, sopstage.EdgeStageMessages)
  17980. }
  17981. return edges
  17982. }
  17983. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17984. // the given name in this mutation.
  17985. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  17986. switch name {
  17987. case sopstage.EdgeStageNodes:
  17988. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  17989. for id := range m.removedstage_nodes {
  17990. ids = append(ids, id)
  17991. }
  17992. return ids
  17993. case sopstage.EdgeStageMessages:
  17994. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  17995. for id := range m.removedstage_messages {
  17996. ids = append(ids, id)
  17997. }
  17998. return ids
  17999. }
  18000. return nil
  18001. }
  18002. // ClearedEdges returns all edge names that were cleared in this mutation.
  18003. func (m *SopStageMutation) ClearedEdges() []string {
  18004. edges := make([]string, 0, 3)
  18005. if m.clearedsop_task {
  18006. edges = append(edges, sopstage.EdgeSopTask)
  18007. }
  18008. if m.clearedstage_nodes {
  18009. edges = append(edges, sopstage.EdgeStageNodes)
  18010. }
  18011. if m.clearedstage_messages {
  18012. edges = append(edges, sopstage.EdgeStageMessages)
  18013. }
  18014. return edges
  18015. }
  18016. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18017. // was cleared in this mutation.
  18018. func (m *SopStageMutation) EdgeCleared(name string) bool {
  18019. switch name {
  18020. case sopstage.EdgeSopTask:
  18021. return m.clearedsop_task
  18022. case sopstage.EdgeStageNodes:
  18023. return m.clearedstage_nodes
  18024. case sopstage.EdgeStageMessages:
  18025. return m.clearedstage_messages
  18026. }
  18027. return false
  18028. }
  18029. // ClearEdge clears the value of the edge with the given name. It returns an error
  18030. // if that edge is not defined in the schema.
  18031. func (m *SopStageMutation) ClearEdge(name string) error {
  18032. switch name {
  18033. case sopstage.EdgeSopTask:
  18034. m.ClearSopTask()
  18035. return nil
  18036. }
  18037. return fmt.Errorf("unknown SopStage unique edge %s", name)
  18038. }
  18039. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18040. // It returns an error if the edge is not defined in the schema.
  18041. func (m *SopStageMutation) ResetEdge(name string) error {
  18042. switch name {
  18043. case sopstage.EdgeSopTask:
  18044. m.ResetSopTask()
  18045. return nil
  18046. case sopstage.EdgeStageNodes:
  18047. m.ResetStageNodes()
  18048. return nil
  18049. case sopstage.EdgeStageMessages:
  18050. m.ResetStageMessages()
  18051. return nil
  18052. }
  18053. return fmt.Errorf("unknown SopStage edge %s", name)
  18054. }
  18055. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  18056. type SopTaskMutation struct {
  18057. config
  18058. op Op
  18059. typ string
  18060. id *uint64
  18061. created_at *time.Time
  18062. updated_at *time.Time
  18063. status *uint8
  18064. addstatus *int8
  18065. deleted_at *time.Time
  18066. name *string
  18067. bot_wxid_list *[]string
  18068. appendbot_wxid_list []string
  18069. _type *int
  18070. add_type *int
  18071. plan_start_time *time.Time
  18072. plan_end_time *time.Time
  18073. creator_id *string
  18074. organization_id *uint64
  18075. addorganization_id *int64
  18076. clearedFields map[string]struct{}
  18077. task_stages map[uint64]struct{}
  18078. removedtask_stages map[uint64]struct{}
  18079. clearedtask_stages bool
  18080. done bool
  18081. oldValue func(context.Context) (*SopTask, error)
  18082. predicates []predicate.SopTask
  18083. }
  18084. var _ ent.Mutation = (*SopTaskMutation)(nil)
  18085. // soptaskOption allows management of the mutation configuration using functional options.
  18086. type soptaskOption func(*SopTaskMutation)
  18087. // newSopTaskMutation creates new mutation for the SopTask entity.
  18088. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  18089. m := &SopTaskMutation{
  18090. config: c,
  18091. op: op,
  18092. typ: TypeSopTask,
  18093. clearedFields: make(map[string]struct{}),
  18094. }
  18095. for _, opt := range opts {
  18096. opt(m)
  18097. }
  18098. return m
  18099. }
  18100. // withSopTaskID sets the ID field of the mutation.
  18101. func withSopTaskID(id uint64) soptaskOption {
  18102. return func(m *SopTaskMutation) {
  18103. var (
  18104. err error
  18105. once sync.Once
  18106. value *SopTask
  18107. )
  18108. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  18109. once.Do(func() {
  18110. if m.done {
  18111. err = errors.New("querying old values post mutation is not allowed")
  18112. } else {
  18113. value, err = m.Client().SopTask.Get(ctx, id)
  18114. }
  18115. })
  18116. return value, err
  18117. }
  18118. m.id = &id
  18119. }
  18120. }
  18121. // withSopTask sets the old SopTask of the mutation.
  18122. func withSopTask(node *SopTask) soptaskOption {
  18123. return func(m *SopTaskMutation) {
  18124. m.oldValue = func(context.Context) (*SopTask, error) {
  18125. return node, nil
  18126. }
  18127. m.id = &node.ID
  18128. }
  18129. }
  18130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18131. // executed in a transaction (ent.Tx), a transactional client is returned.
  18132. func (m SopTaskMutation) Client() *Client {
  18133. client := &Client{config: m.config}
  18134. client.init()
  18135. return client
  18136. }
  18137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18138. // it returns an error otherwise.
  18139. func (m SopTaskMutation) Tx() (*Tx, error) {
  18140. if _, ok := m.driver.(*txDriver); !ok {
  18141. return nil, errors.New("ent: mutation is not running in a transaction")
  18142. }
  18143. tx := &Tx{config: m.config}
  18144. tx.init()
  18145. return tx, nil
  18146. }
  18147. // SetID sets the value of the id field. Note that this
  18148. // operation is only accepted on creation of SopTask entities.
  18149. func (m *SopTaskMutation) SetID(id uint64) {
  18150. m.id = &id
  18151. }
  18152. // ID returns the ID value in the mutation. Note that the ID is only available
  18153. // if it was provided to the builder or after it was returned from the database.
  18154. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  18155. if m.id == nil {
  18156. return
  18157. }
  18158. return *m.id, true
  18159. }
  18160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18161. // That means, if the mutation is applied within a transaction with an isolation level such
  18162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18163. // or updated by the mutation.
  18164. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  18165. switch {
  18166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18167. id, exists := m.ID()
  18168. if exists {
  18169. return []uint64{id}, nil
  18170. }
  18171. fallthrough
  18172. case m.op.Is(OpUpdate | OpDelete):
  18173. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  18174. default:
  18175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18176. }
  18177. }
  18178. // SetCreatedAt sets the "created_at" field.
  18179. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  18180. m.created_at = &t
  18181. }
  18182. // CreatedAt returns the value of the "created_at" field in the mutation.
  18183. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  18184. v := m.created_at
  18185. if v == nil {
  18186. return
  18187. }
  18188. return *v, true
  18189. }
  18190. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  18191. // If the SopTask 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 *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18194. if !m.op.Is(OpUpdateOne) {
  18195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18196. }
  18197. if m.id == nil || m.oldValue == nil {
  18198. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  18203. }
  18204. return oldValue.CreatedAt, nil
  18205. }
  18206. // ResetCreatedAt resets all changes to the "created_at" field.
  18207. func (m *SopTaskMutation) ResetCreatedAt() {
  18208. m.created_at = nil
  18209. }
  18210. // SetUpdatedAt sets the "updated_at" field.
  18211. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  18212. m.updated_at = &t
  18213. }
  18214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18215. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  18216. v := m.updated_at
  18217. if v == nil {
  18218. return
  18219. }
  18220. return *v, true
  18221. }
  18222. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  18223. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18225. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18226. if !m.op.Is(OpUpdateOne) {
  18227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18228. }
  18229. if m.id == nil || m.oldValue == nil {
  18230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18231. }
  18232. oldValue, err := m.oldValue(ctx)
  18233. if err != nil {
  18234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18235. }
  18236. return oldValue.UpdatedAt, nil
  18237. }
  18238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18239. func (m *SopTaskMutation) ResetUpdatedAt() {
  18240. m.updated_at = nil
  18241. }
  18242. // SetStatus sets the "status" field.
  18243. func (m *SopTaskMutation) SetStatus(u uint8) {
  18244. m.status = &u
  18245. m.addstatus = nil
  18246. }
  18247. // Status returns the value of the "status" field in the mutation.
  18248. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  18249. v := m.status
  18250. if v == nil {
  18251. return
  18252. }
  18253. return *v, true
  18254. }
  18255. // OldStatus returns the old "status" field's value of the SopTask entity.
  18256. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18258. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18259. if !m.op.Is(OpUpdateOne) {
  18260. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18261. }
  18262. if m.id == nil || m.oldValue == nil {
  18263. return v, errors.New("OldStatus requires an ID field in the mutation")
  18264. }
  18265. oldValue, err := m.oldValue(ctx)
  18266. if err != nil {
  18267. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18268. }
  18269. return oldValue.Status, nil
  18270. }
  18271. // AddStatus adds u to the "status" field.
  18272. func (m *SopTaskMutation) AddStatus(u int8) {
  18273. if m.addstatus != nil {
  18274. *m.addstatus += u
  18275. } else {
  18276. m.addstatus = &u
  18277. }
  18278. }
  18279. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18280. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  18281. v := m.addstatus
  18282. if v == nil {
  18283. return
  18284. }
  18285. return *v, true
  18286. }
  18287. // ClearStatus clears the value of the "status" field.
  18288. func (m *SopTaskMutation) ClearStatus() {
  18289. m.status = nil
  18290. m.addstatus = nil
  18291. m.clearedFields[soptask.FieldStatus] = struct{}{}
  18292. }
  18293. // StatusCleared returns if the "status" field was cleared in this mutation.
  18294. func (m *SopTaskMutation) StatusCleared() bool {
  18295. _, ok := m.clearedFields[soptask.FieldStatus]
  18296. return ok
  18297. }
  18298. // ResetStatus resets all changes to the "status" field.
  18299. func (m *SopTaskMutation) ResetStatus() {
  18300. m.status = nil
  18301. m.addstatus = nil
  18302. delete(m.clearedFields, soptask.FieldStatus)
  18303. }
  18304. // SetDeletedAt sets the "deleted_at" field.
  18305. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  18306. m.deleted_at = &t
  18307. }
  18308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18309. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  18310. v := m.deleted_at
  18311. if v == nil {
  18312. return
  18313. }
  18314. return *v, true
  18315. }
  18316. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  18317. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18319. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18320. if !m.op.Is(OpUpdateOne) {
  18321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18322. }
  18323. if m.id == nil || m.oldValue == nil {
  18324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18325. }
  18326. oldValue, err := m.oldValue(ctx)
  18327. if err != nil {
  18328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18329. }
  18330. return oldValue.DeletedAt, nil
  18331. }
  18332. // ClearDeletedAt clears the value of the "deleted_at" field.
  18333. func (m *SopTaskMutation) ClearDeletedAt() {
  18334. m.deleted_at = nil
  18335. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  18336. }
  18337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18338. func (m *SopTaskMutation) DeletedAtCleared() bool {
  18339. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  18340. return ok
  18341. }
  18342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18343. func (m *SopTaskMutation) ResetDeletedAt() {
  18344. m.deleted_at = nil
  18345. delete(m.clearedFields, soptask.FieldDeletedAt)
  18346. }
  18347. // SetName sets the "name" field.
  18348. func (m *SopTaskMutation) SetName(s string) {
  18349. m.name = &s
  18350. }
  18351. // Name returns the value of the "name" field in the mutation.
  18352. func (m *SopTaskMutation) Name() (r string, exists bool) {
  18353. v := m.name
  18354. if v == nil {
  18355. return
  18356. }
  18357. return *v, true
  18358. }
  18359. // OldName returns the old "name" field's value of the SopTask entity.
  18360. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18362. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  18363. if !m.op.Is(OpUpdateOne) {
  18364. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18365. }
  18366. if m.id == nil || m.oldValue == nil {
  18367. return v, errors.New("OldName requires an ID field in the mutation")
  18368. }
  18369. oldValue, err := m.oldValue(ctx)
  18370. if err != nil {
  18371. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18372. }
  18373. return oldValue.Name, nil
  18374. }
  18375. // ResetName resets all changes to the "name" field.
  18376. func (m *SopTaskMutation) ResetName() {
  18377. m.name = nil
  18378. }
  18379. // SetBotWxidList sets the "bot_wxid_list" field.
  18380. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  18381. m.bot_wxid_list = &s
  18382. m.appendbot_wxid_list = nil
  18383. }
  18384. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  18385. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  18386. v := m.bot_wxid_list
  18387. if v == nil {
  18388. return
  18389. }
  18390. return *v, true
  18391. }
  18392. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  18393. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18395. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  18396. if !m.op.Is(OpUpdateOne) {
  18397. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  18398. }
  18399. if m.id == nil || m.oldValue == nil {
  18400. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  18401. }
  18402. oldValue, err := m.oldValue(ctx)
  18403. if err != nil {
  18404. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  18405. }
  18406. return oldValue.BotWxidList, nil
  18407. }
  18408. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  18409. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  18410. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  18411. }
  18412. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  18413. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  18414. if len(m.appendbot_wxid_list) == 0 {
  18415. return nil, false
  18416. }
  18417. return m.appendbot_wxid_list, true
  18418. }
  18419. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  18420. func (m *SopTaskMutation) ClearBotWxidList() {
  18421. m.bot_wxid_list = nil
  18422. m.appendbot_wxid_list = nil
  18423. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  18424. }
  18425. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  18426. func (m *SopTaskMutation) BotWxidListCleared() bool {
  18427. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  18428. return ok
  18429. }
  18430. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  18431. func (m *SopTaskMutation) ResetBotWxidList() {
  18432. m.bot_wxid_list = nil
  18433. m.appendbot_wxid_list = nil
  18434. delete(m.clearedFields, soptask.FieldBotWxidList)
  18435. }
  18436. // SetType sets the "type" field.
  18437. func (m *SopTaskMutation) SetType(i int) {
  18438. m._type = &i
  18439. m.add_type = nil
  18440. }
  18441. // GetType returns the value of the "type" field in the mutation.
  18442. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  18443. v := m._type
  18444. if v == nil {
  18445. return
  18446. }
  18447. return *v, true
  18448. }
  18449. // OldType returns the old "type" field's value of the SopTask entity.
  18450. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18452. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  18453. if !m.op.Is(OpUpdateOne) {
  18454. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18455. }
  18456. if m.id == nil || m.oldValue == nil {
  18457. return v, errors.New("OldType requires an ID field in the mutation")
  18458. }
  18459. oldValue, err := m.oldValue(ctx)
  18460. if err != nil {
  18461. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18462. }
  18463. return oldValue.Type, nil
  18464. }
  18465. // AddType adds i to the "type" field.
  18466. func (m *SopTaskMutation) AddType(i int) {
  18467. if m.add_type != nil {
  18468. *m.add_type += i
  18469. } else {
  18470. m.add_type = &i
  18471. }
  18472. }
  18473. // AddedType returns the value that was added to the "type" field in this mutation.
  18474. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  18475. v := m.add_type
  18476. if v == nil {
  18477. return
  18478. }
  18479. return *v, true
  18480. }
  18481. // ResetType resets all changes to the "type" field.
  18482. func (m *SopTaskMutation) ResetType() {
  18483. m._type = nil
  18484. m.add_type = nil
  18485. }
  18486. // SetPlanStartTime sets the "plan_start_time" field.
  18487. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  18488. m.plan_start_time = &t
  18489. }
  18490. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  18491. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  18492. v := m.plan_start_time
  18493. if v == nil {
  18494. return
  18495. }
  18496. return *v, true
  18497. }
  18498. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  18499. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18501. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  18502. if !m.op.Is(OpUpdateOne) {
  18503. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  18504. }
  18505. if m.id == nil || m.oldValue == nil {
  18506. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  18507. }
  18508. oldValue, err := m.oldValue(ctx)
  18509. if err != nil {
  18510. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  18511. }
  18512. return oldValue.PlanStartTime, nil
  18513. }
  18514. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  18515. func (m *SopTaskMutation) ClearPlanStartTime() {
  18516. m.plan_start_time = nil
  18517. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  18518. }
  18519. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  18520. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  18521. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  18522. return ok
  18523. }
  18524. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  18525. func (m *SopTaskMutation) ResetPlanStartTime() {
  18526. m.plan_start_time = nil
  18527. delete(m.clearedFields, soptask.FieldPlanStartTime)
  18528. }
  18529. // SetPlanEndTime sets the "plan_end_time" field.
  18530. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  18531. m.plan_end_time = &t
  18532. }
  18533. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  18534. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  18535. v := m.plan_end_time
  18536. if v == nil {
  18537. return
  18538. }
  18539. return *v, true
  18540. }
  18541. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  18542. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18544. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  18545. if !m.op.Is(OpUpdateOne) {
  18546. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  18547. }
  18548. if m.id == nil || m.oldValue == nil {
  18549. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  18550. }
  18551. oldValue, err := m.oldValue(ctx)
  18552. if err != nil {
  18553. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  18554. }
  18555. return oldValue.PlanEndTime, nil
  18556. }
  18557. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  18558. func (m *SopTaskMutation) ClearPlanEndTime() {
  18559. m.plan_end_time = nil
  18560. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  18561. }
  18562. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  18563. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  18564. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  18565. return ok
  18566. }
  18567. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  18568. func (m *SopTaskMutation) ResetPlanEndTime() {
  18569. m.plan_end_time = nil
  18570. delete(m.clearedFields, soptask.FieldPlanEndTime)
  18571. }
  18572. // SetCreatorID sets the "creator_id" field.
  18573. func (m *SopTaskMutation) SetCreatorID(s string) {
  18574. m.creator_id = &s
  18575. }
  18576. // CreatorID returns the value of the "creator_id" field in the mutation.
  18577. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  18578. v := m.creator_id
  18579. if v == nil {
  18580. return
  18581. }
  18582. return *v, true
  18583. }
  18584. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  18585. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18587. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  18588. if !m.op.Is(OpUpdateOne) {
  18589. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  18590. }
  18591. if m.id == nil || m.oldValue == nil {
  18592. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  18593. }
  18594. oldValue, err := m.oldValue(ctx)
  18595. if err != nil {
  18596. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  18597. }
  18598. return oldValue.CreatorID, nil
  18599. }
  18600. // ClearCreatorID clears the value of the "creator_id" field.
  18601. func (m *SopTaskMutation) ClearCreatorID() {
  18602. m.creator_id = nil
  18603. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  18604. }
  18605. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  18606. func (m *SopTaskMutation) CreatorIDCleared() bool {
  18607. _, ok := m.clearedFields[soptask.FieldCreatorID]
  18608. return ok
  18609. }
  18610. // ResetCreatorID resets all changes to the "creator_id" field.
  18611. func (m *SopTaskMutation) ResetCreatorID() {
  18612. m.creator_id = nil
  18613. delete(m.clearedFields, soptask.FieldCreatorID)
  18614. }
  18615. // SetOrganizationID sets the "organization_id" field.
  18616. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  18617. m.organization_id = &u
  18618. m.addorganization_id = nil
  18619. }
  18620. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18621. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  18622. v := m.organization_id
  18623. if v == nil {
  18624. return
  18625. }
  18626. return *v, true
  18627. }
  18628. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  18629. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  18630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18631. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18632. if !m.op.Is(OpUpdateOne) {
  18633. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18634. }
  18635. if m.id == nil || m.oldValue == nil {
  18636. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18637. }
  18638. oldValue, err := m.oldValue(ctx)
  18639. if err != nil {
  18640. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18641. }
  18642. return oldValue.OrganizationID, nil
  18643. }
  18644. // AddOrganizationID adds u to the "organization_id" field.
  18645. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  18646. if m.addorganization_id != nil {
  18647. *m.addorganization_id += u
  18648. } else {
  18649. m.addorganization_id = &u
  18650. }
  18651. }
  18652. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18653. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  18654. v := m.addorganization_id
  18655. if v == nil {
  18656. return
  18657. }
  18658. return *v, true
  18659. }
  18660. // ClearOrganizationID clears the value of the "organization_id" field.
  18661. func (m *SopTaskMutation) ClearOrganizationID() {
  18662. m.organization_id = nil
  18663. m.addorganization_id = nil
  18664. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  18665. }
  18666. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18667. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  18668. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  18669. return ok
  18670. }
  18671. // ResetOrganizationID resets all changes to the "organization_id" field.
  18672. func (m *SopTaskMutation) ResetOrganizationID() {
  18673. m.organization_id = nil
  18674. m.addorganization_id = nil
  18675. delete(m.clearedFields, soptask.FieldOrganizationID)
  18676. }
  18677. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  18678. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  18679. if m.task_stages == nil {
  18680. m.task_stages = make(map[uint64]struct{})
  18681. }
  18682. for i := range ids {
  18683. m.task_stages[ids[i]] = struct{}{}
  18684. }
  18685. }
  18686. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  18687. func (m *SopTaskMutation) ClearTaskStages() {
  18688. m.clearedtask_stages = true
  18689. }
  18690. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  18691. func (m *SopTaskMutation) TaskStagesCleared() bool {
  18692. return m.clearedtask_stages
  18693. }
  18694. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  18695. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  18696. if m.removedtask_stages == nil {
  18697. m.removedtask_stages = make(map[uint64]struct{})
  18698. }
  18699. for i := range ids {
  18700. delete(m.task_stages, ids[i])
  18701. m.removedtask_stages[ids[i]] = struct{}{}
  18702. }
  18703. }
  18704. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  18705. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  18706. for id := range m.removedtask_stages {
  18707. ids = append(ids, id)
  18708. }
  18709. return
  18710. }
  18711. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  18712. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  18713. for id := range m.task_stages {
  18714. ids = append(ids, id)
  18715. }
  18716. return
  18717. }
  18718. // ResetTaskStages resets all changes to the "task_stages" edge.
  18719. func (m *SopTaskMutation) ResetTaskStages() {
  18720. m.task_stages = nil
  18721. m.clearedtask_stages = false
  18722. m.removedtask_stages = nil
  18723. }
  18724. // Where appends a list predicates to the SopTaskMutation builder.
  18725. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  18726. m.predicates = append(m.predicates, ps...)
  18727. }
  18728. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  18729. // users can use type-assertion to append predicates that do not depend on any generated package.
  18730. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  18731. p := make([]predicate.SopTask, len(ps))
  18732. for i := range ps {
  18733. p[i] = ps[i]
  18734. }
  18735. m.Where(p...)
  18736. }
  18737. // Op returns the operation name.
  18738. func (m *SopTaskMutation) Op() Op {
  18739. return m.op
  18740. }
  18741. // SetOp allows setting the mutation operation.
  18742. func (m *SopTaskMutation) SetOp(op Op) {
  18743. m.op = op
  18744. }
  18745. // Type returns the node type of this mutation (SopTask).
  18746. func (m *SopTaskMutation) Type() string {
  18747. return m.typ
  18748. }
  18749. // Fields returns all fields that were changed during this mutation. Note that in
  18750. // order to get all numeric fields that were incremented/decremented, call
  18751. // AddedFields().
  18752. func (m *SopTaskMutation) Fields() []string {
  18753. fields := make([]string, 0, 11)
  18754. if m.created_at != nil {
  18755. fields = append(fields, soptask.FieldCreatedAt)
  18756. }
  18757. if m.updated_at != nil {
  18758. fields = append(fields, soptask.FieldUpdatedAt)
  18759. }
  18760. if m.status != nil {
  18761. fields = append(fields, soptask.FieldStatus)
  18762. }
  18763. if m.deleted_at != nil {
  18764. fields = append(fields, soptask.FieldDeletedAt)
  18765. }
  18766. if m.name != nil {
  18767. fields = append(fields, soptask.FieldName)
  18768. }
  18769. if m.bot_wxid_list != nil {
  18770. fields = append(fields, soptask.FieldBotWxidList)
  18771. }
  18772. if m._type != nil {
  18773. fields = append(fields, soptask.FieldType)
  18774. }
  18775. if m.plan_start_time != nil {
  18776. fields = append(fields, soptask.FieldPlanStartTime)
  18777. }
  18778. if m.plan_end_time != nil {
  18779. fields = append(fields, soptask.FieldPlanEndTime)
  18780. }
  18781. if m.creator_id != nil {
  18782. fields = append(fields, soptask.FieldCreatorID)
  18783. }
  18784. if m.organization_id != nil {
  18785. fields = append(fields, soptask.FieldOrganizationID)
  18786. }
  18787. return fields
  18788. }
  18789. // Field returns the value of a field with the given name. The second boolean
  18790. // return value indicates that this field was not set, or was not defined in the
  18791. // schema.
  18792. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  18793. switch name {
  18794. case soptask.FieldCreatedAt:
  18795. return m.CreatedAt()
  18796. case soptask.FieldUpdatedAt:
  18797. return m.UpdatedAt()
  18798. case soptask.FieldStatus:
  18799. return m.Status()
  18800. case soptask.FieldDeletedAt:
  18801. return m.DeletedAt()
  18802. case soptask.FieldName:
  18803. return m.Name()
  18804. case soptask.FieldBotWxidList:
  18805. return m.BotWxidList()
  18806. case soptask.FieldType:
  18807. return m.GetType()
  18808. case soptask.FieldPlanStartTime:
  18809. return m.PlanStartTime()
  18810. case soptask.FieldPlanEndTime:
  18811. return m.PlanEndTime()
  18812. case soptask.FieldCreatorID:
  18813. return m.CreatorID()
  18814. case soptask.FieldOrganizationID:
  18815. return m.OrganizationID()
  18816. }
  18817. return nil, false
  18818. }
  18819. // OldField returns the old value of the field from the database. An error is
  18820. // returned if the mutation operation is not UpdateOne, or the query to the
  18821. // database failed.
  18822. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18823. switch name {
  18824. case soptask.FieldCreatedAt:
  18825. return m.OldCreatedAt(ctx)
  18826. case soptask.FieldUpdatedAt:
  18827. return m.OldUpdatedAt(ctx)
  18828. case soptask.FieldStatus:
  18829. return m.OldStatus(ctx)
  18830. case soptask.FieldDeletedAt:
  18831. return m.OldDeletedAt(ctx)
  18832. case soptask.FieldName:
  18833. return m.OldName(ctx)
  18834. case soptask.FieldBotWxidList:
  18835. return m.OldBotWxidList(ctx)
  18836. case soptask.FieldType:
  18837. return m.OldType(ctx)
  18838. case soptask.FieldPlanStartTime:
  18839. return m.OldPlanStartTime(ctx)
  18840. case soptask.FieldPlanEndTime:
  18841. return m.OldPlanEndTime(ctx)
  18842. case soptask.FieldCreatorID:
  18843. return m.OldCreatorID(ctx)
  18844. case soptask.FieldOrganizationID:
  18845. return m.OldOrganizationID(ctx)
  18846. }
  18847. return nil, fmt.Errorf("unknown SopTask field %s", name)
  18848. }
  18849. // SetField sets the value of a field with the given name. It returns an error if
  18850. // the field is not defined in the schema, or if the type mismatched the field
  18851. // type.
  18852. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  18853. switch name {
  18854. case soptask.FieldCreatedAt:
  18855. v, ok := value.(time.Time)
  18856. if !ok {
  18857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18858. }
  18859. m.SetCreatedAt(v)
  18860. return nil
  18861. case soptask.FieldUpdatedAt:
  18862. v, ok := value.(time.Time)
  18863. if !ok {
  18864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18865. }
  18866. m.SetUpdatedAt(v)
  18867. return nil
  18868. case soptask.FieldStatus:
  18869. v, ok := value.(uint8)
  18870. if !ok {
  18871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18872. }
  18873. m.SetStatus(v)
  18874. return nil
  18875. case soptask.FieldDeletedAt:
  18876. v, ok := value.(time.Time)
  18877. if !ok {
  18878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18879. }
  18880. m.SetDeletedAt(v)
  18881. return nil
  18882. case soptask.FieldName:
  18883. v, ok := value.(string)
  18884. if !ok {
  18885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18886. }
  18887. m.SetName(v)
  18888. return nil
  18889. case soptask.FieldBotWxidList:
  18890. v, ok := value.([]string)
  18891. if !ok {
  18892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18893. }
  18894. m.SetBotWxidList(v)
  18895. return nil
  18896. case soptask.FieldType:
  18897. v, ok := value.(int)
  18898. if !ok {
  18899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18900. }
  18901. m.SetType(v)
  18902. return nil
  18903. case soptask.FieldPlanStartTime:
  18904. v, ok := value.(time.Time)
  18905. if !ok {
  18906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18907. }
  18908. m.SetPlanStartTime(v)
  18909. return nil
  18910. case soptask.FieldPlanEndTime:
  18911. v, ok := value.(time.Time)
  18912. if !ok {
  18913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18914. }
  18915. m.SetPlanEndTime(v)
  18916. return nil
  18917. case soptask.FieldCreatorID:
  18918. v, ok := value.(string)
  18919. if !ok {
  18920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18921. }
  18922. m.SetCreatorID(v)
  18923. return nil
  18924. case soptask.FieldOrganizationID:
  18925. v, ok := value.(uint64)
  18926. if !ok {
  18927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18928. }
  18929. m.SetOrganizationID(v)
  18930. return nil
  18931. }
  18932. return fmt.Errorf("unknown SopTask field %s", name)
  18933. }
  18934. // AddedFields returns all numeric fields that were incremented/decremented during
  18935. // this mutation.
  18936. func (m *SopTaskMutation) AddedFields() []string {
  18937. var fields []string
  18938. if m.addstatus != nil {
  18939. fields = append(fields, soptask.FieldStatus)
  18940. }
  18941. if m.add_type != nil {
  18942. fields = append(fields, soptask.FieldType)
  18943. }
  18944. if m.addorganization_id != nil {
  18945. fields = append(fields, soptask.FieldOrganizationID)
  18946. }
  18947. return fields
  18948. }
  18949. // AddedField returns the numeric value that was incremented/decremented on a field
  18950. // with the given name. The second boolean return value indicates that this field
  18951. // was not set, or was not defined in the schema.
  18952. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  18953. switch name {
  18954. case soptask.FieldStatus:
  18955. return m.AddedStatus()
  18956. case soptask.FieldType:
  18957. return m.AddedType()
  18958. case soptask.FieldOrganizationID:
  18959. return m.AddedOrganizationID()
  18960. }
  18961. return nil, false
  18962. }
  18963. // AddField adds the value to the field with the given name. It returns an error if
  18964. // the field is not defined in the schema, or if the type mismatched the field
  18965. // type.
  18966. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  18967. switch name {
  18968. case soptask.FieldStatus:
  18969. v, ok := value.(int8)
  18970. if !ok {
  18971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18972. }
  18973. m.AddStatus(v)
  18974. return nil
  18975. case soptask.FieldType:
  18976. v, ok := value.(int)
  18977. if !ok {
  18978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18979. }
  18980. m.AddType(v)
  18981. return nil
  18982. case soptask.FieldOrganizationID:
  18983. v, ok := value.(int64)
  18984. if !ok {
  18985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18986. }
  18987. m.AddOrganizationID(v)
  18988. return nil
  18989. }
  18990. return fmt.Errorf("unknown SopTask numeric field %s", name)
  18991. }
  18992. // ClearedFields returns all nullable fields that were cleared during this
  18993. // mutation.
  18994. func (m *SopTaskMutation) ClearedFields() []string {
  18995. var fields []string
  18996. if m.FieldCleared(soptask.FieldStatus) {
  18997. fields = append(fields, soptask.FieldStatus)
  18998. }
  18999. if m.FieldCleared(soptask.FieldDeletedAt) {
  19000. fields = append(fields, soptask.FieldDeletedAt)
  19001. }
  19002. if m.FieldCleared(soptask.FieldBotWxidList) {
  19003. fields = append(fields, soptask.FieldBotWxidList)
  19004. }
  19005. if m.FieldCleared(soptask.FieldPlanStartTime) {
  19006. fields = append(fields, soptask.FieldPlanStartTime)
  19007. }
  19008. if m.FieldCleared(soptask.FieldPlanEndTime) {
  19009. fields = append(fields, soptask.FieldPlanEndTime)
  19010. }
  19011. if m.FieldCleared(soptask.FieldCreatorID) {
  19012. fields = append(fields, soptask.FieldCreatorID)
  19013. }
  19014. if m.FieldCleared(soptask.FieldOrganizationID) {
  19015. fields = append(fields, soptask.FieldOrganizationID)
  19016. }
  19017. return fields
  19018. }
  19019. // FieldCleared returns a boolean indicating if a field with the given name was
  19020. // cleared in this mutation.
  19021. func (m *SopTaskMutation) FieldCleared(name string) bool {
  19022. _, ok := m.clearedFields[name]
  19023. return ok
  19024. }
  19025. // ClearField clears the value of the field with the given name. It returns an
  19026. // error if the field is not defined in the schema.
  19027. func (m *SopTaskMutation) ClearField(name string) error {
  19028. switch name {
  19029. case soptask.FieldStatus:
  19030. m.ClearStatus()
  19031. return nil
  19032. case soptask.FieldDeletedAt:
  19033. m.ClearDeletedAt()
  19034. return nil
  19035. case soptask.FieldBotWxidList:
  19036. m.ClearBotWxidList()
  19037. return nil
  19038. case soptask.FieldPlanStartTime:
  19039. m.ClearPlanStartTime()
  19040. return nil
  19041. case soptask.FieldPlanEndTime:
  19042. m.ClearPlanEndTime()
  19043. return nil
  19044. case soptask.FieldCreatorID:
  19045. m.ClearCreatorID()
  19046. return nil
  19047. case soptask.FieldOrganizationID:
  19048. m.ClearOrganizationID()
  19049. return nil
  19050. }
  19051. return fmt.Errorf("unknown SopTask nullable field %s", name)
  19052. }
  19053. // ResetField resets all changes in the mutation for the field with the given name.
  19054. // It returns an error if the field is not defined in the schema.
  19055. func (m *SopTaskMutation) ResetField(name string) error {
  19056. switch name {
  19057. case soptask.FieldCreatedAt:
  19058. m.ResetCreatedAt()
  19059. return nil
  19060. case soptask.FieldUpdatedAt:
  19061. m.ResetUpdatedAt()
  19062. return nil
  19063. case soptask.FieldStatus:
  19064. m.ResetStatus()
  19065. return nil
  19066. case soptask.FieldDeletedAt:
  19067. m.ResetDeletedAt()
  19068. return nil
  19069. case soptask.FieldName:
  19070. m.ResetName()
  19071. return nil
  19072. case soptask.FieldBotWxidList:
  19073. m.ResetBotWxidList()
  19074. return nil
  19075. case soptask.FieldType:
  19076. m.ResetType()
  19077. return nil
  19078. case soptask.FieldPlanStartTime:
  19079. m.ResetPlanStartTime()
  19080. return nil
  19081. case soptask.FieldPlanEndTime:
  19082. m.ResetPlanEndTime()
  19083. return nil
  19084. case soptask.FieldCreatorID:
  19085. m.ResetCreatorID()
  19086. return nil
  19087. case soptask.FieldOrganizationID:
  19088. m.ResetOrganizationID()
  19089. return nil
  19090. }
  19091. return fmt.Errorf("unknown SopTask field %s", name)
  19092. }
  19093. // AddedEdges returns all edge names that were set/added in this mutation.
  19094. func (m *SopTaskMutation) AddedEdges() []string {
  19095. edges := make([]string, 0, 1)
  19096. if m.task_stages != nil {
  19097. edges = append(edges, soptask.EdgeTaskStages)
  19098. }
  19099. return edges
  19100. }
  19101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19102. // name in this mutation.
  19103. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  19104. switch name {
  19105. case soptask.EdgeTaskStages:
  19106. ids := make([]ent.Value, 0, len(m.task_stages))
  19107. for id := range m.task_stages {
  19108. ids = append(ids, id)
  19109. }
  19110. return ids
  19111. }
  19112. return nil
  19113. }
  19114. // RemovedEdges returns all edge names that were removed in this mutation.
  19115. func (m *SopTaskMutation) RemovedEdges() []string {
  19116. edges := make([]string, 0, 1)
  19117. if m.removedtask_stages != nil {
  19118. edges = append(edges, soptask.EdgeTaskStages)
  19119. }
  19120. return edges
  19121. }
  19122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19123. // the given name in this mutation.
  19124. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  19125. switch name {
  19126. case soptask.EdgeTaskStages:
  19127. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  19128. for id := range m.removedtask_stages {
  19129. ids = append(ids, id)
  19130. }
  19131. return ids
  19132. }
  19133. return nil
  19134. }
  19135. // ClearedEdges returns all edge names that were cleared in this mutation.
  19136. func (m *SopTaskMutation) ClearedEdges() []string {
  19137. edges := make([]string, 0, 1)
  19138. if m.clearedtask_stages {
  19139. edges = append(edges, soptask.EdgeTaskStages)
  19140. }
  19141. return edges
  19142. }
  19143. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19144. // was cleared in this mutation.
  19145. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  19146. switch name {
  19147. case soptask.EdgeTaskStages:
  19148. return m.clearedtask_stages
  19149. }
  19150. return false
  19151. }
  19152. // ClearEdge clears the value of the edge with the given name. It returns an error
  19153. // if that edge is not defined in the schema.
  19154. func (m *SopTaskMutation) ClearEdge(name string) error {
  19155. switch name {
  19156. }
  19157. return fmt.Errorf("unknown SopTask unique edge %s", name)
  19158. }
  19159. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19160. // It returns an error if the edge is not defined in the schema.
  19161. func (m *SopTaskMutation) ResetEdge(name string) error {
  19162. switch name {
  19163. case soptask.EdgeTaskStages:
  19164. m.ResetTaskStages()
  19165. return nil
  19166. }
  19167. return fmt.Errorf("unknown SopTask edge %s", name)
  19168. }
  19169. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  19170. type TokenMutation struct {
  19171. config
  19172. op Op
  19173. typ string
  19174. id *uint64
  19175. created_at *time.Time
  19176. updated_at *time.Time
  19177. deleted_at *time.Time
  19178. expire_at *time.Time
  19179. token *string
  19180. mac *string
  19181. clearedFields map[string]struct{}
  19182. done bool
  19183. oldValue func(context.Context) (*Token, error)
  19184. predicates []predicate.Token
  19185. }
  19186. var _ ent.Mutation = (*TokenMutation)(nil)
  19187. // tokenOption allows management of the mutation configuration using functional options.
  19188. type tokenOption func(*TokenMutation)
  19189. // newTokenMutation creates new mutation for the Token entity.
  19190. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  19191. m := &TokenMutation{
  19192. config: c,
  19193. op: op,
  19194. typ: TypeToken,
  19195. clearedFields: make(map[string]struct{}),
  19196. }
  19197. for _, opt := range opts {
  19198. opt(m)
  19199. }
  19200. return m
  19201. }
  19202. // withTokenID sets the ID field of the mutation.
  19203. func withTokenID(id uint64) tokenOption {
  19204. return func(m *TokenMutation) {
  19205. var (
  19206. err error
  19207. once sync.Once
  19208. value *Token
  19209. )
  19210. m.oldValue = func(ctx context.Context) (*Token, error) {
  19211. once.Do(func() {
  19212. if m.done {
  19213. err = errors.New("querying old values post mutation is not allowed")
  19214. } else {
  19215. value, err = m.Client().Token.Get(ctx, id)
  19216. }
  19217. })
  19218. return value, err
  19219. }
  19220. m.id = &id
  19221. }
  19222. }
  19223. // withToken sets the old Token of the mutation.
  19224. func withToken(node *Token) tokenOption {
  19225. return func(m *TokenMutation) {
  19226. m.oldValue = func(context.Context) (*Token, error) {
  19227. return node, nil
  19228. }
  19229. m.id = &node.ID
  19230. }
  19231. }
  19232. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19233. // executed in a transaction (ent.Tx), a transactional client is returned.
  19234. func (m TokenMutation) Client() *Client {
  19235. client := &Client{config: m.config}
  19236. client.init()
  19237. return client
  19238. }
  19239. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19240. // it returns an error otherwise.
  19241. func (m TokenMutation) Tx() (*Tx, error) {
  19242. if _, ok := m.driver.(*txDriver); !ok {
  19243. return nil, errors.New("ent: mutation is not running in a transaction")
  19244. }
  19245. tx := &Tx{config: m.config}
  19246. tx.init()
  19247. return tx, nil
  19248. }
  19249. // SetID sets the value of the id field. Note that this
  19250. // operation is only accepted on creation of Token entities.
  19251. func (m *TokenMutation) SetID(id uint64) {
  19252. m.id = &id
  19253. }
  19254. // ID returns the ID value in the mutation. Note that the ID is only available
  19255. // if it was provided to the builder or after it was returned from the database.
  19256. func (m *TokenMutation) ID() (id uint64, exists bool) {
  19257. if m.id == nil {
  19258. return
  19259. }
  19260. return *m.id, true
  19261. }
  19262. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19263. // That means, if the mutation is applied within a transaction with an isolation level such
  19264. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19265. // or updated by the mutation.
  19266. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  19267. switch {
  19268. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19269. id, exists := m.ID()
  19270. if exists {
  19271. return []uint64{id}, nil
  19272. }
  19273. fallthrough
  19274. case m.op.Is(OpUpdate | OpDelete):
  19275. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  19276. default:
  19277. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19278. }
  19279. }
  19280. // SetCreatedAt sets the "created_at" field.
  19281. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  19282. m.created_at = &t
  19283. }
  19284. // CreatedAt returns the value of the "created_at" field in the mutation.
  19285. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  19286. v := m.created_at
  19287. if v == nil {
  19288. return
  19289. }
  19290. return *v, true
  19291. }
  19292. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  19293. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19295. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19296. if !m.op.Is(OpUpdateOne) {
  19297. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19298. }
  19299. if m.id == nil || m.oldValue == nil {
  19300. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19301. }
  19302. oldValue, err := m.oldValue(ctx)
  19303. if err != nil {
  19304. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19305. }
  19306. return oldValue.CreatedAt, nil
  19307. }
  19308. // ResetCreatedAt resets all changes to the "created_at" field.
  19309. func (m *TokenMutation) ResetCreatedAt() {
  19310. m.created_at = nil
  19311. }
  19312. // SetUpdatedAt sets the "updated_at" field.
  19313. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  19314. m.updated_at = &t
  19315. }
  19316. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19317. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  19318. v := m.updated_at
  19319. if v == nil {
  19320. return
  19321. }
  19322. return *v, true
  19323. }
  19324. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  19325. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19327. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19328. if !m.op.Is(OpUpdateOne) {
  19329. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19330. }
  19331. if m.id == nil || m.oldValue == nil {
  19332. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19333. }
  19334. oldValue, err := m.oldValue(ctx)
  19335. if err != nil {
  19336. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19337. }
  19338. return oldValue.UpdatedAt, nil
  19339. }
  19340. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19341. func (m *TokenMutation) ResetUpdatedAt() {
  19342. m.updated_at = nil
  19343. }
  19344. // SetDeletedAt sets the "deleted_at" field.
  19345. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  19346. m.deleted_at = &t
  19347. }
  19348. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19349. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  19350. v := m.deleted_at
  19351. if v == nil {
  19352. return
  19353. }
  19354. return *v, true
  19355. }
  19356. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  19357. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19359. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19360. if !m.op.Is(OpUpdateOne) {
  19361. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19362. }
  19363. if m.id == nil || m.oldValue == nil {
  19364. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19365. }
  19366. oldValue, err := m.oldValue(ctx)
  19367. if err != nil {
  19368. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19369. }
  19370. return oldValue.DeletedAt, nil
  19371. }
  19372. // ClearDeletedAt clears the value of the "deleted_at" field.
  19373. func (m *TokenMutation) ClearDeletedAt() {
  19374. m.deleted_at = nil
  19375. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  19376. }
  19377. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19378. func (m *TokenMutation) DeletedAtCleared() bool {
  19379. _, ok := m.clearedFields[token.FieldDeletedAt]
  19380. return ok
  19381. }
  19382. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19383. func (m *TokenMutation) ResetDeletedAt() {
  19384. m.deleted_at = nil
  19385. delete(m.clearedFields, token.FieldDeletedAt)
  19386. }
  19387. // SetExpireAt sets the "expire_at" field.
  19388. func (m *TokenMutation) SetExpireAt(t time.Time) {
  19389. m.expire_at = &t
  19390. }
  19391. // ExpireAt returns the value of the "expire_at" field in the mutation.
  19392. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  19393. v := m.expire_at
  19394. if v == nil {
  19395. return
  19396. }
  19397. return *v, true
  19398. }
  19399. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  19400. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19402. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  19403. if !m.op.Is(OpUpdateOne) {
  19404. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  19405. }
  19406. if m.id == nil || m.oldValue == nil {
  19407. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  19408. }
  19409. oldValue, err := m.oldValue(ctx)
  19410. if err != nil {
  19411. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  19412. }
  19413. return oldValue.ExpireAt, nil
  19414. }
  19415. // ClearExpireAt clears the value of the "expire_at" field.
  19416. func (m *TokenMutation) ClearExpireAt() {
  19417. m.expire_at = nil
  19418. m.clearedFields[token.FieldExpireAt] = struct{}{}
  19419. }
  19420. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  19421. func (m *TokenMutation) ExpireAtCleared() bool {
  19422. _, ok := m.clearedFields[token.FieldExpireAt]
  19423. return ok
  19424. }
  19425. // ResetExpireAt resets all changes to the "expire_at" field.
  19426. func (m *TokenMutation) ResetExpireAt() {
  19427. m.expire_at = nil
  19428. delete(m.clearedFields, token.FieldExpireAt)
  19429. }
  19430. // SetToken sets the "token" field.
  19431. func (m *TokenMutation) SetToken(s string) {
  19432. m.token = &s
  19433. }
  19434. // Token returns the value of the "token" field in the mutation.
  19435. func (m *TokenMutation) Token() (r string, exists bool) {
  19436. v := m.token
  19437. if v == nil {
  19438. return
  19439. }
  19440. return *v, true
  19441. }
  19442. // OldToken returns the old "token" field's value of the Token entity.
  19443. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19445. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  19446. if !m.op.Is(OpUpdateOne) {
  19447. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19448. }
  19449. if m.id == nil || m.oldValue == nil {
  19450. return v, errors.New("OldToken requires an ID field in the mutation")
  19451. }
  19452. oldValue, err := m.oldValue(ctx)
  19453. if err != nil {
  19454. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19455. }
  19456. return oldValue.Token, nil
  19457. }
  19458. // ClearToken clears the value of the "token" field.
  19459. func (m *TokenMutation) ClearToken() {
  19460. m.token = nil
  19461. m.clearedFields[token.FieldToken] = struct{}{}
  19462. }
  19463. // TokenCleared returns if the "token" field was cleared in this mutation.
  19464. func (m *TokenMutation) TokenCleared() bool {
  19465. _, ok := m.clearedFields[token.FieldToken]
  19466. return ok
  19467. }
  19468. // ResetToken resets all changes to the "token" field.
  19469. func (m *TokenMutation) ResetToken() {
  19470. m.token = nil
  19471. delete(m.clearedFields, token.FieldToken)
  19472. }
  19473. // SetMAC sets the "mac" field.
  19474. func (m *TokenMutation) SetMAC(s string) {
  19475. m.mac = &s
  19476. }
  19477. // MAC returns the value of the "mac" field in the mutation.
  19478. func (m *TokenMutation) MAC() (r string, exists bool) {
  19479. v := m.mac
  19480. if v == nil {
  19481. return
  19482. }
  19483. return *v, true
  19484. }
  19485. // OldMAC returns the old "mac" field's value of the Token entity.
  19486. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  19487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19488. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  19489. if !m.op.Is(OpUpdateOne) {
  19490. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  19491. }
  19492. if m.id == nil || m.oldValue == nil {
  19493. return v, errors.New("OldMAC requires an ID field in the mutation")
  19494. }
  19495. oldValue, err := m.oldValue(ctx)
  19496. if err != nil {
  19497. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  19498. }
  19499. return oldValue.MAC, nil
  19500. }
  19501. // ResetMAC resets all changes to the "mac" field.
  19502. func (m *TokenMutation) ResetMAC() {
  19503. m.mac = nil
  19504. }
  19505. // Where appends a list predicates to the TokenMutation builder.
  19506. func (m *TokenMutation) Where(ps ...predicate.Token) {
  19507. m.predicates = append(m.predicates, ps...)
  19508. }
  19509. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  19510. // users can use type-assertion to append predicates that do not depend on any generated package.
  19511. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  19512. p := make([]predicate.Token, len(ps))
  19513. for i := range ps {
  19514. p[i] = ps[i]
  19515. }
  19516. m.Where(p...)
  19517. }
  19518. // Op returns the operation name.
  19519. func (m *TokenMutation) Op() Op {
  19520. return m.op
  19521. }
  19522. // SetOp allows setting the mutation operation.
  19523. func (m *TokenMutation) SetOp(op Op) {
  19524. m.op = op
  19525. }
  19526. // Type returns the node type of this mutation (Token).
  19527. func (m *TokenMutation) Type() string {
  19528. return m.typ
  19529. }
  19530. // Fields returns all fields that were changed during this mutation. Note that in
  19531. // order to get all numeric fields that were incremented/decremented, call
  19532. // AddedFields().
  19533. func (m *TokenMutation) Fields() []string {
  19534. fields := make([]string, 0, 6)
  19535. if m.created_at != nil {
  19536. fields = append(fields, token.FieldCreatedAt)
  19537. }
  19538. if m.updated_at != nil {
  19539. fields = append(fields, token.FieldUpdatedAt)
  19540. }
  19541. if m.deleted_at != nil {
  19542. fields = append(fields, token.FieldDeletedAt)
  19543. }
  19544. if m.expire_at != nil {
  19545. fields = append(fields, token.FieldExpireAt)
  19546. }
  19547. if m.token != nil {
  19548. fields = append(fields, token.FieldToken)
  19549. }
  19550. if m.mac != nil {
  19551. fields = append(fields, token.FieldMAC)
  19552. }
  19553. return fields
  19554. }
  19555. // Field returns the value of a field with the given name. The second boolean
  19556. // return value indicates that this field was not set, or was not defined in the
  19557. // schema.
  19558. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  19559. switch name {
  19560. case token.FieldCreatedAt:
  19561. return m.CreatedAt()
  19562. case token.FieldUpdatedAt:
  19563. return m.UpdatedAt()
  19564. case token.FieldDeletedAt:
  19565. return m.DeletedAt()
  19566. case token.FieldExpireAt:
  19567. return m.ExpireAt()
  19568. case token.FieldToken:
  19569. return m.Token()
  19570. case token.FieldMAC:
  19571. return m.MAC()
  19572. }
  19573. return nil, false
  19574. }
  19575. // OldField returns the old value of the field from the database. An error is
  19576. // returned if the mutation operation is not UpdateOne, or the query to the
  19577. // database failed.
  19578. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19579. switch name {
  19580. case token.FieldCreatedAt:
  19581. return m.OldCreatedAt(ctx)
  19582. case token.FieldUpdatedAt:
  19583. return m.OldUpdatedAt(ctx)
  19584. case token.FieldDeletedAt:
  19585. return m.OldDeletedAt(ctx)
  19586. case token.FieldExpireAt:
  19587. return m.OldExpireAt(ctx)
  19588. case token.FieldToken:
  19589. return m.OldToken(ctx)
  19590. case token.FieldMAC:
  19591. return m.OldMAC(ctx)
  19592. }
  19593. return nil, fmt.Errorf("unknown Token field %s", name)
  19594. }
  19595. // SetField sets the value of a field with the given name. It returns an error if
  19596. // the field is not defined in the schema, or if the type mismatched the field
  19597. // type.
  19598. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  19599. switch name {
  19600. case token.FieldCreatedAt:
  19601. v, ok := value.(time.Time)
  19602. if !ok {
  19603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19604. }
  19605. m.SetCreatedAt(v)
  19606. return nil
  19607. case token.FieldUpdatedAt:
  19608. v, ok := value.(time.Time)
  19609. if !ok {
  19610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19611. }
  19612. m.SetUpdatedAt(v)
  19613. return nil
  19614. case token.FieldDeletedAt:
  19615. v, ok := value.(time.Time)
  19616. if !ok {
  19617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19618. }
  19619. m.SetDeletedAt(v)
  19620. return nil
  19621. case token.FieldExpireAt:
  19622. v, ok := value.(time.Time)
  19623. if !ok {
  19624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19625. }
  19626. m.SetExpireAt(v)
  19627. return nil
  19628. case token.FieldToken:
  19629. v, ok := value.(string)
  19630. if !ok {
  19631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19632. }
  19633. m.SetToken(v)
  19634. return nil
  19635. case token.FieldMAC:
  19636. v, ok := value.(string)
  19637. if !ok {
  19638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19639. }
  19640. m.SetMAC(v)
  19641. return nil
  19642. }
  19643. return fmt.Errorf("unknown Token field %s", name)
  19644. }
  19645. // AddedFields returns all numeric fields that were incremented/decremented during
  19646. // this mutation.
  19647. func (m *TokenMutation) AddedFields() []string {
  19648. return nil
  19649. }
  19650. // AddedField returns the numeric value that was incremented/decremented on a field
  19651. // with the given name. The second boolean return value indicates that this field
  19652. // was not set, or was not defined in the schema.
  19653. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  19654. return nil, false
  19655. }
  19656. // AddField adds the value to the field with the given name. It returns an error if
  19657. // the field is not defined in the schema, or if the type mismatched the field
  19658. // type.
  19659. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  19660. switch name {
  19661. }
  19662. return fmt.Errorf("unknown Token numeric field %s", name)
  19663. }
  19664. // ClearedFields returns all nullable fields that were cleared during this
  19665. // mutation.
  19666. func (m *TokenMutation) ClearedFields() []string {
  19667. var fields []string
  19668. if m.FieldCleared(token.FieldDeletedAt) {
  19669. fields = append(fields, token.FieldDeletedAt)
  19670. }
  19671. if m.FieldCleared(token.FieldExpireAt) {
  19672. fields = append(fields, token.FieldExpireAt)
  19673. }
  19674. if m.FieldCleared(token.FieldToken) {
  19675. fields = append(fields, token.FieldToken)
  19676. }
  19677. return fields
  19678. }
  19679. // FieldCleared returns a boolean indicating if a field with the given name was
  19680. // cleared in this mutation.
  19681. func (m *TokenMutation) FieldCleared(name string) bool {
  19682. _, ok := m.clearedFields[name]
  19683. return ok
  19684. }
  19685. // ClearField clears the value of the field with the given name. It returns an
  19686. // error if the field is not defined in the schema.
  19687. func (m *TokenMutation) ClearField(name string) error {
  19688. switch name {
  19689. case token.FieldDeletedAt:
  19690. m.ClearDeletedAt()
  19691. return nil
  19692. case token.FieldExpireAt:
  19693. m.ClearExpireAt()
  19694. return nil
  19695. case token.FieldToken:
  19696. m.ClearToken()
  19697. return nil
  19698. }
  19699. return fmt.Errorf("unknown Token nullable field %s", name)
  19700. }
  19701. // ResetField resets all changes in the mutation for the field with the given name.
  19702. // It returns an error if the field is not defined in the schema.
  19703. func (m *TokenMutation) ResetField(name string) error {
  19704. switch name {
  19705. case token.FieldCreatedAt:
  19706. m.ResetCreatedAt()
  19707. return nil
  19708. case token.FieldUpdatedAt:
  19709. m.ResetUpdatedAt()
  19710. return nil
  19711. case token.FieldDeletedAt:
  19712. m.ResetDeletedAt()
  19713. return nil
  19714. case token.FieldExpireAt:
  19715. m.ResetExpireAt()
  19716. return nil
  19717. case token.FieldToken:
  19718. m.ResetToken()
  19719. return nil
  19720. case token.FieldMAC:
  19721. m.ResetMAC()
  19722. return nil
  19723. }
  19724. return fmt.Errorf("unknown Token field %s", name)
  19725. }
  19726. // AddedEdges returns all edge names that were set/added in this mutation.
  19727. func (m *TokenMutation) AddedEdges() []string {
  19728. edges := make([]string, 0, 0)
  19729. return edges
  19730. }
  19731. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19732. // name in this mutation.
  19733. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  19734. return nil
  19735. }
  19736. // RemovedEdges returns all edge names that were removed in this mutation.
  19737. func (m *TokenMutation) RemovedEdges() []string {
  19738. edges := make([]string, 0, 0)
  19739. return edges
  19740. }
  19741. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19742. // the given name in this mutation.
  19743. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  19744. return nil
  19745. }
  19746. // ClearedEdges returns all edge names that were cleared in this mutation.
  19747. func (m *TokenMutation) ClearedEdges() []string {
  19748. edges := make([]string, 0, 0)
  19749. return edges
  19750. }
  19751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19752. // was cleared in this mutation.
  19753. func (m *TokenMutation) EdgeCleared(name string) bool {
  19754. return false
  19755. }
  19756. // ClearEdge clears the value of the edge with the given name. It returns an error
  19757. // if that edge is not defined in the schema.
  19758. func (m *TokenMutation) ClearEdge(name string) error {
  19759. return fmt.Errorf("unknown Token unique edge %s", name)
  19760. }
  19761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19762. // It returns an error if the edge is not defined in the schema.
  19763. func (m *TokenMutation) ResetEdge(name string) error {
  19764. return fmt.Errorf("unknown Token edge %s", name)
  19765. }
  19766. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  19767. type TutorialMutation struct {
  19768. config
  19769. op Op
  19770. typ string
  19771. id *uint64
  19772. created_at *time.Time
  19773. updated_at *time.Time
  19774. deleted_at *time.Time
  19775. index *int
  19776. addindex *int
  19777. title *string
  19778. content *string
  19779. organization_id *uint64
  19780. addorganization_id *int64
  19781. clearedFields map[string]struct{}
  19782. employee *uint64
  19783. clearedemployee bool
  19784. done bool
  19785. oldValue func(context.Context) (*Tutorial, error)
  19786. predicates []predicate.Tutorial
  19787. }
  19788. var _ ent.Mutation = (*TutorialMutation)(nil)
  19789. // tutorialOption allows management of the mutation configuration using functional options.
  19790. type tutorialOption func(*TutorialMutation)
  19791. // newTutorialMutation creates new mutation for the Tutorial entity.
  19792. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  19793. m := &TutorialMutation{
  19794. config: c,
  19795. op: op,
  19796. typ: TypeTutorial,
  19797. clearedFields: make(map[string]struct{}),
  19798. }
  19799. for _, opt := range opts {
  19800. opt(m)
  19801. }
  19802. return m
  19803. }
  19804. // withTutorialID sets the ID field of the mutation.
  19805. func withTutorialID(id uint64) tutorialOption {
  19806. return func(m *TutorialMutation) {
  19807. var (
  19808. err error
  19809. once sync.Once
  19810. value *Tutorial
  19811. )
  19812. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  19813. once.Do(func() {
  19814. if m.done {
  19815. err = errors.New("querying old values post mutation is not allowed")
  19816. } else {
  19817. value, err = m.Client().Tutorial.Get(ctx, id)
  19818. }
  19819. })
  19820. return value, err
  19821. }
  19822. m.id = &id
  19823. }
  19824. }
  19825. // withTutorial sets the old Tutorial of the mutation.
  19826. func withTutorial(node *Tutorial) tutorialOption {
  19827. return func(m *TutorialMutation) {
  19828. m.oldValue = func(context.Context) (*Tutorial, error) {
  19829. return node, nil
  19830. }
  19831. m.id = &node.ID
  19832. }
  19833. }
  19834. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19835. // executed in a transaction (ent.Tx), a transactional client is returned.
  19836. func (m TutorialMutation) Client() *Client {
  19837. client := &Client{config: m.config}
  19838. client.init()
  19839. return client
  19840. }
  19841. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19842. // it returns an error otherwise.
  19843. func (m TutorialMutation) Tx() (*Tx, error) {
  19844. if _, ok := m.driver.(*txDriver); !ok {
  19845. return nil, errors.New("ent: mutation is not running in a transaction")
  19846. }
  19847. tx := &Tx{config: m.config}
  19848. tx.init()
  19849. return tx, nil
  19850. }
  19851. // SetID sets the value of the id field. Note that this
  19852. // operation is only accepted on creation of Tutorial entities.
  19853. func (m *TutorialMutation) SetID(id uint64) {
  19854. m.id = &id
  19855. }
  19856. // ID returns the ID value in the mutation. Note that the ID is only available
  19857. // if it was provided to the builder or after it was returned from the database.
  19858. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  19859. if m.id == nil {
  19860. return
  19861. }
  19862. return *m.id, true
  19863. }
  19864. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19865. // That means, if the mutation is applied within a transaction with an isolation level such
  19866. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19867. // or updated by the mutation.
  19868. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  19869. switch {
  19870. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19871. id, exists := m.ID()
  19872. if exists {
  19873. return []uint64{id}, nil
  19874. }
  19875. fallthrough
  19876. case m.op.Is(OpUpdate | OpDelete):
  19877. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  19878. default:
  19879. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19880. }
  19881. }
  19882. // SetCreatedAt sets the "created_at" field.
  19883. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  19884. m.created_at = &t
  19885. }
  19886. // CreatedAt returns the value of the "created_at" field in the mutation.
  19887. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  19888. v := m.created_at
  19889. if v == nil {
  19890. return
  19891. }
  19892. return *v, true
  19893. }
  19894. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  19895. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  19896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19897. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19898. if !m.op.Is(OpUpdateOne) {
  19899. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19900. }
  19901. if m.id == nil || m.oldValue == nil {
  19902. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19903. }
  19904. oldValue, err := m.oldValue(ctx)
  19905. if err != nil {
  19906. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19907. }
  19908. return oldValue.CreatedAt, nil
  19909. }
  19910. // ResetCreatedAt resets all changes to the "created_at" field.
  19911. func (m *TutorialMutation) ResetCreatedAt() {
  19912. m.created_at = nil
  19913. }
  19914. // SetUpdatedAt sets the "updated_at" field.
  19915. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  19916. m.updated_at = &t
  19917. }
  19918. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19919. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  19920. v := m.updated_at
  19921. if v == nil {
  19922. return
  19923. }
  19924. return *v, true
  19925. }
  19926. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  19927. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  19928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19929. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19930. if !m.op.Is(OpUpdateOne) {
  19931. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19932. }
  19933. if m.id == nil || m.oldValue == nil {
  19934. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19935. }
  19936. oldValue, err := m.oldValue(ctx)
  19937. if err != nil {
  19938. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19939. }
  19940. return oldValue.UpdatedAt, nil
  19941. }
  19942. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19943. func (m *TutorialMutation) ResetUpdatedAt() {
  19944. m.updated_at = nil
  19945. }
  19946. // SetDeletedAt sets the "deleted_at" field.
  19947. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  19948. m.deleted_at = &t
  19949. }
  19950. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19951. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  19952. v := m.deleted_at
  19953. if v == nil {
  19954. return
  19955. }
  19956. return *v, true
  19957. }
  19958. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  19959. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  19960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19961. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19962. if !m.op.Is(OpUpdateOne) {
  19963. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19964. }
  19965. if m.id == nil || m.oldValue == nil {
  19966. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19967. }
  19968. oldValue, err := m.oldValue(ctx)
  19969. if err != nil {
  19970. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19971. }
  19972. return oldValue.DeletedAt, nil
  19973. }
  19974. // ClearDeletedAt clears the value of the "deleted_at" field.
  19975. func (m *TutorialMutation) ClearDeletedAt() {
  19976. m.deleted_at = nil
  19977. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  19978. }
  19979. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19980. func (m *TutorialMutation) DeletedAtCleared() bool {
  19981. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  19982. return ok
  19983. }
  19984. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19985. func (m *TutorialMutation) ResetDeletedAt() {
  19986. m.deleted_at = nil
  19987. delete(m.clearedFields, tutorial.FieldDeletedAt)
  19988. }
  19989. // SetEmployeeID sets the "employee_id" field.
  19990. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  19991. m.employee = &u
  19992. }
  19993. // EmployeeID returns the value of the "employee_id" field in the mutation.
  19994. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  19995. v := m.employee
  19996. if v == nil {
  19997. return
  19998. }
  19999. return *v, true
  20000. }
  20001. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  20002. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20004. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20005. if !m.op.Is(OpUpdateOne) {
  20006. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20007. }
  20008. if m.id == nil || m.oldValue == nil {
  20009. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20010. }
  20011. oldValue, err := m.oldValue(ctx)
  20012. if err != nil {
  20013. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20014. }
  20015. return oldValue.EmployeeID, nil
  20016. }
  20017. // ResetEmployeeID resets all changes to the "employee_id" field.
  20018. func (m *TutorialMutation) ResetEmployeeID() {
  20019. m.employee = nil
  20020. }
  20021. // SetIndex sets the "index" field.
  20022. func (m *TutorialMutation) SetIndex(i int) {
  20023. m.index = &i
  20024. m.addindex = nil
  20025. }
  20026. // Index returns the value of the "index" field in the mutation.
  20027. func (m *TutorialMutation) Index() (r int, exists bool) {
  20028. v := m.index
  20029. if v == nil {
  20030. return
  20031. }
  20032. return *v, true
  20033. }
  20034. // OldIndex returns the old "index" field's value of the Tutorial entity.
  20035. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20037. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  20038. if !m.op.Is(OpUpdateOne) {
  20039. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  20040. }
  20041. if m.id == nil || m.oldValue == nil {
  20042. return v, errors.New("OldIndex requires an ID field in the mutation")
  20043. }
  20044. oldValue, err := m.oldValue(ctx)
  20045. if err != nil {
  20046. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  20047. }
  20048. return oldValue.Index, nil
  20049. }
  20050. // AddIndex adds i to the "index" field.
  20051. func (m *TutorialMutation) AddIndex(i int) {
  20052. if m.addindex != nil {
  20053. *m.addindex += i
  20054. } else {
  20055. m.addindex = &i
  20056. }
  20057. }
  20058. // AddedIndex returns the value that was added to the "index" field in this mutation.
  20059. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  20060. v := m.addindex
  20061. if v == nil {
  20062. return
  20063. }
  20064. return *v, true
  20065. }
  20066. // ResetIndex resets all changes to the "index" field.
  20067. func (m *TutorialMutation) ResetIndex() {
  20068. m.index = nil
  20069. m.addindex = nil
  20070. }
  20071. // SetTitle sets the "title" field.
  20072. func (m *TutorialMutation) SetTitle(s string) {
  20073. m.title = &s
  20074. }
  20075. // Title returns the value of the "title" field in the mutation.
  20076. func (m *TutorialMutation) Title() (r string, exists bool) {
  20077. v := m.title
  20078. if v == nil {
  20079. return
  20080. }
  20081. return *v, true
  20082. }
  20083. // OldTitle returns the old "title" field's value of the Tutorial entity.
  20084. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20086. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  20087. if !m.op.Is(OpUpdateOne) {
  20088. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20089. }
  20090. if m.id == nil || m.oldValue == nil {
  20091. return v, errors.New("OldTitle requires an ID field in the mutation")
  20092. }
  20093. oldValue, err := m.oldValue(ctx)
  20094. if err != nil {
  20095. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20096. }
  20097. return oldValue.Title, nil
  20098. }
  20099. // ResetTitle resets all changes to the "title" field.
  20100. func (m *TutorialMutation) ResetTitle() {
  20101. m.title = nil
  20102. }
  20103. // SetContent sets the "content" field.
  20104. func (m *TutorialMutation) SetContent(s string) {
  20105. m.content = &s
  20106. }
  20107. // Content returns the value of the "content" field in the mutation.
  20108. func (m *TutorialMutation) Content() (r string, exists bool) {
  20109. v := m.content
  20110. if v == nil {
  20111. return
  20112. }
  20113. return *v, true
  20114. }
  20115. // OldContent returns the old "content" field's value of the Tutorial entity.
  20116. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20118. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  20119. if !m.op.Is(OpUpdateOne) {
  20120. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20121. }
  20122. if m.id == nil || m.oldValue == nil {
  20123. return v, errors.New("OldContent requires an ID field in the mutation")
  20124. }
  20125. oldValue, err := m.oldValue(ctx)
  20126. if err != nil {
  20127. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20128. }
  20129. return oldValue.Content, nil
  20130. }
  20131. // ResetContent resets all changes to the "content" field.
  20132. func (m *TutorialMutation) ResetContent() {
  20133. m.content = nil
  20134. }
  20135. // SetOrganizationID sets the "organization_id" field.
  20136. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  20137. m.organization_id = &u
  20138. m.addorganization_id = nil
  20139. }
  20140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20141. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  20142. v := m.organization_id
  20143. if v == nil {
  20144. return
  20145. }
  20146. return *v, true
  20147. }
  20148. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  20149. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20151. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20152. if !m.op.Is(OpUpdateOne) {
  20153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20154. }
  20155. if m.id == nil || m.oldValue == nil {
  20156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20157. }
  20158. oldValue, err := m.oldValue(ctx)
  20159. if err != nil {
  20160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20161. }
  20162. return oldValue.OrganizationID, nil
  20163. }
  20164. // AddOrganizationID adds u to the "organization_id" field.
  20165. func (m *TutorialMutation) AddOrganizationID(u int64) {
  20166. if m.addorganization_id != nil {
  20167. *m.addorganization_id += u
  20168. } else {
  20169. m.addorganization_id = &u
  20170. }
  20171. }
  20172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20173. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  20174. v := m.addorganization_id
  20175. if v == nil {
  20176. return
  20177. }
  20178. return *v, true
  20179. }
  20180. // ResetOrganizationID resets all changes to the "organization_id" field.
  20181. func (m *TutorialMutation) ResetOrganizationID() {
  20182. m.organization_id = nil
  20183. m.addorganization_id = nil
  20184. }
  20185. // ClearEmployee clears the "employee" edge to the Employee entity.
  20186. func (m *TutorialMutation) ClearEmployee() {
  20187. m.clearedemployee = true
  20188. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  20189. }
  20190. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  20191. func (m *TutorialMutation) EmployeeCleared() bool {
  20192. return m.clearedemployee
  20193. }
  20194. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  20195. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20196. // EmployeeID instead. It exists only for internal usage by the builders.
  20197. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  20198. if id := m.employee; id != nil {
  20199. ids = append(ids, *id)
  20200. }
  20201. return
  20202. }
  20203. // ResetEmployee resets all changes to the "employee" edge.
  20204. func (m *TutorialMutation) ResetEmployee() {
  20205. m.employee = nil
  20206. m.clearedemployee = false
  20207. }
  20208. // Where appends a list predicates to the TutorialMutation builder.
  20209. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  20210. m.predicates = append(m.predicates, ps...)
  20211. }
  20212. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  20213. // users can use type-assertion to append predicates that do not depend on any generated package.
  20214. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  20215. p := make([]predicate.Tutorial, len(ps))
  20216. for i := range ps {
  20217. p[i] = ps[i]
  20218. }
  20219. m.Where(p...)
  20220. }
  20221. // Op returns the operation name.
  20222. func (m *TutorialMutation) Op() Op {
  20223. return m.op
  20224. }
  20225. // SetOp allows setting the mutation operation.
  20226. func (m *TutorialMutation) SetOp(op Op) {
  20227. m.op = op
  20228. }
  20229. // Type returns the node type of this mutation (Tutorial).
  20230. func (m *TutorialMutation) Type() string {
  20231. return m.typ
  20232. }
  20233. // Fields returns all fields that were changed during this mutation. Note that in
  20234. // order to get all numeric fields that were incremented/decremented, call
  20235. // AddedFields().
  20236. func (m *TutorialMutation) Fields() []string {
  20237. fields := make([]string, 0, 8)
  20238. if m.created_at != nil {
  20239. fields = append(fields, tutorial.FieldCreatedAt)
  20240. }
  20241. if m.updated_at != nil {
  20242. fields = append(fields, tutorial.FieldUpdatedAt)
  20243. }
  20244. if m.deleted_at != nil {
  20245. fields = append(fields, tutorial.FieldDeletedAt)
  20246. }
  20247. if m.employee != nil {
  20248. fields = append(fields, tutorial.FieldEmployeeID)
  20249. }
  20250. if m.index != nil {
  20251. fields = append(fields, tutorial.FieldIndex)
  20252. }
  20253. if m.title != nil {
  20254. fields = append(fields, tutorial.FieldTitle)
  20255. }
  20256. if m.content != nil {
  20257. fields = append(fields, tutorial.FieldContent)
  20258. }
  20259. if m.organization_id != nil {
  20260. fields = append(fields, tutorial.FieldOrganizationID)
  20261. }
  20262. return fields
  20263. }
  20264. // Field returns the value of a field with the given name. The second boolean
  20265. // return value indicates that this field was not set, or was not defined in the
  20266. // schema.
  20267. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  20268. switch name {
  20269. case tutorial.FieldCreatedAt:
  20270. return m.CreatedAt()
  20271. case tutorial.FieldUpdatedAt:
  20272. return m.UpdatedAt()
  20273. case tutorial.FieldDeletedAt:
  20274. return m.DeletedAt()
  20275. case tutorial.FieldEmployeeID:
  20276. return m.EmployeeID()
  20277. case tutorial.FieldIndex:
  20278. return m.Index()
  20279. case tutorial.FieldTitle:
  20280. return m.Title()
  20281. case tutorial.FieldContent:
  20282. return m.Content()
  20283. case tutorial.FieldOrganizationID:
  20284. return m.OrganizationID()
  20285. }
  20286. return nil, false
  20287. }
  20288. // OldField returns the old value of the field from the database. An error is
  20289. // returned if the mutation operation is not UpdateOne, or the query to the
  20290. // database failed.
  20291. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20292. switch name {
  20293. case tutorial.FieldCreatedAt:
  20294. return m.OldCreatedAt(ctx)
  20295. case tutorial.FieldUpdatedAt:
  20296. return m.OldUpdatedAt(ctx)
  20297. case tutorial.FieldDeletedAt:
  20298. return m.OldDeletedAt(ctx)
  20299. case tutorial.FieldEmployeeID:
  20300. return m.OldEmployeeID(ctx)
  20301. case tutorial.FieldIndex:
  20302. return m.OldIndex(ctx)
  20303. case tutorial.FieldTitle:
  20304. return m.OldTitle(ctx)
  20305. case tutorial.FieldContent:
  20306. return m.OldContent(ctx)
  20307. case tutorial.FieldOrganizationID:
  20308. return m.OldOrganizationID(ctx)
  20309. }
  20310. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  20311. }
  20312. // SetField sets the value of a field with the given name. It returns an error if
  20313. // the field is not defined in the schema, or if the type mismatched the field
  20314. // type.
  20315. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  20316. switch name {
  20317. case tutorial.FieldCreatedAt:
  20318. v, ok := value.(time.Time)
  20319. if !ok {
  20320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20321. }
  20322. m.SetCreatedAt(v)
  20323. return nil
  20324. case tutorial.FieldUpdatedAt:
  20325. v, ok := value.(time.Time)
  20326. if !ok {
  20327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20328. }
  20329. m.SetUpdatedAt(v)
  20330. return nil
  20331. case tutorial.FieldDeletedAt:
  20332. v, ok := value.(time.Time)
  20333. if !ok {
  20334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20335. }
  20336. m.SetDeletedAt(v)
  20337. return nil
  20338. case tutorial.FieldEmployeeID:
  20339. v, ok := value.(uint64)
  20340. if !ok {
  20341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20342. }
  20343. m.SetEmployeeID(v)
  20344. return nil
  20345. case tutorial.FieldIndex:
  20346. v, ok := value.(int)
  20347. if !ok {
  20348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20349. }
  20350. m.SetIndex(v)
  20351. return nil
  20352. case tutorial.FieldTitle:
  20353. v, ok := value.(string)
  20354. if !ok {
  20355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20356. }
  20357. m.SetTitle(v)
  20358. return nil
  20359. case tutorial.FieldContent:
  20360. v, ok := value.(string)
  20361. if !ok {
  20362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20363. }
  20364. m.SetContent(v)
  20365. return nil
  20366. case tutorial.FieldOrganizationID:
  20367. v, ok := value.(uint64)
  20368. if !ok {
  20369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20370. }
  20371. m.SetOrganizationID(v)
  20372. return nil
  20373. }
  20374. return fmt.Errorf("unknown Tutorial field %s", name)
  20375. }
  20376. // AddedFields returns all numeric fields that were incremented/decremented during
  20377. // this mutation.
  20378. func (m *TutorialMutation) AddedFields() []string {
  20379. var fields []string
  20380. if m.addindex != nil {
  20381. fields = append(fields, tutorial.FieldIndex)
  20382. }
  20383. if m.addorganization_id != nil {
  20384. fields = append(fields, tutorial.FieldOrganizationID)
  20385. }
  20386. return fields
  20387. }
  20388. // AddedField returns the numeric value that was incremented/decremented on a field
  20389. // with the given name. The second boolean return value indicates that this field
  20390. // was not set, or was not defined in the schema.
  20391. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  20392. switch name {
  20393. case tutorial.FieldIndex:
  20394. return m.AddedIndex()
  20395. case tutorial.FieldOrganizationID:
  20396. return m.AddedOrganizationID()
  20397. }
  20398. return nil, false
  20399. }
  20400. // AddField adds the value to the field with the given name. It returns an error if
  20401. // the field is not defined in the schema, or if the type mismatched the field
  20402. // type.
  20403. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  20404. switch name {
  20405. case tutorial.FieldIndex:
  20406. v, ok := value.(int)
  20407. if !ok {
  20408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20409. }
  20410. m.AddIndex(v)
  20411. return nil
  20412. case tutorial.FieldOrganizationID:
  20413. v, ok := value.(int64)
  20414. if !ok {
  20415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20416. }
  20417. m.AddOrganizationID(v)
  20418. return nil
  20419. }
  20420. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  20421. }
  20422. // ClearedFields returns all nullable fields that were cleared during this
  20423. // mutation.
  20424. func (m *TutorialMutation) ClearedFields() []string {
  20425. var fields []string
  20426. if m.FieldCleared(tutorial.FieldDeletedAt) {
  20427. fields = append(fields, tutorial.FieldDeletedAt)
  20428. }
  20429. return fields
  20430. }
  20431. // FieldCleared returns a boolean indicating if a field with the given name was
  20432. // cleared in this mutation.
  20433. func (m *TutorialMutation) FieldCleared(name string) bool {
  20434. _, ok := m.clearedFields[name]
  20435. return ok
  20436. }
  20437. // ClearField clears the value of the field with the given name. It returns an
  20438. // error if the field is not defined in the schema.
  20439. func (m *TutorialMutation) ClearField(name string) error {
  20440. switch name {
  20441. case tutorial.FieldDeletedAt:
  20442. m.ClearDeletedAt()
  20443. return nil
  20444. }
  20445. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  20446. }
  20447. // ResetField resets all changes in the mutation for the field with the given name.
  20448. // It returns an error if the field is not defined in the schema.
  20449. func (m *TutorialMutation) ResetField(name string) error {
  20450. switch name {
  20451. case tutorial.FieldCreatedAt:
  20452. m.ResetCreatedAt()
  20453. return nil
  20454. case tutorial.FieldUpdatedAt:
  20455. m.ResetUpdatedAt()
  20456. return nil
  20457. case tutorial.FieldDeletedAt:
  20458. m.ResetDeletedAt()
  20459. return nil
  20460. case tutorial.FieldEmployeeID:
  20461. m.ResetEmployeeID()
  20462. return nil
  20463. case tutorial.FieldIndex:
  20464. m.ResetIndex()
  20465. return nil
  20466. case tutorial.FieldTitle:
  20467. m.ResetTitle()
  20468. return nil
  20469. case tutorial.FieldContent:
  20470. m.ResetContent()
  20471. return nil
  20472. case tutorial.FieldOrganizationID:
  20473. m.ResetOrganizationID()
  20474. return nil
  20475. }
  20476. return fmt.Errorf("unknown Tutorial field %s", name)
  20477. }
  20478. // AddedEdges returns all edge names that were set/added in this mutation.
  20479. func (m *TutorialMutation) AddedEdges() []string {
  20480. edges := make([]string, 0, 1)
  20481. if m.employee != nil {
  20482. edges = append(edges, tutorial.EdgeEmployee)
  20483. }
  20484. return edges
  20485. }
  20486. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20487. // name in this mutation.
  20488. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  20489. switch name {
  20490. case tutorial.EdgeEmployee:
  20491. if id := m.employee; id != nil {
  20492. return []ent.Value{*id}
  20493. }
  20494. }
  20495. return nil
  20496. }
  20497. // RemovedEdges returns all edge names that were removed in this mutation.
  20498. func (m *TutorialMutation) RemovedEdges() []string {
  20499. edges := make([]string, 0, 1)
  20500. return edges
  20501. }
  20502. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20503. // the given name in this mutation.
  20504. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  20505. return nil
  20506. }
  20507. // ClearedEdges returns all edge names that were cleared in this mutation.
  20508. func (m *TutorialMutation) ClearedEdges() []string {
  20509. edges := make([]string, 0, 1)
  20510. if m.clearedemployee {
  20511. edges = append(edges, tutorial.EdgeEmployee)
  20512. }
  20513. return edges
  20514. }
  20515. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20516. // was cleared in this mutation.
  20517. func (m *TutorialMutation) EdgeCleared(name string) bool {
  20518. switch name {
  20519. case tutorial.EdgeEmployee:
  20520. return m.clearedemployee
  20521. }
  20522. return false
  20523. }
  20524. // ClearEdge clears the value of the edge with the given name. It returns an error
  20525. // if that edge is not defined in the schema.
  20526. func (m *TutorialMutation) ClearEdge(name string) error {
  20527. switch name {
  20528. case tutorial.EdgeEmployee:
  20529. m.ClearEmployee()
  20530. return nil
  20531. }
  20532. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  20533. }
  20534. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20535. // It returns an error if the edge is not defined in the schema.
  20536. func (m *TutorialMutation) ResetEdge(name string) error {
  20537. switch name {
  20538. case tutorial.EdgeEmployee:
  20539. m.ResetEmployee()
  20540. return nil
  20541. }
  20542. return fmt.Errorf("unknown Tutorial edge %s", name)
  20543. }
  20544. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  20545. type WorkExperienceMutation struct {
  20546. config
  20547. op Op
  20548. typ string
  20549. id *uint64
  20550. created_at *time.Time
  20551. updated_at *time.Time
  20552. deleted_at *time.Time
  20553. start_date *time.Time
  20554. end_date *time.Time
  20555. company *string
  20556. experience *string
  20557. organization_id *uint64
  20558. addorganization_id *int64
  20559. clearedFields map[string]struct{}
  20560. employee *uint64
  20561. clearedemployee bool
  20562. done bool
  20563. oldValue func(context.Context) (*WorkExperience, error)
  20564. predicates []predicate.WorkExperience
  20565. }
  20566. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  20567. // workexperienceOption allows management of the mutation configuration using functional options.
  20568. type workexperienceOption func(*WorkExperienceMutation)
  20569. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  20570. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  20571. m := &WorkExperienceMutation{
  20572. config: c,
  20573. op: op,
  20574. typ: TypeWorkExperience,
  20575. clearedFields: make(map[string]struct{}),
  20576. }
  20577. for _, opt := range opts {
  20578. opt(m)
  20579. }
  20580. return m
  20581. }
  20582. // withWorkExperienceID sets the ID field of the mutation.
  20583. func withWorkExperienceID(id uint64) workexperienceOption {
  20584. return func(m *WorkExperienceMutation) {
  20585. var (
  20586. err error
  20587. once sync.Once
  20588. value *WorkExperience
  20589. )
  20590. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  20591. once.Do(func() {
  20592. if m.done {
  20593. err = errors.New("querying old values post mutation is not allowed")
  20594. } else {
  20595. value, err = m.Client().WorkExperience.Get(ctx, id)
  20596. }
  20597. })
  20598. return value, err
  20599. }
  20600. m.id = &id
  20601. }
  20602. }
  20603. // withWorkExperience sets the old WorkExperience of the mutation.
  20604. func withWorkExperience(node *WorkExperience) workexperienceOption {
  20605. return func(m *WorkExperienceMutation) {
  20606. m.oldValue = func(context.Context) (*WorkExperience, error) {
  20607. return node, nil
  20608. }
  20609. m.id = &node.ID
  20610. }
  20611. }
  20612. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20613. // executed in a transaction (ent.Tx), a transactional client is returned.
  20614. func (m WorkExperienceMutation) Client() *Client {
  20615. client := &Client{config: m.config}
  20616. client.init()
  20617. return client
  20618. }
  20619. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20620. // it returns an error otherwise.
  20621. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  20622. if _, ok := m.driver.(*txDriver); !ok {
  20623. return nil, errors.New("ent: mutation is not running in a transaction")
  20624. }
  20625. tx := &Tx{config: m.config}
  20626. tx.init()
  20627. return tx, nil
  20628. }
  20629. // SetID sets the value of the id field. Note that this
  20630. // operation is only accepted on creation of WorkExperience entities.
  20631. func (m *WorkExperienceMutation) SetID(id uint64) {
  20632. m.id = &id
  20633. }
  20634. // ID returns the ID value in the mutation. Note that the ID is only available
  20635. // if it was provided to the builder or after it was returned from the database.
  20636. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  20637. if m.id == nil {
  20638. return
  20639. }
  20640. return *m.id, true
  20641. }
  20642. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20643. // That means, if the mutation is applied within a transaction with an isolation level such
  20644. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20645. // or updated by the mutation.
  20646. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  20647. switch {
  20648. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20649. id, exists := m.ID()
  20650. if exists {
  20651. return []uint64{id}, nil
  20652. }
  20653. fallthrough
  20654. case m.op.Is(OpUpdate | OpDelete):
  20655. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  20656. default:
  20657. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20658. }
  20659. }
  20660. // SetCreatedAt sets the "created_at" field.
  20661. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  20662. m.created_at = &t
  20663. }
  20664. // CreatedAt returns the value of the "created_at" field in the mutation.
  20665. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  20666. v := m.created_at
  20667. if v == nil {
  20668. return
  20669. }
  20670. return *v, true
  20671. }
  20672. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  20673. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20675. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20676. if !m.op.Is(OpUpdateOne) {
  20677. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20678. }
  20679. if m.id == nil || m.oldValue == nil {
  20680. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20681. }
  20682. oldValue, err := m.oldValue(ctx)
  20683. if err != nil {
  20684. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20685. }
  20686. return oldValue.CreatedAt, nil
  20687. }
  20688. // ResetCreatedAt resets all changes to the "created_at" field.
  20689. func (m *WorkExperienceMutation) ResetCreatedAt() {
  20690. m.created_at = nil
  20691. }
  20692. // SetUpdatedAt sets the "updated_at" field.
  20693. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  20694. m.updated_at = &t
  20695. }
  20696. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20697. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  20698. v := m.updated_at
  20699. if v == nil {
  20700. return
  20701. }
  20702. return *v, true
  20703. }
  20704. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  20705. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20707. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20708. if !m.op.Is(OpUpdateOne) {
  20709. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20710. }
  20711. if m.id == nil || m.oldValue == nil {
  20712. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20713. }
  20714. oldValue, err := m.oldValue(ctx)
  20715. if err != nil {
  20716. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20717. }
  20718. return oldValue.UpdatedAt, nil
  20719. }
  20720. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20721. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  20722. m.updated_at = nil
  20723. }
  20724. // SetDeletedAt sets the "deleted_at" field.
  20725. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  20726. m.deleted_at = &t
  20727. }
  20728. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20729. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  20730. v := m.deleted_at
  20731. if v == nil {
  20732. return
  20733. }
  20734. return *v, true
  20735. }
  20736. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  20737. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20739. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20740. if !m.op.Is(OpUpdateOne) {
  20741. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20742. }
  20743. if m.id == nil || m.oldValue == nil {
  20744. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20745. }
  20746. oldValue, err := m.oldValue(ctx)
  20747. if err != nil {
  20748. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20749. }
  20750. return oldValue.DeletedAt, nil
  20751. }
  20752. // ClearDeletedAt clears the value of the "deleted_at" field.
  20753. func (m *WorkExperienceMutation) ClearDeletedAt() {
  20754. m.deleted_at = nil
  20755. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  20756. }
  20757. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20758. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  20759. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  20760. return ok
  20761. }
  20762. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20763. func (m *WorkExperienceMutation) ResetDeletedAt() {
  20764. m.deleted_at = nil
  20765. delete(m.clearedFields, workexperience.FieldDeletedAt)
  20766. }
  20767. // SetEmployeeID sets the "employee_id" field.
  20768. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  20769. m.employee = &u
  20770. }
  20771. // EmployeeID returns the value of the "employee_id" field in the mutation.
  20772. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  20773. v := m.employee
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  20780. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20782. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  20783. if !m.op.Is(OpUpdateOne) {
  20784. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  20785. }
  20786. if m.id == nil || m.oldValue == nil {
  20787. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  20788. }
  20789. oldValue, err := m.oldValue(ctx)
  20790. if err != nil {
  20791. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  20792. }
  20793. return oldValue.EmployeeID, nil
  20794. }
  20795. // ResetEmployeeID resets all changes to the "employee_id" field.
  20796. func (m *WorkExperienceMutation) ResetEmployeeID() {
  20797. m.employee = nil
  20798. }
  20799. // SetStartDate sets the "start_date" field.
  20800. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  20801. m.start_date = &t
  20802. }
  20803. // StartDate returns the value of the "start_date" field in the mutation.
  20804. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  20805. v := m.start_date
  20806. if v == nil {
  20807. return
  20808. }
  20809. return *v, true
  20810. }
  20811. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  20812. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20814. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  20815. if !m.op.Is(OpUpdateOne) {
  20816. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  20817. }
  20818. if m.id == nil || m.oldValue == nil {
  20819. return v, errors.New("OldStartDate requires an ID field in the mutation")
  20820. }
  20821. oldValue, err := m.oldValue(ctx)
  20822. if err != nil {
  20823. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  20824. }
  20825. return oldValue.StartDate, nil
  20826. }
  20827. // ResetStartDate resets all changes to the "start_date" field.
  20828. func (m *WorkExperienceMutation) ResetStartDate() {
  20829. m.start_date = nil
  20830. }
  20831. // SetEndDate sets the "end_date" field.
  20832. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  20833. m.end_date = &t
  20834. }
  20835. // EndDate returns the value of the "end_date" field in the mutation.
  20836. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  20837. v := m.end_date
  20838. if v == nil {
  20839. return
  20840. }
  20841. return *v, true
  20842. }
  20843. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  20844. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20846. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  20847. if !m.op.Is(OpUpdateOne) {
  20848. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  20849. }
  20850. if m.id == nil || m.oldValue == nil {
  20851. return v, errors.New("OldEndDate requires an ID field in the mutation")
  20852. }
  20853. oldValue, err := m.oldValue(ctx)
  20854. if err != nil {
  20855. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  20856. }
  20857. return oldValue.EndDate, nil
  20858. }
  20859. // ResetEndDate resets all changes to the "end_date" field.
  20860. func (m *WorkExperienceMutation) ResetEndDate() {
  20861. m.end_date = nil
  20862. }
  20863. // SetCompany sets the "company" field.
  20864. func (m *WorkExperienceMutation) SetCompany(s string) {
  20865. m.company = &s
  20866. }
  20867. // Company returns the value of the "company" field in the mutation.
  20868. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  20869. v := m.company
  20870. if v == nil {
  20871. return
  20872. }
  20873. return *v, true
  20874. }
  20875. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  20876. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20878. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  20879. if !m.op.Is(OpUpdateOne) {
  20880. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  20881. }
  20882. if m.id == nil || m.oldValue == nil {
  20883. return v, errors.New("OldCompany requires an ID field in the mutation")
  20884. }
  20885. oldValue, err := m.oldValue(ctx)
  20886. if err != nil {
  20887. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  20888. }
  20889. return oldValue.Company, nil
  20890. }
  20891. // ResetCompany resets all changes to the "company" field.
  20892. func (m *WorkExperienceMutation) ResetCompany() {
  20893. m.company = nil
  20894. }
  20895. // SetExperience sets the "experience" field.
  20896. func (m *WorkExperienceMutation) SetExperience(s string) {
  20897. m.experience = &s
  20898. }
  20899. // Experience returns the value of the "experience" field in the mutation.
  20900. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  20901. v := m.experience
  20902. if v == nil {
  20903. return
  20904. }
  20905. return *v, true
  20906. }
  20907. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  20908. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20910. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  20911. if !m.op.Is(OpUpdateOne) {
  20912. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  20913. }
  20914. if m.id == nil || m.oldValue == nil {
  20915. return v, errors.New("OldExperience requires an ID field in the mutation")
  20916. }
  20917. oldValue, err := m.oldValue(ctx)
  20918. if err != nil {
  20919. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  20920. }
  20921. return oldValue.Experience, nil
  20922. }
  20923. // ResetExperience resets all changes to the "experience" field.
  20924. func (m *WorkExperienceMutation) ResetExperience() {
  20925. m.experience = nil
  20926. }
  20927. // SetOrganizationID sets the "organization_id" field.
  20928. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  20929. m.organization_id = &u
  20930. m.addorganization_id = nil
  20931. }
  20932. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20933. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  20934. v := m.organization_id
  20935. if v == nil {
  20936. return
  20937. }
  20938. return *v, true
  20939. }
  20940. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  20941. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  20942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20943. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20944. if !m.op.Is(OpUpdateOne) {
  20945. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20946. }
  20947. if m.id == nil || m.oldValue == nil {
  20948. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20949. }
  20950. oldValue, err := m.oldValue(ctx)
  20951. if err != nil {
  20952. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20953. }
  20954. return oldValue.OrganizationID, nil
  20955. }
  20956. // AddOrganizationID adds u to the "organization_id" field.
  20957. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  20958. if m.addorganization_id != nil {
  20959. *m.addorganization_id += u
  20960. } else {
  20961. m.addorganization_id = &u
  20962. }
  20963. }
  20964. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20965. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  20966. v := m.addorganization_id
  20967. if v == nil {
  20968. return
  20969. }
  20970. return *v, true
  20971. }
  20972. // ResetOrganizationID resets all changes to the "organization_id" field.
  20973. func (m *WorkExperienceMutation) ResetOrganizationID() {
  20974. m.organization_id = nil
  20975. m.addorganization_id = nil
  20976. }
  20977. // ClearEmployee clears the "employee" edge to the Employee entity.
  20978. func (m *WorkExperienceMutation) ClearEmployee() {
  20979. m.clearedemployee = true
  20980. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  20981. }
  20982. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  20983. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  20984. return m.clearedemployee
  20985. }
  20986. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  20987. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20988. // EmployeeID instead. It exists only for internal usage by the builders.
  20989. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  20990. if id := m.employee; id != nil {
  20991. ids = append(ids, *id)
  20992. }
  20993. return
  20994. }
  20995. // ResetEmployee resets all changes to the "employee" edge.
  20996. func (m *WorkExperienceMutation) ResetEmployee() {
  20997. m.employee = nil
  20998. m.clearedemployee = false
  20999. }
  21000. // Where appends a list predicates to the WorkExperienceMutation builder.
  21001. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  21002. m.predicates = append(m.predicates, ps...)
  21003. }
  21004. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  21005. // users can use type-assertion to append predicates that do not depend on any generated package.
  21006. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  21007. p := make([]predicate.WorkExperience, len(ps))
  21008. for i := range ps {
  21009. p[i] = ps[i]
  21010. }
  21011. m.Where(p...)
  21012. }
  21013. // Op returns the operation name.
  21014. func (m *WorkExperienceMutation) Op() Op {
  21015. return m.op
  21016. }
  21017. // SetOp allows setting the mutation operation.
  21018. func (m *WorkExperienceMutation) SetOp(op Op) {
  21019. m.op = op
  21020. }
  21021. // Type returns the node type of this mutation (WorkExperience).
  21022. func (m *WorkExperienceMutation) Type() string {
  21023. return m.typ
  21024. }
  21025. // Fields returns all fields that were changed during this mutation. Note that in
  21026. // order to get all numeric fields that were incremented/decremented, call
  21027. // AddedFields().
  21028. func (m *WorkExperienceMutation) Fields() []string {
  21029. fields := make([]string, 0, 9)
  21030. if m.created_at != nil {
  21031. fields = append(fields, workexperience.FieldCreatedAt)
  21032. }
  21033. if m.updated_at != nil {
  21034. fields = append(fields, workexperience.FieldUpdatedAt)
  21035. }
  21036. if m.deleted_at != nil {
  21037. fields = append(fields, workexperience.FieldDeletedAt)
  21038. }
  21039. if m.employee != nil {
  21040. fields = append(fields, workexperience.FieldEmployeeID)
  21041. }
  21042. if m.start_date != nil {
  21043. fields = append(fields, workexperience.FieldStartDate)
  21044. }
  21045. if m.end_date != nil {
  21046. fields = append(fields, workexperience.FieldEndDate)
  21047. }
  21048. if m.company != nil {
  21049. fields = append(fields, workexperience.FieldCompany)
  21050. }
  21051. if m.experience != nil {
  21052. fields = append(fields, workexperience.FieldExperience)
  21053. }
  21054. if m.organization_id != nil {
  21055. fields = append(fields, workexperience.FieldOrganizationID)
  21056. }
  21057. return fields
  21058. }
  21059. // Field returns the value of a field with the given name. The second boolean
  21060. // return value indicates that this field was not set, or was not defined in the
  21061. // schema.
  21062. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  21063. switch name {
  21064. case workexperience.FieldCreatedAt:
  21065. return m.CreatedAt()
  21066. case workexperience.FieldUpdatedAt:
  21067. return m.UpdatedAt()
  21068. case workexperience.FieldDeletedAt:
  21069. return m.DeletedAt()
  21070. case workexperience.FieldEmployeeID:
  21071. return m.EmployeeID()
  21072. case workexperience.FieldStartDate:
  21073. return m.StartDate()
  21074. case workexperience.FieldEndDate:
  21075. return m.EndDate()
  21076. case workexperience.FieldCompany:
  21077. return m.Company()
  21078. case workexperience.FieldExperience:
  21079. return m.Experience()
  21080. case workexperience.FieldOrganizationID:
  21081. return m.OrganizationID()
  21082. }
  21083. return nil, false
  21084. }
  21085. // OldField returns the old value of the field from the database. An error is
  21086. // returned if the mutation operation is not UpdateOne, or the query to the
  21087. // database failed.
  21088. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21089. switch name {
  21090. case workexperience.FieldCreatedAt:
  21091. return m.OldCreatedAt(ctx)
  21092. case workexperience.FieldUpdatedAt:
  21093. return m.OldUpdatedAt(ctx)
  21094. case workexperience.FieldDeletedAt:
  21095. return m.OldDeletedAt(ctx)
  21096. case workexperience.FieldEmployeeID:
  21097. return m.OldEmployeeID(ctx)
  21098. case workexperience.FieldStartDate:
  21099. return m.OldStartDate(ctx)
  21100. case workexperience.FieldEndDate:
  21101. return m.OldEndDate(ctx)
  21102. case workexperience.FieldCompany:
  21103. return m.OldCompany(ctx)
  21104. case workexperience.FieldExperience:
  21105. return m.OldExperience(ctx)
  21106. case workexperience.FieldOrganizationID:
  21107. return m.OldOrganizationID(ctx)
  21108. }
  21109. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  21110. }
  21111. // SetField sets the value of a 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 *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  21115. switch name {
  21116. case workexperience.FieldCreatedAt:
  21117. v, ok := value.(time.Time)
  21118. if !ok {
  21119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21120. }
  21121. m.SetCreatedAt(v)
  21122. return nil
  21123. case workexperience.FieldUpdatedAt:
  21124. v, ok := value.(time.Time)
  21125. if !ok {
  21126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21127. }
  21128. m.SetUpdatedAt(v)
  21129. return nil
  21130. case workexperience.FieldDeletedAt:
  21131. v, ok := value.(time.Time)
  21132. if !ok {
  21133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21134. }
  21135. m.SetDeletedAt(v)
  21136. return nil
  21137. case workexperience.FieldEmployeeID:
  21138. v, ok := value.(uint64)
  21139. if !ok {
  21140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21141. }
  21142. m.SetEmployeeID(v)
  21143. return nil
  21144. case workexperience.FieldStartDate:
  21145. v, ok := value.(time.Time)
  21146. if !ok {
  21147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21148. }
  21149. m.SetStartDate(v)
  21150. return nil
  21151. case workexperience.FieldEndDate:
  21152. v, ok := value.(time.Time)
  21153. if !ok {
  21154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21155. }
  21156. m.SetEndDate(v)
  21157. return nil
  21158. case workexperience.FieldCompany:
  21159. v, ok := value.(string)
  21160. if !ok {
  21161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21162. }
  21163. m.SetCompany(v)
  21164. return nil
  21165. case workexperience.FieldExperience:
  21166. v, ok := value.(string)
  21167. if !ok {
  21168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21169. }
  21170. m.SetExperience(v)
  21171. return nil
  21172. case workexperience.FieldOrganizationID:
  21173. v, ok := value.(uint64)
  21174. if !ok {
  21175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21176. }
  21177. m.SetOrganizationID(v)
  21178. return nil
  21179. }
  21180. return fmt.Errorf("unknown WorkExperience field %s", name)
  21181. }
  21182. // AddedFields returns all numeric fields that were incremented/decremented during
  21183. // this mutation.
  21184. func (m *WorkExperienceMutation) AddedFields() []string {
  21185. var fields []string
  21186. if m.addorganization_id != nil {
  21187. fields = append(fields, workexperience.FieldOrganizationID)
  21188. }
  21189. return fields
  21190. }
  21191. // AddedField returns the numeric value that was incremented/decremented on a field
  21192. // with the given name. The second boolean return value indicates that this field
  21193. // was not set, or was not defined in the schema.
  21194. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  21195. switch name {
  21196. case workexperience.FieldOrganizationID:
  21197. return m.AddedOrganizationID()
  21198. }
  21199. return nil, false
  21200. }
  21201. // AddField adds the value to the field with the given name. It returns an error if
  21202. // the field is not defined in the schema, or if the type mismatched the field
  21203. // type.
  21204. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  21205. switch name {
  21206. case workexperience.FieldOrganizationID:
  21207. v, ok := value.(int64)
  21208. if !ok {
  21209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21210. }
  21211. m.AddOrganizationID(v)
  21212. return nil
  21213. }
  21214. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  21215. }
  21216. // ClearedFields returns all nullable fields that were cleared during this
  21217. // mutation.
  21218. func (m *WorkExperienceMutation) ClearedFields() []string {
  21219. var fields []string
  21220. if m.FieldCleared(workexperience.FieldDeletedAt) {
  21221. fields = append(fields, workexperience.FieldDeletedAt)
  21222. }
  21223. return fields
  21224. }
  21225. // FieldCleared returns a boolean indicating if a field with the given name was
  21226. // cleared in this mutation.
  21227. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  21228. _, ok := m.clearedFields[name]
  21229. return ok
  21230. }
  21231. // ClearField clears the value of the field with the given name. It returns an
  21232. // error if the field is not defined in the schema.
  21233. func (m *WorkExperienceMutation) ClearField(name string) error {
  21234. switch name {
  21235. case workexperience.FieldDeletedAt:
  21236. m.ClearDeletedAt()
  21237. return nil
  21238. }
  21239. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  21240. }
  21241. // ResetField resets all changes in the mutation for the field with the given name.
  21242. // It returns an error if the field is not defined in the schema.
  21243. func (m *WorkExperienceMutation) ResetField(name string) error {
  21244. switch name {
  21245. case workexperience.FieldCreatedAt:
  21246. m.ResetCreatedAt()
  21247. return nil
  21248. case workexperience.FieldUpdatedAt:
  21249. m.ResetUpdatedAt()
  21250. return nil
  21251. case workexperience.FieldDeletedAt:
  21252. m.ResetDeletedAt()
  21253. return nil
  21254. case workexperience.FieldEmployeeID:
  21255. m.ResetEmployeeID()
  21256. return nil
  21257. case workexperience.FieldStartDate:
  21258. m.ResetStartDate()
  21259. return nil
  21260. case workexperience.FieldEndDate:
  21261. m.ResetEndDate()
  21262. return nil
  21263. case workexperience.FieldCompany:
  21264. m.ResetCompany()
  21265. return nil
  21266. case workexperience.FieldExperience:
  21267. m.ResetExperience()
  21268. return nil
  21269. case workexperience.FieldOrganizationID:
  21270. m.ResetOrganizationID()
  21271. return nil
  21272. }
  21273. return fmt.Errorf("unknown WorkExperience field %s", name)
  21274. }
  21275. // AddedEdges returns all edge names that were set/added in this mutation.
  21276. func (m *WorkExperienceMutation) AddedEdges() []string {
  21277. edges := make([]string, 0, 1)
  21278. if m.employee != nil {
  21279. edges = append(edges, workexperience.EdgeEmployee)
  21280. }
  21281. return edges
  21282. }
  21283. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21284. // name in this mutation.
  21285. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  21286. switch name {
  21287. case workexperience.EdgeEmployee:
  21288. if id := m.employee; id != nil {
  21289. return []ent.Value{*id}
  21290. }
  21291. }
  21292. return nil
  21293. }
  21294. // RemovedEdges returns all edge names that were removed in this mutation.
  21295. func (m *WorkExperienceMutation) RemovedEdges() []string {
  21296. edges := make([]string, 0, 1)
  21297. return edges
  21298. }
  21299. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21300. // the given name in this mutation.
  21301. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  21302. return nil
  21303. }
  21304. // ClearedEdges returns all edge names that were cleared in this mutation.
  21305. func (m *WorkExperienceMutation) ClearedEdges() []string {
  21306. edges := make([]string, 0, 1)
  21307. if m.clearedemployee {
  21308. edges = append(edges, workexperience.EdgeEmployee)
  21309. }
  21310. return edges
  21311. }
  21312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21313. // was cleared in this mutation.
  21314. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  21315. switch name {
  21316. case workexperience.EdgeEmployee:
  21317. return m.clearedemployee
  21318. }
  21319. return false
  21320. }
  21321. // ClearEdge clears the value of the edge with the given name. It returns an error
  21322. // if that edge is not defined in the schema.
  21323. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  21324. switch name {
  21325. case workexperience.EdgeEmployee:
  21326. m.ClearEmployee()
  21327. return nil
  21328. }
  21329. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  21330. }
  21331. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21332. // It returns an error if the edge is not defined in the schema.
  21333. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  21334. switch name {
  21335. case workexperience.EdgeEmployee:
  21336. m.ResetEmployee()
  21337. return nil
  21338. }
  21339. return fmt.Errorf("unknown WorkExperience edge %s", name)
  21340. }
  21341. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  21342. type WxMutation struct {
  21343. config
  21344. op Op
  21345. typ string
  21346. id *uint64
  21347. created_at *time.Time
  21348. updated_at *time.Time
  21349. status *uint8
  21350. addstatus *int8
  21351. deleted_at *time.Time
  21352. port *string
  21353. process_id *string
  21354. callback *string
  21355. wxid *string
  21356. account *string
  21357. nickname *string
  21358. tel *string
  21359. head_big *string
  21360. organization_id *uint64
  21361. addorganization_id *int64
  21362. api_base *string
  21363. api_key *string
  21364. allow_list *[]string
  21365. appendallow_list []string
  21366. group_allow_list *[]string
  21367. appendgroup_allow_list []string
  21368. block_list *[]string
  21369. appendblock_list []string
  21370. group_block_list *[]string
  21371. appendgroup_block_list []string
  21372. clearedFields map[string]struct{}
  21373. server *uint64
  21374. clearedserver bool
  21375. agent *uint64
  21376. clearedagent bool
  21377. done bool
  21378. oldValue func(context.Context) (*Wx, error)
  21379. predicates []predicate.Wx
  21380. }
  21381. var _ ent.Mutation = (*WxMutation)(nil)
  21382. // wxOption allows management of the mutation configuration using functional options.
  21383. type wxOption func(*WxMutation)
  21384. // newWxMutation creates new mutation for the Wx entity.
  21385. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  21386. m := &WxMutation{
  21387. config: c,
  21388. op: op,
  21389. typ: TypeWx,
  21390. clearedFields: make(map[string]struct{}),
  21391. }
  21392. for _, opt := range opts {
  21393. opt(m)
  21394. }
  21395. return m
  21396. }
  21397. // withWxID sets the ID field of the mutation.
  21398. func withWxID(id uint64) wxOption {
  21399. return func(m *WxMutation) {
  21400. var (
  21401. err error
  21402. once sync.Once
  21403. value *Wx
  21404. )
  21405. m.oldValue = func(ctx context.Context) (*Wx, error) {
  21406. once.Do(func() {
  21407. if m.done {
  21408. err = errors.New("querying old values post mutation is not allowed")
  21409. } else {
  21410. value, err = m.Client().Wx.Get(ctx, id)
  21411. }
  21412. })
  21413. return value, err
  21414. }
  21415. m.id = &id
  21416. }
  21417. }
  21418. // withWx sets the old Wx of the mutation.
  21419. func withWx(node *Wx) wxOption {
  21420. return func(m *WxMutation) {
  21421. m.oldValue = func(context.Context) (*Wx, error) {
  21422. return node, nil
  21423. }
  21424. m.id = &node.ID
  21425. }
  21426. }
  21427. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21428. // executed in a transaction (ent.Tx), a transactional client is returned.
  21429. func (m WxMutation) Client() *Client {
  21430. client := &Client{config: m.config}
  21431. client.init()
  21432. return client
  21433. }
  21434. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21435. // it returns an error otherwise.
  21436. func (m WxMutation) Tx() (*Tx, error) {
  21437. if _, ok := m.driver.(*txDriver); !ok {
  21438. return nil, errors.New("ent: mutation is not running in a transaction")
  21439. }
  21440. tx := &Tx{config: m.config}
  21441. tx.init()
  21442. return tx, nil
  21443. }
  21444. // SetID sets the value of the id field. Note that this
  21445. // operation is only accepted on creation of Wx entities.
  21446. func (m *WxMutation) SetID(id uint64) {
  21447. m.id = &id
  21448. }
  21449. // ID returns the ID value in the mutation. Note that the ID is only available
  21450. // if it was provided to the builder or after it was returned from the database.
  21451. func (m *WxMutation) ID() (id uint64, exists bool) {
  21452. if m.id == nil {
  21453. return
  21454. }
  21455. return *m.id, true
  21456. }
  21457. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21458. // That means, if the mutation is applied within a transaction with an isolation level such
  21459. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21460. // or updated by the mutation.
  21461. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  21462. switch {
  21463. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21464. id, exists := m.ID()
  21465. if exists {
  21466. return []uint64{id}, nil
  21467. }
  21468. fallthrough
  21469. case m.op.Is(OpUpdate | OpDelete):
  21470. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  21471. default:
  21472. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21473. }
  21474. }
  21475. // SetCreatedAt sets the "created_at" field.
  21476. func (m *WxMutation) SetCreatedAt(t time.Time) {
  21477. m.created_at = &t
  21478. }
  21479. // CreatedAt returns the value of the "created_at" field in the mutation.
  21480. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  21481. v := m.created_at
  21482. if v == nil {
  21483. return
  21484. }
  21485. return *v, true
  21486. }
  21487. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  21488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21490. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21491. if !m.op.Is(OpUpdateOne) {
  21492. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21493. }
  21494. if m.id == nil || m.oldValue == nil {
  21495. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21496. }
  21497. oldValue, err := m.oldValue(ctx)
  21498. if err != nil {
  21499. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21500. }
  21501. return oldValue.CreatedAt, nil
  21502. }
  21503. // ResetCreatedAt resets all changes to the "created_at" field.
  21504. func (m *WxMutation) ResetCreatedAt() {
  21505. m.created_at = nil
  21506. }
  21507. // SetUpdatedAt sets the "updated_at" field.
  21508. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  21509. m.updated_at = &t
  21510. }
  21511. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21512. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  21513. v := m.updated_at
  21514. if v == nil {
  21515. return
  21516. }
  21517. return *v, true
  21518. }
  21519. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  21520. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21522. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21523. if !m.op.Is(OpUpdateOne) {
  21524. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21525. }
  21526. if m.id == nil || m.oldValue == nil {
  21527. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21528. }
  21529. oldValue, err := m.oldValue(ctx)
  21530. if err != nil {
  21531. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21532. }
  21533. return oldValue.UpdatedAt, nil
  21534. }
  21535. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21536. func (m *WxMutation) ResetUpdatedAt() {
  21537. m.updated_at = nil
  21538. }
  21539. // SetStatus sets the "status" field.
  21540. func (m *WxMutation) SetStatus(u uint8) {
  21541. m.status = &u
  21542. m.addstatus = nil
  21543. }
  21544. // Status returns the value of the "status" field in the mutation.
  21545. func (m *WxMutation) Status() (r uint8, exists bool) {
  21546. v := m.status
  21547. if v == nil {
  21548. return
  21549. }
  21550. return *v, true
  21551. }
  21552. // OldStatus returns the old "status" field's value of the Wx entity.
  21553. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21555. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21556. if !m.op.Is(OpUpdateOne) {
  21557. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21558. }
  21559. if m.id == nil || m.oldValue == nil {
  21560. return v, errors.New("OldStatus requires an ID field in the mutation")
  21561. }
  21562. oldValue, err := m.oldValue(ctx)
  21563. if err != nil {
  21564. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21565. }
  21566. return oldValue.Status, nil
  21567. }
  21568. // AddStatus adds u to the "status" field.
  21569. func (m *WxMutation) AddStatus(u int8) {
  21570. if m.addstatus != nil {
  21571. *m.addstatus += u
  21572. } else {
  21573. m.addstatus = &u
  21574. }
  21575. }
  21576. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21577. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  21578. v := m.addstatus
  21579. if v == nil {
  21580. return
  21581. }
  21582. return *v, true
  21583. }
  21584. // ClearStatus clears the value of the "status" field.
  21585. func (m *WxMutation) ClearStatus() {
  21586. m.status = nil
  21587. m.addstatus = nil
  21588. m.clearedFields[wx.FieldStatus] = struct{}{}
  21589. }
  21590. // StatusCleared returns if the "status" field was cleared in this mutation.
  21591. func (m *WxMutation) StatusCleared() bool {
  21592. _, ok := m.clearedFields[wx.FieldStatus]
  21593. return ok
  21594. }
  21595. // ResetStatus resets all changes to the "status" field.
  21596. func (m *WxMutation) ResetStatus() {
  21597. m.status = nil
  21598. m.addstatus = nil
  21599. delete(m.clearedFields, wx.FieldStatus)
  21600. }
  21601. // SetDeletedAt sets the "deleted_at" field.
  21602. func (m *WxMutation) SetDeletedAt(t time.Time) {
  21603. m.deleted_at = &t
  21604. }
  21605. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21606. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  21607. v := m.deleted_at
  21608. if v == nil {
  21609. return
  21610. }
  21611. return *v, true
  21612. }
  21613. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  21614. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21616. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21617. if !m.op.Is(OpUpdateOne) {
  21618. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21619. }
  21620. if m.id == nil || m.oldValue == nil {
  21621. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21622. }
  21623. oldValue, err := m.oldValue(ctx)
  21624. if err != nil {
  21625. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21626. }
  21627. return oldValue.DeletedAt, nil
  21628. }
  21629. // ClearDeletedAt clears the value of the "deleted_at" field.
  21630. func (m *WxMutation) ClearDeletedAt() {
  21631. m.deleted_at = nil
  21632. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  21633. }
  21634. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21635. func (m *WxMutation) DeletedAtCleared() bool {
  21636. _, ok := m.clearedFields[wx.FieldDeletedAt]
  21637. return ok
  21638. }
  21639. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21640. func (m *WxMutation) ResetDeletedAt() {
  21641. m.deleted_at = nil
  21642. delete(m.clearedFields, wx.FieldDeletedAt)
  21643. }
  21644. // SetServerID sets the "server_id" field.
  21645. func (m *WxMutation) SetServerID(u uint64) {
  21646. m.server = &u
  21647. }
  21648. // ServerID returns the value of the "server_id" field in the mutation.
  21649. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  21650. v := m.server
  21651. if v == nil {
  21652. return
  21653. }
  21654. return *v, true
  21655. }
  21656. // OldServerID returns the old "server_id" field's value of the Wx entity.
  21657. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21659. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  21660. if !m.op.Is(OpUpdateOne) {
  21661. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  21662. }
  21663. if m.id == nil || m.oldValue == nil {
  21664. return v, errors.New("OldServerID requires an ID field in the mutation")
  21665. }
  21666. oldValue, err := m.oldValue(ctx)
  21667. if err != nil {
  21668. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  21669. }
  21670. return oldValue.ServerID, nil
  21671. }
  21672. // ClearServerID clears the value of the "server_id" field.
  21673. func (m *WxMutation) ClearServerID() {
  21674. m.server = nil
  21675. m.clearedFields[wx.FieldServerID] = struct{}{}
  21676. }
  21677. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  21678. func (m *WxMutation) ServerIDCleared() bool {
  21679. _, ok := m.clearedFields[wx.FieldServerID]
  21680. return ok
  21681. }
  21682. // ResetServerID resets all changes to the "server_id" field.
  21683. func (m *WxMutation) ResetServerID() {
  21684. m.server = nil
  21685. delete(m.clearedFields, wx.FieldServerID)
  21686. }
  21687. // SetPort sets the "port" field.
  21688. func (m *WxMutation) SetPort(s string) {
  21689. m.port = &s
  21690. }
  21691. // Port returns the value of the "port" field in the mutation.
  21692. func (m *WxMutation) Port() (r string, exists bool) {
  21693. v := m.port
  21694. if v == nil {
  21695. return
  21696. }
  21697. return *v, true
  21698. }
  21699. // OldPort returns the old "port" field's value of the Wx entity.
  21700. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21702. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  21703. if !m.op.Is(OpUpdateOne) {
  21704. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  21705. }
  21706. if m.id == nil || m.oldValue == nil {
  21707. return v, errors.New("OldPort requires an ID field in the mutation")
  21708. }
  21709. oldValue, err := m.oldValue(ctx)
  21710. if err != nil {
  21711. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  21712. }
  21713. return oldValue.Port, nil
  21714. }
  21715. // ResetPort resets all changes to the "port" field.
  21716. func (m *WxMutation) ResetPort() {
  21717. m.port = nil
  21718. }
  21719. // SetProcessID sets the "process_id" field.
  21720. func (m *WxMutation) SetProcessID(s string) {
  21721. m.process_id = &s
  21722. }
  21723. // ProcessID returns the value of the "process_id" field in the mutation.
  21724. func (m *WxMutation) ProcessID() (r string, exists bool) {
  21725. v := m.process_id
  21726. if v == nil {
  21727. return
  21728. }
  21729. return *v, true
  21730. }
  21731. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  21732. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21734. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  21735. if !m.op.Is(OpUpdateOne) {
  21736. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  21737. }
  21738. if m.id == nil || m.oldValue == nil {
  21739. return v, errors.New("OldProcessID requires an ID field in the mutation")
  21740. }
  21741. oldValue, err := m.oldValue(ctx)
  21742. if err != nil {
  21743. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  21744. }
  21745. return oldValue.ProcessID, nil
  21746. }
  21747. // ResetProcessID resets all changes to the "process_id" field.
  21748. func (m *WxMutation) ResetProcessID() {
  21749. m.process_id = nil
  21750. }
  21751. // SetCallback sets the "callback" field.
  21752. func (m *WxMutation) SetCallback(s string) {
  21753. m.callback = &s
  21754. }
  21755. // Callback returns the value of the "callback" field in the mutation.
  21756. func (m *WxMutation) Callback() (r string, exists bool) {
  21757. v := m.callback
  21758. if v == nil {
  21759. return
  21760. }
  21761. return *v, true
  21762. }
  21763. // OldCallback returns the old "callback" field's value of the Wx entity.
  21764. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21766. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  21767. if !m.op.Is(OpUpdateOne) {
  21768. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  21769. }
  21770. if m.id == nil || m.oldValue == nil {
  21771. return v, errors.New("OldCallback requires an ID field in the mutation")
  21772. }
  21773. oldValue, err := m.oldValue(ctx)
  21774. if err != nil {
  21775. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  21776. }
  21777. return oldValue.Callback, nil
  21778. }
  21779. // ResetCallback resets all changes to the "callback" field.
  21780. func (m *WxMutation) ResetCallback() {
  21781. m.callback = nil
  21782. }
  21783. // SetWxid sets the "wxid" field.
  21784. func (m *WxMutation) SetWxid(s string) {
  21785. m.wxid = &s
  21786. }
  21787. // Wxid returns the value of the "wxid" field in the mutation.
  21788. func (m *WxMutation) Wxid() (r string, exists bool) {
  21789. v := m.wxid
  21790. if v == nil {
  21791. return
  21792. }
  21793. return *v, true
  21794. }
  21795. // OldWxid returns the old "wxid" field's value of the Wx entity.
  21796. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21798. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  21799. if !m.op.Is(OpUpdateOne) {
  21800. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  21801. }
  21802. if m.id == nil || m.oldValue == nil {
  21803. return v, errors.New("OldWxid requires an ID field in the mutation")
  21804. }
  21805. oldValue, err := m.oldValue(ctx)
  21806. if err != nil {
  21807. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  21808. }
  21809. return oldValue.Wxid, nil
  21810. }
  21811. // ResetWxid resets all changes to the "wxid" field.
  21812. func (m *WxMutation) ResetWxid() {
  21813. m.wxid = nil
  21814. }
  21815. // SetAccount sets the "account" field.
  21816. func (m *WxMutation) SetAccount(s string) {
  21817. m.account = &s
  21818. }
  21819. // Account returns the value of the "account" field in the mutation.
  21820. func (m *WxMutation) Account() (r string, exists bool) {
  21821. v := m.account
  21822. if v == nil {
  21823. return
  21824. }
  21825. return *v, true
  21826. }
  21827. // OldAccount returns the old "account" field's value of the Wx entity.
  21828. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21830. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  21831. if !m.op.Is(OpUpdateOne) {
  21832. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  21833. }
  21834. if m.id == nil || m.oldValue == nil {
  21835. return v, errors.New("OldAccount requires an ID field in the mutation")
  21836. }
  21837. oldValue, err := m.oldValue(ctx)
  21838. if err != nil {
  21839. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  21840. }
  21841. return oldValue.Account, nil
  21842. }
  21843. // ResetAccount resets all changes to the "account" field.
  21844. func (m *WxMutation) ResetAccount() {
  21845. m.account = nil
  21846. }
  21847. // SetNickname sets the "nickname" field.
  21848. func (m *WxMutation) SetNickname(s string) {
  21849. m.nickname = &s
  21850. }
  21851. // Nickname returns the value of the "nickname" field in the mutation.
  21852. func (m *WxMutation) Nickname() (r string, exists bool) {
  21853. v := m.nickname
  21854. if v == nil {
  21855. return
  21856. }
  21857. return *v, true
  21858. }
  21859. // OldNickname returns the old "nickname" field's value of the Wx entity.
  21860. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21862. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  21863. if !m.op.Is(OpUpdateOne) {
  21864. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  21865. }
  21866. if m.id == nil || m.oldValue == nil {
  21867. return v, errors.New("OldNickname requires an ID field in the mutation")
  21868. }
  21869. oldValue, err := m.oldValue(ctx)
  21870. if err != nil {
  21871. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  21872. }
  21873. return oldValue.Nickname, nil
  21874. }
  21875. // ResetNickname resets all changes to the "nickname" field.
  21876. func (m *WxMutation) ResetNickname() {
  21877. m.nickname = nil
  21878. }
  21879. // SetTel sets the "tel" field.
  21880. func (m *WxMutation) SetTel(s string) {
  21881. m.tel = &s
  21882. }
  21883. // Tel returns the value of the "tel" field in the mutation.
  21884. func (m *WxMutation) Tel() (r string, exists bool) {
  21885. v := m.tel
  21886. if v == nil {
  21887. return
  21888. }
  21889. return *v, true
  21890. }
  21891. // OldTel returns the old "tel" field's value of the Wx entity.
  21892. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21894. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  21895. if !m.op.Is(OpUpdateOne) {
  21896. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  21897. }
  21898. if m.id == nil || m.oldValue == nil {
  21899. return v, errors.New("OldTel requires an ID field in the mutation")
  21900. }
  21901. oldValue, err := m.oldValue(ctx)
  21902. if err != nil {
  21903. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  21904. }
  21905. return oldValue.Tel, nil
  21906. }
  21907. // ResetTel resets all changes to the "tel" field.
  21908. func (m *WxMutation) ResetTel() {
  21909. m.tel = nil
  21910. }
  21911. // SetHeadBig sets the "head_big" field.
  21912. func (m *WxMutation) SetHeadBig(s string) {
  21913. m.head_big = &s
  21914. }
  21915. // HeadBig returns the value of the "head_big" field in the mutation.
  21916. func (m *WxMutation) HeadBig() (r string, exists bool) {
  21917. v := m.head_big
  21918. if v == nil {
  21919. return
  21920. }
  21921. return *v, true
  21922. }
  21923. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  21924. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21926. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  21927. if !m.op.Is(OpUpdateOne) {
  21928. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  21929. }
  21930. if m.id == nil || m.oldValue == nil {
  21931. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  21932. }
  21933. oldValue, err := m.oldValue(ctx)
  21934. if err != nil {
  21935. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  21936. }
  21937. return oldValue.HeadBig, nil
  21938. }
  21939. // ResetHeadBig resets all changes to the "head_big" field.
  21940. func (m *WxMutation) ResetHeadBig() {
  21941. m.head_big = nil
  21942. }
  21943. // SetOrganizationID sets the "organization_id" field.
  21944. func (m *WxMutation) SetOrganizationID(u uint64) {
  21945. m.organization_id = &u
  21946. m.addorganization_id = nil
  21947. }
  21948. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21949. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  21950. v := m.organization_id
  21951. if v == nil {
  21952. return
  21953. }
  21954. return *v, true
  21955. }
  21956. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  21957. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  21958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21959. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21960. if !m.op.Is(OpUpdateOne) {
  21961. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21962. }
  21963. if m.id == nil || m.oldValue == nil {
  21964. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21965. }
  21966. oldValue, err := m.oldValue(ctx)
  21967. if err != nil {
  21968. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21969. }
  21970. return oldValue.OrganizationID, nil
  21971. }
  21972. // AddOrganizationID adds u to the "organization_id" field.
  21973. func (m *WxMutation) AddOrganizationID(u int64) {
  21974. if m.addorganization_id != nil {
  21975. *m.addorganization_id += u
  21976. } else {
  21977. m.addorganization_id = &u
  21978. }
  21979. }
  21980. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21981. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  21982. v := m.addorganization_id
  21983. if v == nil {
  21984. return
  21985. }
  21986. return *v, true
  21987. }
  21988. // ClearOrganizationID clears the value of the "organization_id" field.
  21989. func (m *WxMutation) ClearOrganizationID() {
  21990. m.organization_id = nil
  21991. m.addorganization_id = nil
  21992. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  21993. }
  21994. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21995. func (m *WxMutation) OrganizationIDCleared() bool {
  21996. _, ok := m.clearedFields[wx.FieldOrganizationID]
  21997. return ok
  21998. }
  21999. // ResetOrganizationID resets all changes to the "organization_id" field.
  22000. func (m *WxMutation) ResetOrganizationID() {
  22001. m.organization_id = nil
  22002. m.addorganization_id = nil
  22003. delete(m.clearedFields, wx.FieldOrganizationID)
  22004. }
  22005. // SetAgentID sets the "agent_id" field.
  22006. func (m *WxMutation) SetAgentID(u uint64) {
  22007. m.agent = &u
  22008. }
  22009. // AgentID returns the value of the "agent_id" field in the mutation.
  22010. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  22011. v := m.agent
  22012. if v == nil {
  22013. return
  22014. }
  22015. return *v, true
  22016. }
  22017. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  22018. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22020. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  22021. if !m.op.Is(OpUpdateOne) {
  22022. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  22023. }
  22024. if m.id == nil || m.oldValue == nil {
  22025. return v, errors.New("OldAgentID requires an ID field in the mutation")
  22026. }
  22027. oldValue, err := m.oldValue(ctx)
  22028. if err != nil {
  22029. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  22030. }
  22031. return oldValue.AgentID, nil
  22032. }
  22033. // ResetAgentID resets all changes to the "agent_id" field.
  22034. func (m *WxMutation) ResetAgentID() {
  22035. m.agent = nil
  22036. }
  22037. // SetAPIBase sets the "api_base" field.
  22038. func (m *WxMutation) SetAPIBase(s string) {
  22039. m.api_base = &s
  22040. }
  22041. // APIBase returns the value of the "api_base" field in the mutation.
  22042. func (m *WxMutation) APIBase() (r string, exists bool) {
  22043. v := m.api_base
  22044. if v == nil {
  22045. return
  22046. }
  22047. return *v, true
  22048. }
  22049. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  22050. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22052. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  22053. if !m.op.Is(OpUpdateOne) {
  22054. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  22055. }
  22056. if m.id == nil || m.oldValue == nil {
  22057. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  22058. }
  22059. oldValue, err := m.oldValue(ctx)
  22060. if err != nil {
  22061. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  22062. }
  22063. return oldValue.APIBase, nil
  22064. }
  22065. // ClearAPIBase clears the value of the "api_base" field.
  22066. func (m *WxMutation) ClearAPIBase() {
  22067. m.api_base = nil
  22068. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  22069. }
  22070. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  22071. func (m *WxMutation) APIBaseCleared() bool {
  22072. _, ok := m.clearedFields[wx.FieldAPIBase]
  22073. return ok
  22074. }
  22075. // ResetAPIBase resets all changes to the "api_base" field.
  22076. func (m *WxMutation) ResetAPIBase() {
  22077. m.api_base = nil
  22078. delete(m.clearedFields, wx.FieldAPIBase)
  22079. }
  22080. // SetAPIKey sets the "api_key" field.
  22081. func (m *WxMutation) SetAPIKey(s string) {
  22082. m.api_key = &s
  22083. }
  22084. // APIKey returns the value of the "api_key" field in the mutation.
  22085. func (m *WxMutation) APIKey() (r string, exists bool) {
  22086. v := m.api_key
  22087. if v == nil {
  22088. return
  22089. }
  22090. return *v, true
  22091. }
  22092. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  22093. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22095. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  22096. if !m.op.Is(OpUpdateOne) {
  22097. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  22098. }
  22099. if m.id == nil || m.oldValue == nil {
  22100. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  22101. }
  22102. oldValue, err := m.oldValue(ctx)
  22103. if err != nil {
  22104. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  22105. }
  22106. return oldValue.APIKey, nil
  22107. }
  22108. // ClearAPIKey clears the value of the "api_key" field.
  22109. func (m *WxMutation) ClearAPIKey() {
  22110. m.api_key = nil
  22111. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  22112. }
  22113. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  22114. func (m *WxMutation) APIKeyCleared() bool {
  22115. _, ok := m.clearedFields[wx.FieldAPIKey]
  22116. return ok
  22117. }
  22118. // ResetAPIKey resets all changes to the "api_key" field.
  22119. func (m *WxMutation) ResetAPIKey() {
  22120. m.api_key = nil
  22121. delete(m.clearedFields, wx.FieldAPIKey)
  22122. }
  22123. // SetAllowList sets the "allow_list" field.
  22124. func (m *WxMutation) SetAllowList(s []string) {
  22125. m.allow_list = &s
  22126. m.appendallow_list = nil
  22127. }
  22128. // AllowList returns the value of the "allow_list" field in the mutation.
  22129. func (m *WxMutation) AllowList() (r []string, exists bool) {
  22130. v := m.allow_list
  22131. if v == nil {
  22132. return
  22133. }
  22134. return *v, true
  22135. }
  22136. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  22137. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22139. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  22140. if !m.op.Is(OpUpdateOne) {
  22141. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  22142. }
  22143. if m.id == nil || m.oldValue == nil {
  22144. return v, errors.New("OldAllowList requires an ID field in the mutation")
  22145. }
  22146. oldValue, err := m.oldValue(ctx)
  22147. if err != nil {
  22148. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  22149. }
  22150. return oldValue.AllowList, nil
  22151. }
  22152. // AppendAllowList adds s to the "allow_list" field.
  22153. func (m *WxMutation) AppendAllowList(s []string) {
  22154. m.appendallow_list = append(m.appendallow_list, s...)
  22155. }
  22156. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  22157. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  22158. if len(m.appendallow_list) == 0 {
  22159. return nil, false
  22160. }
  22161. return m.appendallow_list, true
  22162. }
  22163. // ResetAllowList resets all changes to the "allow_list" field.
  22164. func (m *WxMutation) ResetAllowList() {
  22165. m.allow_list = nil
  22166. m.appendallow_list = nil
  22167. }
  22168. // SetGroupAllowList sets the "group_allow_list" field.
  22169. func (m *WxMutation) SetGroupAllowList(s []string) {
  22170. m.group_allow_list = &s
  22171. m.appendgroup_allow_list = nil
  22172. }
  22173. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  22174. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  22175. v := m.group_allow_list
  22176. if v == nil {
  22177. return
  22178. }
  22179. return *v, true
  22180. }
  22181. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  22182. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22184. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  22185. if !m.op.Is(OpUpdateOne) {
  22186. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  22187. }
  22188. if m.id == nil || m.oldValue == nil {
  22189. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  22190. }
  22191. oldValue, err := m.oldValue(ctx)
  22192. if err != nil {
  22193. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  22194. }
  22195. return oldValue.GroupAllowList, nil
  22196. }
  22197. // AppendGroupAllowList adds s to the "group_allow_list" field.
  22198. func (m *WxMutation) AppendGroupAllowList(s []string) {
  22199. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  22200. }
  22201. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  22202. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  22203. if len(m.appendgroup_allow_list) == 0 {
  22204. return nil, false
  22205. }
  22206. return m.appendgroup_allow_list, true
  22207. }
  22208. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  22209. func (m *WxMutation) ResetGroupAllowList() {
  22210. m.group_allow_list = nil
  22211. m.appendgroup_allow_list = nil
  22212. }
  22213. // SetBlockList sets the "block_list" field.
  22214. func (m *WxMutation) SetBlockList(s []string) {
  22215. m.block_list = &s
  22216. m.appendblock_list = nil
  22217. }
  22218. // BlockList returns the value of the "block_list" field in the mutation.
  22219. func (m *WxMutation) BlockList() (r []string, exists bool) {
  22220. v := m.block_list
  22221. if v == nil {
  22222. return
  22223. }
  22224. return *v, true
  22225. }
  22226. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  22227. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22229. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  22230. if !m.op.Is(OpUpdateOne) {
  22231. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  22232. }
  22233. if m.id == nil || m.oldValue == nil {
  22234. return v, errors.New("OldBlockList requires an ID field in the mutation")
  22235. }
  22236. oldValue, err := m.oldValue(ctx)
  22237. if err != nil {
  22238. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  22239. }
  22240. return oldValue.BlockList, nil
  22241. }
  22242. // AppendBlockList adds s to the "block_list" field.
  22243. func (m *WxMutation) AppendBlockList(s []string) {
  22244. m.appendblock_list = append(m.appendblock_list, s...)
  22245. }
  22246. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  22247. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  22248. if len(m.appendblock_list) == 0 {
  22249. return nil, false
  22250. }
  22251. return m.appendblock_list, true
  22252. }
  22253. // ResetBlockList resets all changes to the "block_list" field.
  22254. func (m *WxMutation) ResetBlockList() {
  22255. m.block_list = nil
  22256. m.appendblock_list = nil
  22257. }
  22258. // SetGroupBlockList sets the "group_block_list" field.
  22259. func (m *WxMutation) SetGroupBlockList(s []string) {
  22260. m.group_block_list = &s
  22261. m.appendgroup_block_list = nil
  22262. }
  22263. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  22264. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  22265. v := m.group_block_list
  22266. if v == nil {
  22267. return
  22268. }
  22269. return *v, true
  22270. }
  22271. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  22272. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22274. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  22275. if !m.op.Is(OpUpdateOne) {
  22276. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  22277. }
  22278. if m.id == nil || m.oldValue == nil {
  22279. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  22280. }
  22281. oldValue, err := m.oldValue(ctx)
  22282. if err != nil {
  22283. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  22284. }
  22285. return oldValue.GroupBlockList, nil
  22286. }
  22287. // AppendGroupBlockList adds s to the "group_block_list" field.
  22288. func (m *WxMutation) AppendGroupBlockList(s []string) {
  22289. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  22290. }
  22291. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  22292. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  22293. if len(m.appendgroup_block_list) == 0 {
  22294. return nil, false
  22295. }
  22296. return m.appendgroup_block_list, true
  22297. }
  22298. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  22299. func (m *WxMutation) ResetGroupBlockList() {
  22300. m.group_block_list = nil
  22301. m.appendgroup_block_list = nil
  22302. }
  22303. // ClearServer clears the "server" edge to the Server entity.
  22304. func (m *WxMutation) ClearServer() {
  22305. m.clearedserver = true
  22306. m.clearedFields[wx.FieldServerID] = struct{}{}
  22307. }
  22308. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  22309. func (m *WxMutation) ServerCleared() bool {
  22310. return m.ServerIDCleared() || m.clearedserver
  22311. }
  22312. // ServerIDs returns the "server" edge IDs in the mutation.
  22313. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22314. // ServerID instead. It exists only for internal usage by the builders.
  22315. func (m *WxMutation) ServerIDs() (ids []uint64) {
  22316. if id := m.server; id != nil {
  22317. ids = append(ids, *id)
  22318. }
  22319. return
  22320. }
  22321. // ResetServer resets all changes to the "server" edge.
  22322. func (m *WxMutation) ResetServer() {
  22323. m.server = nil
  22324. m.clearedserver = false
  22325. }
  22326. // ClearAgent clears the "agent" edge to the Agent entity.
  22327. func (m *WxMutation) ClearAgent() {
  22328. m.clearedagent = true
  22329. m.clearedFields[wx.FieldAgentID] = struct{}{}
  22330. }
  22331. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22332. func (m *WxMutation) AgentCleared() bool {
  22333. return m.clearedagent
  22334. }
  22335. // AgentIDs returns the "agent" edge IDs in the mutation.
  22336. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22337. // AgentID instead. It exists only for internal usage by the builders.
  22338. func (m *WxMutation) AgentIDs() (ids []uint64) {
  22339. if id := m.agent; id != nil {
  22340. ids = append(ids, *id)
  22341. }
  22342. return
  22343. }
  22344. // ResetAgent resets all changes to the "agent" edge.
  22345. func (m *WxMutation) ResetAgent() {
  22346. m.agent = nil
  22347. m.clearedagent = false
  22348. }
  22349. // Where appends a list predicates to the WxMutation builder.
  22350. func (m *WxMutation) Where(ps ...predicate.Wx) {
  22351. m.predicates = append(m.predicates, ps...)
  22352. }
  22353. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  22354. // users can use type-assertion to append predicates that do not depend on any generated package.
  22355. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  22356. p := make([]predicate.Wx, len(ps))
  22357. for i := range ps {
  22358. p[i] = ps[i]
  22359. }
  22360. m.Where(p...)
  22361. }
  22362. // Op returns the operation name.
  22363. func (m *WxMutation) Op() Op {
  22364. return m.op
  22365. }
  22366. // SetOp allows setting the mutation operation.
  22367. func (m *WxMutation) SetOp(op Op) {
  22368. m.op = op
  22369. }
  22370. // Type returns the node type of this mutation (Wx).
  22371. func (m *WxMutation) Type() string {
  22372. return m.typ
  22373. }
  22374. // Fields returns all fields that were changed during this mutation. Note that in
  22375. // order to get all numeric fields that were incremented/decremented, call
  22376. // AddedFields().
  22377. func (m *WxMutation) Fields() []string {
  22378. fields := make([]string, 0, 21)
  22379. if m.created_at != nil {
  22380. fields = append(fields, wx.FieldCreatedAt)
  22381. }
  22382. if m.updated_at != nil {
  22383. fields = append(fields, wx.FieldUpdatedAt)
  22384. }
  22385. if m.status != nil {
  22386. fields = append(fields, wx.FieldStatus)
  22387. }
  22388. if m.deleted_at != nil {
  22389. fields = append(fields, wx.FieldDeletedAt)
  22390. }
  22391. if m.server != nil {
  22392. fields = append(fields, wx.FieldServerID)
  22393. }
  22394. if m.port != nil {
  22395. fields = append(fields, wx.FieldPort)
  22396. }
  22397. if m.process_id != nil {
  22398. fields = append(fields, wx.FieldProcessID)
  22399. }
  22400. if m.callback != nil {
  22401. fields = append(fields, wx.FieldCallback)
  22402. }
  22403. if m.wxid != nil {
  22404. fields = append(fields, wx.FieldWxid)
  22405. }
  22406. if m.account != nil {
  22407. fields = append(fields, wx.FieldAccount)
  22408. }
  22409. if m.nickname != nil {
  22410. fields = append(fields, wx.FieldNickname)
  22411. }
  22412. if m.tel != nil {
  22413. fields = append(fields, wx.FieldTel)
  22414. }
  22415. if m.head_big != nil {
  22416. fields = append(fields, wx.FieldHeadBig)
  22417. }
  22418. if m.organization_id != nil {
  22419. fields = append(fields, wx.FieldOrganizationID)
  22420. }
  22421. if m.agent != nil {
  22422. fields = append(fields, wx.FieldAgentID)
  22423. }
  22424. if m.api_base != nil {
  22425. fields = append(fields, wx.FieldAPIBase)
  22426. }
  22427. if m.api_key != nil {
  22428. fields = append(fields, wx.FieldAPIKey)
  22429. }
  22430. if m.allow_list != nil {
  22431. fields = append(fields, wx.FieldAllowList)
  22432. }
  22433. if m.group_allow_list != nil {
  22434. fields = append(fields, wx.FieldGroupAllowList)
  22435. }
  22436. if m.block_list != nil {
  22437. fields = append(fields, wx.FieldBlockList)
  22438. }
  22439. if m.group_block_list != nil {
  22440. fields = append(fields, wx.FieldGroupBlockList)
  22441. }
  22442. return fields
  22443. }
  22444. // Field returns the value of a field with the given name. The second boolean
  22445. // return value indicates that this field was not set, or was not defined in the
  22446. // schema.
  22447. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  22448. switch name {
  22449. case wx.FieldCreatedAt:
  22450. return m.CreatedAt()
  22451. case wx.FieldUpdatedAt:
  22452. return m.UpdatedAt()
  22453. case wx.FieldStatus:
  22454. return m.Status()
  22455. case wx.FieldDeletedAt:
  22456. return m.DeletedAt()
  22457. case wx.FieldServerID:
  22458. return m.ServerID()
  22459. case wx.FieldPort:
  22460. return m.Port()
  22461. case wx.FieldProcessID:
  22462. return m.ProcessID()
  22463. case wx.FieldCallback:
  22464. return m.Callback()
  22465. case wx.FieldWxid:
  22466. return m.Wxid()
  22467. case wx.FieldAccount:
  22468. return m.Account()
  22469. case wx.FieldNickname:
  22470. return m.Nickname()
  22471. case wx.FieldTel:
  22472. return m.Tel()
  22473. case wx.FieldHeadBig:
  22474. return m.HeadBig()
  22475. case wx.FieldOrganizationID:
  22476. return m.OrganizationID()
  22477. case wx.FieldAgentID:
  22478. return m.AgentID()
  22479. case wx.FieldAPIBase:
  22480. return m.APIBase()
  22481. case wx.FieldAPIKey:
  22482. return m.APIKey()
  22483. case wx.FieldAllowList:
  22484. return m.AllowList()
  22485. case wx.FieldGroupAllowList:
  22486. return m.GroupAllowList()
  22487. case wx.FieldBlockList:
  22488. return m.BlockList()
  22489. case wx.FieldGroupBlockList:
  22490. return m.GroupBlockList()
  22491. }
  22492. return nil, false
  22493. }
  22494. // OldField returns the old value of the field from the database. An error is
  22495. // returned if the mutation operation is not UpdateOne, or the query to the
  22496. // database failed.
  22497. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22498. switch name {
  22499. case wx.FieldCreatedAt:
  22500. return m.OldCreatedAt(ctx)
  22501. case wx.FieldUpdatedAt:
  22502. return m.OldUpdatedAt(ctx)
  22503. case wx.FieldStatus:
  22504. return m.OldStatus(ctx)
  22505. case wx.FieldDeletedAt:
  22506. return m.OldDeletedAt(ctx)
  22507. case wx.FieldServerID:
  22508. return m.OldServerID(ctx)
  22509. case wx.FieldPort:
  22510. return m.OldPort(ctx)
  22511. case wx.FieldProcessID:
  22512. return m.OldProcessID(ctx)
  22513. case wx.FieldCallback:
  22514. return m.OldCallback(ctx)
  22515. case wx.FieldWxid:
  22516. return m.OldWxid(ctx)
  22517. case wx.FieldAccount:
  22518. return m.OldAccount(ctx)
  22519. case wx.FieldNickname:
  22520. return m.OldNickname(ctx)
  22521. case wx.FieldTel:
  22522. return m.OldTel(ctx)
  22523. case wx.FieldHeadBig:
  22524. return m.OldHeadBig(ctx)
  22525. case wx.FieldOrganizationID:
  22526. return m.OldOrganizationID(ctx)
  22527. case wx.FieldAgentID:
  22528. return m.OldAgentID(ctx)
  22529. case wx.FieldAPIBase:
  22530. return m.OldAPIBase(ctx)
  22531. case wx.FieldAPIKey:
  22532. return m.OldAPIKey(ctx)
  22533. case wx.FieldAllowList:
  22534. return m.OldAllowList(ctx)
  22535. case wx.FieldGroupAllowList:
  22536. return m.OldGroupAllowList(ctx)
  22537. case wx.FieldBlockList:
  22538. return m.OldBlockList(ctx)
  22539. case wx.FieldGroupBlockList:
  22540. return m.OldGroupBlockList(ctx)
  22541. }
  22542. return nil, fmt.Errorf("unknown Wx field %s", name)
  22543. }
  22544. // SetField sets the value of a field with the given name. It returns an error if
  22545. // the field is not defined in the schema, or if the type mismatched the field
  22546. // type.
  22547. func (m *WxMutation) SetField(name string, value ent.Value) error {
  22548. switch name {
  22549. case wx.FieldCreatedAt:
  22550. v, ok := value.(time.Time)
  22551. if !ok {
  22552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22553. }
  22554. m.SetCreatedAt(v)
  22555. return nil
  22556. case wx.FieldUpdatedAt:
  22557. v, ok := value.(time.Time)
  22558. if !ok {
  22559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22560. }
  22561. m.SetUpdatedAt(v)
  22562. return nil
  22563. case wx.FieldStatus:
  22564. v, ok := value.(uint8)
  22565. if !ok {
  22566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22567. }
  22568. m.SetStatus(v)
  22569. return nil
  22570. case wx.FieldDeletedAt:
  22571. v, ok := value.(time.Time)
  22572. if !ok {
  22573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22574. }
  22575. m.SetDeletedAt(v)
  22576. return nil
  22577. case wx.FieldServerID:
  22578. v, ok := value.(uint64)
  22579. if !ok {
  22580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22581. }
  22582. m.SetServerID(v)
  22583. return nil
  22584. case wx.FieldPort:
  22585. v, ok := value.(string)
  22586. if !ok {
  22587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22588. }
  22589. m.SetPort(v)
  22590. return nil
  22591. case wx.FieldProcessID:
  22592. v, ok := value.(string)
  22593. if !ok {
  22594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22595. }
  22596. m.SetProcessID(v)
  22597. return nil
  22598. case wx.FieldCallback:
  22599. v, ok := value.(string)
  22600. if !ok {
  22601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22602. }
  22603. m.SetCallback(v)
  22604. return nil
  22605. case wx.FieldWxid:
  22606. v, ok := value.(string)
  22607. if !ok {
  22608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22609. }
  22610. m.SetWxid(v)
  22611. return nil
  22612. case wx.FieldAccount:
  22613. v, ok := value.(string)
  22614. if !ok {
  22615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22616. }
  22617. m.SetAccount(v)
  22618. return nil
  22619. case wx.FieldNickname:
  22620. v, ok := value.(string)
  22621. if !ok {
  22622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22623. }
  22624. m.SetNickname(v)
  22625. return nil
  22626. case wx.FieldTel:
  22627. v, ok := value.(string)
  22628. if !ok {
  22629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22630. }
  22631. m.SetTel(v)
  22632. return nil
  22633. case wx.FieldHeadBig:
  22634. v, ok := value.(string)
  22635. if !ok {
  22636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22637. }
  22638. m.SetHeadBig(v)
  22639. return nil
  22640. case wx.FieldOrganizationID:
  22641. v, ok := value.(uint64)
  22642. if !ok {
  22643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22644. }
  22645. m.SetOrganizationID(v)
  22646. return nil
  22647. case wx.FieldAgentID:
  22648. v, ok := value.(uint64)
  22649. if !ok {
  22650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22651. }
  22652. m.SetAgentID(v)
  22653. return nil
  22654. case wx.FieldAPIBase:
  22655. v, ok := value.(string)
  22656. if !ok {
  22657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22658. }
  22659. m.SetAPIBase(v)
  22660. return nil
  22661. case wx.FieldAPIKey:
  22662. v, ok := value.(string)
  22663. if !ok {
  22664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22665. }
  22666. m.SetAPIKey(v)
  22667. return nil
  22668. case wx.FieldAllowList:
  22669. v, ok := value.([]string)
  22670. if !ok {
  22671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22672. }
  22673. m.SetAllowList(v)
  22674. return nil
  22675. case wx.FieldGroupAllowList:
  22676. v, ok := value.([]string)
  22677. if !ok {
  22678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22679. }
  22680. m.SetGroupAllowList(v)
  22681. return nil
  22682. case wx.FieldBlockList:
  22683. v, ok := value.([]string)
  22684. if !ok {
  22685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22686. }
  22687. m.SetBlockList(v)
  22688. return nil
  22689. case wx.FieldGroupBlockList:
  22690. v, ok := value.([]string)
  22691. if !ok {
  22692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22693. }
  22694. m.SetGroupBlockList(v)
  22695. return nil
  22696. }
  22697. return fmt.Errorf("unknown Wx field %s", name)
  22698. }
  22699. // AddedFields returns all numeric fields that were incremented/decremented during
  22700. // this mutation.
  22701. func (m *WxMutation) AddedFields() []string {
  22702. var fields []string
  22703. if m.addstatus != nil {
  22704. fields = append(fields, wx.FieldStatus)
  22705. }
  22706. if m.addorganization_id != nil {
  22707. fields = append(fields, wx.FieldOrganizationID)
  22708. }
  22709. return fields
  22710. }
  22711. // AddedField returns the numeric value that was incremented/decremented on a field
  22712. // with the given name. The second boolean return value indicates that this field
  22713. // was not set, or was not defined in the schema.
  22714. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  22715. switch name {
  22716. case wx.FieldStatus:
  22717. return m.AddedStatus()
  22718. case wx.FieldOrganizationID:
  22719. return m.AddedOrganizationID()
  22720. }
  22721. return nil, false
  22722. }
  22723. // AddField adds the value to the field with the given name. It returns an error if
  22724. // the field is not defined in the schema, or if the type mismatched the field
  22725. // type.
  22726. func (m *WxMutation) AddField(name string, value ent.Value) error {
  22727. switch name {
  22728. case wx.FieldStatus:
  22729. v, ok := value.(int8)
  22730. if !ok {
  22731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22732. }
  22733. m.AddStatus(v)
  22734. return nil
  22735. case wx.FieldOrganizationID:
  22736. v, ok := value.(int64)
  22737. if !ok {
  22738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22739. }
  22740. m.AddOrganizationID(v)
  22741. return nil
  22742. }
  22743. return fmt.Errorf("unknown Wx numeric field %s", name)
  22744. }
  22745. // ClearedFields returns all nullable fields that were cleared during this
  22746. // mutation.
  22747. func (m *WxMutation) ClearedFields() []string {
  22748. var fields []string
  22749. if m.FieldCleared(wx.FieldStatus) {
  22750. fields = append(fields, wx.FieldStatus)
  22751. }
  22752. if m.FieldCleared(wx.FieldDeletedAt) {
  22753. fields = append(fields, wx.FieldDeletedAt)
  22754. }
  22755. if m.FieldCleared(wx.FieldServerID) {
  22756. fields = append(fields, wx.FieldServerID)
  22757. }
  22758. if m.FieldCleared(wx.FieldOrganizationID) {
  22759. fields = append(fields, wx.FieldOrganizationID)
  22760. }
  22761. if m.FieldCleared(wx.FieldAPIBase) {
  22762. fields = append(fields, wx.FieldAPIBase)
  22763. }
  22764. if m.FieldCleared(wx.FieldAPIKey) {
  22765. fields = append(fields, wx.FieldAPIKey)
  22766. }
  22767. return fields
  22768. }
  22769. // FieldCleared returns a boolean indicating if a field with the given name was
  22770. // cleared in this mutation.
  22771. func (m *WxMutation) FieldCleared(name string) bool {
  22772. _, ok := m.clearedFields[name]
  22773. return ok
  22774. }
  22775. // ClearField clears the value of the field with the given name. It returns an
  22776. // error if the field is not defined in the schema.
  22777. func (m *WxMutation) ClearField(name string) error {
  22778. switch name {
  22779. case wx.FieldStatus:
  22780. m.ClearStatus()
  22781. return nil
  22782. case wx.FieldDeletedAt:
  22783. m.ClearDeletedAt()
  22784. return nil
  22785. case wx.FieldServerID:
  22786. m.ClearServerID()
  22787. return nil
  22788. case wx.FieldOrganizationID:
  22789. m.ClearOrganizationID()
  22790. return nil
  22791. case wx.FieldAPIBase:
  22792. m.ClearAPIBase()
  22793. return nil
  22794. case wx.FieldAPIKey:
  22795. m.ClearAPIKey()
  22796. return nil
  22797. }
  22798. return fmt.Errorf("unknown Wx nullable field %s", name)
  22799. }
  22800. // ResetField resets all changes in the mutation for the field with the given name.
  22801. // It returns an error if the field is not defined in the schema.
  22802. func (m *WxMutation) ResetField(name string) error {
  22803. switch name {
  22804. case wx.FieldCreatedAt:
  22805. m.ResetCreatedAt()
  22806. return nil
  22807. case wx.FieldUpdatedAt:
  22808. m.ResetUpdatedAt()
  22809. return nil
  22810. case wx.FieldStatus:
  22811. m.ResetStatus()
  22812. return nil
  22813. case wx.FieldDeletedAt:
  22814. m.ResetDeletedAt()
  22815. return nil
  22816. case wx.FieldServerID:
  22817. m.ResetServerID()
  22818. return nil
  22819. case wx.FieldPort:
  22820. m.ResetPort()
  22821. return nil
  22822. case wx.FieldProcessID:
  22823. m.ResetProcessID()
  22824. return nil
  22825. case wx.FieldCallback:
  22826. m.ResetCallback()
  22827. return nil
  22828. case wx.FieldWxid:
  22829. m.ResetWxid()
  22830. return nil
  22831. case wx.FieldAccount:
  22832. m.ResetAccount()
  22833. return nil
  22834. case wx.FieldNickname:
  22835. m.ResetNickname()
  22836. return nil
  22837. case wx.FieldTel:
  22838. m.ResetTel()
  22839. return nil
  22840. case wx.FieldHeadBig:
  22841. m.ResetHeadBig()
  22842. return nil
  22843. case wx.FieldOrganizationID:
  22844. m.ResetOrganizationID()
  22845. return nil
  22846. case wx.FieldAgentID:
  22847. m.ResetAgentID()
  22848. return nil
  22849. case wx.FieldAPIBase:
  22850. m.ResetAPIBase()
  22851. return nil
  22852. case wx.FieldAPIKey:
  22853. m.ResetAPIKey()
  22854. return nil
  22855. case wx.FieldAllowList:
  22856. m.ResetAllowList()
  22857. return nil
  22858. case wx.FieldGroupAllowList:
  22859. m.ResetGroupAllowList()
  22860. return nil
  22861. case wx.FieldBlockList:
  22862. m.ResetBlockList()
  22863. return nil
  22864. case wx.FieldGroupBlockList:
  22865. m.ResetGroupBlockList()
  22866. return nil
  22867. }
  22868. return fmt.Errorf("unknown Wx field %s", name)
  22869. }
  22870. // AddedEdges returns all edge names that were set/added in this mutation.
  22871. func (m *WxMutation) AddedEdges() []string {
  22872. edges := make([]string, 0, 2)
  22873. if m.server != nil {
  22874. edges = append(edges, wx.EdgeServer)
  22875. }
  22876. if m.agent != nil {
  22877. edges = append(edges, wx.EdgeAgent)
  22878. }
  22879. return edges
  22880. }
  22881. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22882. // name in this mutation.
  22883. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  22884. switch name {
  22885. case wx.EdgeServer:
  22886. if id := m.server; id != nil {
  22887. return []ent.Value{*id}
  22888. }
  22889. case wx.EdgeAgent:
  22890. if id := m.agent; id != nil {
  22891. return []ent.Value{*id}
  22892. }
  22893. }
  22894. return nil
  22895. }
  22896. // RemovedEdges returns all edge names that were removed in this mutation.
  22897. func (m *WxMutation) RemovedEdges() []string {
  22898. edges := make([]string, 0, 2)
  22899. return edges
  22900. }
  22901. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22902. // the given name in this mutation.
  22903. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  22904. return nil
  22905. }
  22906. // ClearedEdges returns all edge names that were cleared in this mutation.
  22907. func (m *WxMutation) ClearedEdges() []string {
  22908. edges := make([]string, 0, 2)
  22909. if m.clearedserver {
  22910. edges = append(edges, wx.EdgeServer)
  22911. }
  22912. if m.clearedagent {
  22913. edges = append(edges, wx.EdgeAgent)
  22914. }
  22915. return edges
  22916. }
  22917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22918. // was cleared in this mutation.
  22919. func (m *WxMutation) EdgeCleared(name string) bool {
  22920. switch name {
  22921. case wx.EdgeServer:
  22922. return m.clearedserver
  22923. case wx.EdgeAgent:
  22924. return m.clearedagent
  22925. }
  22926. return false
  22927. }
  22928. // ClearEdge clears the value of the edge with the given name. It returns an error
  22929. // if that edge is not defined in the schema.
  22930. func (m *WxMutation) ClearEdge(name string) error {
  22931. switch name {
  22932. case wx.EdgeServer:
  22933. m.ClearServer()
  22934. return nil
  22935. case wx.EdgeAgent:
  22936. m.ClearAgent()
  22937. return nil
  22938. }
  22939. return fmt.Errorf("unknown Wx unique edge %s", name)
  22940. }
  22941. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22942. // It returns an error if the edge is not defined in the schema.
  22943. func (m *WxMutation) ResetEdge(name string) error {
  22944. switch name {
  22945. case wx.EdgeServer:
  22946. m.ResetServer()
  22947. return nil
  22948. case wx.EdgeAgent:
  22949. m.ResetAgent()
  22950. return nil
  22951. }
  22952. return fmt.Errorf("unknown Wx edge %s", name)
  22953. }
  22954. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  22955. type WxCardMutation struct {
  22956. config
  22957. op Op
  22958. typ string
  22959. id *uint64
  22960. created_at *time.Time
  22961. updated_at *time.Time
  22962. deleted_at *time.Time
  22963. user_id *uint64
  22964. adduser_id *int64
  22965. wx_user_id *uint64
  22966. addwx_user_id *int64
  22967. avatar *string
  22968. logo *string
  22969. name *string
  22970. company *string
  22971. address *string
  22972. phone *string
  22973. official_account *string
  22974. wechat_account *string
  22975. email *string
  22976. api_base *string
  22977. api_key *string
  22978. ai_info *string
  22979. intro *string
  22980. clearedFields map[string]struct{}
  22981. done bool
  22982. oldValue func(context.Context) (*WxCard, error)
  22983. predicates []predicate.WxCard
  22984. }
  22985. var _ ent.Mutation = (*WxCardMutation)(nil)
  22986. // wxcardOption allows management of the mutation configuration using functional options.
  22987. type wxcardOption func(*WxCardMutation)
  22988. // newWxCardMutation creates new mutation for the WxCard entity.
  22989. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  22990. m := &WxCardMutation{
  22991. config: c,
  22992. op: op,
  22993. typ: TypeWxCard,
  22994. clearedFields: make(map[string]struct{}),
  22995. }
  22996. for _, opt := range opts {
  22997. opt(m)
  22998. }
  22999. return m
  23000. }
  23001. // withWxCardID sets the ID field of the mutation.
  23002. func withWxCardID(id uint64) wxcardOption {
  23003. return func(m *WxCardMutation) {
  23004. var (
  23005. err error
  23006. once sync.Once
  23007. value *WxCard
  23008. )
  23009. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  23010. once.Do(func() {
  23011. if m.done {
  23012. err = errors.New("querying old values post mutation is not allowed")
  23013. } else {
  23014. value, err = m.Client().WxCard.Get(ctx, id)
  23015. }
  23016. })
  23017. return value, err
  23018. }
  23019. m.id = &id
  23020. }
  23021. }
  23022. // withWxCard sets the old WxCard of the mutation.
  23023. func withWxCard(node *WxCard) wxcardOption {
  23024. return func(m *WxCardMutation) {
  23025. m.oldValue = func(context.Context) (*WxCard, error) {
  23026. return node, nil
  23027. }
  23028. m.id = &node.ID
  23029. }
  23030. }
  23031. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23032. // executed in a transaction (ent.Tx), a transactional client is returned.
  23033. func (m WxCardMutation) Client() *Client {
  23034. client := &Client{config: m.config}
  23035. client.init()
  23036. return client
  23037. }
  23038. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23039. // it returns an error otherwise.
  23040. func (m WxCardMutation) Tx() (*Tx, error) {
  23041. if _, ok := m.driver.(*txDriver); !ok {
  23042. return nil, errors.New("ent: mutation is not running in a transaction")
  23043. }
  23044. tx := &Tx{config: m.config}
  23045. tx.init()
  23046. return tx, nil
  23047. }
  23048. // SetID sets the value of the id field. Note that this
  23049. // operation is only accepted on creation of WxCard entities.
  23050. func (m *WxCardMutation) SetID(id uint64) {
  23051. m.id = &id
  23052. }
  23053. // ID returns the ID value in the mutation. Note that the ID is only available
  23054. // if it was provided to the builder or after it was returned from the database.
  23055. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  23056. if m.id == nil {
  23057. return
  23058. }
  23059. return *m.id, true
  23060. }
  23061. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23062. // That means, if the mutation is applied within a transaction with an isolation level such
  23063. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23064. // or updated by the mutation.
  23065. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  23066. switch {
  23067. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23068. id, exists := m.ID()
  23069. if exists {
  23070. return []uint64{id}, nil
  23071. }
  23072. fallthrough
  23073. case m.op.Is(OpUpdate | OpDelete):
  23074. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  23075. default:
  23076. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23077. }
  23078. }
  23079. // SetCreatedAt sets the "created_at" field.
  23080. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  23081. m.created_at = &t
  23082. }
  23083. // CreatedAt returns the value of the "created_at" field in the mutation.
  23084. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  23085. v := m.created_at
  23086. if v == nil {
  23087. return
  23088. }
  23089. return *v, true
  23090. }
  23091. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  23092. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23094. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23095. if !m.op.Is(OpUpdateOne) {
  23096. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23097. }
  23098. if m.id == nil || m.oldValue == nil {
  23099. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23100. }
  23101. oldValue, err := m.oldValue(ctx)
  23102. if err != nil {
  23103. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23104. }
  23105. return oldValue.CreatedAt, nil
  23106. }
  23107. // ResetCreatedAt resets all changes to the "created_at" field.
  23108. func (m *WxCardMutation) ResetCreatedAt() {
  23109. m.created_at = nil
  23110. }
  23111. // SetUpdatedAt sets the "updated_at" field.
  23112. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  23113. m.updated_at = &t
  23114. }
  23115. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23116. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  23117. v := m.updated_at
  23118. if v == nil {
  23119. return
  23120. }
  23121. return *v, true
  23122. }
  23123. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  23124. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23126. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23127. if !m.op.Is(OpUpdateOne) {
  23128. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23129. }
  23130. if m.id == nil || m.oldValue == nil {
  23131. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23132. }
  23133. oldValue, err := m.oldValue(ctx)
  23134. if err != nil {
  23135. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23136. }
  23137. return oldValue.UpdatedAt, nil
  23138. }
  23139. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23140. func (m *WxCardMutation) ResetUpdatedAt() {
  23141. m.updated_at = nil
  23142. }
  23143. // SetDeletedAt sets the "deleted_at" field.
  23144. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  23145. m.deleted_at = &t
  23146. }
  23147. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23148. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  23149. v := m.deleted_at
  23150. if v == nil {
  23151. return
  23152. }
  23153. return *v, true
  23154. }
  23155. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  23156. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23158. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23159. if !m.op.Is(OpUpdateOne) {
  23160. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23161. }
  23162. if m.id == nil || m.oldValue == nil {
  23163. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23164. }
  23165. oldValue, err := m.oldValue(ctx)
  23166. if err != nil {
  23167. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23168. }
  23169. return oldValue.DeletedAt, nil
  23170. }
  23171. // ClearDeletedAt clears the value of the "deleted_at" field.
  23172. func (m *WxCardMutation) ClearDeletedAt() {
  23173. m.deleted_at = nil
  23174. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  23175. }
  23176. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23177. func (m *WxCardMutation) DeletedAtCleared() bool {
  23178. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  23179. return ok
  23180. }
  23181. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23182. func (m *WxCardMutation) ResetDeletedAt() {
  23183. m.deleted_at = nil
  23184. delete(m.clearedFields, wxcard.FieldDeletedAt)
  23185. }
  23186. // SetUserID sets the "user_id" field.
  23187. func (m *WxCardMutation) SetUserID(u uint64) {
  23188. m.user_id = &u
  23189. m.adduser_id = nil
  23190. }
  23191. // UserID returns the value of the "user_id" field in the mutation.
  23192. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  23193. v := m.user_id
  23194. if v == nil {
  23195. return
  23196. }
  23197. return *v, true
  23198. }
  23199. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  23200. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23202. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  23203. if !m.op.Is(OpUpdateOne) {
  23204. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23205. }
  23206. if m.id == nil || m.oldValue == nil {
  23207. return v, errors.New("OldUserID requires an ID field in the mutation")
  23208. }
  23209. oldValue, err := m.oldValue(ctx)
  23210. if err != nil {
  23211. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23212. }
  23213. return oldValue.UserID, nil
  23214. }
  23215. // AddUserID adds u to the "user_id" field.
  23216. func (m *WxCardMutation) AddUserID(u int64) {
  23217. if m.adduser_id != nil {
  23218. *m.adduser_id += u
  23219. } else {
  23220. m.adduser_id = &u
  23221. }
  23222. }
  23223. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  23224. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  23225. v := m.adduser_id
  23226. if v == nil {
  23227. return
  23228. }
  23229. return *v, true
  23230. }
  23231. // ClearUserID clears the value of the "user_id" field.
  23232. func (m *WxCardMutation) ClearUserID() {
  23233. m.user_id = nil
  23234. m.adduser_id = nil
  23235. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  23236. }
  23237. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  23238. func (m *WxCardMutation) UserIDCleared() bool {
  23239. _, ok := m.clearedFields[wxcard.FieldUserID]
  23240. return ok
  23241. }
  23242. // ResetUserID resets all changes to the "user_id" field.
  23243. func (m *WxCardMutation) ResetUserID() {
  23244. m.user_id = nil
  23245. m.adduser_id = nil
  23246. delete(m.clearedFields, wxcard.FieldUserID)
  23247. }
  23248. // SetWxUserID sets the "wx_user_id" field.
  23249. func (m *WxCardMutation) SetWxUserID(u uint64) {
  23250. m.wx_user_id = &u
  23251. m.addwx_user_id = nil
  23252. }
  23253. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  23254. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  23255. v := m.wx_user_id
  23256. if v == nil {
  23257. return
  23258. }
  23259. return *v, true
  23260. }
  23261. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  23262. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23264. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  23265. if !m.op.Is(OpUpdateOne) {
  23266. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  23267. }
  23268. if m.id == nil || m.oldValue == nil {
  23269. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  23270. }
  23271. oldValue, err := m.oldValue(ctx)
  23272. if err != nil {
  23273. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  23274. }
  23275. return oldValue.WxUserID, nil
  23276. }
  23277. // AddWxUserID adds u to the "wx_user_id" field.
  23278. func (m *WxCardMutation) AddWxUserID(u int64) {
  23279. if m.addwx_user_id != nil {
  23280. *m.addwx_user_id += u
  23281. } else {
  23282. m.addwx_user_id = &u
  23283. }
  23284. }
  23285. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  23286. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  23287. v := m.addwx_user_id
  23288. if v == nil {
  23289. return
  23290. }
  23291. return *v, true
  23292. }
  23293. // ClearWxUserID clears the value of the "wx_user_id" field.
  23294. func (m *WxCardMutation) ClearWxUserID() {
  23295. m.wx_user_id = nil
  23296. m.addwx_user_id = nil
  23297. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  23298. }
  23299. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  23300. func (m *WxCardMutation) WxUserIDCleared() bool {
  23301. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  23302. return ok
  23303. }
  23304. // ResetWxUserID resets all changes to the "wx_user_id" field.
  23305. func (m *WxCardMutation) ResetWxUserID() {
  23306. m.wx_user_id = nil
  23307. m.addwx_user_id = nil
  23308. delete(m.clearedFields, wxcard.FieldWxUserID)
  23309. }
  23310. // SetAvatar sets the "avatar" field.
  23311. func (m *WxCardMutation) SetAvatar(s string) {
  23312. m.avatar = &s
  23313. }
  23314. // Avatar returns the value of the "avatar" field in the mutation.
  23315. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  23316. v := m.avatar
  23317. if v == nil {
  23318. return
  23319. }
  23320. return *v, true
  23321. }
  23322. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  23323. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23325. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  23326. if !m.op.Is(OpUpdateOne) {
  23327. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  23328. }
  23329. if m.id == nil || m.oldValue == nil {
  23330. return v, errors.New("OldAvatar requires an ID field in the mutation")
  23331. }
  23332. oldValue, err := m.oldValue(ctx)
  23333. if err != nil {
  23334. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  23335. }
  23336. return oldValue.Avatar, nil
  23337. }
  23338. // ResetAvatar resets all changes to the "avatar" field.
  23339. func (m *WxCardMutation) ResetAvatar() {
  23340. m.avatar = nil
  23341. }
  23342. // SetLogo sets the "logo" field.
  23343. func (m *WxCardMutation) SetLogo(s string) {
  23344. m.logo = &s
  23345. }
  23346. // Logo returns the value of the "logo" field in the mutation.
  23347. func (m *WxCardMutation) Logo() (r string, exists bool) {
  23348. v := m.logo
  23349. if v == nil {
  23350. return
  23351. }
  23352. return *v, true
  23353. }
  23354. // OldLogo returns the old "logo" field's value of the WxCard entity.
  23355. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23357. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  23358. if !m.op.Is(OpUpdateOne) {
  23359. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  23360. }
  23361. if m.id == nil || m.oldValue == nil {
  23362. return v, errors.New("OldLogo requires an ID field in the mutation")
  23363. }
  23364. oldValue, err := m.oldValue(ctx)
  23365. if err != nil {
  23366. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  23367. }
  23368. return oldValue.Logo, nil
  23369. }
  23370. // ResetLogo resets all changes to the "logo" field.
  23371. func (m *WxCardMutation) ResetLogo() {
  23372. m.logo = nil
  23373. }
  23374. // SetName sets the "name" field.
  23375. func (m *WxCardMutation) SetName(s string) {
  23376. m.name = &s
  23377. }
  23378. // Name returns the value of the "name" field in the mutation.
  23379. func (m *WxCardMutation) Name() (r string, exists bool) {
  23380. v := m.name
  23381. if v == nil {
  23382. return
  23383. }
  23384. return *v, true
  23385. }
  23386. // OldName returns the old "name" field's value of the WxCard entity.
  23387. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23389. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  23390. if !m.op.Is(OpUpdateOne) {
  23391. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23392. }
  23393. if m.id == nil || m.oldValue == nil {
  23394. return v, errors.New("OldName requires an ID field in the mutation")
  23395. }
  23396. oldValue, err := m.oldValue(ctx)
  23397. if err != nil {
  23398. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23399. }
  23400. return oldValue.Name, nil
  23401. }
  23402. // ResetName resets all changes to the "name" field.
  23403. func (m *WxCardMutation) ResetName() {
  23404. m.name = nil
  23405. }
  23406. // SetCompany sets the "company" field.
  23407. func (m *WxCardMutation) SetCompany(s string) {
  23408. m.company = &s
  23409. }
  23410. // Company returns the value of the "company" field in the mutation.
  23411. func (m *WxCardMutation) Company() (r string, exists bool) {
  23412. v := m.company
  23413. if v == nil {
  23414. return
  23415. }
  23416. return *v, true
  23417. }
  23418. // OldCompany returns the old "company" field's value of the WxCard entity.
  23419. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23421. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  23422. if !m.op.Is(OpUpdateOne) {
  23423. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  23424. }
  23425. if m.id == nil || m.oldValue == nil {
  23426. return v, errors.New("OldCompany requires an ID field in the mutation")
  23427. }
  23428. oldValue, err := m.oldValue(ctx)
  23429. if err != nil {
  23430. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  23431. }
  23432. return oldValue.Company, nil
  23433. }
  23434. // ResetCompany resets all changes to the "company" field.
  23435. func (m *WxCardMutation) ResetCompany() {
  23436. m.company = nil
  23437. }
  23438. // SetAddress sets the "address" field.
  23439. func (m *WxCardMutation) SetAddress(s string) {
  23440. m.address = &s
  23441. }
  23442. // Address returns the value of the "address" field in the mutation.
  23443. func (m *WxCardMutation) Address() (r string, exists bool) {
  23444. v := m.address
  23445. if v == nil {
  23446. return
  23447. }
  23448. return *v, true
  23449. }
  23450. // OldAddress returns the old "address" field's value of the WxCard entity.
  23451. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23453. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  23454. if !m.op.Is(OpUpdateOne) {
  23455. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  23456. }
  23457. if m.id == nil || m.oldValue == nil {
  23458. return v, errors.New("OldAddress requires an ID field in the mutation")
  23459. }
  23460. oldValue, err := m.oldValue(ctx)
  23461. if err != nil {
  23462. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  23463. }
  23464. return oldValue.Address, nil
  23465. }
  23466. // ResetAddress resets all changes to the "address" field.
  23467. func (m *WxCardMutation) ResetAddress() {
  23468. m.address = nil
  23469. }
  23470. // SetPhone sets the "phone" field.
  23471. func (m *WxCardMutation) SetPhone(s string) {
  23472. m.phone = &s
  23473. }
  23474. // Phone returns the value of the "phone" field in the mutation.
  23475. func (m *WxCardMutation) Phone() (r string, exists bool) {
  23476. v := m.phone
  23477. if v == nil {
  23478. return
  23479. }
  23480. return *v, true
  23481. }
  23482. // OldPhone returns the old "phone" field's value of the WxCard entity.
  23483. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23485. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  23486. if !m.op.Is(OpUpdateOne) {
  23487. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23488. }
  23489. if m.id == nil || m.oldValue == nil {
  23490. return v, errors.New("OldPhone requires an ID field in the mutation")
  23491. }
  23492. oldValue, err := m.oldValue(ctx)
  23493. if err != nil {
  23494. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23495. }
  23496. return oldValue.Phone, nil
  23497. }
  23498. // ResetPhone resets all changes to the "phone" field.
  23499. func (m *WxCardMutation) ResetPhone() {
  23500. m.phone = nil
  23501. }
  23502. // SetOfficialAccount sets the "official_account" field.
  23503. func (m *WxCardMutation) SetOfficialAccount(s string) {
  23504. m.official_account = &s
  23505. }
  23506. // OfficialAccount returns the value of the "official_account" field in the mutation.
  23507. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  23508. v := m.official_account
  23509. if v == nil {
  23510. return
  23511. }
  23512. return *v, true
  23513. }
  23514. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  23515. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23517. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  23518. if !m.op.Is(OpUpdateOne) {
  23519. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  23520. }
  23521. if m.id == nil || m.oldValue == nil {
  23522. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  23523. }
  23524. oldValue, err := m.oldValue(ctx)
  23525. if err != nil {
  23526. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  23527. }
  23528. return oldValue.OfficialAccount, nil
  23529. }
  23530. // ResetOfficialAccount resets all changes to the "official_account" field.
  23531. func (m *WxCardMutation) ResetOfficialAccount() {
  23532. m.official_account = nil
  23533. }
  23534. // SetWechatAccount sets the "wechat_account" field.
  23535. func (m *WxCardMutation) SetWechatAccount(s string) {
  23536. m.wechat_account = &s
  23537. }
  23538. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  23539. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  23540. v := m.wechat_account
  23541. if v == nil {
  23542. return
  23543. }
  23544. return *v, true
  23545. }
  23546. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  23547. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23549. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  23550. if !m.op.Is(OpUpdateOne) {
  23551. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  23552. }
  23553. if m.id == nil || m.oldValue == nil {
  23554. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  23555. }
  23556. oldValue, err := m.oldValue(ctx)
  23557. if err != nil {
  23558. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  23559. }
  23560. return oldValue.WechatAccount, nil
  23561. }
  23562. // ResetWechatAccount resets all changes to the "wechat_account" field.
  23563. func (m *WxCardMutation) ResetWechatAccount() {
  23564. m.wechat_account = nil
  23565. }
  23566. // SetEmail sets the "email" field.
  23567. func (m *WxCardMutation) SetEmail(s string) {
  23568. m.email = &s
  23569. }
  23570. // Email returns the value of the "email" field in the mutation.
  23571. func (m *WxCardMutation) Email() (r string, exists bool) {
  23572. v := m.email
  23573. if v == nil {
  23574. return
  23575. }
  23576. return *v, true
  23577. }
  23578. // OldEmail returns the old "email" field's value of the WxCard entity.
  23579. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23581. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  23582. if !m.op.Is(OpUpdateOne) {
  23583. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  23584. }
  23585. if m.id == nil || m.oldValue == nil {
  23586. return v, errors.New("OldEmail requires an ID field in the mutation")
  23587. }
  23588. oldValue, err := m.oldValue(ctx)
  23589. if err != nil {
  23590. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  23591. }
  23592. return oldValue.Email, nil
  23593. }
  23594. // ClearEmail clears the value of the "email" field.
  23595. func (m *WxCardMutation) ClearEmail() {
  23596. m.email = nil
  23597. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  23598. }
  23599. // EmailCleared returns if the "email" field was cleared in this mutation.
  23600. func (m *WxCardMutation) EmailCleared() bool {
  23601. _, ok := m.clearedFields[wxcard.FieldEmail]
  23602. return ok
  23603. }
  23604. // ResetEmail resets all changes to the "email" field.
  23605. func (m *WxCardMutation) ResetEmail() {
  23606. m.email = nil
  23607. delete(m.clearedFields, wxcard.FieldEmail)
  23608. }
  23609. // SetAPIBase sets the "api_base" field.
  23610. func (m *WxCardMutation) SetAPIBase(s string) {
  23611. m.api_base = &s
  23612. }
  23613. // APIBase returns the value of the "api_base" field in the mutation.
  23614. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  23615. v := m.api_base
  23616. if v == nil {
  23617. return
  23618. }
  23619. return *v, true
  23620. }
  23621. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  23622. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23624. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23625. if !m.op.Is(OpUpdateOne) {
  23626. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23627. }
  23628. if m.id == nil || m.oldValue == nil {
  23629. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23630. }
  23631. oldValue, err := m.oldValue(ctx)
  23632. if err != nil {
  23633. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23634. }
  23635. return oldValue.APIBase, nil
  23636. }
  23637. // ClearAPIBase clears the value of the "api_base" field.
  23638. func (m *WxCardMutation) ClearAPIBase() {
  23639. m.api_base = nil
  23640. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  23641. }
  23642. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23643. func (m *WxCardMutation) APIBaseCleared() bool {
  23644. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  23645. return ok
  23646. }
  23647. // ResetAPIBase resets all changes to the "api_base" field.
  23648. func (m *WxCardMutation) ResetAPIBase() {
  23649. m.api_base = nil
  23650. delete(m.clearedFields, wxcard.FieldAPIBase)
  23651. }
  23652. // SetAPIKey sets the "api_key" field.
  23653. func (m *WxCardMutation) SetAPIKey(s string) {
  23654. m.api_key = &s
  23655. }
  23656. // APIKey returns the value of the "api_key" field in the mutation.
  23657. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  23658. v := m.api_key
  23659. if v == nil {
  23660. return
  23661. }
  23662. return *v, true
  23663. }
  23664. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  23665. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23667. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23668. if !m.op.Is(OpUpdateOne) {
  23669. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23670. }
  23671. if m.id == nil || m.oldValue == nil {
  23672. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23673. }
  23674. oldValue, err := m.oldValue(ctx)
  23675. if err != nil {
  23676. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23677. }
  23678. return oldValue.APIKey, nil
  23679. }
  23680. // ClearAPIKey clears the value of the "api_key" field.
  23681. func (m *WxCardMutation) ClearAPIKey() {
  23682. m.api_key = nil
  23683. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  23684. }
  23685. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23686. func (m *WxCardMutation) APIKeyCleared() bool {
  23687. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  23688. return ok
  23689. }
  23690. // ResetAPIKey resets all changes to the "api_key" field.
  23691. func (m *WxCardMutation) ResetAPIKey() {
  23692. m.api_key = nil
  23693. delete(m.clearedFields, wxcard.FieldAPIKey)
  23694. }
  23695. // SetAiInfo sets the "ai_info" field.
  23696. func (m *WxCardMutation) SetAiInfo(s string) {
  23697. m.ai_info = &s
  23698. }
  23699. // AiInfo returns the value of the "ai_info" field in the mutation.
  23700. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  23701. v := m.ai_info
  23702. if v == nil {
  23703. return
  23704. }
  23705. return *v, true
  23706. }
  23707. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  23708. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23710. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  23711. if !m.op.Is(OpUpdateOne) {
  23712. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  23713. }
  23714. if m.id == nil || m.oldValue == nil {
  23715. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  23716. }
  23717. oldValue, err := m.oldValue(ctx)
  23718. if err != nil {
  23719. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  23720. }
  23721. return oldValue.AiInfo, nil
  23722. }
  23723. // ClearAiInfo clears the value of the "ai_info" field.
  23724. func (m *WxCardMutation) ClearAiInfo() {
  23725. m.ai_info = nil
  23726. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  23727. }
  23728. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  23729. func (m *WxCardMutation) AiInfoCleared() bool {
  23730. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  23731. return ok
  23732. }
  23733. // ResetAiInfo resets all changes to the "ai_info" field.
  23734. func (m *WxCardMutation) ResetAiInfo() {
  23735. m.ai_info = nil
  23736. delete(m.clearedFields, wxcard.FieldAiInfo)
  23737. }
  23738. // SetIntro sets the "intro" field.
  23739. func (m *WxCardMutation) SetIntro(s string) {
  23740. m.intro = &s
  23741. }
  23742. // Intro returns the value of the "intro" field in the mutation.
  23743. func (m *WxCardMutation) Intro() (r string, exists bool) {
  23744. v := m.intro
  23745. if v == nil {
  23746. return
  23747. }
  23748. return *v, true
  23749. }
  23750. // OldIntro returns the old "intro" field's value of the WxCard entity.
  23751. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  23752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23753. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  23754. if !m.op.Is(OpUpdateOne) {
  23755. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  23756. }
  23757. if m.id == nil || m.oldValue == nil {
  23758. return v, errors.New("OldIntro requires an ID field in the mutation")
  23759. }
  23760. oldValue, err := m.oldValue(ctx)
  23761. if err != nil {
  23762. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  23763. }
  23764. return oldValue.Intro, nil
  23765. }
  23766. // ClearIntro clears the value of the "intro" field.
  23767. func (m *WxCardMutation) ClearIntro() {
  23768. m.intro = nil
  23769. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  23770. }
  23771. // IntroCleared returns if the "intro" field was cleared in this mutation.
  23772. func (m *WxCardMutation) IntroCleared() bool {
  23773. _, ok := m.clearedFields[wxcard.FieldIntro]
  23774. return ok
  23775. }
  23776. // ResetIntro resets all changes to the "intro" field.
  23777. func (m *WxCardMutation) ResetIntro() {
  23778. m.intro = nil
  23779. delete(m.clearedFields, wxcard.FieldIntro)
  23780. }
  23781. // Where appends a list predicates to the WxCardMutation builder.
  23782. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  23783. m.predicates = append(m.predicates, ps...)
  23784. }
  23785. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  23786. // users can use type-assertion to append predicates that do not depend on any generated package.
  23787. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  23788. p := make([]predicate.WxCard, len(ps))
  23789. for i := range ps {
  23790. p[i] = ps[i]
  23791. }
  23792. m.Where(p...)
  23793. }
  23794. // Op returns the operation name.
  23795. func (m *WxCardMutation) Op() Op {
  23796. return m.op
  23797. }
  23798. // SetOp allows setting the mutation operation.
  23799. func (m *WxCardMutation) SetOp(op Op) {
  23800. m.op = op
  23801. }
  23802. // Type returns the node type of this mutation (WxCard).
  23803. func (m *WxCardMutation) Type() string {
  23804. return m.typ
  23805. }
  23806. // Fields returns all fields that were changed during this mutation. Note that in
  23807. // order to get all numeric fields that were incremented/decremented, call
  23808. // AddedFields().
  23809. func (m *WxCardMutation) Fields() []string {
  23810. fields := make([]string, 0, 18)
  23811. if m.created_at != nil {
  23812. fields = append(fields, wxcard.FieldCreatedAt)
  23813. }
  23814. if m.updated_at != nil {
  23815. fields = append(fields, wxcard.FieldUpdatedAt)
  23816. }
  23817. if m.deleted_at != nil {
  23818. fields = append(fields, wxcard.FieldDeletedAt)
  23819. }
  23820. if m.user_id != nil {
  23821. fields = append(fields, wxcard.FieldUserID)
  23822. }
  23823. if m.wx_user_id != nil {
  23824. fields = append(fields, wxcard.FieldWxUserID)
  23825. }
  23826. if m.avatar != nil {
  23827. fields = append(fields, wxcard.FieldAvatar)
  23828. }
  23829. if m.logo != nil {
  23830. fields = append(fields, wxcard.FieldLogo)
  23831. }
  23832. if m.name != nil {
  23833. fields = append(fields, wxcard.FieldName)
  23834. }
  23835. if m.company != nil {
  23836. fields = append(fields, wxcard.FieldCompany)
  23837. }
  23838. if m.address != nil {
  23839. fields = append(fields, wxcard.FieldAddress)
  23840. }
  23841. if m.phone != nil {
  23842. fields = append(fields, wxcard.FieldPhone)
  23843. }
  23844. if m.official_account != nil {
  23845. fields = append(fields, wxcard.FieldOfficialAccount)
  23846. }
  23847. if m.wechat_account != nil {
  23848. fields = append(fields, wxcard.FieldWechatAccount)
  23849. }
  23850. if m.email != nil {
  23851. fields = append(fields, wxcard.FieldEmail)
  23852. }
  23853. if m.api_base != nil {
  23854. fields = append(fields, wxcard.FieldAPIBase)
  23855. }
  23856. if m.api_key != nil {
  23857. fields = append(fields, wxcard.FieldAPIKey)
  23858. }
  23859. if m.ai_info != nil {
  23860. fields = append(fields, wxcard.FieldAiInfo)
  23861. }
  23862. if m.intro != nil {
  23863. fields = append(fields, wxcard.FieldIntro)
  23864. }
  23865. return fields
  23866. }
  23867. // Field returns the value of a field with the given name. The second boolean
  23868. // return value indicates that this field was not set, or was not defined in the
  23869. // schema.
  23870. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  23871. switch name {
  23872. case wxcard.FieldCreatedAt:
  23873. return m.CreatedAt()
  23874. case wxcard.FieldUpdatedAt:
  23875. return m.UpdatedAt()
  23876. case wxcard.FieldDeletedAt:
  23877. return m.DeletedAt()
  23878. case wxcard.FieldUserID:
  23879. return m.UserID()
  23880. case wxcard.FieldWxUserID:
  23881. return m.WxUserID()
  23882. case wxcard.FieldAvatar:
  23883. return m.Avatar()
  23884. case wxcard.FieldLogo:
  23885. return m.Logo()
  23886. case wxcard.FieldName:
  23887. return m.Name()
  23888. case wxcard.FieldCompany:
  23889. return m.Company()
  23890. case wxcard.FieldAddress:
  23891. return m.Address()
  23892. case wxcard.FieldPhone:
  23893. return m.Phone()
  23894. case wxcard.FieldOfficialAccount:
  23895. return m.OfficialAccount()
  23896. case wxcard.FieldWechatAccount:
  23897. return m.WechatAccount()
  23898. case wxcard.FieldEmail:
  23899. return m.Email()
  23900. case wxcard.FieldAPIBase:
  23901. return m.APIBase()
  23902. case wxcard.FieldAPIKey:
  23903. return m.APIKey()
  23904. case wxcard.FieldAiInfo:
  23905. return m.AiInfo()
  23906. case wxcard.FieldIntro:
  23907. return m.Intro()
  23908. }
  23909. return nil, false
  23910. }
  23911. // OldField returns the old value of the field from the database. An error is
  23912. // returned if the mutation operation is not UpdateOne, or the query to the
  23913. // database failed.
  23914. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23915. switch name {
  23916. case wxcard.FieldCreatedAt:
  23917. return m.OldCreatedAt(ctx)
  23918. case wxcard.FieldUpdatedAt:
  23919. return m.OldUpdatedAt(ctx)
  23920. case wxcard.FieldDeletedAt:
  23921. return m.OldDeletedAt(ctx)
  23922. case wxcard.FieldUserID:
  23923. return m.OldUserID(ctx)
  23924. case wxcard.FieldWxUserID:
  23925. return m.OldWxUserID(ctx)
  23926. case wxcard.FieldAvatar:
  23927. return m.OldAvatar(ctx)
  23928. case wxcard.FieldLogo:
  23929. return m.OldLogo(ctx)
  23930. case wxcard.FieldName:
  23931. return m.OldName(ctx)
  23932. case wxcard.FieldCompany:
  23933. return m.OldCompany(ctx)
  23934. case wxcard.FieldAddress:
  23935. return m.OldAddress(ctx)
  23936. case wxcard.FieldPhone:
  23937. return m.OldPhone(ctx)
  23938. case wxcard.FieldOfficialAccount:
  23939. return m.OldOfficialAccount(ctx)
  23940. case wxcard.FieldWechatAccount:
  23941. return m.OldWechatAccount(ctx)
  23942. case wxcard.FieldEmail:
  23943. return m.OldEmail(ctx)
  23944. case wxcard.FieldAPIBase:
  23945. return m.OldAPIBase(ctx)
  23946. case wxcard.FieldAPIKey:
  23947. return m.OldAPIKey(ctx)
  23948. case wxcard.FieldAiInfo:
  23949. return m.OldAiInfo(ctx)
  23950. case wxcard.FieldIntro:
  23951. return m.OldIntro(ctx)
  23952. }
  23953. return nil, fmt.Errorf("unknown WxCard field %s", name)
  23954. }
  23955. // SetField sets the value of a field with the given name. It returns an error if
  23956. // the field is not defined in the schema, or if the type mismatched the field
  23957. // type.
  23958. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  23959. switch name {
  23960. case wxcard.FieldCreatedAt:
  23961. v, ok := value.(time.Time)
  23962. if !ok {
  23963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23964. }
  23965. m.SetCreatedAt(v)
  23966. return nil
  23967. case wxcard.FieldUpdatedAt:
  23968. v, ok := value.(time.Time)
  23969. if !ok {
  23970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23971. }
  23972. m.SetUpdatedAt(v)
  23973. return nil
  23974. case wxcard.FieldDeletedAt:
  23975. v, ok := value.(time.Time)
  23976. if !ok {
  23977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23978. }
  23979. m.SetDeletedAt(v)
  23980. return nil
  23981. case wxcard.FieldUserID:
  23982. v, ok := value.(uint64)
  23983. if !ok {
  23984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23985. }
  23986. m.SetUserID(v)
  23987. return nil
  23988. case wxcard.FieldWxUserID:
  23989. v, ok := value.(uint64)
  23990. if !ok {
  23991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23992. }
  23993. m.SetWxUserID(v)
  23994. return nil
  23995. case wxcard.FieldAvatar:
  23996. v, ok := value.(string)
  23997. if !ok {
  23998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23999. }
  24000. m.SetAvatar(v)
  24001. return nil
  24002. case wxcard.FieldLogo:
  24003. v, ok := value.(string)
  24004. if !ok {
  24005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24006. }
  24007. m.SetLogo(v)
  24008. return nil
  24009. case wxcard.FieldName:
  24010. v, ok := value.(string)
  24011. if !ok {
  24012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24013. }
  24014. m.SetName(v)
  24015. return nil
  24016. case wxcard.FieldCompany:
  24017. v, ok := value.(string)
  24018. if !ok {
  24019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24020. }
  24021. m.SetCompany(v)
  24022. return nil
  24023. case wxcard.FieldAddress:
  24024. v, ok := value.(string)
  24025. if !ok {
  24026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24027. }
  24028. m.SetAddress(v)
  24029. return nil
  24030. case wxcard.FieldPhone:
  24031. v, ok := value.(string)
  24032. if !ok {
  24033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24034. }
  24035. m.SetPhone(v)
  24036. return nil
  24037. case wxcard.FieldOfficialAccount:
  24038. v, ok := value.(string)
  24039. if !ok {
  24040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24041. }
  24042. m.SetOfficialAccount(v)
  24043. return nil
  24044. case wxcard.FieldWechatAccount:
  24045. v, ok := value.(string)
  24046. if !ok {
  24047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24048. }
  24049. m.SetWechatAccount(v)
  24050. return nil
  24051. case wxcard.FieldEmail:
  24052. v, ok := value.(string)
  24053. if !ok {
  24054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24055. }
  24056. m.SetEmail(v)
  24057. return nil
  24058. case wxcard.FieldAPIBase:
  24059. v, ok := value.(string)
  24060. if !ok {
  24061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24062. }
  24063. m.SetAPIBase(v)
  24064. return nil
  24065. case wxcard.FieldAPIKey:
  24066. v, ok := value.(string)
  24067. if !ok {
  24068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24069. }
  24070. m.SetAPIKey(v)
  24071. return nil
  24072. case wxcard.FieldAiInfo:
  24073. v, ok := value.(string)
  24074. if !ok {
  24075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24076. }
  24077. m.SetAiInfo(v)
  24078. return nil
  24079. case wxcard.FieldIntro:
  24080. v, ok := value.(string)
  24081. if !ok {
  24082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24083. }
  24084. m.SetIntro(v)
  24085. return nil
  24086. }
  24087. return fmt.Errorf("unknown WxCard field %s", name)
  24088. }
  24089. // AddedFields returns all numeric fields that were incremented/decremented during
  24090. // this mutation.
  24091. func (m *WxCardMutation) AddedFields() []string {
  24092. var fields []string
  24093. if m.adduser_id != nil {
  24094. fields = append(fields, wxcard.FieldUserID)
  24095. }
  24096. if m.addwx_user_id != nil {
  24097. fields = append(fields, wxcard.FieldWxUserID)
  24098. }
  24099. return fields
  24100. }
  24101. // AddedField returns the numeric value that was incremented/decremented on a field
  24102. // with the given name. The second boolean return value indicates that this field
  24103. // was not set, or was not defined in the schema.
  24104. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  24105. switch name {
  24106. case wxcard.FieldUserID:
  24107. return m.AddedUserID()
  24108. case wxcard.FieldWxUserID:
  24109. return m.AddedWxUserID()
  24110. }
  24111. return nil, false
  24112. }
  24113. // AddField adds the value to the field with the given name. It returns an error if
  24114. // the field is not defined in the schema, or if the type mismatched the field
  24115. // type.
  24116. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  24117. switch name {
  24118. case wxcard.FieldUserID:
  24119. v, ok := value.(int64)
  24120. if !ok {
  24121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24122. }
  24123. m.AddUserID(v)
  24124. return nil
  24125. case wxcard.FieldWxUserID:
  24126. v, ok := value.(int64)
  24127. if !ok {
  24128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24129. }
  24130. m.AddWxUserID(v)
  24131. return nil
  24132. }
  24133. return fmt.Errorf("unknown WxCard numeric field %s", name)
  24134. }
  24135. // ClearedFields returns all nullable fields that were cleared during this
  24136. // mutation.
  24137. func (m *WxCardMutation) ClearedFields() []string {
  24138. var fields []string
  24139. if m.FieldCleared(wxcard.FieldDeletedAt) {
  24140. fields = append(fields, wxcard.FieldDeletedAt)
  24141. }
  24142. if m.FieldCleared(wxcard.FieldUserID) {
  24143. fields = append(fields, wxcard.FieldUserID)
  24144. }
  24145. if m.FieldCleared(wxcard.FieldWxUserID) {
  24146. fields = append(fields, wxcard.FieldWxUserID)
  24147. }
  24148. if m.FieldCleared(wxcard.FieldEmail) {
  24149. fields = append(fields, wxcard.FieldEmail)
  24150. }
  24151. if m.FieldCleared(wxcard.FieldAPIBase) {
  24152. fields = append(fields, wxcard.FieldAPIBase)
  24153. }
  24154. if m.FieldCleared(wxcard.FieldAPIKey) {
  24155. fields = append(fields, wxcard.FieldAPIKey)
  24156. }
  24157. if m.FieldCleared(wxcard.FieldAiInfo) {
  24158. fields = append(fields, wxcard.FieldAiInfo)
  24159. }
  24160. if m.FieldCleared(wxcard.FieldIntro) {
  24161. fields = append(fields, wxcard.FieldIntro)
  24162. }
  24163. return fields
  24164. }
  24165. // FieldCleared returns a boolean indicating if a field with the given name was
  24166. // cleared in this mutation.
  24167. func (m *WxCardMutation) FieldCleared(name string) bool {
  24168. _, ok := m.clearedFields[name]
  24169. return ok
  24170. }
  24171. // ClearField clears the value of the field with the given name. It returns an
  24172. // error if the field is not defined in the schema.
  24173. func (m *WxCardMutation) ClearField(name string) error {
  24174. switch name {
  24175. case wxcard.FieldDeletedAt:
  24176. m.ClearDeletedAt()
  24177. return nil
  24178. case wxcard.FieldUserID:
  24179. m.ClearUserID()
  24180. return nil
  24181. case wxcard.FieldWxUserID:
  24182. m.ClearWxUserID()
  24183. return nil
  24184. case wxcard.FieldEmail:
  24185. m.ClearEmail()
  24186. return nil
  24187. case wxcard.FieldAPIBase:
  24188. m.ClearAPIBase()
  24189. return nil
  24190. case wxcard.FieldAPIKey:
  24191. m.ClearAPIKey()
  24192. return nil
  24193. case wxcard.FieldAiInfo:
  24194. m.ClearAiInfo()
  24195. return nil
  24196. case wxcard.FieldIntro:
  24197. m.ClearIntro()
  24198. return nil
  24199. }
  24200. return fmt.Errorf("unknown WxCard nullable field %s", name)
  24201. }
  24202. // ResetField resets all changes in the mutation for the field with the given name.
  24203. // It returns an error if the field is not defined in the schema.
  24204. func (m *WxCardMutation) ResetField(name string) error {
  24205. switch name {
  24206. case wxcard.FieldCreatedAt:
  24207. m.ResetCreatedAt()
  24208. return nil
  24209. case wxcard.FieldUpdatedAt:
  24210. m.ResetUpdatedAt()
  24211. return nil
  24212. case wxcard.FieldDeletedAt:
  24213. m.ResetDeletedAt()
  24214. return nil
  24215. case wxcard.FieldUserID:
  24216. m.ResetUserID()
  24217. return nil
  24218. case wxcard.FieldWxUserID:
  24219. m.ResetWxUserID()
  24220. return nil
  24221. case wxcard.FieldAvatar:
  24222. m.ResetAvatar()
  24223. return nil
  24224. case wxcard.FieldLogo:
  24225. m.ResetLogo()
  24226. return nil
  24227. case wxcard.FieldName:
  24228. m.ResetName()
  24229. return nil
  24230. case wxcard.FieldCompany:
  24231. m.ResetCompany()
  24232. return nil
  24233. case wxcard.FieldAddress:
  24234. m.ResetAddress()
  24235. return nil
  24236. case wxcard.FieldPhone:
  24237. m.ResetPhone()
  24238. return nil
  24239. case wxcard.FieldOfficialAccount:
  24240. m.ResetOfficialAccount()
  24241. return nil
  24242. case wxcard.FieldWechatAccount:
  24243. m.ResetWechatAccount()
  24244. return nil
  24245. case wxcard.FieldEmail:
  24246. m.ResetEmail()
  24247. return nil
  24248. case wxcard.FieldAPIBase:
  24249. m.ResetAPIBase()
  24250. return nil
  24251. case wxcard.FieldAPIKey:
  24252. m.ResetAPIKey()
  24253. return nil
  24254. case wxcard.FieldAiInfo:
  24255. m.ResetAiInfo()
  24256. return nil
  24257. case wxcard.FieldIntro:
  24258. m.ResetIntro()
  24259. return nil
  24260. }
  24261. return fmt.Errorf("unknown WxCard field %s", name)
  24262. }
  24263. // AddedEdges returns all edge names that were set/added in this mutation.
  24264. func (m *WxCardMutation) AddedEdges() []string {
  24265. edges := make([]string, 0, 0)
  24266. return edges
  24267. }
  24268. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24269. // name in this mutation.
  24270. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  24271. return nil
  24272. }
  24273. // RemovedEdges returns all edge names that were removed in this mutation.
  24274. func (m *WxCardMutation) RemovedEdges() []string {
  24275. edges := make([]string, 0, 0)
  24276. return edges
  24277. }
  24278. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24279. // the given name in this mutation.
  24280. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  24281. return nil
  24282. }
  24283. // ClearedEdges returns all edge names that were cleared in this mutation.
  24284. func (m *WxCardMutation) ClearedEdges() []string {
  24285. edges := make([]string, 0, 0)
  24286. return edges
  24287. }
  24288. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24289. // was cleared in this mutation.
  24290. func (m *WxCardMutation) EdgeCleared(name string) bool {
  24291. return false
  24292. }
  24293. // ClearEdge clears the value of the edge with the given name. It returns an error
  24294. // if that edge is not defined in the schema.
  24295. func (m *WxCardMutation) ClearEdge(name string) error {
  24296. return fmt.Errorf("unknown WxCard unique edge %s", name)
  24297. }
  24298. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24299. // It returns an error if the edge is not defined in the schema.
  24300. func (m *WxCardMutation) ResetEdge(name string) error {
  24301. return fmt.Errorf("unknown WxCard edge %s", name)
  24302. }
  24303. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  24304. type WxCardUserMutation struct {
  24305. config
  24306. op Op
  24307. typ string
  24308. id *uint64
  24309. created_at *time.Time
  24310. updated_at *time.Time
  24311. deleted_at *time.Time
  24312. wxid *string
  24313. account *string
  24314. avatar *string
  24315. nickname *string
  24316. remark *string
  24317. phone *string
  24318. open_id *string
  24319. union_id *string
  24320. session_key *string
  24321. clearedFields map[string]struct{}
  24322. done bool
  24323. oldValue func(context.Context) (*WxCardUser, error)
  24324. predicates []predicate.WxCardUser
  24325. }
  24326. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  24327. // wxcarduserOption allows management of the mutation configuration using functional options.
  24328. type wxcarduserOption func(*WxCardUserMutation)
  24329. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  24330. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  24331. m := &WxCardUserMutation{
  24332. config: c,
  24333. op: op,
  24334. typ: TypeWxCardUser,
  24335. clearedFields: make(map[string]struct{}),
  24336. }
  24337. for _, opt := range opts {
  24338. opt(m)
  24339. }
  24340. return m
  24341. }
  24342. // withWxCardUserID sets the ID field of the mutation.
  24343. func withWxCardUserID(id uint64) wxcarduserOption {
  24344. return func(m *WxCardUserMutation) {
  24345. var (
  24346. err error
  24347. once sync.Once
  24348. value *WxCardUser
  24349. )
  24350. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  24351. once.Do(func() {
  24352. if m.done {
  24353. err = errors.New("querying old values post mutation is not allowed")
  24354. } else {
  24355. value, err = m.Client().WxCardUser.Get(ctx, id)
  24356. }
  24357. })
  24358. return value, err
  24359. }
  24360. m.id = &id
  24361. }
  24362. }
  24363. // withWxCardUser sets the old WxCardUser of the mutation.
  24364. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  24365. return func(m *WxCardUserMutation) {
  24366. m.oldValue = func(context.Context) (*WxCardUser, error) {
  24367. return node, nil
  24368. }
  24369. m.id = &node.ID
  24370. }
  24371. }
  24372. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24373. // executed in a transaction (ent.Tx), a transactional client is returned.
  24374. func (m WxCardUserMutation) Client() *Client {
  24375. client := &Client{config: m.config}
  24376. client.init()
  24377. return client
  24378. }
  24379. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24380. // it returns an error otherwise.
  24381. func (m WxCardUserMutation) Tx() (*Tx, error) {
  24382. if _, ok := m.driver.(*txDriver); !ok {
  24383. return nil, errors.New("ent: mutation is not running in a transaction")
  24384. }
  24385. tx := &Tx{config: m.config}
  24386. tx.init()
  24387. return tx, nil
  24388. }
  24389. // SetID sets the value of the id field. Note that this
  24390. // operation is only accepted on creation of WxCardUser entities.
  24391. func (m *WxCardUserMutation) SetID(id uint64) {
  24392. m.id = &id
  24393. }
  24394. // ID returns the ID value in the mutation. Note that the ID is only available
  24395. // if it was provided to the builder or after it was returned from the database.
  24396. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  24397. if m.id == nil {
  24398. return
  24399. }
  24400. return *m.id, true
  24401. }
  24402. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24403. // That means, if the mutation is applied within a transaction with an isolation level such
  24404. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24405. // or updated by the mutation.
  24406. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  24407. switch {
  24408. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24409. id, exists := m.ID()
  24410. if exists {
  24411. return []uint64{id}, nil
  24412. }
  24413. fallthrough
  24414. case m.op.Is(OpUpdate | OpDelete):
  24415. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  24416. default:
  24417. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24418. }
  24419. }
  24420. // SetCreatedAt sets the "created_at" field.
  24421. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  24422. m.created_at = &t
  24423. }
  24424. // CreatedAt returns the value of the "created_at" field in the mutation.
  24425. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  24426. v := m.created_at
  24427. if v == nil {
  24428. return
  24429. }
  24430. return *v, true
  24431. }
  24432. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  24433. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24435. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24436. if !m.op.Is(OpUpdateOne) {
  24437. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24438. }
  24439. if m.id == nil || m.oldValue == nil {
  24440. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24441. }
  24442. oldValue, err := m.oldValue(ctx)
  24443. if err != nil {
  24444. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24445. }
  24446. return oldValue.CreatedAt, nil
  24447. }
  24448. // ResetCreatedAt resets all changes to the "created_at" field.
  24449. func (m *WxCardUserMutation) ResetCreatedAt() {
  24450. m.created_at = nil
  24451. }
  24452. // SetUpdatedAt sets the "updated_at" field.
  24453. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  24454. m.updated_at = &t
  24455. }
  24456. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24457. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  24458. v := m.updated_at
  24459. if v == nil {
  24460. return
  24461. }
  24462. return *v, true
  24463. }
  24464. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  24465. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24467. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24468. if !m.op.Is(OpUpdateOne) {
  24469. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24470. }
  24471. if m.id == nil || m.oldValue == nil {
  24472. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24473. }
  24474. oldValue, err := m.oldValue(ctx)
  24475. if err != nil {
  24476. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24477. }
  24478. return oldValue.UpdatedAt, nil
  24479. }
  24480. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24481. func (m *WxCardUserMutation) ResetUpdatedAt() {
  24482. m.updated_at = nil
  24483. }
  24484. // SetDeletedAt sets the "deleted_at" field.
  24485. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  24486. m.deleted_at = &t
  24487. }
  24488. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24489. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  24490. v := m.deleted_at
  24491. if v == nil {
  24492. return
  24493. }
  24494. return *v, true
  24495. }
  24496. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  24497. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24499. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24500. if !m.op.Is(OpUpdateOne) {
  24501. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24502. }
  24503. if m.id == nil || m.oldValue == nil {
  24504. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24505. }
  24506. oldValue, err := m.oldValue(ctx)
  24507. if err != nil {
  24508. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24509. }
  24510. return oldValue.DeletedAt, nil
  24511. }
  24512. // ClearDeletedAt clears the value of the "deleted_at" field.
  24513. func (m *WxCardUserMutation) ClearDeletedAt() {
  24514. m.deleted_at = nil
  24515. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  24516. }
  24517. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24518. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  24519. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  24520. return ok
  24521. }
  24522. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24523. func (m *WxCardUserMutation) ResetDeletedAt() {
  24524. m.deleted_at = nil
  24525. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  24526. }
  24527. // SetWxid sets the "wxid" field.
  24528. func (m *WxCardUserMutation) SetWxid(s string) {
  24529. m.wxid = &s
  24530. }
  24531. // Wxid returns the value of the "wxid" field in the mutation.
  24532. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  24533. v := m.wxid
  24534. if v == nil {
  24535. return
  24536. }
  24537. return *v, true
  24538. }
  24539. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  24540. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24542. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  24543. if !m.op.Is(OpUpdateOne) {
  24544. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  24545. }
  24546. if m.id == nil || m.oldValue == nil {
  24547. return v, errors.New("OldWxid requires an ID field in the mutation")
  24548. }
  24549. oldValue, err := m.oldValue(ctx)
  24550. if err != nil {
  24551. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  24552. }
  24553. return oldValue.Wxid, nil
  24554. }
  24555. // ResetWxid resets all changes to the "wxid" field.
  24556. func (m *WxCardUserMutation) ResetWxid() {
  24557. m.wxid = nil
  24558. }
  24559. // SetAccount sets the "account" field.
  24560. func (m *WxCardUserMutation) SetAccount(s string) {
  24561. m.account = &s
  24562. }
  24563. // Account returns the value of the "account" field in the mutation.
  24564. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  24565. v := m.account
  24566. if v == nil {
  24567. return
  24568. }
  24569. return *v, true
  24570. }
  24571. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  24572. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24574. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  24575. if !m.op.Is(OpUpdateOne) {
  24576. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  24577. }
  24578. if m.id == nil || m.oldValue == nil {
  24579. return v, errors.New("OldAccount requires an ID field in the mutation")
  24580. }
  24581. oldValue, err := m.oldValue(ctx)
  24582. if err != nil {
  24583. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  24584. }
  24585. return oldValue.Account, nil
  24586. }
  24587. // ResetAccount resets all changes to the "account" field.
  24588. func (m *WxCardUserMutation) ResetAccount() {
  24589. m.account = nil
  24590. }
  24591. // SetAvatar sets the "avatar" field.
  24592. func (m *WxCardUserMutation) SetAvatar(s string) {
  24593. m.avatar = &s
  24594. }
  24595. // Avatar returns the value of the "avatar" field in the mutation.
  24596. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  24597. v := m.avatar
  24598. if v == nil {
  24599. return
  24600. }
  24601. return *v, true
  24602. }
  24603. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  24604. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24606. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24607. if !m.op.Is(OpUpdateOne) {
  24608. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24609. }
  24610. if m.id == nil || m.oldValue == nil {
  24611. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24612. }
  24613. oldValue, err := m.oldValue(ctx)
  24614. if err != nil {
  24615. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24616. }
  24617. return oldValue.Avatar, nil
  24618. }
  24619. // ResetAvatar resets all changes to the "avatar" field.
  24620. func (m *WxCardUserMutation) ResetAvatar() {
  24621. m.avatar = nil
  24622. }
  24623. // SetNickname sets the "nickname" field.
  24624. func (m *WxCardUserMutation) SetNickname(s string) {
  24625. m.nickname = &s
  24626. }
  24627. // Nickname returns the value of the "nickname" field in the mutation.
  24628. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  24629. v := m.nickname
  24630. if v == nil {
  24631. return
  24632. }
  24633. return *v, true
  24634. }
  24635. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  24636. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24638. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  24639. if !m.op.Is(OpUpdateOne) {
  24640. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  24641. }
  24642. if m.id == nil || m.oldValue == nil {
  24643. return v, errors.New("OldNickname requires an ID field in the mutation")
  24644. }
  24645. oldValue, err := m.oldValue(ctx)
  24646. if err != nil {
  24647. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  24648. }
  24649. return oldValue.Nickname, nil
  24650. }
  24651. // ResetNickname resets all changes to the "nickname" field.
  24652. func (m *WxCardUserMutation) ResetNickname() {
  24653. m.nickname = nil
  24654. }
  24655. // SetRemark sets the "remark" field.
  24656. func (m *WxCardUserMutation) SetRemark(s string) {
  24657. m.remark = &s
  24658. }
  24659. // Remark returns the value of the "remark" field in the mutation.
  24660. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  24661. v := m.remark
  24662. if v == nil {
  24663. return
  24664. }
  24665. return *v, true
  24666. }
  24667. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  24668. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24670. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  24671. if !m.op.Is(OpUpdateOne) {
  24672. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  24673. }
  24674. if m.id == nil || m.oldValue == nil {
  24675. return v, errors.New("OldRemark requires an ID field in the mutation")
  24676. }
  24677. oldValue, err := m.oldValue(ctx)
  24678. if err != nil {
  24679. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  24680. }
  24681. return oldValue.Remark, nil
  24682. }
  24683. // ResetRemark resets all changes to the "remark" field.
  24684. func (m *WxCardUserMutation) ResetRemark() {
  24685. m.remark = nil
  24686. }
  24687. // SetPhone sets the "phone" field.
  24688. func (m *WxCardUserMutation) SetPhone(s string) {
  24689. m.phone = &s
  24690. }
  24691. // Phone returns the value of the "phone" field in the mutation.
  24692. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  24693. v := m.phone
  24694. if v == nil {
  24695. return
  24696. }
  24697. return *v, true
  24698. }
  24699. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  24700. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24702. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  24703. if !m.op.Is(OpUpdateOne) {
  24704. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24705. }
  24706. if m.id == nil || m.oldValue == nil {
  24707. return v, errors.New("OldPhone requires an ID field in the mutation")
  24708. }
  24709. oldValue, err := m.oldValue(ctx)
  24710. if err != nil {
  24711. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24712. }
  24713. return oldValue.Phone, nil
  24714. }
  24715. // ResetPhone resets all changes to the "phone" field.
  24716. func (m *WxCardUserMutation) ResetPhone() {
  24717. m.phone = nil
  24718. }
  24719. // SetOpenID sets the "open_id" field.
  24720. func (m *WxCardUserMutation) SetOpenID(s string) {
  24721. m.open_id = &s
  24722. }
  24723. // OpenID returns the value of the "open_id" field in the mutation.
  24724. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  24725. v := m.open_id
  24726. if v == nil {
  24727. return
  24728. }
  24729. return *v, true
  24730. }
  24731. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  24732. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24734. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  24735. if !m.op.Is(OpUpdateOne) {
  24736. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  24737. }
  24738. if m.id == nil || m.oldValue == nil {
  24739. return v, errors.New("OldOpenID requires an ID field in the mutation")
  24740. }
  24741. oldValue, err := m.oldValue(ctx)
  24742. if err != nil {
  24743. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  24744. }
  24745. return oldValue.OpenID, nil
  24746. }
  24747. // ResetOpenID resets all changes to the "open_id" field.
  24748. func (m *WxCardUserMutation) ResetOpenID() {
  24749. m.open_id = nil
  24750. }
  24751. // SetUnionID sets the "union_id" field.
  24752. func (m *WxCardUserMutation) SetUnionID(s string) {
  24753. m.union_id = &s
  24754. }
  24755. // UnionID returns the value of the "union_id" field in the mutation.
  24756. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  24757. v := m.union_id
  24758. if v == nil {
  24759. return
  24760. }
  24761. return *v, true
  24762. }
  24763. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  24764. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24766. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  24767. if !m.op.Is(OpUpdateOne) {
  24768. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  24769. }
  24770. if m.id == nil || m.oldValue == nil {
  24771. return v, errors.New("OldUnionID requires an ID field in the mutation")
  24772. }
  24773. oldValue, err := m.oldValue(ctx)
  24774. if err != nil {
  24775. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  24776. }
  24777. return oldValue.UnionID, nil
  24778. }
  24779. // ResetUnionID resets all changes to the "union_id" field.
  24780. func (m *WxCardUserMutation) ResetUnionID() {
  24781. m.union_id = nil
  24782. }
  24783. // SetSessionKey sets the "session_key" field.
  24784. func (m *WxCardUserMutation) SetSessionKey(s string) {
  24785. m.session_key = &s
  24786. }
  24787. // SessionKey returns the value of the "session_key" field in the mutation.
  24788. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  24789. v := m.session_key
  24790. if v == nil {
  24791. return
  24792. }
  24793. return *v, true
  24794. }
  24795. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  24796. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  24797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24798. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  24799. if !m.op.Is(OpUpdateOne) {
  24800. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  24801. }
  24802. if m.id == nil || m.oldValue == nil {
  24803. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  24804. }
  24805. oldValue, err := m.oldValue(ctx)
  24806. if err != nil {
  24807. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  24808. }
  24809. return oldValue.SessionKey, nil
  24810. }
  24811. // ResetSessionKey resets all changes to the "session_key" field.
  24812. func (m *WxCardUserMutation) ResetSessionKey() {
  24813. m.session_key = nil
  24814. }
  24815. // Where appends a list predicates to the WxCardUserMutation builder.
  24816. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  24817. m.predicates = append(m.predicates, ps...)
  24818. }
  24819. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  24820. // users can use type-assertion to append predicates that do not depend on any generated package.
  24821. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  24822. p := make([]predicate.WxCardUser, len(ps))
  24823. for i := range ps {
  24824. p[i] = ps[i]
  24825. }
  24826. m.Where(p...)
  24827. }
  24828. // Op returns the operation name.
  24829. func (m *WxCardUserMutation) Op() Op {
  24830. return m.op
  24831. }
  24832. // SetOp allows setting the mutation operation.
  24833. func (m *WxCardUserMutation) SetOp(op Op) {
  24834. m.op = op
  24835. }
  24836. // Type returns the node type of this mutation (WxCardUser).
  24837. func (m *WxCardUserMutation) Type() string {
  24838. return m.typ
  24839. }
  24840. // Fields returns all fields that were changed during this mutation. Note that in
  24841. // order to get all numeric fields that were incremented/decremented, call
  24842. // AddedFields().
  24843. func (m *WxCardUserMutation) Fields() []string {
  24844. fields := make([]string, 0, 12)
  24845. if m.created_at != nil {
  24846. fields = append(fields, wxcarduser.FieldCreatedAt)
  24847. }
  24848. if m.updated_at != nil {
  24849. fields = append(fields, wxcarduser.FieldUpdatedAt)
  24850. }
  24851. if m.deleted_at != nil {
  24852. fields = append(fields, wxcarduser.FieldDeletedAt)
  24853. }
  24854. if m.wxid != nil {
  24855. fields = append(fields, wxcarduser.FieldWxid)
  24856. }
  24857. if m.account != nil {
  24858. fields = append(fields, wxcarduser.FieldAccount)
  24859. }
  24860. if m.avatar != nil {
  24861. fields = append(fields, wxcarduser.FieldAvatar)
  24862. }
  24863. if m.nickname != nil {
  24864. fields = append(fields, wxcarduser.FieldNickname)
  24865. }
  24866. if m.remark != nil {
  24867. fields = append(fields, wxcarduser.FieldRemark)
  24868. }
  24869. if m.phone != nil {
  24870. fields = append(fields, wxcarduser.FieldPhone)
  24871. }
  24872. if m.open_id != nil {
  24873. fields = append(fields, wxcarduser.FieldOpenID)
  24874. }
  24875. if m.union_id != nil {
  24876. fields = append(fields, wxcarduser.FieldUnionID)
  24877. }
  24878. if m.session_key != nil {
  24879. fields = append(fields, wxcarduser.FieldSessionKey)
  24880. }
  24881. return fields
  24882. }
  24883. // Field returns the value of a field with the given name. The second boolean
  24884. // return value indicates that this field was not set, or was not defined in the
  24885. // schema.
  24886. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  24887. switch name {
  24888. case wxcarduser.FieldCreatedAt:
  24889. return m.CreatedAt()
  24890. case wxcarduser.FieldUpdatedAt:
  24891. return m.UpdatedAt()
  24892. case wxcarduser.FieldDeletedAt:
  24893. return m.DeletedAt()
  24894. case wxcarduser.FieldWxid:
  24895. return m.Wxid()
  24896. case wxcarduser.FieldAccount:
  24897. return m.Account()
  24898. case wxcarduser.FieldAvatar:
  24899. return m.Avatar()
  24900. case wxcarduser.FieldNickname:
  24901. return m.Nickname()
  24902. case wxcarduser.FieldRemark:
  24903. return m.Remark()
  24904. case wxcarduser.FieldPhone:
  24905. return m.Phone()
  24906. case wxcarduser.FieldOpenID:
  24907. return m.OpenID()
  24908. case wxcarduser.FieldUnionID:
  24909. return m.UnionID()
  24910. case wxcarduser.FieldSessionKey:
  24911. return m.SessionKey()
  24912. }
  24913. return nil, false
  24914. }
  24915. // OldField returns the old value of the field from the database. An error is
  24916. // returned if the mutation operation is not UpdateOne, or the query to the
  24917. // database failed.
  24918. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24919. switch name {
  24920. case wxcarduser.FieldCreatedAt:
  24921. return m.OldCreatedAt(ctx)
  24922. case wxcarduser.FieldUpdatedAt:
  24923. return m.OldUpdatedAt(ctx)
  24924. case wxcarduser.FieldDeletedAt:
  24925. return m.OldDeletedAt(ctx)
  24926. case wxcarduser.FieldWxid:
  24927. return m.OldWxid(ctx)
  24928. case wxcarduser.FieldAccount:
  24929. return m.OldAccount(ctx)
  24930. case wxcarduser.FieldAvatar:
  24931. return m.OldAvatar(ctx)
  24932. case wxcarduser.FieldNickname:
  24933. return m.OldNickname(ctx)
  24934. case wxcarduser.FieldRemark:
  24935. return m.OldRemark(ctx)
  24936. case wxcarduser.FieldPhone:
  24937. return m.OldPhone(ctx)
  24938. case wxcarduser.FieldOpenID:
  24939. return m.OldOpenID(ctx)
  24940. case wxcarduser.FieldUnionID:
  24941. return m.OldUnionID(ctx)
  24942. case wxcarduser.FieldSessionKey:
  24943. return m.OldSessionKey(ctx)
  24944. }
  24945. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  24946. }
  24947. // SetField sets the value of a field with the given name. It returns an error if
  24948. // the field is not defined in the schema, or if the type mismatched the field
  24949. // type.
  24950. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  24951. switch name {
  24952. case wxcarduser.FieldCreatedAt:
  24953. v, ok := value.(time.Time)
  24954. if !ok {
  24955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24956. }
  24957. m.SetCreatedAt(v)
  24958. return nil
  24959. case wxcarduser.FieldUpdatedAt:
  24960. v, ok := value.(time.Time)
  24961. if !ok {
  24962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24963. }
  24964. m.SetUpdatedAt(v)
  24965. return nil
  24966. case wxcarduser.FieldDeletedAt:
  24967. v, ok := value.(time.Time)
  24968. if !ok {
  24969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24970. }
  24971. m.SetDeletedAt(v)
  24972. return nil
  24973. case wxcarduser.FieldWxid:
  24974. v, ok := value.(string)
  24975. if !ok {
  24976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24977. }
  24978. m.SetWxid(v)
  24979. return nil
  24980. case wxcarduser.FieldAccount:
  24981. v, ok := value.(string)
  24982. if !ok {
  24983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24984. }
  24985. m.SetAccount(v)
  24986. return nil
  24987. case wxcarduser.FieldAvatar:
  24988. v, ok := value.(string)
  24989. if !ok {
  24990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24991. }
  24992. m.SetAvatar(v)
  24993. return nil
  24994. case wxcarduser.FieldNickname:
  24995. v, ok := value.(string)
  24996. if !ok {
  24997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24998. }
  24999. m.SetNickname(v)
  25000. return nil
  25001. case wxcarduser.FieldRemark:
  25002. v, ok := value.(string)
  25003. if !ok {
  25004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25005. }
  25006. m.SetRemark(v)
  25007. return nil
  25008. case wxcarduser.FieldPhone:
  25009. v, ok := value.(string)
  25010. if !ok {
  25011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25012. }
  25013. m.SetPhone(v)
  25014. return nil
  25015. case wxcarduser.FieldOpenID:
  25016. v, ok := value.(string)
  25017. if !ok {
  25018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25019. }
  25020. m.SetOpenID(v)
  25021. return nil
  25022. case wxcarduser.FieldUnionID:
  25023. v, ok := value.(string)
  25024. if !ok {
  25025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25026. }
  25027. m.SetUnionID(v)
  25028. return nil
  25029. case wxcarduser.FieldSessionKey:
  25030. v, ok := value.(string)
  25031. if !ok {
  25032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25033. }
  25034. m.SetSessionKey(v)
  25035. return nil
  25036. }
  25037. return fmt.Errorf("unknown WxCardUser field %s", name)
  25038. }
  25039. // AddedFields returns all numeric fields that were incremented/decremented during
  25040. // this mutation.
  25041. func (m *WxCardUserMutation) AddedFields() []string {
  25042. return nil
  25043. }
  25044. // AddedField returns the numeric value that was incremented/decremented on a field
  25045. // with the given name. The second boolean return value indicates that this field
  25046. // was not set, or was not defined in the schema.
  25047. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  25048. return nil, false
  25049. }
  25050. // AddField adds the value to the field with the given name. It returns an error if
  25051. // the field is not defined in the schema, or if the type mismatched the field
  25052. // type.
  25053. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  25054. switch name {
  25055. }
  25056. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  25057. }
  25058. // ClearedFields returns all nullable fields that were cleared during this
  25059. // mutation.
  25060. func (m *WxCardUserMutation) ClearedFields() []string {
  25061. var fields []string
  25062. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  25063. fields = append(fields, wxcarduser.FieldDeletedAt)
  25064. }
  25065. return fields
  25066. }
  25067. // FieldCleared returns a boolean indicating if a field with the given name was
  25068. // cleared in this mutation.
  25069. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  25070. _, ok := m.clearedFields[name]
  25071. return ok
  25072. }
  25073. // ClearField clears the value of the field with the given name. It returns an
  25074. // error if the field is not defined in the schema.
  25075. func (m *WxCardUserMutation) ClearField(name string) error {
  25076. switch name {
  25077. case wxcarduser.FieldDeletedAt:
  25078. m.ClearDeletedAt()
  25079. return nil
  25080. }
  25081. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  25082. }
  25083. // ResetField resets all changes in the mutation for the field with the given name.
  25084. // It returns an error if the field is not defined in the schema.
  25085. func (m *WxCardUserMutation) ResetField(name string) error {
  25086. switch name {
  25087. case wxcarduser.FieldCreatedAt:
  25088. m.ResetCreatedAt()
  25089. return nil
  25090. case wxcarduser.FieldUpdatedAt:
  25091. m.ResetUpdatedAt()
  25092. return nil
  25093. case wxcarduser.FieldDeletedAt:
  25094. m.ResetDeletedAt()
  25095. return nil
  25096. case wxcarduser.FieldWxid:
  25097. m.ResetWxid()
  25098. return nil
  25099. case wxcarduser.FieldAccount:
  25100. m.ResetAccount()
  25101. return nil
  25102. case wxcarduser.FieldAvatar:
  25103. m.ResetAvatar()
  25104. return nil
  25105. case wxcarduser.FieldNickname:
  25106. m.ResetNickname()
  25107. return nil
  25108. case wxcarduser.FieldRemark:
  25109. m.ResetRemark()
  25110. return nil
  25111. case wxcarduser.FieldPhone:
  25112. m.ResetPhone()
  25113. return nil
  25114. case wxcarduser.FieldOpenID:
  25115. m.ResetOpenID()
  25116. return nil
  25117. case wxcarduser.FieldUnionID:
  25118. m.ResetUnionID()
  25119. return nil
  25120. case wxcarduser.FieldSessionKey:
  25121. m.ResetSessionKey()
  25122. return nil
  25123. }
  25124. return fmt.Errorf("unknown WxCardUser field %s", name)
  25125. }
  25126. // AddedEdges returns all edge names that were set/added in this mutation.
  25127. func (m *WxCardUserMutation) AddedEdges() []string {
  25128. edges := make([]string, 0, 0)
  25129. return edges
  25130. }
  25131. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25132. // name in this mutation.
  25133. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  25134. return nil
  25135. }
  25136. // RemovedEdges returns all edge names that were removed in this mutation.
  25137. func (m *WxCardUserMutation) RemovedEdges() []string {
  25138. edges := make([]string, 0, 0)
  25139. return edges
  25140. }
  25141. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25142. // the given name in this mutation.
  25143. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  25144. return nil
  25145. }
  25146. // ClearedEdges returns all edge names that were cleared in this mutation.
  25147. func (m *WxCardUserMutation) ClearedEdges() []string {
  25148. edges := make([]string, 0, 0)
  25149. return edges
  25150. }
  25151. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25152. // was cleared in this mutation.
  25153. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  25154. return false
  25155. }
  25156. // ClearEdge clears the value of the edge with the given name. It returns an error
  25157. // if that edge is not defined in the schema.
  25158. func (m *WxCardUserMutation) ClearEdge(name string) error {
  25159. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  25160. }
  25161. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25162. // It returns an error if the edge is not defined in the schema.
  25163. func (m *WxCardUserMutation) ResetEdge(name string) error {
  25164. return fmt.Errorf("unknown WxCardUser edge %s", name)
  25165. }
  25166. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  25167. type WxCardVisitMutation struct {
  25168. config
  25169. op Op
  25170. typ string
  25171. id *uint64
  25172. created_at *time.Time
  25173. updated_at *time.Time
  25174. deleted_at *time.Time
  25175. user_id *uint64
  25176. adduser_id *int64
  25177. bot_id *uint64
  25178. addbot_id *int64
  25179. bot_type *uint8
  25180. addbot_type *int8
  25181. clearedFields map[string]struct{}
  25182. done bool
  25183. oldValue func(context.Context) (*WxCardVisit, error)
  25184. predicates []predicate.WxCardVisit
  25185. }
  25186. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  25187. // wxcardvisitOption allows management of the mutation configuration using functional options.
  25188. type wxcardvisitOption func(*WxCardVisitMutation)
  25189. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  25190. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  25191. m := &WxCardVisitMutation{
  25192. config: c,
  25193. op: op,
  25194. typ: TypeWxCardVisit,
  25195. clearedFields: make(map[string]struct{}),
  25196. }
  25197. for _, opt := range opts {
  25198. opt(m)
  25199. }
  25200. return m
  25201. }
  25202. // withWxCardVisitID sets the ID field of the mutation.
  25203. func withWxCardVisitID(id uint64) wxcardvisitOption {
  25204. return func(m *WxCardVisitMutation) {
  25205. var (
  25206. err error
  25207. once sync.Once
  25208. value *WxCardVisit
  25209. )
  25210. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  25211. once.Do(func() {
  25212. if m.done {
  25213. err = errors.New("querying old values post mutation is not allowed")
  25214. } else {
  25215. value, err = m.Client().WxCardVisit.Get(ctx, id)
  25216. }
  25217. })
  25218. return value, err
  25219. }
  25220. m.id = &id
  25221. }
  25222. }
  25223. // withWxCardVisit sets the old WxCardVisit of the mutation.
  25224. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  25225. return func(m *WxCardVisitMutation) {
  25226. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  25227. return node, nil
  25228. }
  25229. m.id = &node.ID
  25230. }
  25231. }
  25232. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25233. // executed in a transaction (ent.Tx), a transactional client is returned.
  25234. func (m WxCardVisitMutation) Client() *Client {
  25235. client := &Client{config: m.config}
  25236. client.init()
  25237. return client
  25238. }
  25239. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25240. // it returns an error otherwise.
  25241. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  25242. if _, ok := m.driver.(*txDriver); !ok {
  25243. return nil, errors.New("ent: mutation is not running in a transaction")
  25244. }
  25245. tx := &Tx{config: m.config}
  25246. tx.init()
  25247. return tx, nil
  25248. }
  25249. // SetID sets the value of the id field. Note that this
  25250. // operation is only accepted on creation of WxCardVisit entities.
  25251. func (m *WxCardVisitMutation) SetID(id uint64) {
  25252. m.id = &id
  25253. }
  25254. // ID returns the ID value in the mutation. Note that the ID is only available
  25255. // if it was provided to the builder or after it was returned from the database.
  25256. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  25257. if m.id == nil {
  25258. return
  25259. }
  25260. return *m.id, true
  25261. }
  25262. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25263. // That means, if the mutation is applied within a transaction with an isolation level such
  25264. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25265. // or updated by the mutation.
  25266. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  25267. switch {
  25268. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25269. id, exists := m.ID()
  25270. if exists {
  25271. return []uint64{id}, nil
  25272. }
  25273. fallthrough
  25274. case m.op.Is(OpUpdate | OpDelete):
  25275. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  25276. default:
  25277. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25278. }
  25279. }
  25280. // SetCreatedAt sets the "created_at" field.
  25281. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  25282. m.created_at = &t
  25283. }
  25284. // CreatedAt returns the value of the "created_at" field in the mutation.
  25285. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  25286. v := m.created_at
  25287. if v == nil {
  25288. return
  25289. }
  25290. return *v, true
  25291. }
  25292. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  25293. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25295. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25296. if !m.op.Is(OpUpdateOne) {
  25297. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25298. }
  25299. if m.id == nil || m.oldValue == nil {
  25300. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25301. }
  25302. oldValue, err := m.oldValue(ctx)
  25303. if err != nil {
  25304. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25305. }
  25306. return oldValue.CreatedAt, nil
  25307. }
  25308. // ResetCreatedAt resets all changes to the "created_at" field.
  25309. func (m *WxCardVisitMutation) ResetCreatedAt() {
  25310. m.created_at = nil
  25311. }
  25312. // SetUpdatedAt sets the "updated_at" field.
  25313. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  25314. m.updated_at = &t
  25315. }
  25316. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25317. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  25318. v := m.updated_at
  25319. if v == nil {
  25320. return
  25321. }
  25322. return *v, true
  25323. }
  25324. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  25325. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25327. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25328. if !m.op.Is(OpUpdateOne) {
  25329. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25330. }
  25331. if m.id == nil || m.oldValue == nil {
  25332. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25333. }
  25334. oldValue, err := m.oldValue(ctx)
  25335. if err != nil {
  25336. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25337. }
  25338. return oldValue.UpdatedAt, nil
  25339. }
  25340. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25341. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  25342. m.updated_at = nil
  25343. }
  25344. // SetDeletedAt sets the "deleted_at" field.
  25345. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  25346. m.deleted_at = &t
  25347. }
  25348. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25349. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  25350. v := m.deleted_at
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  25357. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25369. }
  25370. return oldValue.DeletedAt, nil
  25371. }
  25372. // ClearDeletedAt clears the value of the "deleted_at" field.
  25373. func (m *WxCardVisitMutation) ClearDeletedAt() {
  25374. m.deleted_at = nil
  25375. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  25376. }
  25377. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25378. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  25379. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  25380. return ok
  25381. }
  25382. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25383. func (m *WxCardVisitMutation) ResetDeletedAt() {
  25384. m.deleted_at = nil
  25385. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  25386. }
  25387. // SetUserID sets the "user_id" field.
  25388. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  25389. m.user_id = &u
  25390. m.adduser_id = nil
  25391. }
  25392. // UserID returns the value of the "user_id" field in the mutation.
  25393. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  25394. v := m.user_id
  25395. if v == nil {
  25396. return
  25397. }
  25398. return *v, true
  25399. }
  25400. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  25401. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25403. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  25404. if !m.op.Is(OpUpdateOne) {
  25405. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25406. }
  25407. if m.id == nil || m.oldValue == nil {
  25408. return v, errors.New("OldUserID requires an ID field in the mutation")
  25409. }
  25410. oldValue, err := m.oldValue(ctx)
  25411. if err != nil {
  25412. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25413. }
  25414. return oldValue.UserID, nil
  25415. }
  25416. // AddUserID adds u to the "user_id" field.
  25417. func (m *WxCardVisitMutation) AddUserID(u int64) {
  25418. if m.adduser_id != nil {
  25419. *m.adduser_id += u
  25420. } else {
  25421. m.adduser_id = &u
  25422. }
  25423. }
  25424. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  25425. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  25426. v := m.adduser_id
  25427. if v == nil {
  25428. return
  25429. }
  25430. return *v, true
  25431. }
  25432. // ClearUserID clears the value of the "user_id" field.
  25433. func (m *WxCardVisitMutation) ClearUserID() {
  25434. m.user_id = nil
  25435. m.adduser_id = nil
  25436. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  25437. }
  25438. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  25439. func (m *WxCardVisitMutation) UserIDCleared() bool {
  25440. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  25441. return ok
  25442. }
  25443. // ResetUserID resets all changes to the "user_id" field.
  25444. func (m *WxCardVisitMutation) ResetUserID() {
  25445. m.user_id = nil
  25446. m.adduser_id = nil
  25447. delete(m.clearedFields, wxcardvisit.FieldUserID)
  25448. }
  25449. // SetBotID sets the "bot_id" field.
  25450. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  25451. m.bot_id = &u
  25452. m.addbot_id = nil
  25453. }
  25454. // BotID returns the value of the "bot_id" field in the mutation.
  25455. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  25456. v := m.bot_id
  25457. if v == nil {
  25458. return
  25459. }
  25460. return *v, true
  25461. }
  25462. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  25463. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25465. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  25466. if !m.op.Is(OpUpdateOne) {
  25467. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25468. }
  25469. if m.id == nil || m.oldValue == nil {
  25470. return v, errors.New("OldBotID requires an ID field in the mutation")
  25471. }
  25472. oldValue, err := m.oldValue(ctx)
  25473. if err != nil {
  25474. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25475. }
  25476. return oldValue.BotID, nil
  25477. }
  25478. // AddBotID adds u to the "bot_id" field.
  25479. func (m *WxCardVisitMutation) AddBotID(u int64) {
  25480. if m.addbot_id != nil {
  25481. *m.addbot_id += u
  25482. } else {
  25483. m.addbot_id = &u
  25484. }
  25485. }
  25486. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  25487. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  25488. v := m.addbot_id
  25489. if v == nil {
  25490. return
  25491. }
  25492. return *v, true
  25493. }
  25494. // ResetBotID resets all changes to the "bot_id" field.
  25495. func (m *WxCardVisitMutation) ResetBotID() {
  25496. m.bot_id = nil
  25497. m.addbot_id = nil
  25498. }
  25499. // SetBotType sets the "bot_type" field.
  25500. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  25501. m.bot_type = &u
  25502. m.addbot_type = nil
  25503. }
  25504. // BotType returns the value of the "bot_type" field in the mutation.
  25505. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  25506. v := m.bot_type
  25507. if v == nil {
  25508. return
  25509. }
  25510. return *v, true
  25511. }
  25512. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  25513. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  25514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25515. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  25516. if !m.op.Is(OpUpdateOne) {
  25517. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  25518. }
  25519. if m.id == nil || m.oldValue == nil {
  25520. return v, errors.New("OldBotType requires an ID field in the mutation")
  25521. }
  25522. oldValue, err := m.oldValue(ctx)
  25523. if err != nil {
  25524. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  25525. }
  25526. return oldValue.BotType, nil
  25527. }
  25528. // AddBotType adds u to the "bot_type" field.
  25529. func (m *WxCardVisitMutation) AddBotType(u int8) {
  25530. if m.addbot_type != nil {
  25531. *m.addbot_type += u
  25532. } else {
  25533. m.addbot_type = &u
  25534. }
  25535. }
  25536. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  25537. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  25538. v := m.addbot_type
  25539. if v == nil {
  25540. return
  25541. }
  25542. return *v, true
  25543. }
  25544. // ResetBotType resets all changes to the "bot_type" field.
  25545. func (m *WxCardVisitMutation) ResetBotType() {
  25546. m.bot_type = nil
  25547. m.addbot_type = nil
  25548. }
  25549. // Where appends a list predicates to the WxCardVisitMutation builder.
  25550. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  25551. m.predicates = append(m.predicates, ps...)
  25552. }
  25553. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  25554. // users can use type-assertion to append predicates that do not depend on any generated package.
  25555. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  25556. p := make([]predicate.WxCardVisit, len(ps))
  25557. for i := range ps {
  25558. p[i] = ps[i]
  25559. }
  25560. m.Where(p...)
  25561. }
  25562. // Op returns the operation name.
  25563. func (m *WxCardVisitMutation) Op() Op {
  25564. return m.op
  25565. }
  25566. // SetOp allows setting the mutation operation.
  25567. func (m *WxCardVisitMutation) SetOp(op Op) {
  25568. m.op = op
  25569. }
  25570. // Type returns the node type of this mutation (WxCardVisit).
  25571. func (m *WxCardVisitMutation) Type() string {
  25572. return m.typ
  25573. }
  25574. // Fields returns all fields that were changed during this mutation. Note that in
  25575. // order to get all numeric fields that were incremented/decremented, call
  25576. // AddedFields().
  25577. func (m *WxCardVisitMutation) Fields() []string {
  25578. fields := make([]string, 0, 6)
  25579. if m.created_at != nil {
  25580. fields = append(fields, wxcardvisit.FieldCreatedAt)
  25581. }
  25582. if m.updated_at != nil {
  25583. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  25584. }
  25585. if m.deleted_at != nil {
  25586. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25587. }
  25588. if m.user_id != nil {
  25589. fields = append(fields, wxcardvisit.FieldUserID)
  25590. }
  25591. if m.bot_id != nil {
  25592. fields = append(fields, wxcardvisit.FieldBotID)
  25593. }
  25594. if m.bot_type != nil {
  25595. fields = append(fields, wxcardvisit.FieldBotType)
  25596. }
  25597. return fields
  25598. }
  25599. // Field returns the value of a field with the given name. The second boolean
  25600. // return value indicates that this field was not set, or was not defined in the
  25601. // schema.
  25602. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  25603. switch name {
  25604. case wxcardvisit.FieldCreatedAt:
  25605. return m.CreatedAt()
  25606. case wxcardvisit.FieldUpdatedAt:
  25607. return m.UpdatedAt()
  25608. case wxcardvisit.FieldDeletedAt:
  25609. return m.DeletedAt()
  25610. case wxcardvisit.FieldUserID:
  25611. return m.UserID()
  25612. case wxcardvisit.FieldBotID:
  25613. return m.BotID()
  25614. case wxcardvisit.FieldBotType:
  25615. return m.BotType()
  25616. }
  25617. return nil, false
  25618. }
  25619. // OldField returns the old value of the field from the database. An error is
  25620. // returned if the mutation operation is not UpdateOne, or the query to the
  25621. // database failed.
  25622. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25623. switch name {
  25624. case wxcardvisit.FieldCreatedAt:
  25625. return m.OldCreatedAt(ctx)
  25626. case wxcardvisit.FieldUpdatedAt:
  25627. return m.OldUpdatedAt(ctx)
  25628. case wxcardvisit.FieldDeletedAt:
  25629. return m.OldDeletedAt(ctx)
  25630. case wxcardvisit.FieldUserID:
  25631. return m.OldUserID(ctx)
  25632. case wxcardvisit.FieldBotID:
  25633. return m.OldBotID(ctx)
  25634. case wxcardvisit.FieldBotType:
  25635. return m.OldBotType(ctx)
  25636. }
  25637. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  25638. }
  25639. // SetField sets the value of a field with the given name. It returns an error if
  25640. // the field is not defined in the schema, or if the type mismatched the field
  25641. // type.
  25642. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  25643. switch name {
  25644. case wxcardvisit.FieldCreatedAt:
  25645. v, ok := value.(time.Time)
  25646. if !ok {
  25647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25648. }
  25649. m.SetCreatedAt(v)
  25650. return nil
  25651. case wxcardvisit.FieldUpdatedAt:
  25652. v, ok := value.(time.Time)
  25653. if !ok {
  25654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25655. }
  25656. m.SetUpdatedAt(v)
  25657. return nil
  25658. case wxcardvisit.FieldDeletedAt:
  25659. v, ok := value.(time.Time)
  25660. if !ok {
  25661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25662. }
  25663. m.SetDeletedAt(v)
  25664. return nil
  25665. case wxcardvisit.FieldUserID:
  25666. v, ok := value.(uint64)
  25667. if !ok {
  25668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25669. }
  25670. m.SetUserID(v)
  25671. return nil
  25672. case wxcardvisit.FieldBotID:
  25673. v, ok := value.(uint64)
  25674. if !ok {
  25675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25676. }
  25677. m.SetBotID(v)
  25678. return nil
  25679. case wxcardvisit.FieldBotType:
  25680. v, ok := value.(uint8)
  25681. if !ok {
  25682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25683. }
  25684. m.SetBotType(v)
  25685. return nil
  25686. }
  25687. return fmt.Errorf("unknown WxCardVisit field %s", name)
  25688. }
  25689. // AddedFields returns all numeric fields that were incremented/decremented during
  25690. // this mutation.
  25691. func (m *WxCardVisitMutation) AddedFields() []string {
  25692. var fields []string
  25693. if m.adduser_id != nil {
  25694. fields = append(fields, wxcardvisit.FieldUserID)
  25695. }
  25696. if m.addbot_id != nil {
  25697. fields = append(fields, wxcardvisit.FieldBotID)
  25698. }
  25699. if m.addbot_type != nil {
  25700. fields = append(fields, wxcardvisit.FieldBotType)
  25701. }
  25702. return fields
  25703. }
  25704. // AddedField returns the numeric value that was incremented/decremented on a field
  25705. // with the given name. The second boolean return value indicates that this field
  25706. // was not set, or was not defined in the schema.
  25707. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  25708. switch name {
  25709. case wxcardvisit.FieldUserID:
  25710. return m.AddedUserID()
  25711. case wxcardvisit.FieldBotID:
  25712. return m.AddedBotID()
  25713. case wxcardvisit.FieldBotType:
  25714. return m.AddedBotType()
  25715. }
  25716. return nil, false
  25717. }
  25718. // AddField adds the value to the field with the given name. It returns an error if
  25719. // the field is not defined in the schema, or if the type mismatched the field
  25720. // type.
  25721. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  25722. switch name {
  25723. case wxcardvisit.FieldUserID:
  25724. v, ok := value.(int64)
  25725. if !ok {
  25726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25727. }
  25728. m.AddUserID(v)
  25729. return nil
  25730. case wxcardvisit.FieldBotID:
  25731. v, ok := value.(int64)
  25732. if !ok {
  25733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25734. }
  25735. m.AddBotID(v)
  25736. return nil
  25737. case wxcardvisit.FieldBotType:
  25738. v, ok := value.(int8)
  25739. if !ok {
  25740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25741. }
  25742. m.AddBotType(v)
  25743. return nil
  25744. }
  25745. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  25746. }
  25747. // ClearedFields returns all nullable fields that were cleared during this
  25748. // mutation.
  25749. func (m *WxCardVisitMutation) ClearedFields() []string {
  25750. var fields []string
  25751. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  25752. fields = append(fields, wxcardvisit.FieldDeletedAt)
  25753. }
  25754. if m.FieldCleared(wxcardvisit.FieldUserID) {
  25755. fields = append(fields, wxcardvisit.FieldUserID)
  25756. }
  25757. return fields
  25758. }
  25759. // FieldCleared returns a boolean indicating if a field with the given name was
  25760. // cleared in this mutation.
  25761. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  25762. _, ok := m.clearedFields[name]
  25763. return ok
  25764. }
  25765. // ClearField clears the value of the field with the given name. It returns an
  25766. // error if the field is not defined in the schema.
  25767. func (m *WxCardVisitMutation) ClearField(name string) error {
  25768. switch name {
  25769. case wxcardvisit.FieldDeletedAt:
  25770. m.ClearDeletedAt()
  25771. return nil
  25772. case wxcardvisit.FieldUserID:
  25773. m.ClearUserID()
  25774. return nil
  25775. }
  25776. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  25777. }
  25778. // ResetField resets all changes in the mutation for the field with the given name.
  25779. // It returns an error if the field is not defined in the schema.
  25780. func (m *WxCardVisitMutation) ResetField(name string) error {
  25781. switch name {
  25782. case wxcardvisit.FieldCreatedAt:
  25783. m.ResetCreatedAt()
  25784. return nil
  25785. case wxcardvisit.FieldUpdatedAt:
  25786. m.ResetUpdatedAt()
  25787. return nil
  25788. case wxcardvisit.FieldDeletedAt:
  25789. m.ResetDeletedAt()
  25790. return nil
  25791. case wxcardvisit.FieldUserID:
  25792. m.ResetUserID()
  25793. return nil
  25794. case wxcardvisit.FieldBotID:
  25795. m.ResetBotID()
  25796. return nil
  25797. case wxcardvisit.FieldBotType:
  25798. m.ResetBotType()
  25799. return nil
  25800. }
  25801. return fmt.Errorf("unknown WxCardVisit field %s", name)
  25802. }
  25803. // AddedEdges returns all edge names that were set/added in this mutation.
  25804. func (m *WxCardVisitMutation) AddedEdges() []string {
  25805. edges := make([]string, 0, 0)
  25806. return edges
  25807. }
  25808. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25809. // name in this mutation.
  25810. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  25811. return nil
  25812. }
  25813. // RemovedEdges returns all edge names that were removed in this mutation.
  25814. func (m *WxCardVisitMutation) RemovedEdges() []string {
  25815. edges := make([]string, 0, 0)
  25816. return edges
  25817. }
  25818. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25819. // the given name in this mutation.
  25820. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  25821. return nil
  25822. }
  25823. // ClearedEdges returns all edge names that were cleared in this mutation.
  25824. func (m *WxCardVisitMutation) ClearedEdges() []string {
  25825. edges := make([]string, 0, 0)
  25826. return edges
  25827. }
  25828. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25829. // was cleared in this mutation.
  25830. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  25831. return false
  25832. }
  25833. // ClearEdge clears the value of the edge with the given name. It returns an error
  25834. // if that edge is not defined in the schema.
  25835. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  25836. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  25837. }
  25838. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25839. // It returns an error if the edge is not defined in the schema.
  25840. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  25841. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  25842. }