package handler import ( "github.com/gin-gonic/gin" "github.com/go-kratos/kratos/v3/errors" businessbiz "kra/internal/biz/business" "kra/internal/service/business" "kra/internal/service/dto" ) type Workbench struct{ service *business.WorkbenchService } func NewWorkbench(service *business.WorkbenchService) *Workbench { return &Workbench{service: service} } func (h *Workbench) Summary(c *gin.Context) { var req dto.WorkbenchQuery if c.ShouldBindQuery(&req) != nil { Fail(c, "工作台查询参数不正确") return } data, err := h.service.Summary(c.Request.Context(), &req) if err != nil { Fail(c, errors.FromError(err).Message) return } OKWithData(c, data) } func (h *Workbench) ranks(c *gin.Context, kind businessbiz.WorkbenchRankKind) { var req dto.WorkbenchQuery if c.ShouldBindQuery(&req) != nil { Fail(c, "工作台查询参数不正确") return } data, err := h.service.Ranks(c.Request.Context(), &req, kind) if err != nil { Fail(c, errors.FromError(err).Message) return } OKWithData(c, data) } func (h *Workbench) RegisterTop(c *gin.Context) { h.ranks(c, businessbiz.WorkbenchRegister) } func (h *Workbench) PayRank(c *gin.Context) { h.ranks(c, businessbiz.WorkbenchPayHigh) } func (h *Workbench) UnloginTop(c *gin.Context) { h.ranks(c, businessbiz.WorkbenchUnlogin) }