2021-10-09 11:55:54 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"SciencesServer/config"
|
|
|
|
"SciencesServer/utils"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IDForm struct {
|
|
|
|
ID uint64 `json:"id" form:"id" binding:"required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDStringForm struct {
|
2021-10-11 16:30:53 +08:00
|
|
|
ID string `json:"id" form:"id"`
|
2021-10-09 11:55:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *IDStringForm) Convert() uint64 {
|
2021-10-11 16:30:53 +08:00
|
|
|
if this.ID == "" {
|
|
|
|
return 0
|
|
|
|
}
|
2021-10-09 11:55:54 +08:00
|
|
|
return uint64(utils.HASHIDDecode(this.ID))
|
|
|
|
}
|
|
|
|
|
2022-01-10 17:43:43 +08:00
|
|
|
type TenantIDStringForm struct {
|
|
|
|
TenantID string `json:"tenant_id" form:"tenant_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *TenantIDStringForm) Convert() uint64 {
|
|
|
|
if this.TenantID == "" {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return uint64(utils.HASHIDDecode(this.TenantID))
|
|
|
|
}
|
|
|
|
|
2021-10-09 11:55:54 +08:00
|
|
|
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 {
|
2022-01-17 09:57:57 +08:00
|
|
|
return strings.Replace(this.Image, config.SystemConfig[config.SysImageDomain], "", -1)
|
2021-10-09 11:55:54 +08:00
|
|
|
}
|
|
|
|
|
2022-01-13 15:23:27 +08:00
|
|
|
type ImagesForm struct {
|
2022-01-13 16:50:38 +08:00
|
|
|
Images string `json:"images" form:"images"`
|
2022-01-13 15:23:27 +08:00
|
|
|
}
|
|
|
|
|
2022-01-13 16:50:38 +08:00
|
|
|
func (this *ImagesForm) FilterImageURL() string {
|
|
|
|
out := make([]string, 0)
|
|
|
|
|
|
|
|
for _, v := range strings.Split(this.Images, ",") {
|
2022-01-17 09:57:57 +08:00
|
|
|
out = append(out, strings.Replace(v, config.SystemConfig[config.SysImageDomain], "", -1))
|
2022-01-13 15:23:27 +08:00
|
|
|
}
|
2022-01-13 16:50:38 +08:00
|
|
|
return strings.Join(out, ",")
|
2022-01-13 15:23:27 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 13:31:33 +08:00
|
|
|
type FileForm struct {
|
|
|
|
File string `json:"file" form:"file"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *FileForm) FilterURL() string {
|
2022-01-17 09:57:57 +08:00
|
|
|
return strings.Replace(this.File, config.SystemConfig[config.SysImageDomain], "", -1)
|
2021-11-29 13:31:33 +08:00
|
|
|
}
|
|
|
|
|
2021-10-09 11:55:54 +08:00
|
|
|
type PositionForm struct {
|
|
|
|
Longitude float64 `json:"longitude" form:"longitude" binding:"required"`
|
|
|
|
Latitude float64 `json:"latitude" form:"latitude" binding:"required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PageForm struct {
|
2022-01-06 10:43:27 +08:00
|
|
|
Page int `json:"page_num" form:"page_num" binding:"required"`
|
2021-10-09 11:55:54 +08:00
|
|
|
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
|
|
|
}
|