12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package handler
- import (
- "github.com/gin-gonic/gin"
- v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
- "github.com/go-nunu/nunu-layout-advanced/internal/service"
- "net/http"
- )
- type CcHandler struct {
- *Handler
- ccService service.CcService
- }
- func NewCcHandler(
- handler *Handler,
- ccService service.CcService,
- ) *CcHandler {
- return &CcHandler{
- Handler: handler,
- ccService: ccService,
- }
- }
- func (h *CcHandler) GetCcList(ctx *gin.Context) {
- var req v1.CCListRequest
- if err := ctx.ShouldBind(&req); err != nil {
- v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
- return
- }
- resp, err := h.ccService.GetCcList(ctx, req)
- if err != nil {
- v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
- return
- }
- v1.HandleSuccess(ctx, resp)
- }
- func (h *CcHandler) EditCcState(ctx *gin.Context) {
- var req v1.CCStateRequest
- if err := ctx.ShouldBind(&req); err != nil {
- v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
- return
- }
- err := h.ccService.EditCcState(ctx, req)
- if err != nil {
- v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
- return
- }
- v1.HandleSuccess(ctx, nil)
- }
|