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("") }