完成 微前端拆分 提交遗漏文件
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Product } from "@domains/product/domain/entities/Product.ts";
|
||||
import { ProductType } from "@domains/product/domain/type/ProductType.ts";
|
||||
import { ProductRepository } from "@domains/product/ports/repositories/ProductRepository";
|
||||
// @ts-ignore
|
||||
import { http } from "mainApp/shared";
|
||||
import HttpConfig from "../config/HttpConfig";
|
||||
|
||||
/**
|
||||
* HTTP商品仓储实现 - 实现商品数据的HTTP访问
|
||||
* 这是基础设施层,负责具体的数据获取实现
|
||||
*/
|
||||
export class HttpProductRepository implements ProductRepository {
|
||||
|
||||
async findAll(): Promise<Array<ProductType>> {
|
||||
const result: Array<ProductType> = await http.get({ url: HttpConfig.apiUrlList.productsListUrl });
|
||||
const items = result.map((item) => Product.fromDTO(item))
|
||||
return items;
|
||||
}
|
||||
|
||||
async findById(id: number): Promise<Product> {
|
||||
const result: ProductType = await http.get({
|
||||
url: HttpConfig.apiUrlList.productsInfoUrl,
|
||||
data: { id }
|
||||
});
|
||||
return Product.fromDTO(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface apiUrlListType {
|
||||
productsListUrl: string
|
||||
productsInfoUrl: string
|
||||
}
|
||||
|
||||
export default class HttpConfig {
|
||||
public static apiUrlList: apiUrlListType = {
|
||||
productsListUrl: '/productsList',
|
||||
productsInfoUrl: '/productsInfo',
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user