refactor🎨 api业务dto bind()、Generate()优化
This commit is contained in:
1 parent
b21f665760
commit
77c149af04
1 file changed
+1
-35
@@ -1,10 +1,6 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
|
||||||
|
|
||||||
"go-admin/app/admin/models"
|
"go-admin/app/admin/models"
|
||||||
"go-admin/common/dto"
|
"go-admin/common/dto"
|
||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
@@ -29,19 +25,6 @@ func (m *SysApiSearch) GetNeedSearch() interface{} {
|
|||||||
return *m
|
return *m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysApiSearch) Generate() dto.Index {
|
|
||||||
o := *m
|
|
||||||
return &o
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *SysApiSearch) Bind(ctx *gin.Context) error {
|
|
||||||
log := api.GetRequestLogger(ctx)
|
|
||||||
err := ctx.ShouldBind(m)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShouldBind error: %s", err.Error())
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type SysApiControl struct {
|
type SysApiControl struct {
|
||||||
Id int `uri:"id" comment:"编码"` // 编码
|
Id int `uri:"id" comment:"编码"` // 编码
|
||||||
@@ -70,6 +53,7 @@ func (s *SysApiControl) GetId() interface{} {
|
|||||||
|
|
||||||
type SysApiById struct {
|
type SysApiById struct {
|
||||||
dto.ObjectById
|
dto.ObjectById
|
||||||
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysApiById) GetId() interface{} {
|
func (s *SysApiById) GetId() interface{} {
|
||||||
@@ -80,24 +64,6 @@ func (s *SysApiById) GetId() interface{} {
|
|||||||
return s.Id
|
return s.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysApiById) Bind(ctx *gin.Context) error {
|
|
||||||
log := api.GetRequestLogger(ctx)
|
|
||||||
err := ctx.ShouldBindUri(s)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShouldBindUri error: %s", err.Error())
|
|
||||||
return errors.New("数据绑定出错")
|
|
||||||
}
|
|
||||||
err = ctx.ShouldBind(s)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShouldBind error: %s", err.Error())
|
|
||||||
err = errors.New("数据绑定出错")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysApiById) SetUpdateBy(id int) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysApiById) Generate() dto.Control {
|
func (s *SysApiById) Generate() dto.Control {
|
||||||
o := *s
|
o := *s
|
||||||
|
|||||||
Reference in new issue
Block a user