package controller import ( "github.com/gofiber/fiber/v2" "matrix-middle-service/pkg/database" response "matrix-middle-service/pkg/resp" "matrix-middle-service/pkg/resp/errorx" ) func SetupBotController(r fiber.Router) { api := r.Group("/bot") api.Get("/type/list", GetBotTypeList) } // GetBotTypeList // @Summary 获取 bot 类型列表 // @Description 获取 bot 类型列表 // @Tags BotType // @Accept json // @Produce json // @Success 200 {object} response.Response{data=[]model.BotType} // @Failure default {object} errorx.CodeErrorResponse // @Router /bot/type/list [get] func GetBotTypeList(ctx *fiber.Ctx) error { return database.Exec(func(db database.DataBase) error { list, err := db.GetAllBotTypes() if err = errorx.ParseError(err); err != nil { return ctx.JSON(err) } return ctx.JSON(response.NewResponse(list)) }) }