2021-11-02 10:02:52 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
2021-11-02 16:22:07 +08:00
|
|
|
|
"ArmedPolice/config"
|
2021-11-02 10:02:52 +08:00
|
|
|
|
"ArmedPolice/utils"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Gender struct {
|
|
|
|
|
Gender GenderKind `gorm:"column:gender;type:tinyint(1);default:1;comment:性别(1:男,2:女)" json:"gender"` // 性别(1:男,2:女)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GenderKind int
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// GenderKindForMale 男性
|
|
|
|
|
GenderKindForMale GenderKind = iota + 1
|
|
|
|
|
// GenderKindForFemale 女性
|
|
|
|
|
GenderKindForFemale
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (m *Gender) GenderTitle() string {
|
|
|
|
|
if m.Gender == GenderKindForMale {
|
|
|
|
|
return "男"
|
|
|
|
|
} else if m.Gender == GenderKindForFemale {
|
|
|
|
|
return "女"
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Image 单一图片信息
|
|
|
|
|
type Image struct {
|
|
|
|
|
Image string `gorm:"column:image;type:varchar(255);default:null;comment:图片" json:"image"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Image) Analysis(domain string) string {
|
|
|
|
|
return domain + m.Image
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Images 多个图片信息
|
|
|
|
|
type Images struct {
|
|
|
|
|
Images string `gorm:"column:images;type:text;default:null;comment:图片" json:"images"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AnalysisSlice Slice解析
|
|
|
|
|
func (m *Images) AnalysisSlice(domain string) []string {
|
|
|
|
|
images := make([]string, 0)
|
|
|
|
|
utils.FromJSON(m.Images, &images)
|
|
|
|
|
|
|
|
|
|
for k, v := range images {
|
|
|
|
|
images[k] = domain + v
|
|
|
|
|
}
|
|
|
|
|
return images
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 16:22:07 +08:00
|
|
|
|
type Area struct {
|
|
|
|
|
Province string `gorm:"column:province;type:varchar(8);default:null;comment:所在省" json:"province"`
|
|
|
|
|
City string `gorm:"column:city;type:varchar(8);default:null;comment:所在市" json:"city"`
|
|
|
|
|
District string `gorm:"column:district;type:varchar(8);default:null;comment:所在区/县" json:"district"`
|
|
|
|
|
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 15:15:11 +08:00
|
|
|
|
type AreaInfo struct {
|
|
|
|
|
Province string `json:"province"`
|
|
|
|
|
City string `json:"city"`
|
|
|
|
|
District string `json:"district"`
|
|
|
|
|
Address string `json:"address"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Area) Format() *AreaInfo {
|
|
|
|
|
out := &AreaInfo{Address: m.Address}
|
2021-11-02 16:22:07 +08:00
|
|
|
|
|
2021-11-04 15:15:11 +08:00
|
|
|
|
if m.Province != "" {
|
|
|
|
|
out.Province = config.SettingAreaInfo[config.DefaultChinaAreaCode][m.Province]
|
|
|
|
|
}
|
2021-11-02 16:22:07 +08:00
|
|
|
|
if m.City != "" {
|
2021-11-04 15:15:11 +08:00
|
|
|
|
out.City = config.SettingAreaInfo[m.Province][m.City]
|
2021-11-02 16:22:07 +08:00
|
|
|
|
}
|
|
|
|
|
if m.District != "" {
|
2021-11-04 15:15:11 +08:00
|
|
|
|
out.District = config.SettingAreaInfo[m.City][m.District]
|
2021-11-02 16:22:07 +08:00
|
|
|
|
}
|
2021-11-04 15:15:11 +08:00
|
|
|
|
return out
|
2021-11-02 16:22:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 10:02:52 +08:00
|
|
|
|
// Position 坐标信息
|
|
|
|
|
type Position struct {
|
|
|
|
|
Longitude float64 `json:"longitude"` // 经度
|
|
|
|
|
Latitude float64 `json:"latitude"` // 纬度
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Format 格式化
|
|
|
|
|
func (m *Position) Format() string {
|
|
|
|
|
return utils.AnyToJSON(m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tags 标签
|
|
|
|
|
type Tags struct {
|
|
|
|
|
Key string `json:"key"`
|
|
|
|
|
Value string `json:"value"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Format 格式化
|
|
|
|
|
func (m *Tags) Format() string {
|
|
|
|
|
return utils.AnyToJSON(m)
|
|
|
|
|
}
|