修复模版不兼容actions模式生成

迁移重复问题
This commit is contained in:
linwenxiang
2021-03-11 22:19:12 +08:00
parent dbf4b36687
commit 8a471e1db7
5 changed files with 42 additions and 17 deletions
+6
View File
@@ -4,6 +4,8 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"go-admin/common/apis"
)
type ObjectById struct {
@@ -13,13 +15,16 @@ type ObjectById struct {
func (s *ObjectById) Bind(ctx *gin.Context) error {
var err error
log := apis.GetRequestLogger(ctx)
err = ctx.ShouldBindUri(s)
if err != nil {
log.Warnf("ShouldBindUri error: %s", err.Error())
return err
}
if ctx.Request.Method == http.MethodDelete {
err = ctx.ShouldBind(&s.Ids)
if err != nil {
log.Warnf("ShouldBind error: %s", err.Error())
return err
}
if len(s.Ids) > 0 {
@@ -37,6 +42,7 @@ func (s *ObjectById) Bind(ctx *gin.Context) error {
func (s *ObjectById) GetId() interface{} {
if len(s.Ids) > 0 {
s.Ids = append(s.Ids, s.Id)
return s.Ids
}
return s.Id