Files
ArmedPolice/app/api/struct.go

49 lines
1.0 KiB
Go
Raw Permalink Normal View History

2021-11-02 10:02:52 +08:00
package api
import (
"ArmedPolice/config"
"ArmedPolice/utils"
"strings"
)
2021-11-02 16:22:07 +08:00
type IDForm struct {
2021-11-02 10:02:52 +08:00
ID uint64 `json:"id" form:"id" binding:"required"`
}
2021-11-02 16:22:07 +08:00
type IDStringForm struct {
ID string `json:"id" form:"id"`
}
func (this *IDStringForm) Convert() uint64 {
2021-11-12 15:28:27 +08:00
if this.ID == "" || this.ID == "0" {
2021-11-02 16:22:07 +08:00
return 0
}
return uint64(utils.HASHIDDecode(this.ID))
}
type UIDForm struct {
2021-11-02 10:02:52 +08:00
UID string `json:"uid" form:"uid" binding:"required"`
}
2021-11-02 16:22:07 +08:00
func (this *UIDForm) Convert() uint64 {
2021-11-02 10:02:52 +08:00
return utils.StringToUnit64(this.UID)
}
2021-11-02 16:22:07 +08:00
type ImageForm struct {
2021-11-02 10:02:52 +08:00
Image string `json:"image" form:"image"`
}
2021-11-02 16:22:07 +08:00
func (this *ImageForm) FilterImageURL() string {
2021-11-19 19:11:33 +08:00
return strings.Replace(this.Image, config.SystemConfig[config.Domain].(string), "", -1)
2021-11-02 10:02:52 +08:00
}
2021-11-02 16:22:07 +08:00
type PositionForm struct {
2021-11-02 10:02:52 +08:00
Longitude float64 `json:"longitude" form:"longitude" binding:"required"`
Latitude float64 `json:"latitude" form:"latitude" binding:"required"`
}
2021-11-02 16:22:07 +08:00
type PageForm struct {
2021-11-02 10:02:52 +08:00
Page int `json:"current" form:"current" binding:"required"`
2021-11-02 16:22:07 +08:00
PageSize int `json:"page_size" form:"page_size" binding:"required"`
2021-11-02 10:02:52 +08:00
}