106 lines
2.3 KiB
TypeScript
106 lines
2.3 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { ShopBrand2, ShopBrand2Param } from './model';
|
|
|
|
/**
|
|
* 分页查询品牌
|
|
*/
|
|
export async function pageShopBrand2(params: ShopBrand2Param) {
|
|
const res = await request.get<ApiResult<PageResult<ShopBrand2>>>(
|
|
'/shop/shop-brand2/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询品牌列表
|
|
*/
|
|
export async function listShopBrand2(params?: ShopBrand2Param) {
|
|
const res = await request.get<ApiResult<ShopBrand2[]>>(
|
|
'/shop/shop-brand2',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加品牌
|
|
*/
|
|
export async function addShopBrand2(data: ShopBrand2) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/shop/shop-brand2',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改品牌
|
|
*/
|
|
export async function updateShopBrand2(data: ShopBrand2) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/shop/shop-brand2',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除品牌
|
|
*/
|
|
export async function removeShopBrand2(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/shop-brand2/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除品牌
|
|
*/
|
|
export async function removeBatchShopBrand2(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/shop-brand2/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询品牌
|
|
*/
|
|
export async function getShopBrand2(id: number) {
|
|
const res = await request.get<ApiResult<ShopBrand2>>(
|
|
'/shop/shop-brand2/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|