package content import ( "github.com/gin-gonic/gin" "github.com/go-sonic/sonic/handler/content/model" "github.com/go-sonic/sonic/service" "github.com/go-sonic/sonic/template" "github.com/go-sonic/sonic/util" ) type SheetHandler struct { OptionService service.OptionService SheetService service.SheetService SheetModel *model.SheetModel } func NewSheetHandler( optionService service.OptionService, sheetService service.SheetService, sheetModel *model.SheetModel, ) *SheetHandler { return &SheetHandler{ OptionService: optionService, SheetService: sheetService, SheetModel: sheetModel, } } func (s *SheetHandler) SheetBySlug(ctx *gin.Context, model template.Model) (string, error) { slug, err := util.ParamString(ctx, "slug") if err != nil { return "", err } sheet, err := s.SheetService.GetBySlug(ctx, slug) if err != nil { return "", err } token, _ := ctx.Cookie("authentication") return s.SheetModel.Content(ctx, sheet, token, model) }