refactor(shop): 重构商铺相关 API
- 移除 ApiResult 和 PageResult 的冗余导入 - 更新请求路径,移除 MODULES_API_URL 的使用 - 调整请求头,移除不必要的 Content-Type 设置 -统一处理 enabled 字段类型
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopCoupon, ShopCouponParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询优惠券
|
||||
*/
|
||||
export async function pageShopCoupon(params: ShopCouponParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopCoupon>>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/page',
|
||||
'/shop/shop-coupon/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopCoupon(params: ShopCouponParam) {
|
||||
*/
|
||||
export async function listShopCoupon(params?: ShopCouponParam) {
|
||||
const res = await request.get<ApiResult<ShopCoupon[]>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
'/shop/shop-coupon',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,13 +39,8 @@ export async function listShopCoupon(params?: ShopCouponParam) {
|
||||
*/
|
||||
export async function addShopCoupon(data: ShopCoupon) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
'/shop/shop-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -59,13 +53,8 @@ export async function addShopCoupon(data: ShopCoupon) {
|
||||
*/
|
||||
export async function updateShopCoupon(data: ShopCoupon) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
'/shop/shop-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -78,7 +67,7 @@ export async function updateShopCoupon(data: ShopCoupon) {
|
||||
*/
|
||||
export async function removeShopCoupon(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/' + id
|
||||
'/shop/shop-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -91,7 +80,7 @@ export async function removeShopCoupon(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopCoupon(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/batch',
|
||||
'/shop/shop-coupon/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -107,7 +96,7 @@ export async function removeBatchShopCoupon(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopCoupon(id: number) {
|
||||
const res = await request.get<ApiResult<ShopCoupon>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/' + id
|
||||
'/shop/shop-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 优惠券
|
||||
@@ -53,7 +53,7 @@ export interface ShopCoupon {
|
||||
// 每人限领数量(-1表示无限制)
|
||||
limitPerUser?: number;
|
||||
// 是否启用(0禁用 1启用)
|
||||
enabled?: boolean;
|
||||
enabled?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user