mirror of https://github.com/go-sonic/sonic.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
981 B
Go
42 lines
981 B
Go
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)
|
|
}
|