diff --git a/backend_v1/app/http/admin/auth.go b/backend_v1/app/http/admin/auth.go index 9d1c6e8..4c6b748 100644 --- a/backend_v1/app/http/admin/auth.go +++ b/backend_v1/app/http/admin/auth.go @@ -28,7 +28,7 @@ type TokenResponse struct { // @Produce json // @Param body body AuthBody true "请求体" // @Success 200 {object} TokenResponse "成功" -// @Router /admin/auth [post] +// @Router /admin/v1/auth [post] // @Bind body body func (ctl *auth) Login(ctx fiber.Ctx, body *AuthBody) (*TokenResponse, error) { if body.Username == "pl.yang" && body.Password == "Xixi@0202" { diff --git a/backend_v1/app/http/admin/medias.go b/backend_v1/app/http/admin/medias.go index 898b02f..6a8d9cc 100644 --- a/backend_v1/app/http/admin/medias.go +++ b/backend_v1/app/http/admin/medias.go @@ -8,6 +8,7 @@ import ( "quyun/v2/providers/ali" "github.com/gofiber/fiber/v3" + "go.ipao.vip/gen" ) // @provider @@ -23,11 +24,16 @@ type medias struct { // @Param pagination query requests.Pagination false "分页参数" // @Param query query ListQuery false "筛选条件" // @Success 200 {object} requests.Pager{items=models.Medium} "成功" -// @Router /admin/medias [get] +// @Router /admin/v1/medias [get] // @Bind pagination query // @Bind query query func (ctl *medias) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) { - return services.Media.List(ctx, pagination, models.MediumQuery.Name.Like(database.WrapLike(*query.Keyword))) + conds := []gen.Condition{} + if query.Keyword != nil { + conds = append(conds, models.MediumQuery.Name.Like(database.WrapLike(*query.Keyword))) + } + + return services.Media.List(ctx, pagination, conds...) } // Show media @@ -36,7 +42,7 @@ func (ctl *medias) List(ctx fiber.Ctx, pagination *requests.Pagination, query *L // @Tags Admin Medias // @Param id path int64 true "媒体 ID" // @Success 302 {string} string "跳转" -// @Router /admin/medias/:id [get] +// @Router /admin/v1/medias/:id [get] // @Bind media path key(id) model(id) func (ctl *medias) Show(ctx fiber.Ctx, media *models.Medium) error { url, err := ctl.oss.GetSignedUrl(ctx, media.Path) @@ -54,7 +60,7 @@ func (ctl *medias) Show(ctx fiber.Ctx, media *models.Medium) error { // @Produce json // @Param id path int64 true "媒体 ID" // @Success 204 {object} any "成功" -// @Router /admin/medias/:id [delete] +// @Router /admin/v1/medias/:id [delete] // @Bind media path key(id) model(id) func (ctl *medias) Delete(ctx fiber.Ctx, media *models.Medium) error { if err := ctl.oss.Delete(ctx, media.Path); err != nil { diff --git a/backend_v1/app/http/admin/orders.go b/backend_v1/app/http/admin/orders.go index 69f8757..b6a5636 100644 --- a/backend_v1/app/http/admin/orders.go +++ b/backend_v1/app/http/admin/orders.go @@ -25,7 +25,7 @@ type orders struct{} // @Param pagination query requests.Pagination false "分页参数" // @Param query query OrderListQuery false "筛选条件" // @Success 200 {object} requests.Pager{items=services.OrderListItem} "成功" -// @Router /admin/orders [get] +// @Router /admin/v1/orders [get] // @Bind pagination query // @Bind query query func (ctl *orders) List( @@ -52,7 +52,7 @@ func (ctl *orders) List( // @Produce json // @Param id path int64 true "订单 ID" // @Success 200 {object} any "成功" -// @Router /admin/orders/:id/refund [post] +// @Router /admin/v1/orders/:id/refund [post] // @Bind order path key(id) model(id) func (ctl *orders) Refund(ctx fiber.Ctx, order *models.Order) error { return services.Orders.Refund(ctx, order) diff --git a/backend_v1/app/http/admin/posts.go b/backend_v1/app/http/admin/posts.go index f0c2e2f..b88dd68 100644 --- a/backend_v1/app/http/admin/posts.go +++ b/backend_v1/app/http/admin/posts.go @@ -3,6 +3,7 @@ package admin import ( "quyun/v2/app/requests" "quyun/v2/app/services" + "quyun/v2/database" "quyun/v2/database/models" "quyun/v2/pkg/fields" @@ -27,12 +28,13 @@ type posts struct{} // @Param pagination query requests.Pagination false "分页参数" // @Param query query ListQuery false "筛选条件" // @Success 200 {object} requests.Pager{items=PostItem} "成功" -// @Router /admin/posts [get] +// @Router /admin/v1/posts [get] // @Bind pagination query // @Bind query query func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) { - conds := []gen.Condition{ - models.PostQuery.Title.Like(*query.Keyword), + conds := []gen.Condition{} + if query.Keyword != nil && *query.Keyword != "" { + conds = append(conds, models.PostQuery.Title.Like(database.WrapLike(*query.Keyword))) } pager, err := services.Posts.List(ctx, pagination, conds...) if err != nil { @@ -81,7 +83,7 @@ type PostForm struct { // @Produce json // @Param form body PostForm true "请求体" // @Success 200 {object} any "成功" -// @Router /admin/posts [post] +// @Router /admin/v1/posts [post] // @Bind form body func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error { post := models.Post{ @@ -126,7 +128,7 @@ func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error { // @Param id path int64 true "作品 ID" // @Param form body PostForm true "请求体" // @Success 200 {object} any "成功" -// @Router /admin/posts/:id [put] +// @Router /admin/v1/posts/:id [put] // @Bind post path key(id) model(id) // @Bind form body func (ctl *posts) Update(ctx fiber.Ctx, post *models.Post, form *PostForm) error { @@ -167,7 +169,7 @@ func (ctl *posts) Update(ctx fiber.Ctx, post *models.Post, form *PostForm) error // @Produce json // @Param id path int64 true "作品 ID" // @Success 204 {object} any "成功" -// @Router /admin/posts/:id [delete] +// @Router /admin/v1/posts/:id [delete] // @Bind post path key(id) model(id) func (ctl *posts) Delete(ctx fiber.Ctx, post *models.Post) error { if _, err := post.ForceDelete(ctx); err != nil { @@ -189,7 +191,7 @@ type PostItem struct { // @Produce json // @Param id path int64 true "作品 ID" // @Success 200 {object} PostItem "成功" -// @Router /admin/posts/:id [get] +// @Router /admin/v1/posts/:id [get] // @Bind post path key(id) model(id) func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post) (*PostItem, error) { medias, err := services.Media.GetByIds(ctx, lo.Map(post.Assets.Data(), func(asset fields.MediaAsset, _ int) int64 { @@ -212,7 +214,7 @@ func (ctl *posts) Show(ctx fiber.Ctx, post *models.Post) (*PostItem, error) { // @Param id path int64 true "作品 ID" // @Param userId path int64 true "用户 ID" // @Success 200 {object} any "成功" -// @Router /admin/posts/:id/send-to/:userId [post] +// @Router /admin/v1/posts/:id/send-to/:userId [post] // @Bind post path key(id) model(id) // @Bind user path key(userId) model(id) func (ctl *posts) SendTo(ctx fiber.Ctx, post *models.Post, user *models.User) error { diff --git a/backend_v1/app/http/admin/routes.gen.go b/backend_v1/app/http/admin/routes.gen.go index f49daca..227ec69 100644 --- a/backend_v1/app/http/admin/routes.gen.go +++ b/backend_v1/app/http/admin/routes.gen.go @@ -50,28 +50,28 @@ func (r *Routes) Name() string { // Each route is registered with its corresponding controller action and parameter bindings. func (r *Routes) Register(router fiber.Router) { // Register routes for controller: auth - r.log.Debugf("Registering route: Post /admin/auth -> auth.Login") - router.Post("/admin/auth"[len(r.Path()):], DataFunc1( + r.log.Debugf("Registering route: Post /admin/v1/auth -> auth.Login") + router.Post("/admin/v1/auth"[len(r.Path()):], DataFunc1( r.auth.Login, Body[AuthBody]("body"), )) // Register routes for controller: medias - r.log.Debugf("Registering route: Delete /admin/medias/:id -> medias.Delete") - router.Delete("/admin/medias/:id"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Delete /admin/v1/medias/:id -> medias.Delete") + router.Delete("/admin/v1/medias/:id"[len(r.Path()):], Func1( r.medias.Delete, func(ctx fiber.Ctx) (*models.Medium, error) { v := fiber.Params[int](ctx, "id") return models.MediumQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First() }, )) - r.log.Debugf("Registering route: Get /admin/medias -> medias.List") - router.Get("/admin/medias"[len(r.Path()):], DataFunc2( + r.log.Debugf("Registering route: Get /admin/v1/medias -> medias.List") + router.Get("/admin/v1/medias"[len(r.Path()):], DataFunc2( r.medias.List, Query[requests.Pagination]("pagination"), Query[ListQuery]("query"), )) - r.log.Debugf("Registering route: Get /admin/medias/:id -> medias.Show") - router.Get("/admin/medias/:id"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Get /admin/v1/medias/:id -> medias.Show") + router.Get("/admin/v1/medias/:id"[len(r.Path()):], Func1( r.medias.Show, func(ctx fiber.Ctx) (*models.Medium, error) { v := fiber.Params[int](ctx, "id") @@ -79,14 +79,14 @@ func (r *Routes) Register(router fiber.Router) { }, )) // Register routes for controller: orders - r.log.Debugf("Registering route: Get /admin/orders -> orders.List") - router.Get("/admin/orders"[len(r.Path()):], DataFunc2( + r.log.Debugf("Registering route: Get /admin/v1/orders -> orders.List") + router.Get("/admin/v1/orders"[len(r.Path()):], DataFunc2( r.orders.List, Query[requests.Pagination]("pagination"), Query[OrderListQuery]("query"), )) - r.log.Debugf("Registering route: Post /admin/orders/:id/refund -> orders.Refund") - router.Post("/admin/orders/:id/refund"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Post /admin/v1/orders/:id/refund -> orders.Refund") + router.Post("/admin/v1/orders/:id/refund"[len(r.Path()):], Func1( r.orders.Refund, func(ctx fiber.Ctx) (*models.Order, error) { v := fiber.Params[int](ctx, "id") @@ -94,35 +94,35 @@ func (r *Routes) Register(router fiber.Router) { }, )) // Register routes for controller: posts - r.log.Debugf("Registering route: Delete /admin/posts/:id -> posts.Delete") - router.Delete("/admin/posts/:id"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Delete /admin/v1/posts/:id -> posts.Delete") + router.Delete("/admin/v1/posts/:id"[len(r.Path()):], Func1( r.posts.Delete, func(ctx fiber.Ctx) (*models.Post, error) { v := fiber.Params[int](ctx, "id") return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First() }, )) - r.log.Debugf("Registering route: Get /admin/posts -> posts.List") - router.Get("/admin/posts"[len(r.Path()):], DataFunc2( + r.log.Debugf("Registering route: Get /admin/v1/posts -> posts.List") + router.Get("/admin/v1/posts"[len(r.Path()):], DataFunc2( r.posts.List, Query[requests.Pagination]("pagination"), Query[ListQuery]("query"), )) - r.log.Debugf("Registering route: Get /admin/posts/:id -> posts.Show") - router.Get("/admin/posts/:id"[len(r.Path()):], DataFunc1( + r.log.Debugf("Registering route: Get /admin/v1/posts/:id -> posts.Show") + router.Get("/admin/v1/posts/:id"[len(r.Path()):], DataFunc1( r.posts.Show, func(ctx fiber.Ctx) (*models.Post, error) { v := fiber.Params[int](ctx, "id") return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First() }, )) - r.log.Debugf("Registering route: Post /admin/posts -> posts.Create") - router.Post("/admin/posts"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Post /admin/v1/posts -> posts.Create") + router.Post("/admin/v1/posts"[len(r.Path()):], Func1( r.posts.Create, Body[PostForm]("form"), )) - r.log.Debugf("Registering route: Post /admin/posts/:id/send-to/:userId -> posts.SendTo") - router.Post("/admin/posts/:id/send-to/:userId"[len(r.Path()):], Func2( + r.log.Debugf("Registering route: Post /admin/v1/posts/:id/send-to/:userId -> posts.SendTo") + router.Post("/admin/v1/posts/:id/send-to/:userId"[len(r.Path()):], Func2( r.posts.SendTo, func(ctx fiber.Ctx) (*models.Post, error) { v := fiber.Params[int](ctx, "id") @@ -133,8 +133,8 @@ func (r *Routes) Register(router fiber.Router) { return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First() }, )) - r.log.Debugf("Registering route: Put /admin/posts/:id -> posts.Update") - router.Put("/admin/posts/:id"[len(r.Path()):], Func2( + r.log.Debugf("Registering route: Put /admin/v1/posts/:id -> posts.Update") + router.Put("/admin/v1/posts/:id"[len(r.Path()):], Func2( r.posts.Update, func(ctx fiber.Ctx) (*models.Post, error) { v := fiber.Params[int](ctx, "id") @@ -143,40 +143,40 @@ func (r *Routes) Register(router fiber.Router) { Body[PostForm]("form"), )) // Register routes for controller: statistics - r.log.Debugf("Registering route: Get /admin/statistics -> statistics.statistics") - router.Get("/admin/statistics"[len(r.Path()):], DataFunc0( + r.log.Debugf("Registering route: Get /admin/v1/statistics -> statistics.statistics") + router.Get("/admin/v1/statistics"[len(r.Path()):], DataFunc0( r.statistics.statistics, )) // Register routes for controller: uploads - r.log.Debugf("Registering route: Get /admin/uploads/pre-uploaded-check/:md5.:ext -> uploads.PreUploadCheck") - router.Get("/admin/uploads/pre-uploaded-check/:md5.:ext"[len(r.Path()):], DataFunc3( + r.log.Debugf("Registering route: Get /admin/v1/uploads/pre-uploaded-check/:md5.:ext -> uploads.PreUploadCheck") + router.Get("/admin/v1/uploads/pre-uploaded-check/:md5.:ext"[len(r.Path()):], DataFunc3( r.uploads.PreUploadCheck, PathParam[string]("md5"), PathParam[string]("ext"), QueryParam[string]("mime"), )) - r.log.Debugf("Registering route: Post /admin/uploads/post-uploaded-action -> uploads.PostUploadedAction") - router.Post("/admin/uploads/post-uploaded-action"[len(r.Path()):], Func1( + r.log.Debugf("Registering route: Post /admin/v1/uploads/post-uploaded-action -> uploads.PostUploadedAction") + router.Post("/admin/v1/uploads/post-uploaded-action"[len(r.Path()):], Func1( r.uploads.PostUploadedAction, Body[PostUploadedForm]("body"), )) // Register routes for controller: users - r.log.Debugf("Registering route: Get /admin/users -> users.List") - router.Get("/admin/users"[len(r.Path()):], DataFunc2( + r.log.Debugf("Registering route: Get /admin/v1/users -> users.List") + router.Get("/admin/v1/users"[len(r.Path()):], DataFunc2( r.users.List, Query[requests.Pagination]("pagination"), Query[UserListQuery]("query"), )) - r.log.Debugf("Registering route: Get /admin/users/:id -> users.Show") - router.Get("/admin/users/:id"[len(r.Path()):], DataFunc1( + r.log.Debugf("Registering route: Get /admin/v1/users/:id -> users.Show") + router.Get("/admin/v1/users/:id"[len(r.Path()):], DataFunc1( r.users.Show, func(ctx fiber.Ctx) (*models.User, error) { v := fiber.Params[int](ctx, "id") return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First() }, )) - r.log.Debugf("Registering route: Get /admin/users/:id/articles -> users.Articles") - router.Get("/admin/users/:id/articles"[len(r.Path()):], DataFunc2( + r.log.Debugf("Registering route: Get /admin/v1/users/:id/articles -> users.Articles") + router.Get("/admin/v1/users/:id/articles"[len(r.Path()):], DataFunc2( r.users.Articles, func(ctx fiber.Ctx) (*models.User, error) { v := fiber.Params[int](ctx, "id") @@ -184,8 +184,8 @@ func (r *Routes) Register(router fiber.Router) { }, Query[requests.Pagination]("pagination"), )) - r.log.Debugf("Registering route: Post /admin/users/:id/balance -> users.Balance") - router.Post("/admin/users/:id/balance"[len(r.Path()):], Func2( + r.log.Debugf("Registering route: Post /admin/v1/users/:id/balance -> users.Balance") + router.Post("/admin/v1/users/:id/balance"[len(r.Path()):], Func2( r.users.Balance, func(ctx fiber.Ctx) (*models.User, error) { v := fiber.Params[int](ctx, "id") diff --git a/backend_v1/app/http/admin/statistics.go b/backend_v1/app/http/admin/statistics.go index 9f0f42d..6312951 100644 --- a/backend_v1/app/http/admin/statistics.go +++ b/backend_v1/app/http/admin/statistics.go @@ -26,7 +26,7 @@ type StatisticsResponse struct { // @Tags Admin Statistics // @Produce json // @Success 200 {object} StatisticsResponse "成功" -// @Router /admin/statistics [get] +// @Router /admin/v1/statistics [get] func (s *statistics) statistics(ctx fiber.Ctx) (*StatisticsResponse, error) { statistics := &StatisticsResponse{} diff --git a/backend_v1/app/http/admin/uploads.go b/backend_v1/app/http/admin/uploads.go index 95ae08c..3d47c8d 100644 --- a/backend_v1/app/http/admin/uploads.go +++ b/backend_v1/app/http/admin/uploads.go @@ -41,7 +41,7 @@ type PreCheckResp struct { // @Param ext path string true "文件扩展名(不含点)" // @Param mime query string true "文件 MIME 类型" // @Success 200 {object} PreCheckResp "成功" -// @Router /admin/uploads/pre-uploaded-check/:md5.:ext [get] +// @Router /admin/v1/uploads/pre-uploaded-check/:md5.:ext [get] // @Bind md5 path // @Bind ext path // @Bind mime query @@ -74,7 +74,7 @@ type PostUploadedForm struct { // @Produce json // @Param body body PostUploadedForm true "请求体" // @Success 200 {object} any "成功" -// @Router /admin/uploads/post-uploaded-action [post] +// @Router /admin/v1/uploads/post-uploaded-action [post] // @Bind body body func (up *uploads) PostUploadedAction(ctx fiber.Ctx, body *PostUploadedForm) error { m, err := services.Media.GetByHash(ctx, body.Md5) diff --git a/backend_v1/app/http/admin/users.go b/backend_v1/app/http/admin/users.go index 623e95b..665d65a 100644 --- a/backend_v1/app/http/admin/users.go +++ b/backend_v1/app/http/admin/users.go @@ -25,7 +25,7 @@ type users struct{} // @Param pagination query requests.Pagination false "分页参数" // @Param query query UserListQuery false "筛选条件" // @Success 200 {object} requests.Pager{items=models.User} "成功" -// @Router /admin/users [get] +// @Router /admin/v1/users [get] // @Bind pagination query // @Bind query query func (ctl *users) List(ctx fiber.Ctx, pagination *requests.Pagination, query *UserListQuery) (*requests.Pager, error) { @@ -42,7 +42,7 @@ func (ctl *users) List(ctx fiber.Ctx, pagination *requests.Pagination, query *Us // @Produce json // @Param id path int64 true "用户 ID" // @Success 200 {object} models.User "成功" -// @Router /admin/users/:id [get] +// @Router /admin/v1/users/:id [get] // @Bind user path key(id) model(id) func (ctl *users) Show(ctx fiber.Ctx, user *models.User) (*models.User, error) { return user, nil @@ -56,7 +56,7 @@ func (ctl *users) Show(ctx fiber.Ctx, user *models.User) (*models.User, error) { // @Param id path int64 true "用户 ID" // @Param pagination query requests.Pagination false "分页参数" // @Success 200 {object} requests.Pager{items=models.Post} "成功" -// @Router /admin/users/:id/articles [get] +// @Router /admin/v1/users/:id/articles [get] // @Bind user path key(id) model(id) // @Bind pagination query func (ctl *users) Articles(ctx fiber.Ctx, user *models.User, pagination *requests.Pagination) (*requests.Pager, error) { @@ -76,7 +76,7 @@ type UserBalance struct { // @Param id path int64 true "用户 ID" // @Param balance body UserBalance true "请求体" // @Success 200 {object} any "成功" -// @Router /admin/users/:id/balance [post] +// @Router /admin/v1/users/:id/balance [post] // @Bind user path key(id) model(id) // @Bind balance body func (ctl *users) Balance(ctx fiber.Ctx, user *models.User, balance *UserBalance) error { diff --git a/frontend/admin/src/api/apiClient.js b/frontend/admin/src/api/apiClient.js index 2c77064..5b1ee6b 100644 --- a/frontend/admin/src/api/apiClient.js +++ b/frontend/admin/src/api/apiClient.js @@ -2,7 +2,7 @@ import axios from 'axios'; // Create a base axios instance export const apiClient = axios.create({ - baseURL: import.meta.env.VITE_API_BASE_URL || '/v1', + baseURL: import.meta.env.VITE_API_BASE_URL || '', timeout: 10000, headers: { 'Content-Type': 'application/json', diff --git a/frontend/admin/src/api/authService.js b/frontend/admin/src/api/authService.js index dcfef21..1d3962a 100644 --- a/frontend/admin/src/api/authService.js +++ b/frontend/admin/src/api/authService.js @@ -2,6 +2,6 @@ import httpClient from './httpClient'; export const authService = { login(username, password) { - return httpClient.post('/admin/auth', { username, password }); + return httpClient.post('/auth', { username, password }); }, }; diff --git a/frontend/admin/src/api/httpClient.js b/frontend/admin/src/api/httpClient.js index 7d6d83e..162cfc3 100644 --- a/frontend/admin/src/api/httpClient.js +++ b/frontend/admin/src/api/httpClient.js @@ -4,7 +4,7 @@ import axios from 'axios'; // Create axios instance with default config const httpClient = axios.create({ - baseURL: '/v1', + baseURL: '/admin/v1', timeout: 10000, headers: { 'Content-Type': 'application/json', diff --git a/frontend/admin/src/api/mediaService.js b/frontend/admin/src/api/mediaService.js index 6ffecde..7adccd6 100644 --- a/frontend/admin/src/api/mediaService.js +++ b/frontend/admin/src/api/mediaService.js @@ -2,30 +2,30 @@ import httpClient from './httpClient'; export const mediaService = { getMedias({ page = 1, limit = 10 } = {}) { - return httpClient.get('/admin/medias', { + return httpClient.get('/medias', { params: { page, limit } }); }, createMedia(mediaInfo) { - return httpClient.post('/admin/medias', mediaInfo); + return httpClient.post('/medias', mediaInfo); }, preUploadedCheck(md5, ext, mime) { - return httpClient.get(`/admin/uploads/pre-uploaded-check/${md5}.${ext}`, { + return httpClient.get(`/uploads/pre-uploaded-check/${md5}.${ext}`, { params: { mime } }); }, uploadedSuccess(data) { - return httpClient.post('/admin/uploads/post-uploaded-action', data); + return httpClient.post('/uploads/post-uploaded-action', data); }, getMediaPreviewUrl(id) { const token = localStorage.getItem('__token'); - return `${httpClient.defaults.baseURL}/admin/medias/${id}?token=${token}`; + return `${httpClient.defaults.baseURL}/medias/${id}?token=${token}`; }, delete(id) { - return httpClient.delete(`/admin/medias/${id}`); + return httpClient.delete(`/medias/${id}`); }, }; \ No newline at end of file diff --git a/frontend/admin/src/api/orderService.js b/frontend/admin/src/api/orderService.js index 78a8b7f..1b1b7a9 100644 --- a/frontend/admin/src/api/orderService.js +++ b/frontend/admin/src/api/orderService.js @@ -2,7 +2,7 @@ import httpClient from './httpClient'; export const orderService = { get({ page = 1, limit = 10, keyword = '' } = {}) { - return httpClient.get('/admin/orders', { + return httpClient.get('/orders', { params: { page, limit, @@ -11,6 +11,6 @@ export const orderService = { }); }, refund(id) { - return httpClient.post(`/admin/orders/${id}/refund`); + return httpClient.post(`/orders/${id}/refund`); } } \ No newline at end of file diff --git a/frontend/admin/src/api/postService.js b/frontend/admin/src/api/postService.js index d048da6..5189253 100644 --- a/frontend/admin/src/api/postService.js +++ b/frontend/admin/src/api/postService.js @@ -2,7 +2,7 @@ import httpClient from './httpClient'; export const postService = { getPosts({ page = 1, limit = 10, keyword = '' } = {}) { - return httpClient.get('/admin/posts', { + return httpClient.get('/posts', { params: { page, limit, @@ -11,19 +11,19 @@ export const postService = { }); }, getPost(id) { - return httpClient.get(`/admin/posts/${id}`); + return httpClient.get(`/posts/${id}`); }, createPost(post) { - return httpClient.post('/admin/posts', post); + return httpClient.post('/posts', post); }, updatePost(id, post) { - return httpClient.put(`/admin/posts/${id}`, post); + return httpClient.put(`/posts/${id}`, post); }, deletePost(id) { - return httpClient.delete(`/admin/posts/${id}`); + return httpClient.delete(`/posts/${id}`); }, sendTo(id, userId) { - return httpClient.post(`/admin/posts/${id}/send-to/${userId}`); + return httpClient.post(`/posts/${id}/send-to/${userId}`); }, } \ No newline at end of file diff --git a/frontend/admin/src/api/statisticsService.js b/frontend/admin/src/api/statisticsService.js index 84b64c7..bdb39ea 100644 --- a/frontend/admin/src/api/statisticsService.js +++ b/frontend/admin/src/api/statisticsService.js @@ -2,6 +2,6 @@ import httpClient from './httpClient'; export const statisticsService = { get() { - return httpClient.get('/admin/statistics'); + return httpClient.get('/statistics'); }, } \ No newline at end of file diff --git a/frontend/admin/src/api/userService.js b/frontend/admin/src/api/userService.js index 5f57095..8f84817 100644 --- a/frontend/admin/src/api/userService.js +++ b/frontend/admin/src/api/userService.js @@ -2,7 +2,7 @@ import httpClient from './httpClient'; export const userService = { getUsers({ page = 1, limit = 10, keyword = '' } = {}) { - return httpClient.get('/admin/users', { + return httpClient.get('/users', { params: { page, limit, @@ -11,24 +11,24 @@ export const userService = { }); }, searchUser(id) { - return httpClient.get(`/admin/users/${id}`); + return httpClient.get(`/users/${id}`); }, userBalance(id, balance) { - return httpClient.post(`/admin/users/${id}/balance`, { + return httpClient.post(`/users/${id}/balance`, { balance }); }, getUser(id) { - return httpClient.get(`/admin/users/${id}`); + return httpClient.get(`/users/${id}`); }, deleteUser(id) { - return httpClient.delete(`/admin/users/${id}`); + return httpClient.delete(`/users/${id}`); }, getUserById(id) { - return httpClient.get(`/admin/users/${id}`); + return httpClient.get(`/users/${id}`); }, getUserArticles(userId, page, limit) { - return httpClient.get(`/admin/users/${userId}/articles`, { + return httpClient.get(`/users/${userId}/articles`, { params: { page, limit, diff --git a/frontend/admin/vite.config.js b/frontend/admin/vite.config.js index bc0f015..bf5f432 100644 --- a/frontend/admin/vite.config.js +++ b/frontend/admin/vite.config.js @@ -27,11 +27,11 @@ export default defineConfig({ }, server: { host: '0.0.0.0', - allowedHosts: ['mp.jdwan.com'], + allowedHosts: ['mp.jdwan.com'], port: 3000, open: true, proxy: { - '/v1': 'http://localhost:8088', + '/admin/v1': 'http://localhost:8088', } } });