refactor🎨: 简化数据绑定

This commit is contained in:
zhangwenjian committed 2021-06-07 16:39:59 +08:00
1 parent 190dcfedc0
commit 3be02f1364
6 files changed
+3 -154

No files matched your search

-27
View File
@@ -4,9 +4,6 @@ import (
"go-admin/app/admin/models"
common "go-admin/common/models"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
"go-admin/common/dto"
)
@@ -25,16 +22,6 @@ func (m *SysPostSearch) GetNeedSearch() interface{} {
return *m
}
// Bind 映射上下文中的结构体数据
func (m *SysPostSearch) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
// SysPostControl 增、改使用的结构体
type SysPostControl struct {
PostId int `uri:"id" comment:"id"` // id
@@ -93,20 +80,6 @@ func (s *SysPostById) GetId() interface{} {
return s.Id
}
func (s *SysPostById) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("ShouldBindUri error: %s", err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (s *SysPostById) GenerateM() (*models.SysPost, error) {
return &models.SysPost{}, nil
}