mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
40 lines
606 B
Go
40 lines
606 B
Go
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
|
|
//ids := make([]int64, 0)
|
|
//var i int64
|
|
//for _, id := range s.Ids {
|
|
// i, _ = id.Int64()
|
|
// ids = append(ids, i)
|
|
//}
|
|
//return ids
|
|
}
|
|
return s.Id
|
|
}
|