mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 08:20:25 +08:00
refactor: interface{} -> any
feat: 新增外链菜单
This commit is contained in:
@@ -13,14 +13,14 @@ import (
|
||||
)
|
||||
|
||||
// 绑定并校验请求结构体参数
|
||||
func BindJsonAndValid(g *gin.Context, data interface{}) {
|
||||
func BindJsonAndValid(g *gin.Context, data any) {
|
||||
if err := g.ShouldBindJSON(data); err != nil {
|
||||
panic(biz.NewBizErr(err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定查询字符串到
|
||||
func BindQuery(g *gin.Context, data interface{}) {
|
||||
func BindQuery(g *gin.Context, data any) {
|
||||
if err := g.ShouldBindQuery(data); err != nil {
|
||||
panic(biz.NewBizErr(err.Error()))
|
||||
}
|
||||
@@ -65,12 +65,12 @@ func Download(g *gin.Context, reader io.Reader, filename string) {
|
||||
}
|
||||
|
||||
// 返回统一成功结果
|
||||
func SuccessRes(g *gin.Context, data interface{}) {
|
||||
func SuccessRes(g *gin.Context, data any) {
|
||||
g.JSON(http.StatusOK, model.Success(data))
|
||||
}
|
||||
|
||||
// 返回失败结果集
|
||||
func ErrorRes(g *gin.Context, err interface{}) {
|
||||
func ErrorRes(g *gin.Context, err any) {
|
||||
switch t := err.(type) {
|
||||
case biz.BizError:
|
||||
g.JSON(http.StatusOK, model.Error(t))
|
||||
|
||||
Reference in New Issue
Block a user