Files
kra-new/internal/server/handler/activation_pool.go
T

55 lines
1.3 KiB
Go

package handler
import (
"github.com/gin-gonic/gin"
"github.com/go-kratos/kratos/v3/errors"
"kra/internal/service/dto"
)
func (h *Activation) Pool(c *gin.Context) {
var req dto.ActivationPoolQuery
if c.ShouldBindQuery(&req) != nil {
Fail(c, "申请绑定查询参数不正确")
return
}
result, err := h.service.Pool(c.Request.Context(), &req)
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}
func (h *Activation) Options(c *gin.Context) {
result, err := h.service.Options(c.Request.Context())
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}
func (h *Activation) Apply(c *gin.Context) {
var req dto.ActivationApplyRequest
if c.ShouldBindJSON(&req) != nil {
Fail(c, "激活申请参数不正确")
return
}
if err := h.service.Apply(c.Request.Context(), &req); err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, nil)
}
func (h *Activation) Churn(c *gin.Context) {
var req dto.ActivationPoolQuery
if c.ShouldBindQuery(&req) != nil {
Fail(c, "流失记录查询参数不正确")
return
}
result, err := h.service.Churn(c.Request.Context(), &req)
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}