132 lines
3.1 KiB
TypeScript
132 lines
3.1 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { GoodsPrice, GoodsPriceParam } from './model';
|
|
|
|
/**
|
|
* 分页查询订单商品
|
|
*/
|
|
export async function goodsPriceByGoods(params: GoodsPriceParam) {
|
|
const res = await request.get<ApiResult<GoodsPrice>>(
|
|
`/shop/goods-price/by-goodsId-n-city/${params.goodsId}`,
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
export async function goodsPriceByGoodsNCity(params: GoodsPriceParam) {
|
|
const res = await request.get<ApiResult<GoodsPrice>>(
|
|
`/shop/goods-price/info-by-city/${params.goodsId}/${params.cityId}`,
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 分页查询订单商品
|
|
*/
|
|
export async function pageGoodsPrice(params: GoodsPriceParam) {
|
|
const res = await request.get<ApiResult<PageResult<GoodsPrice>>>(
|
|
'/shop/goods-price/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询订单商品列表
|
|
*/
|
|
export async function listGoodsPrice(params?: GoodsPriceParam) {
|
|
const res = await request.get<ApiResult<GoodsPrice[]>>('/shop/goods-price', {
|
|
params
|
|
});
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加订单商品
|
|
*/
|
|
export async function addGoodsPrice(data: GoodsPrice) {
|
|
const res = await request.post<ApiResult<unknown>>('/shop/goods-price', data);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改订单商品
|
|
*/
|
|
export async function updateGoodsPrice(data: GoodsPrice) {
|
|
const res = await request.put<ApiResult<unknown>>('/shop/goods-price', data);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除订单商品
|
|
*/
|
|
export async function removeGoodsPrice(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/goods-price/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除订单商品
|
|
*/
|
|
export async function removeBatchGoodsPrice(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/goods-price/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 检查IP是否存在
|
|
*/
|
|
export async function checkExistence(
|
|
field: string,
|
|
value: string,
|
|
id?: number
|
|
) {
|
|
const res = await request.get<ApiResult<unknown>>(
|
|
'/shop/goods-price/existence',
|
|
{
|
|
params: { field, value, id }
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|