Initial commit: 商品售卖网站
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
import api from '../utils/request'
|
||||
|
||||
export const uploadApi = {
|
||||
uploadImage: (file: File) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return api.post('/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
uploadMultiple: (files: File[]) => {
|
||||
const formData = new FormData()
|
||||
files.forEach(file => formData.append('files', file))
|
||||
return api.post('/upload/multiple', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
deleteImage: (filename: string) => api.delete(`/upload/${filename}`)
|
||||
}
|
||||
|
||||
export const systemApi = {
|
||||
checkInstalled: () => api.get('/installed'),
|
||||
install: (data: any) => api.post('/install', data),
|
||||
getPublicSettings: () => api.get('/settings/public'),
|
||||
}
|
||||
|
||||
export const authApi = {
|
||||
register: (data: any) => api.post('/auth/register', data),
|
||||
login: (data: any) => api.post('/auth/login', data),
|
||||
forgotPassword: (data: any) => api.post('/auth/forgot-password', data),
|
||||
resetPassword: (data: any) => api.post('/auth/reset-password', data),
|
||||
verifyEmail: (params: any) => api.get('/auth/verify-email', { params }),
|
||||
sendVerifyCode: () => api.post('/users/send-verify-code'),
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
getProfile: () => api.get('/users/profile'),
|
||||
updateProfile: (data: any) => api.put('/users/profile', data),
|
||||
changePassword: (data: any) => api.put('/users/password', data),
|
||||
}
|
||||
|
||||
export const addressApi = {
|
||||
list: () => api.get('/users/addresses'),
|
||||
create: (data: any) => api.post('/users/addresses', data),
|
||||
update: (id: number, data: any) => api.put(`/users/addresses/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/users/addresses/${id}`),
|
||||
setDefault: (id: number) => api.put(`/users/addresses/${id}/default`),
|
||||
}
|
||||
|
||||
export const categoryApi = {
|
||||
list: () => api.get('/categories'),
|
||||
}
|
||||
|
||||
export const brandApi = {
|
||||
list: () => api.get('/brands'),
|
||||
}
|
||||
|
||||
export const productApi = {
|
||||
list: (params?: any) => api.get('/products', { params }),
|
||||
getById: (id: number) => api.get(`/products/${id}`),
|
||||
}
|
||||
|
||||
export const cartApi = {
|
||||
list: () => api.get('/cart'),
|
||||
add: (data: any) => api.post('/cart', data),
|
||||
update: (id: number, data: any) => api.put(`/cart/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/cart/${id}`),
|
||||
}
|
||||
|
||||
export const orderApi = {
|
||||
list: () => api.get('/orders'),
|
||||
getById: (id: number) => api.get(`/orders/${id}`),
|
||||
create: (data: any) => api.post('/orders', data),
|
||||
refund: (id: number, data: any) => api.post(`/orders/${id}/refund`, data),
|
||||
}
|
||||
|
||||
export const articleApi = {
|
||||
list: (params?: any) => api.get('/articles', { params }),
|
||||
getById: (id: number) => api.get(`/articles/${id}`),
|
||||
}
|
||||
|
||||
export const lotteryApi = {
|
||||
list: () => api.get('/lotteries'),
|
||||
getById: (id: number) => api.get(`/lotteries/${id}`),
|
||||
register: (id: number) => api.post(`/lotteries/${id}/register`),
|
||||
}
|
||||
|
||||
export const ticketApi = {
|
||||
list: (params?: any) => api.get('/tickets', { params }),
|
||||
create: (data: any) => api.post('/tickets', data),
|
||||
getById: (id: number) => api.get(`/tickets/${id}`),
|
||||
}
|
||||
|
||||
export const menuApi = {
|
||||
list: () => api.get('/menus'),
|
||||
}
|
||||
|
||||
export const supplierApi = {
|
||||
getOrders: () => api.get('/supplier/orders'),
|
||||
getOrderById: (id: number) => api.get(`/supplier/orders/${id}`),
|
||||
confirmOrder: (id: number) => api.put(`/supplier/orders/${id}/confirm`),
|
||||
shipOrder: (id: number, data: any) => api.put(`/supplier/orders/${id}/ship`, data),
|
||||
getInventory: () => api.get('/supplier/inventory'),
|
||||
updateInventory: (id: number, data: any) => api.put(`/supplier/inventory/${id}`, data),
|
||||
}
|
||||
|
||||
export const adminApi = {
|
||||
getCategories: () => api.get('/categories'),
|
||||
createCategory: (data: any) => api.post('/admin/categories', data),
|
||||
updateCategory: (id: number, data: any) => api.put(`/admin/categories/${id}`, data),
|
||||
deleteCategory: (id: number) => api.delete(`/admin/categories/${id}`),
|
||||
|
||||
getBrands: () => api.get('/admin/brands'),
|
||||
createBrand: (data: any) => api.post('/admin/brands', data),
|
||||
updateBrand: (id: number, data: any) => api.put(`/admin/brands/${id}`, data),
|
||||
deleteBrand: (id: number) => api.delete(`/admin/brands/${id}`),
|
||||
|
||||
getProducts: () => api.get('/admin/products'),
|
||||
createProduct: (data: any) => api.post('/admin/products', data),
|
||||
updateProduct: (id: number, data: any) => api.put(`/admin/products/${id}`, data),
|
||||
deleteProduct: (id: number) => api.delete(`/admin/products/${id}`),
|
||||
addCustomField: (id: number, data: any) => api.post(`/admin/products/${id}/custom-fields`, data),
|
||||
|
||||
getOrders: (params?: any) => api.get('/admin/orders', { params }),
|
||||
exportOrders: () => api.get('/admin/orders/export'),
|
||||
processRefund: (id: number, data: any) => api.put(`/admin/orders/${id}/refund`, data),
|
||||
|
||||
getSuppliers: () => api.get('/admin/suppliers'),
|
||||
createSupplier: (data: any) => api.post('/admin/suppliers', data),
|
||||
updateSupplier: (id: number, data: any) => api.put(`/admin/suppliers/${id}`, data),
|
||||
deleteSupplier: (id: number) => api.delete(`/admin/suppliers/${id}`),
|
||||
authorizeSupplier: (id: number, data: any) => api.post(`/admin/suppliers/${id}/authorize`, data),
|
||||
|
||||
getLotteries: () => api.get('/lotteries'),
|
||||
createLottery: (data: any) => api.post('/admin/lotteries', data),
|
||||
updateLottery: (id: number, data: any) => api.put(`/admin/lotteries/${id}`, data),
|
||||
deleteLottery: (id: number) => api.delete(`/admin/lotteries/${id}`),
|
||||
addLotteryPrize: (id: number, data: any) => api.post(`/admin/lotteries/${id}/prizes`, data),
|
||||
drawLottery: (id: number) => api.post(`/admin/lotteries/${id}/draw`),
|
||||
|
||||
getTickets: (params?: any) => api.get('/admin/tickets', { params }),
|
||||
updateTicket: (id: number, data: any) => api.put(`/admin/tickets/${id}`, data),
|
||||
assignTicket: (id: number, data: any) => api.put(`/admin/tickets/${id}/assign`, data),
|
||||
|
||||
getSettings: () => api.get('/admin/settings'),
|
||||
updateSettings: (data: any) => api.put('/admin/settings', data),
|
||||
updateSMTP: (data: any) => api.put('/admin/settings/smtp', data),
|
||||
updatePayment: (data: any) => api.put('/admin/settings/payment', data),
|
||||
|
||||
getMenus: () => api.get('/admin/menus'),
|
||||
createMenu: (data: any) => api.post('/admin/menus', data),
|
||||
updateMenu: (id: number, data: any) => api.put(`/admin/menus/${id}`, data),
|
||||
deleteMenu: (id: number) => api.delete(`/admin/menus/${id}`),
|
||||
|
||||
getInventory: () => api.get('/admin/inventory'),
|
||||
|
||||
getArticles: (params?: any) => api.get('/admin/articles', { params }),
|
||||
createArticle: (data: any) => api.post('/admin/articles', data),
|
||||
updateArticle: (id: number, data: any) => api.put(`/admin/articles/${id}`, data),
|
||||
deleteArticle: (id: number) => api.delete(`/admin/articles/${id}`),
|
||||
togglePinArticle: (id: number) => api.put(`/admin/articles/${id}/pin`),
|
||||
}
|
||||
Reference in New Issue
Block a user