mh_goadmin_server/common/dto/generate.go

33 lines
461 B
Go
Raw Permalink Normal View History

2023-09-16 02:56:39 +00:00
package dto
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ObjectById struct {
Id int `uri:"id"`
Ids []int `json:"ids"`
}
func (s *ObjectById) Bind(ctx *gin.Context) error {
if ctx.Request.Method == http.MethodDelete {
err := ctx.Bind(s)
if err != nil {
return err
}
if len(s.Ids) > 0 {
return nil
}
}
return ctx.BindUri(s)
}
func (s *ObjectById) GetId() interface{} {
if len(s.Ids) > 0 {
return s.Ids
}
return s.Id
}