Zeus/handler/category.go

24 lines
417 B
Go
Raw Normal View History

2021-12-13 21:39:15 +08:00
package handler
import (
"bgm/model"
"bgm/service"
"errors"
"github.com/gofiber/fiber/v2"
"github.com/rs/xid"
"gorm.io/gorm"
)
func CreateCategoryH(ctx *fiber.Ctx) error {
i := ctx.UserContext().Value("local")
category := &model.Category{
Key: 1,
Value: "默认",
Gid: xid.New().String(),
}
if k, ok := i.(*gorm.DB); ok {
return service.CreateCategory(category, k)
}
return errors.New("")
}