31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
import { axios } from "timi-web-api";
|
|
import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store";
|
|
import type { GaoCustomerPackage, GaoPackageConfig, PackageConfigPage, PackagePageResult, PackagePurchaseRequest } from "@/types/Package";
|
|
|
|
const CONFIG_URI = "/gao/package/config";
|
|
const CUSTOMER_PACKAGE_URI = "/gao/customer/package";
|
|
|
|
async function configList(page: PackageConfigPage): Promise<PackagePageResult<GaoPackageConfig>> {
|
|
return await axios.post(`${CONFIG_URI}/list`, withCurrentStoreId(page));
|
|
}
|
|
async function configListValid(storeId?: string): Promise<GaoPackageConfig[]> {
|
|
return await axios.post(`${CONFIG_URI}/list/valid`, undefined, { params: { storeId: storeId || getCurrentStoreId() } });
|
|
}
|
|
async function configDetail(id: string): Promise<GaoPackageConfig> {
|
|
return await axios.post(`${CONFIG_URI}/detail`, undefined, { params: { id } });
|
|
}
|
|
async function configCreate(config: GaoPackageConfig): Promise<string> {
|
|
return await axios.post(`${CONFIG_URI}/create`, withCurrentStoreId(config));
|
|
}
|
|
async function configUpdate(config: GaoPackageConfig): Promise<void> {
|
|
await axios.post(`${CONFIG_URI}/update`, withCurrentStoreId(config));
|
|
}
|
|
async function configRemove(id: string): Promise<void> {
|
|
await axios.post(`${CONFIG_URI}/delete`, undefined, { params: { id } });
|
|
}
|
|
async function purchase(request: PackagePurchaseRequest): Promise<GaoCustomerPackage> {
|
|
return await axios.post(`${CUSTOMER_PACKAGE_URI}/purchase`, request);
|
|
}
|
|
|
|
export default { configList, configListValid, configDetail, configCreate, configUpdate, configRemove, purchase };
|