Refactor super module: Move HTTP handlers to new super/v1 package

- Deleted old super.go file and moved all related HTTP handlers to new package structure under backend/app/http/super/v1.
- Updated service imports in super.go and super_test.go to reflect new DTO paths.
- Created new auth, contents, orders, tenants, and users handlers with corresponding routes and methods.
- Added new DTO definitions for authentication and content management in the super/v1/dto directory.
- Implemented new migration for content_access table and created model for it.
This commit is contained in:
2025-12-29 17:17:07 +08:00
parent bdf20fb0c6
commit 33e1921e17
18 changed files with 665 additions and 443 deletions

View File

@@ -28,7 +28,6 @@ type Routes struct {
common *Common
content *Content
creator *Creator
super *Super
tenant *Tenant
transaction *Transaction
user *User
@@ -169,109 +168,6 @@ func (r *Routes) Register(router fiber.Router) {
r.creator.UpdateSettings,
Body[dto.Settings]("form"),
))
// Register routes for controller: Super
r.log.Debugf("Registering route: Get /v1/auth/token -> super.CheckToken")
router.Get("/v1/auth/token"[len(r.Path()):], DataFunc0(
r.super.CheckToken,
))
r.log.Debugf("Registering route: Get /v1/contents -> super.ListContents")
router.Get("/v1/contents"[len(r.Path()):], DataFunc1(
r.super.ListContents,
Query[dto.SuperContentListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/orders -> super.ListOrders")
router.Get("/v1/orders"[len(r.Path()):], DataFunc1(
r.super.ListOrders,
Query[dto.SuperOrderListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/orders/:id -> super.GetOrder")
router.Get("/v1/orders/:id"[len(r.Path()):], DataFunc1(
r.super.GetOrder,
PathParam[int64]("id"),
))
r.log.Debugf("Registering route: Get /v1/orders/statistics -> super.OrderStatistics")
router.Get("/v1/orders/statistics"[len(r.Path()):], DataFunc0(
r.super.OrderStatistics,
))
r.log.Debugf("Registering route: Get /v1/tenants -> super.ListTenants")
router.Get("/v1/tenants"[len(r.Path()):], DataFunc1(
r.super.ListTenants,
Query[dto.TenantListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/tenants/:id -> super.GetTenant")
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc1(
r.super.GetTenant,
PathParam[int64]("id"),
))
r.log.Debugf("Registering route: Get /v1/tenants/statuses -> super.TenantStatuses")
router.Get("/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
r.super.TenantStatuses,
))
r.log.Debugf("Registering route: Get /v1/users -> super.ListUsers")
router.Get("/v1/users"[len(r.Path()):], DataFunc1(
r.super.ListUsers,
Query[dto.UserListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/users/:id -> super.GetUser")
router.Get("/v1/users/:id"[len(r.Path()):], DataFunc1(
r.super.GetUser,
PathParam[int64]("id"),
))
r.log.Debugf("Registering route: Get /v1/users/statistics -> super.UserStatistics")
router.Get("/v1/users/statistics"[len(r.Path()):], DataFunc0(
r.super.UserStatistics,
))
r.log.Debugf("Registering route: Get /v1/users/statuses -> super.UserStatuses")
router.Get("/v1/users/statuses"[len(r.Path()):], DataFunc0(
r.super.UserStatuses,
))
r.log.Debugf("Registering route: Patch /v1/tenants/:id -> super.UpdateTenantExpire")
router.Patch("/v1/tenants/:id"[len(r.Path()):], Func2(
r.super.UpdateTenantExpire,
PathParam[int64]("id"),
Body[dto.TenantExpireUpdateForm]("form"),
))
r.log.Debugf("Registering route: Patch /v1/tenants/:id/status -> super.UpdateTenantStatus")
router.Patch("/v1/tenants/:id/status"[len(r.Path()):], Func2(
r.super.UpdateTenantStatus,
PathParam[int64]("id"),
Body[dto.TenantStatusUpdateForm]("form"),
))
r.log.Debugf("Registering route: Patch /v1/tenants/:tenantID/contents/:contentID/status -> super.UpdateContentStatus")
router.Patch("/v1/tenants/:tenantID/contents/:contentID/status"[len(r.Path()):], Func3(
r.super.UpdateContentStatus,
PathParam[int64]("tenantID"),
PathParam[int64]("contentID"),
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
))
r.log.Debugf("Registering route: Patch /v1/users/:id/roles -> super.UpdateUserRoles")
router.Patch("/v1/users/:id/roles"[len(r.Path()):], Func2(
r.super.UpdateUserRoles,
PathParam[int64]("id"),
Body[dto.UserRolesUpdateForm]("form"),
))
r.log.Debugf("Registering route: Patch /v1/users/:id/status -> super.UpdateUserStatus")
router.Patch("/v1/users/:id/status"[len(r.Path()):], Func2(
r.super.UpdateUserStatus,
PathParam[int64]("id"),
Body[dto.UserStatusUpdateForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/auth/login -> super.Login")
router.Post("/v1/auth/login"[len(r.Path()):], DataFunc1(
r.super.Login,
Body[dto.LoginForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/orders/:id/refund -> super.RefundOrder")
router.Post("/v1/orders/:id/refund"[len(r.Path()):], Func2(
r.super.RefundOrder,
PathParam[int64]("id"),
Body[dto.SuperOrderRefundForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/tenants -> super.CreateTenant")
router.Post("/v1/tenants"[len(r.Path()):], Func1(
r.super.CreateTenant,
Body[dto.TenantCreateForm]("form"),
))
// Register routes for controller: Tenant
r.log.Debugf("Registering route: Delete /v1/tenants/:id/follow -> tenant.Unfollow")
router.Delete("/v1/tenants/:id/follow"[len(r.Path()):], Func1(