911 lines
170 KiB
Plaintext
911 lines
170 KiB
Plaintext
import axios, { AxiosError } from "/node_modules/.vite/deps/axios.js?v=e2549d3d";
|
||||
|
|
import { message } from "/node_modules/.vite/deps/ant-design-vue.js?v=e2549d3d";
|
|||
|
|
import { ADMIN_API_BASE_URL } from "/src/config/api.ts";
|
|||
|
|
import { clearAdminSessionStorage } from "/src/utils/admin-session.ts";
|
|||
|
|
import { attachRequestSignature } from "/src/utils/request-signature.ts";
|
|||
|
|
import { isAdminApiAuthFreePath } from "/src/api/auth-free-paths.ts";
|
|||
|
|
let lastErrorTime = 0;
|
|||
|
|
let lastErrorMessage = "";
|
|||
|
|
const ERROR_DEBOUNCE_TIME = 1e3;
|
|||
|
|
const adminApi = axios.create({
|
|||
|
|
baseURL: ADMIN_API_BASE_URL,
|
|||
|
|
timeout: 6e4,
|
|||
|
|
headers: {
|
|||
|
|
"Content-Type": "application/json"
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
let isRefreshing = false;
|
|||
|
|
let failedQueue = [];
|
|||
|
|
const processQueue = (error, token = null) => {
|
|||
|
|
failedQueue.forEach((prom) => {
|
|||
|
|
if (error) {
|
|||
|
|
prom.reject(error);
|
|||
|
|
} else {
|
|||
|
|
prom.resolve(token);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
failedQueue = [];
|
|||
|
|
};
|
|||
|
|
const getStoredAdminAccessToken = () => {
|
|||
|
|
return localStorage.getItem("adminAccessToken") || sessionStorage.getItem("adminAccessToken");
|
|||
|
|
};
|
|||
|
|
const getRequestToken = (request) => {
|
|||
|
|
if (request?._authToken) {
|
|||
|
|
return request._authToken;
|
|||
|
|
}
|
|||
|
|
const authHeader = request?.headers?.Authorization || request?.headers?.authorization;
|
|||
|
|
if (typeof authHeader !== "string") {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
return authHeader.startsWith("Bearer ") ? authHeader.slice("Bearer ".length) : null;
|
|||
|
|
};
|
|||
|
|
const isCurrentStoredAdminToken = (token) => {
|
|||
|
|
return Boolean(token && token === getStoredAdminAccessToken());
|
|||
|
|
};
|
|||
|
|
const showError = (msg) => {
|
|||
|
|
const now = Date.now();
|
|||
|
|
if (now - lastErrorTime > ERROR_DEBOUNCE_TIME || msg !== lastErrorMessage) {
|
|||
|
|
lastErrorTime = now;
|
|||
|
|
lastErrorMessage = msg;
|
|||
|
|
message.error(msg);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const isAuthFreePath = (url) => {
|
|||
|
|
return isAdminApiAuthFreePath(url);
|
|||
|
|
};
|
|||
|
|
const handleAdminTokenExpired = (failedToken = null) => {
|
|||
|
|
if (!isCurrentStoredAdminToken(failedToken)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
clearAdminSessionStorage();
|
|||
|
|
if (Date.now() - lastErrorTime > ERROR_DEBOUNCE_TIME || lastErrorMessage !== "登录已过期,请重新登录") {
|
|||
|
|
showError("登录已过期,请重新登录");
|
|||
|
|
}
|
|||
|
|
setTimeout(() => {
|
|||
|
|
window.location.href = "/admin/login";
|
|||
|
|
}, 300);
|
|||
|
|
};
|
|||
|
|
adminApi.interceptors.request.use(
|
|||
|
|
async (config) => {
|
|||
|
|
let token = null;
|
|||
|
|
if (!isAuthFreePath(config.url)) {
|
|||
|
|
token = getStoredAdminAccessToken();
|
|||
|
|
if (token) {
|
|||
|
|
config.headers.Authorization = `Bearer ${token}`;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
;
|
|||
|
|
config._authToken = token || null;
|
|||
|
|
return attachRequestSignature(config, token, {
|
|||
|
|
authFree: isAuthFreePath(config.url)
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
(error) => Promise.reject(error)
|
|||
|
|
);
|
|||
|
|
adminApi.interceptors.response.use(
|
|||
|
|
(response) => {
|
|||
|
|
const res = response.data;
|
|||
|
|
if (res.code !== 200) {
|
|||
|
|
const errorMsg = res.message || "请求失败";
|
|||
|
|
if (!errorMsg.includes("权限") && !errorMsg.includes("permission")) {
|
|||
|
|
showError(errorMsg);
|
|||
|
|
} else {
|
|||
|
|
console.error("权限不足:", errorMsg);
|
|||
|
|
}
|
|||
|
|
return Promise.reject(new Error(errorMsg));
|
|||
|
|
}
|
|||
|
|
return res.data;
|
|||
|
|
},
|
|||
|
|
async (error) => {
|
|||
|
|
const originalRequest = error.config;
|
|||
|
|
if (error.response?.status === 401) {
|
|||
|
|
const requestToken = getRequestToken(originalRequest);
|
|||
|
|
if (!isCurrentStoredAdminToken(requestToken)) {
|
|||
|
|
return Promise.reject(error);
|
|||
|
|
}
|
|||
|
|
if (!originalRequest?._retry && !isAuthFreePath(originalRequest?.url)) {
|
|||
|
|
if (isRefreshing) {
|
|||
|
|
return new Promise((resolve, reject) => {
|
|||
|
|
failedQueue.push({ resolve, reject });
|
|||
|
|
}).then((token) => {
|
|||
|
|
if (token) {
|
|||
|
|
originalRequest.headers.Authorization = `Bearer ${token}`;
|
|||
|
|
}
|
|||
|
|
return adminApi(originalRequest);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
originalRequest._retry = true;
|
|||
|
|
isRefreshing = true;
|
|||
|
|
try {
|
|||
|
|
let refreshToken = localStorage.getItem("adminRefreshToken");
|
|||
|
|
if (!refreshToken) {
|
|||
|
|
refreshToken = sessionStorage.getItem("adminRefreshToken");
|
|||
|
|
}
|
|||
|
|
if (!refreshToken) {
|
|||
|
|
throw new Error("No refresh token available");
|
|||
|
|
}
|
|||
|
|
const response = await adminAuthApi.refreshToken(refreshToken);
|
|||
|
|
const newToken = response.accessToken;
|
|||
|
|
const newRefreshToken = response.refreshToken;
|
|||
|
|
localStorage.setItem("adminAccessToken", newToken);
|
|||
|
|
localStorage.setItem("adminRefreshToken", newRefreshToken);
|
|||
|
|
sessionStorage.setItem("adminAccessToken", newToken);
|
|||
|
|
sessionStorage.setItem("adminRefreshToken", newRefreshToken);
|
|||
|
|
processQueue(null, newToken);
|
|||
|
|
originalRequest.headers.Authorization = `Bearer ${newToken}`;
|
|||
|
|
return adminApi(originalRequest);
|
|||
|
|
} catch (refreshError) {
|
|||
|
|
processQueue(refreshError, null);
|
|||
|
|
handleAdminTokenExpired(requestToken);
|
|||
|
|
return Promise.reject(refreshError);
|
|||
|
|
} finally {
|
|||
|
|
isRefreshing = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
handleAdminTokenExpired(requestToken);
|
|||
|
|
} else if (error.response?.status !== 403) {
|
|||
|
|
const errorMsg = error.response?.data?.message || error.message || "请求失败";
|
|||
|
|
showError(errorMsg);
|
|||
|
|
} else {
|
|||
|
|
console.error("权限不足:", error);
|
|||
|
|
}
|
|||
|
|
if (error.response?.status === 403) {
|
|||
|
|
const errorMsg = error.response?.data?.message || "权限不足";
|
|||
|
|
console.error("Admin API Permission Error:", errorMsg);
|
|||
|
|
return Promise.reject(new Error(errorMsg));
|
|||
|
|
}
|
|||
|
|
console.error("Admin API Error:", error);
|
|||
|
|
return Promise.reject(error);
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
export const adminAuthApi = {
|
|||
|
|
/**
|
|||
|
|
* `login` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: AdminLoginRequest caller-supplied value for `data: AdminLoginRequest`
|
|||
|
|
*/
|
|||
|
|
login: (data) => {
|
|||
|
|
return adminApi.post("/auth/login", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getLoginShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param account: string caller-supplied value for `account: string`
|
|||
|
|
*/
|
|||
|
|
getLoginShops: (account) => {
|
|||
|
|
return adminApi.get(`/auth/login-shops/${encodeURIComponent(account)}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `logout` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
logout: () => {
|
|||
|
|
return adminApi.post("/auth/logout");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `switchShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
switchShop: (shopId) => {
|
|||
|
|
return adminApi.post("/auth/switch-shop", { shopId });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `refreshToken` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param refreshToken: string caller-supplied value for `refreshToken: string`
|
|||
|
|
*/
|
|||
|
|
refreshToken: (refreshToken) => {
|
|||
|
|
return adminApi.post("/auth/refresh", { refreshToken });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminLegalAgreementApi = {
|
|||
|
|
list: () => adminApi.get("/legal-agreement/list"),
|
|||
|
|
create: (data) => adminApi.post("/legal-agreement/create", data),
|
|||
|
|
update: (id, data) => adminApi.put(`/legal-agreement/${id}`, data),
|
|||
|
|
publish: (id) => adminApi.put(`/legal-agreement/${id}/publish`),
|
|||
|
|
disable: (id) => adminApi.put(`/legal-agreement/${id}/disable`)
|
|||
|
|
};
|
|||
|
|
export const adminFileApi = {
|
|||
|
|
/**
|
|||
|
|
* `uploadFile` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param file: File caller-supplied value for `file: File`
|
|||
|
|
*/
|
|||
|
|
uploadFile: (file) => {
|
|||
|
|
const formData = new FormData();
|
|||
|
|
formData.append("file", file);
|
|||
|
|
return adminApi.post("/object-storage-file/upload", formData, {
|
|||
|
|
headers: {
|
|||
|
|
"Content-Type": "multipart/form-data"
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `initChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: ChunkUploadInitRequest caller-supplied value for `data: ChunkUploadInitRequest`
|
|||
|
|
*/
|
|||
|
|
initChunkUpload: (data) => {
|
|||
|
|
return adminApi.post("/object-storage-file/upload/init", data);
|
|||
|
|
},
|
|||
|
|
uploadChunk: (data, config) => {
|
|||
|
|
const formData = new FormData();
|
|||
|
|
formData.append("uploadId", data.uploadId);
|
|||
|
|
formData.append("chunkIndex", String(data.chunkIndex));
|
|||
|
|
formData.append("totalChunks", String(data.totalChunks));
|
|||
|
|
formData.append("chunk", data.chunk);
|
|||
|
|
return adminApi.post("/object-storage-file/upload/chunk", formData, {
|
|||
|
|
/**
|
|||
|
|
* Purpose: headers supports admin.ts by holding or executing the headers page or API role.
|
|||
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|||
|
|
*/
|
|||
|
|
headers: {
|
|||
|
|
"Content-Type": "multipart/form-data"
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* Purpose: signal supports admin.ts by holding or executing the signal page or API role.
|
|||
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|||
|
|
*/
|
|||
|
|
signal: config?.signal,
|
|||
|
|
/**
|
|||
|
|
* Purpose: onUploadProgress supports admin.ts by holding or executing the on upload progress page or API role.
|
|||
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|||
|
|
*/
|
|||
|
|
onUploadProgress: config?.onUploadProgress
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `completeChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param uploadId: string caller-supplied value for `uploadId: string`
|
|||
|
|
*/
|
|||
|
|
completeChunkUpload: (uploadId) => {
|
|||
|
|
return adminApi.post("/object-storage-file/upload/complete", { uploadId });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `cancelChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param uploadId: string caller-supplied value for `uploadId: string`
|
|||
|
|
*/
|
|||
|
|
cancelChunkUpload: (uploadId) => {
|
|||
|
|
return adminApi.delete(`/object-storage-file/upload/${uploadId}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getSignedUrl` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
getSignedUrl: (id) => {
|
|||
|
|
return adminApi.get(`/object-storage-file/get-signed-url/${id}`);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminTagApi = {
|
|||
|
|
/**
|
|||
|
|
* `listAllTags` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listAllTags: () => {
|
|||
|
|
return adminApi.get("/tag/list/all");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `listTagsByShopId` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId: IdType caller-supplied value for `shopId: IdType`
|
|||
|
|
*/
|
|||
|
|
listTagsByShopId: (shopId) => {
|
|||
|
|
return adminApi.get(`/tag/list/by-shop/${shopId}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }`
|
|||
|
|
*/
|
|||
|
|
createTag: (data) => {
|
|||
|
|
return adminApi.post("/tag/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }`
|
|||
|
|
*/
|
|||
|
|
updateTag: (id, data) => {
|
|||
|
|
return adminApi.put(`/tag/update/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `deleteTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
deleteTag: (id) => {
|
|||
|
|
return adminApi.delete(`/tag/delete/${id}`);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminArtistApi = {
|
|||
|
|
/**
|
|||
|
|
* `listArtists` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
listArtists: (shopId) => {
|
|||
|
|
const params = {};
|
|||
|
|
if (shopId) {
|
|||
|
|
params.shopId = shopId;
|
|||
|
|
}
|
|||
|
|
return adminApi.get("/user/list/artists", { params });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminCouponApi = {
|
|||
|
|
/**
|
|||
|
|
* `listAllCoupons` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
listAllCoupons: (shopId) => {
|
|||
|
|
const params = shopId ? { shopId } : {};
|
|||
|
|
return adminApi.get("/coupon/list/all", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
createCoupon: (data) => {
|
|||
|
|
return adminApi.post("/coupon/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
updateCoupon: (id, data) => {
|
|||
|
|
return adminApi.put(`/coupon/update/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `deleteCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
deleteCoupon: (id) => {
|
|||
|
|
return adminApi.delete(`/coupon/delete/${id}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `distributeCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
distributeCoupon: (data) => {
|
|||
|
|
return adminApi.post("/coupon/distribute", null, { params: data });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminCommentApi = {
|
|||
|
|
/**
|
|||
|
|
* `listComments` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { productId?: IdType; userId?: IdType; shopId?: IdType; keyword?: string } caller-supplied value for `params: { productId?: IdType; userId?: IdType; shopId?: IdType; keyword?: string }`
|
|||
|
|
*/
|
|||
|
|
listComments: (params) => {
|
|||
|
|
return adminApi.get("/comment/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `deleteComment` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
deleteComment: (id) => {
|
|||
|
|
return adminApi.delete(`/comment/delete/${id}`);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminProductApi = {
|
|||
|
|
/**
|
|||
|
|
* `listProducts` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { page: number; size: number; keyword?: string; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; shopId?: IdType }`
|
|||
|
|
*/
|
|||
|
|
listProducts: (params) => {
|
|||
|
|
return adminApi.get("/product/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `listAllProducts` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listAllProducts: () => {
|
|||
|
|
return adminApi.get("/product/list/all");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
createProduct: (data) => {
|
|||
|
|
return adminApi.post("/product/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
updateProduct: (id, data) => {
|
|||
|
|
return adminApi.put(`/product/update/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `deleteProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
deleteProduct: (id) => {
|
|||
|
|
return adminApi.delete(`/product/delete/${id}`);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminShopApi = {
|
|||
|
|
/**
|
|||
|
|
* `listShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { page: number; size: number; keyword?: string; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; shopId?: IdType }`
|
|||
|
|
*/
|
|||
|
|
listShops: (params) => {
|
|||
|
|
return adminApi.get("/shops/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `listAllShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listAllShops: () => {
|
|||
|
|
return adminApi.get("/shops/list/all");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: CreateShopRequest caller-supplied value for `data: CreateShopRequest`
|
|||
|
|
*/
|
|||
|
|
createShop: (data) => {
|
|||
|
|
return adminApi.post("/shops/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: CreateShopRequest caller-supplied value for `data: CreateShopRequest`
|
|||
|
|
*/
|
|||
|
|
updateShop: (id, data) => {
|
|||
|
|
return adminApi.put(`/shops/update/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateShopStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param status: number caller-supplied value for `status: number`
|
|||
|
|
*/
|
|||
|
|
updateShopStatus: (id, status) => {
|
|||
|
|
return adminApi.put(`/shops/status/${id}`, { status });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminArtistScheduleApi = {
|
|||
|
|
listSchedules: (params = {}) => {
|
|||
|
|
return adminApi.get("/artist-schedule/list", { params });
|
|||
|
|
},
|
|||
|
|
saveSchedule: (data) => {
|
|||
|
|
return adminApi.post("/artist-schedule/save", data);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminPaymentApi = {
|
|||
|
|
manualConfirmOrder: (orderId, remark) => {
|
|||
|
|
return adminApi.post(`/payment/order/${orderId}/manual-confirm`, void 0, {
|
|||
|
|
params: { remark }
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminAfterSaleApi = {
|
|||
|
|
listAfterSales: (params) => {
|
|||
|
|
return adminApi.get("/after-sale/list", { params });
|
|||
|
|
},
|
|||
|
|
approveAfterSale: (id, data) => {
|
|||
|
|
return adminApi.put(`/after-sale/${id}/approve`, data || {});
|
|||
|
|
},
|
|||
|
|
rejectAfterSale: (id, data) => {
|
|||
|
|
return adminApi.put(`/after-sale/${id}/reject`, data || {});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminInventoryApi = {
|
|||
|
|
listItems: (params) => {
|
|||
|
|
return adminApi.get("/inventory/list", { params });
|
|||
|
|
},
|
|||
|
|
saveItem: (data) => {
|
|||
|
|
return adminApi.post("/inventory/save", data);
|
|||
|
|
},
|
|||
|
|
adjustStock: (id, data) => {
|
|||
|
|
return adminApi.post(`/inventory/${id}/adjust`, data);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminCampaignApi = {
|
|||
|
|
listCampaigns: (params) => {
|
|||
|
|
return adminApi.get("/campaign/list", { params });
|
|||
|
|
},
|
|||
|
|
saveCampaign: (data) => {
|
|||
|
|
return adminApi.post("/campaign/save", data);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminUserApi = {
|
|||
|
|
// 后台用户列表支持多维筛选;页面侧应优先展示 maskedPhone/maskedEmail,
|
|||
|
|
// 避免在列表中直接暴露完整手机号或邮箱。
|
|||
|
|
/**
|
|||
|
|
* `listUsers` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean } caller-supplied value for `params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }`
|
|||
|
|
*/
|
|||
|
|
listUsers: (params) => {
|
|||
|
|
return adminApi.get("/user/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getUserStatistics` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean } caller-supplied value for `params: { keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }`
|
|||
|
|
*/
|
|||
|
|
getUserStatistics: (params) => {
|
|||
|
|
return adminApi.get("/user/statistics", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `listAllUsers` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listAllUsers: () => {
|
|||
|
|
return adminApi.get("/user/list/all");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
createUser: (data) => {
|
|||
|
|
return adminApi.post("/user/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
updateUser: (id, data) => {
|
|||
|
|
return adminApi.put(`/user/update/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `deleteUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
deleteUser: (id) => {
|
|||
|
|
return adminApi.delete(`/user/delete/${id}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `unbindUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
unbindUser: (id) => {
|
|||
|
|
return adminApi.put(`/user/unbind/${id}`, {});
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateUserStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param status: number caller-supplied value for `status: number`
|
|||
|
|
*/
|
|||
|
|
updateUserStatus: (id, status) => {
|
|||
|
|
return adminApi.put(`/user/status/${id}`, { status });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getRelationOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
getRelationOptions: (shopId) => {
|
|||
|
|
return adminApi.get(`/user/relation/options`, { params: { shopId } });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateUserRelation` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: { shopId?: IdType; parentUserId?: IdType; parentRoleType?: number; sourceType?: string } caller-supplied value for `data: { shopId?: IdType; parentUserId?: IdType; parentRoleType?: number; sourceType?: string }`
|
|||
|
|
*/
|
|||
|
|
updateUserRelation: (id, data) => {
|
|||
|
|
return adminApi.put(`/user/${id}/relation`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `resetPassword` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
resetPassword: (id) => {
|
|||
|
|
return adminApi.post(`/user/reset-password/${id}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getUserInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
getUserInfo: () => {
|
|||
|
|
return adminApi.get("/user/info");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getUserAsset` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
getUserAsset: (id) => {
|
|||
|
|
return adminApi.get(`/user/${id}/asset`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getUserBalanceHistory` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
getUserBalanceHistory: (id) => {
|
|||
|
|
return adminApi.get(`/user/${id}/balance/history`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `changeUserBalance` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: AdminUserBalanceChangeRequest caller-supplied value for `data: AdminUserBalanceChangeRequest`
|
|||
|
|
*/
|
|||
|
|
changeUserBalance: (id, data) => {
|
|||
|
|
return adminApi.post(`/user/${id}/balance/change`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `overrideUserVip` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: AdminUserVipOverrideRequest caller-supplied value for `data: AdminUserVipOverrideRequest`
|
|||
|
|
*/
|
|||
|
|
overrideUserVip: (id, data) => {
|
|||
|
|
return adminApi.post(`/user/${id}/vip/override`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `recalculateUserVip` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
recalculateUserVip: (id) => {
|
|||
|
|
return adminApi.post(`/user/${id}/vip/recalculate`);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const userApi = adminUserApi;
|
|||
|
|
export const adminOrderApi = {
|
|||
|
|
/**
|
|||
|
|
* `listOrders` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType }`
|
|||
|
|
*/
|
|||
|
|
listOrders: (params) => {
|
|||
|
|
return adminApi.get("/order/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateOrderStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param status: number caller-supplied value for `status: number`
|
|||
|
|
*/
|
|||
|
|
updateOrderStatus: (id, status) => {
|
|||
|
|
return adminApi.put(`/order/update-status/${id}`, {}, { params: { status } });
|
|||
|
|
},
|
|||
|
|
manualConfirmPayment: (id, remark) => {
|
|||
|
|
return adminPaymentApi.manualConfirmOrder(id, remark);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminDashboardApi = {
|
|||
|
|
/**
|
|||
|
|
* `getStats` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
getStats: () => {
|
|||
|
|
return adminApi.get("/dashboard/stats");
|
|||
|
|
},
|
|||
|
|
getAnalytics: () => {
|
|||
|
|
return adminApi.get("/dashboard/analytics");
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminNailArtistApi = {
|
|||
|
|
/**
|
|||
|
|
* `listNailArtists` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listNailArtists: () => {
|
|||
|
|
return adminApi.get("/nail-artist/list");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getNailArtistInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param userId: IdType caller-supplied value for `userId: IdType`
|
|||
|
|
*/
|
|||
|
|
getNailArtistInfo: (userId) => {
|
|||
|
|
return adminApi.get(`/nail-artist/get/${userId}`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `saveNailArtistInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: any caller-supplied value for `data: any`
|
|||
|
|
*/
|
|||
|
|
saveNailArtistInfo: (data) => {
|
|||
|
|
return adminApi.post("/nail-artist/save", data);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminSystemMessageApi = {
|
|||
|
|
// 消息通知会进入用户“消息通知”列表;如果 popupEnabled=1,
|
|||
|
|
// 前端展示弹窗后必须调用 mark popup-shown,保证每人每条只弹一次。
|
|||
|
|
/**
|
|||
|
|
* `listMessages` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listMessages: () => {
|
|||
|
|
return adminApi.get("/system-message/admin/list");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createMessage` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: SystemMessageCreateRequest caller-supplied value for `data: SystemMessageCreateRequest`
|
|||
|
|
*/
|
|||
|
|
createMessage: (data) => {
|
|||
|
|
return adminApi.post("/system-message/admin/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `revokeMessage` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
revokeMessage: (id) => {
|
|||
|
|
return adminApi.put(`/system-message/admin/${id}/revoke`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getTargetOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
getTargetOptions: () => {
|
|||
|
|
return adminApi.get("/system-message/admin/target-options");
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminAnnouncementApi = {
|
|||
|
|
// 公告只在首页顶部滚动显示,不写入消息已读/未读状态。
|
|||
|
|
/**
|
|||
|
|
* `listAnnouncements` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listAnnouncements: () => {
|
|||
|
|
return adminApi.get("/announcement/admin/list");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createAnnouncement` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: AnnouncementCreateRequest caller-supplied value for `data: AnnouncementCreateRequest`
|
|||
|
|
*/
|
|||
|
|
createAnnouncement: (data) => {
|
|||
|
|
return adminApi.post("/announcement/admin/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `revokeAnnouncement` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
*/
|
|||
|
|
revokeAnnouncement: (id) => {
|
|||
|
|
return adminApi.put(`/announcement/admin/${id}/revoke`);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `getTargetOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
getTargetOptions: () => {
|
|||
|
|
return adminApi.get("/announcement/admin/target-options");
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminVipRechargePlanApi = {
|
|||
|
|
/**
|
|||
|
|
* `listPlans` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
listPlans: (shopId) => {
|
|||
|
|
const params = shopId ? { shopId } : {};
|
|||
|
|
return adminApi.get("/vip-recharge-plan/admin/list", { params });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createPlan` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: VipRechargePlanRequest caller-supplied value for `data: VipRechargePlanRequest`
|
|||
|
|
*/
|
|||
|
|
createPlan: (data) => {
|
|||
|
|
return adminApi.post("/vip-recharge-plan/admin/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updatePlan` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: VipRechargePlanRequest caller-supplied value for `data: VipRechargePlanRequest`
|
|||
|
|
*/
|
|||
|
|
updatePlan: (id, data) => {
|
|||
|
|
return adminApi.put(`/vip-recharge-plan/admin/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param status: number caller-supplied value for `status: number`
|
|||
|
|
*/
|
|||
|
|
updateStatus: (id, status) => {
|
|||
|
|
return adminApi.put(`/vip-recharge-plan/admin/${id}/status`, null, { params: { status } });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `listVipLevelOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param shopId?: IdType caller-supplied value for `shopId?: IdType`
|
|||
|
|
*/
|
|||
|
|
listVipLevelOptions: (shopId) => {
|
|||
|
|
const params = shopId ? { shopId } : {};
|
|||
|
|
return adminApi.get("/vip-recharge-plan/admin/vip-level-options", { params });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminMessageHubPushConfigApi = {
|
|||
|
|
/**
|
|||
|
|
* `listConfigs` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
*/
|
|||
|
|
listConfigs: () => {
|
|||
|
|
return adminApi.get("/messagehub-push-config/admin/list");
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `createConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param data: MessageHubPushConfigRequest caller-supplied value for `data: MessageHubPushConfigRequest`
|
|||
|
|
*/
|
|||
|
|
createConfig: (data) => {
|
|||
|
|
return adminApi.post("/messagehub-push-config/admin/create", data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param data: MessageHubPushConfigRequest caller-supplied value for `data: MessageHubPushConfigRequest`
|
|||
|
|
*/
|
|||
|
|
updateConfig: (id, data) => {
|
|||
|
|
return adminApi.put(`/messagehub-push-config/admin/${id}`, data);
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `updateStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param enabled: number caller-supplied value for `enabled: number`
|
|||
|
|
*/
|
|||
|
|
updateStatus: (id, enabled) => {
|
|||
|
|
return adminApi.put(`/messagehub-push-config/admin/${id}/status`, null, { params: { enabled } });
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* `testConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|||
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|||
|
|
* @param id: IdType caller-supplied value for `id: IdType`
|
|||
|
|
* @param phone: string caller-supplied value for `phone: string`
|
|||
|
|
*/
|
|||
|
|
testConfig: (id, phone) => {
|
|||
|
|
return adminApi.post(`/messagehub-push-config/admin/${id}/test`, { phone });
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export const adminSystemParameterConfigApi = {
|
|||
|
|
listConfigs: (configGroup) => {
|
|||
|
|
return adminApi.get("/system-parameter-config/admin/list", { params: { configGroup } });
|
|||
|
|
},
|
|||
|
|
saveConfig: (data) => {
|
|||
|
|
return adminApi.post("/system-parameter-config/admin/save", data);
|
|||
|
|
},
|
|||
|
|
getTencentMapKey: () => {
|
|||
|
|
return adminApi.get("/system-parameter-config/admin/tencent-map");
|
|||
|
|
},
|
|||
|
|
getMapConfig: () => {
|
|||
|
|
return adminApi.get("/system-parameter-config/admin/map-config");
|
|||
|
|
},
|
|||
|
|
getUserDefaultPassword: () => {
|
|||
|
|
return adminApi.get("/system-parameter-config/admin/user-default-password");
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
export { adminApi };
|
|||
|
|
export default adminApi;
|
|||
|
|
|
|||
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFkbWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRnJvbnQtZW5kIEFQSSB3cmFwcGVyIGZvciB0aGlzIG1vZHVsZS5cbiAqIENhbGwgZ3VpZGU6IGltcG9ydCB0aGUgbmFtZWQgQVBJIG9iamVjdCwgdGhlbiBjYWxsIHRoZSBtYXRjaGluZyBtZXRob2QgZnJvbSBhIFZ1ZSBwYWdlIG9yIGNvbXBvc2FibGUuXG4gKi9cbmltcG9ydCBheGlvcywgeyBBeGlvc0Vycm9yLCB0eXBlIEF4aW9zUHJvZ3Jlc3NFdmVudCB9IGZyb20gJ2F4aW9zJ1xuaW1wb3J0IHsgbWVzc2FnZSB9IGZyb20gJ2FudC1kZXNpZ24tdnVlJ1xuaW1wb3J0IHsgQURNSU5fQVBJX0JBU0VfVVJMIH0gZnJvbSAnLi4vY29uZm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