49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"ArmedPolice/config"
|
|
"ArmedPolice/utils"
|
|
"strings"
|
|
)
|
|
|
|
type IDForm struct {
|
|
ID uint64 `json:"id" form:"id" binding:"required"`
|
|
}
|
|
|
|
type IDStringForm struct {
|
|
ID string `json:"id" form:"id"`
|
|
}
|
|
|
|
func (this *IDStringForm) Convert() uint64 {
|
|
if this.ID == "" || this.ID == "0" {
|
|
return 0
|
|
}
|
|
return uint64(utils.HASHIDDecode(this.ID))
|
|
}
|
|
|
|
type UIDForm struct {
|
|
UID string `json:"uid" form:"uid" binding:"required"`
|
|
}
|
|
|
|
func (this *UIDForm) Convert() uint64 {
|
|
return utils.StringToUnit64(this.UID)
|
|
}
|
|
|
|
type ImageForm struct {
|
|
Image string `json:"image" form:"image"`
|
|
}
|
|
|
|
func (this *ImageForm) FilterImageURL() string {
|
|
return strings.Replace(this.Image, config.SystemConfig[config.Domain].(string), "", -1)
|
|
}
|
|
|
|
type PositionForm struct {
|
|
Longitude float64 `json:"longitude" form:"longitude" binding:"required"`
|
|
Latitude float64 `json:"latitude" form:"latitude" binding:"required"`
|
|
}
|
|
|
|
type PageForm struct {
|
|
Page int `json:"current" form:"current" binding:"required"`
|
|
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
|
}
|