feat: add superadmin member review and coupon ops
This commit is contained in:
@@ -2,8 +2,10 @@ package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
v1_dto "quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
@@ -26,3 +28,81 @@ type coupons struct{}
|
||||
func (c *coupons) List(ctx fiber.Ctx, filter *dto.SuperCouponListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListCoupons(ctx, filter)
|
||||
}
|
||||
|
||||
// Create coupon
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/coupons [post]
|
||||
// @Summary Create coupon
|
||||
// @Description Create coupon for tenant
|
||||
// @Tags Coupon
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param form body v1_dto.CouponCreateForm true "Create form"
|
||||
// @Success 200 {object} v1_dto.CouponItem
|
||||
// @Bind tenantID path
|
||||
// @Bind form body
|
||||
// @Bind user local key(__ctx_user)
|
||||
func (c *coupons) Create(ctx fiber.Ctx, user *models.User, tenantID int64, form *v1_dto.CouponCreateForm) (*v1_dto.CouponItem, error) {
|
||||
return services.Coupon.Create(ctx, tenantID, user.ID, form)
|
||||
}
|
||||
|
||||
// Get coupon
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/coupons/:id<int> [get]
|
||||
// @Summary Get coupon
|
||||
// @Description Get coupon detail
|
||||
// @Tags Coupon
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Success 200 {object} v1_dto.CouponItem
|
||||
// @Bind tenantID path
|
||||
// @Bind id path
|
||||
func (c *coupons) Get(ctx fiber.Ctx, tenantID, id int64) (*v1_dto.CouponItem, error) {
|
||||
return services.Coupon.Get(ctx, tenantID, id)
|
||||
}
|
||||
|
||||
// Update coupon
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/coupons/:id<int> [put]
|
||||
// @Summary Update coupon
|
||||
// @Description Update coupon for tenant
|
||||
// @Tags Coupon
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Param form body v1_dto.CouponUpdateForm true "Update form"
|
||||
// @Success 200 {object} v1_dto.CouponItem
|
||||
// @Bind tenantID path
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
// @Bind user local key(__ctx_user)
|
||||
func (c *coupons) Update(ctx fiber.Ctx, user *models.User, tenantID, id int64, form *v1_dto.CouponUpdateForm) (*v1_dto.CouponItem, error) {
|
||||
return services.Coupon.Update(ctx, tenantID, user.ID, id, form)
|
||||
}
|
||||
|
||||
// Grant coupon
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/coupons/:id<int>/grant [post]
|
||||
// @Summary Grant coupon
|
||||
// @Description Grant coupon to users
|
||||
// @Tags Coupon
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Param form body v1_dto.CouponGrantForm true "Grant form"
|
||||
// @Success 200 {object} dto.SuperCouponGrantResponse
|
||||
// @Bind tenantID path
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *coupons) Grant(ctx fiber.Ctx, tenantID, id int64, form *v1_dto.CouponGrantForm) (*dto.SuperCouponGrantResponse, error) {
|
||||
granted, err := services.Coupon.Grant(ctx, tenantID, id, form.UserIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dto.SuperCouponGrantResponse{Granted: granted}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user