小程序一些功能更新
This commit is contained in:
55
internal/controller/promo.go
Normal file
55
internal/controller/promo.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
adminv1 "tool-api/api/admin/v1"
|
||||
userv1 "tool-api/api/user/v1"
|
||||
"tool-api/internal/logic"
|
||||
)
|
||||
|
||||
// ============================================================================
|
||||
// 优惠码控制器
|
||||
//
|
||||
// 拆成两个对象分别挂到 UserAuth / AdminAuth 两组:
|
||||
// - Promo 用户端(P1 /promo/validate)
|
||||
// - AdminPromo 管理端(A1–A5)
|
||||
//
|
||||
// ⚠️ 不能把同一个对象同时 Bind 到两组:group.Bind 会把该对象的**全部**方法都注册到该组,
|
||||
// 导致管理端方法暴露在用户组(或反之)。
|
||||
// ============================================================================
|
||||
|
||||
// cPromo 用户端优惠码接口(需用户登录)
|
||||
type cPromo struct{}
|
||||
|
||||
// cAdminPromo 管理端优惠码接口(需管理员登录)
|
||||
type cAdminPromo struct{}
|
||||
|
||||
var (
|
||||
Promo = &cPromo{}
|
||||
AdminPromo = &cAdminPromo{}
|
||||
)
|
||||
|
||||
func (c *cPromo) PromoValidate(ctx context.Context, req *userv1.PromoValidateReq) (res *userv1.PromoValidateRes, err error) {
|
||||
return logic.PromoValidate(ctx, req.Code, req.OrderType, req.TargetKey)
|
||||
}
|
||||
|
||||
func (c *cAdminPromo) PromoList(ctx context.Context, req *adminv1.PromoListReq) (res *adminv1.PromoListRes, err error) {
|
||||
return logic.AdminPromoList(ctx, req)
|
||||
}
|
||||
|
||||
func (c *cAdminPromo) PromoSave(ctx context.Context, req *adminv1.PromoSaveReq) (res *adminv1.PromoSaveRes, err error) {
|
||||
return logic.AdminPromoSave(ctx, req)
|
||||
}
|
||||
|
||||
func (c *cAdminPromo) PromoToggle(ctx context.Context, req *adminv1.PromoToggleReq) (res *adminv1.PromoToggleRes, err error) {
|
||||
return logic.AdminPromoToggle(ctx, req.Id, req.Status)
|
||||
}
|
||||
|
||||
func (c *cAdminPromo) PromoDelete(ctx context.Context, req *adminv1.PromoDeleteReq) (res *adminv1.PromoDeleteRes, err error) {
|
||||
return logic.AdminPromoDelete(ctx, req.Id)
|
||||
}
|
||||
|
||||
func (c *cAdminPromo) PromoUsages(ctx context.Context, req *adminv1.PromoUsagesReq) (res *adminv1.PromoUsagesRes, err error) {
|
||||
return logic.AdminPromoUsages(ctx, req)
|
||||
}
|
||||
Reference in New Issue
Block a user