109 lines
2.7 KiB
TypeScript
109 lines
2.7 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { ShopUserCollection, ShopUserCollectionParam } from './model';
|
|
import { MODULES_API_URL } from '@/config/setting';
|
|
|
|
/**
|
|
* 分页查询我的收藏
|
|
*/
|
|
export async function pageShopUserCollection(params: ShopUserCollectionParam) {
|
|
const res = await request.get<ApiResult<PageResult<ShopUserCollection>>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询我的收藏列表
|
|
*/
|
|
export async function listShopUserCollection(params?: ShopUserCollectionParam) {
|
|
const res = await request.get<ApiResult<ShopUserCollection[]>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加我的收藏
|
|
*/
|
|
export async function addShopUserCollection(data: ShopUserCollection) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改我的收藏
|
|
*/
|
|
export async function updateShopUserCollection(data: ShopUserCollection) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除我的收藏
|
|
*/
|
|
export async function removeShopUserCollection(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除我的收藏
|
|
*/
|
|
export async function removeBatchShopUserCollection(
|
|
data: (number | undefined)[]
|
|
) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询我的收藏
|
|
*/
|
|
export async function getShopUserCollection(id: number) {
|
|
const res = await request.get<ApiResult<ShopUserCollection>>(
|
|
MODULES_API_URL + '/mall/shop-user-collection/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|