package handler import ( "bgm/consts" bgm "bgm/helper" "bgm/model" "bgm/service" "fmt" "github.com/gofiber/fiber/v2" "github.com/rs/xid" ) func CreateCategoryH(ctx *fiber.Ctx, mysqlMap bgm.MysqlMap) error { category := &model.Category{ Key: 1, Value: "默认", Gid: xid.New().String(), } return service.CreatCategory(category, mysqlMap[consts.TestDB]) } func GetCategoryH(ctx *fiber.Ctx, mysqlMap bgm.MysqlMap) error { fmt.Println(string(ctx.Request().URI().QueryString())) page, _ := ctx.ParamsInt("page", 1) limit, _ := ctx.ParamsInt("size", 10) s := ctx.Query("query", "") queryMap := bgm.GetQueryMap(s) dto, err := service.GetCategoryDto(page, limit, queryMap, mysqlMap[consts.TestDB]) if err != nil { return ctx.JSON(model.Response{ Message: consts.ResponseFail, Data: nil, }) } else { return ctx.JSON(model.Response{ Message: consts.ResponseSuccess, Data: dto, }) } } //func GetScriptH(ctx*fiber.Ctx, mysqlMap bgm.MysqlMap) error { // page, _ := ctx.ParamsInt("page", 1) // limit, _ := ctx.ParamsInt("size", 10) // queryParam := ctx.Params("query","") // // dto, err := service.GetCategoryDto(page, limit, mysqlMap[consts.TestDB]) // if err != nil { // return ctx.JSON(model.Response{ // Message: consts.ResponseFail, // Data: nil, // }) // }else { // return ctx.JSON(model.Response{ // Message: consts.ResponseSuccess, // Data: dto, // }) // } //}