Files
app-product/dist/assets/__federation_expose_ProductDomain-J98eKK33.js
编码猿 b77e36a178
Some checks failed
build and push / build-and-push (push) Has been cancelled
first commit
2025-10-07 03:17:55 +08:00

2 lines
3.1 KiB
JavaScript

var o=(e=>(e.PriceNotNegativein="商品 价格 不能为负数",e.StockNotNegativein="商品 库存 不能为负数",e.StockIsGreaterThanZero="减少的库存数量必须大于0",e.LowStock="库存不足",e.IdNotNull="商品Id不能为空",e))(o||{});class I{constructor(t){this.productRepository=t}async getProductList(){return await this.productRepository.findAll()}async getProductInfo(t){if(!t)throw new Error(o.IdNotNull);return await this.productRepository.findById(t)}}class c{_id;_name;_description;_price;_imageUrl;_stock;_categoryId;constructor(t,r,i,_,a,s,n){this._id=t,this._name=r,this._description=i,this._price=_,this._imageUrl=a,this._stock=s,this._categoryId=n}get id(){return this._id}get name(){return this._name}set name(t){this._name=t}get description(){return this._description}set description(t){this._description=t}get price(){return this._price}set price(t){if(t<0)throw new Error(o.PriceNotNegativein);this._price=t}get imageUrl(){return this._imageUrl}set imageUrl(t){this._imageUrl=t}get stock(){return this._stock}set stock(t){if(t<0)throw new Error(o.StockNotNegativein);this._stock=t}get categoryId(){return this._categoryId}set categoryId(t){this._categoryId=t}hasStock(){return this._stock>0}reduceStock(t){if(t<=0)throw new Error(o.StockIsGreaterThanZero);if(this._stock<t)throw new Error(o.LowStock);this._stock-=t}toDTO(){return{id:this._id,name:this._name,description:this._description,price:this._price,imageUrl:this._imageUrl,stock:this._stock,categoryId:this._categoryId}}static fromDTO(t){return new c(t.id,t.name,t.description,t.price,t.imageUrl,t.stock,t.categoryId)}}const m={shared:{url:"http://192.168.31.101:1333/app-shared/assets/remoteEntry.js",format:"esm",from:"vite"}},u={};function d(e,t){return g(e).then(r=>()=>r)}function l(e,t){const r=Object.assign(e,t);for(const i of Object.keys(r))typeof r[i]=="object"&&typeof t[i]=="object"&&(r[i]=l(r[i],t[i]));return r}const f=e=>l({vue:{undefined:{get:()=>d(new URL("__federation_shared_vue-CmZhWQPe.js",import.meta.url).href),loaded:1}},"vue-router":{undefined:{get:()=>d(new URL("__federation_shared_vue-router-CUrgpNf2.js",import.meta.url).href),loaded:1}},pinia:{undefined:{get:()=>d(new URL("__federation_shared_pinia-o7RAmTGs.js",import.meta.url).href),loaded:1}}},(globalThis.__federation_shared__||{}).default||{});async function g(e){return u[e]??=import(e),u[e]}async function y(e){const t=m[e];if(t.inited)return t.lib;if(["esm","systemjs"].includes(t.format))return new Promise((r,i)=>{Promise.resolve(t.url).then(a=>{import(a).then(s=>{if(!t.inited){const n=f();s.init(n),t.lib=s,t.lib.init(n),t.inited=!0}r(t.lib)}).catch(i)})})}function w(e,t){return y(e).then(r=>r.get(t).then(i=>i()))}class h{static apiUrlList={productsListUrl:"/productsList",productsInfoUrl:"/productsInfo"}}const k=await w("shared","./infra");let{http:p}=k;class U{async findAll(){return(await p.get({url:h.apiUrlList.productsListUrl})).map(i=>c.fromDTO(i))}async findById(t){const r=await p.get({url:h.apiUrlList.productsInfoUrl,data:{id:t}});return c.fromDTO(r)}}export{o as ErrorText,U as HttpProductRepository,c as Product,I as ProductApplicationService,w as __federation_method_getRemote};