feat: add superadmin member review and coupon ops

This commit is contained in:
2026-01-15 11:53:52 +08:00
parent 56082bad4f
commit 8419ddede7
11 changed files with 1254 additions and 96 deletions

View File

@@ -6,6 +6,7 @@ package v1
import (
dto "quyun/v2/app/http/super/v1/dto"
v1_dto "quyun/v2/app/http/v1/dto"
"quyun/v2/app/middlewares"
"quyun/v2/database/models"
@@ -87,6 +88,34 @@ func (r *Routes) Register(router fiber.Router) {
r.coupons.List,
Query[dto.SuperCouponListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/coupons/:id<int> -> coupons.Get")
router.Get("/super/v1/tenants/:tenantID<int>/coupons/:id<int>"[len(r.Path()):], DataFunc2(
r.coupons.Get,
PathParam[int64]("tenantID"),
PathParam[int64]("id"),
))
r.log.Debugf("Registering route: Post /super/v1/tenants/:tenantID<int>/coupons -> coupons.Create")
router.Post("/super/v1/tenants/:tenantID<int>/coupons"[len(r.Path()):], DataFunc3(
r.coupons.Create,
Local[*models.User]("__ctx_user"),
PathParam[int64]("tenantID"),
Body[v1_dto.CouponCreateForm]("form"),
))
r.log.Debugf("Registering route: Post /super/v1/tenants/:tenantID<int>/coupons/:id<int>/grant -> coupons.Grant")
router.Post("/super/v1/tenants/:tenantID<int>/coupons/:id<int>/grant"[len(r.Path()):], DataFunc3(
r.coupons.Grant,
PathParam[int64]("tenantID"),
PathParam[int64]("id"),
Body[v1_dto.CouponGrantForm]("form"),
))
r.log.Debugf("Registering route: Put /super/v1/tenants/:tenantID<int>/coupons/:id<int> -> coupons.Update")
router.Put("/super/v1/tenants/:tenantID<int>/coupons/:id<int>"[len(r.Path()):], DataFunc4(
r.coupons.Update,
Local[*models.User]("__ctx_user"),
PathParam[int64]("tenantID"),
PathParam[int64]("id"),
Body[v1_dto.CouponUpdateForm]("form"),
))
// Register routes for controller: creators
r.log.Debugf("Registering route: Get /super/v1/creators -> creators.List")
router.Get("/super/v1/creators"[len(r.Path()):], DataFunc1(
@@ -126,6 +155,11 @@ func (r *Routes) Register(router fiber.Router) {
Body[dto.SuperReportExportForm]("form"),
))
// Register routes for controller: tenants
r.log.Debugf("Registering route: Get /super/v1/tenant-join-requests -> tenants.ListJoinRequests")
router.Get("/super/v1/tenant-join-requests"[len(r.Path()):], DataFunc1(
r.tenants.ListJoinRequests,
Query[dto.SuperTenantJoinRequestListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /super/v1/tenants -> tenants.List")
router.Get("/super/v1/tenants"[len(r.Path()):], DataFunc1(
r.tenants.List,
@@ -163,11 +197,24 @@ func (r *Routes) Register(router fiber.Router) {
PathParam[int64]("id"),
Body[dto.TenantStatusUpdateForm]("form"),
))
r.log.Debugf("Registering route: Post /super/v1/tenant-join-requests/:id<int>/review -> tenants.ReviewJoinRequest")
router.Post("/super/v1/tenant-join-requests/:id<int>/review"[len(r.Path()):], Func3(
r.tenants.ReviewJoinRequest,
Local[*models.User]("__ctx_user"),
PathParam[int64]("id"),
Body[v1_dto.TenantJoinReviewForm]("form"),
))
r.log.Debugf("Registering route: Post /super/v1/tenants -> tenants.Create")
router.Post("/super/v1/tenants"[len(r.Path()):], Func1(
r.tenants.Create,
Body[dto.TenantCreateForm]("form"),
))
r.log.Debugf("Registering route: Post /super/v1/tenants/:tenantID<int>/invites -> tenants.CreateInvite")
router.Post("/super/v1/tenants/:tenantID<int>/invites"[len(r.Path()):], DataFunc2(
r.tenants.CreateInvite,
PathParam[int64]("tenantID"),
Body[v1_dto.TenantInviteCreateForm]("form"),
))
// Register routes for controller: users
r.log.Debugf("Registering route: Get /super/v1/users -> users.List")
router.Get("/super/v1/users"[len(r.Path()):], DataFunc1(