2021-09-28 11:47:19 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
2021-11-24 09:59:29 +08:00
|
|
|
|
"SciencesServer/config"
|
2021-09-28 11:47:19 +08:00
|
|
|
|
"SciencesServer/utils"
|
2021-11-24 09:59:29 +08:00
|
|
|
|
"strings"
|
2021-09-28 11:47:19 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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-10-12 16:53:49 +08:00
|
|
|
|
type Local struct {
|
2021-10-13 14:41:46 +08:00
|
|
|
|
Local string `gorm:"column:local;type:varchar(8);default:null;comment:数据位置来源" json:"-"`
|
2021-10-12 16:53:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 16:25:56 +08:00
|
|
|
|
// AccountStatus 账号状态
|
|
|
|
|
type AccountStatus struct {
|
|
|
|
|
Status AccountStatusKind `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:启用,2:禁用)" json:"-"`
|
2021-09-28 11:47:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 16:25:56 +08:00
|
|
|
|
// AccountStatusKind 状态
|
|
|
|
|
type AccountStatusKind int
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// AccountStatusForEnable 启用
|
|
|
|
|
AccountStatusForEnable AccountStatusKind = iota + 1
|
|
|
|
|
// AccountStatusForDisable 禁用
|
|
|
|
|
AccountStatusForDisable
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-12 11:40:02 +08:00
|
|
|
|
// ShelfStatus 上下架状态
|
|
|
|
|
type ShelfStatus struct {
|
2021-11-26 17:26:01 +08:00
|
|
|
|
Shelf ShelfStatusKind `gorm:"column:shelf;type:tinyint(1);default:0;comment:上下架状态(1:上架,2:下架)" json:"shelf"`
|
2021-10-12 11:40:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ShelfStatusKind int
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// ShelfStatusForUp 上架
|
|
|
|
|
ShelfStatusForUp ShelfStatusKind = iota
|
|
|
|
|
// ShelfStatusForDown 下架
|
|
|
|
|
ShelfStatusForDown
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-09 17:32:23 +08:00
|
|
|
|
// ExamineStatus 审核状态
|
|
|
|
|
type ExamineStatus struct {
|
|
|
|
|
Status ExamineStatusKind `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态(0:审核中,1:审核通过,2:审核拒绝)" json:"status"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ExamineStatusKind 审核状态
|
|
|
|
|
type ExamineStatusKind int
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// ExamineStatusForOngoing 审核中
|
|
|
|
|
ExamineStatusForOngoing ExamineStatusKind = iota
|
|
|
|
|
// ExamineStatusForAgree 审核通过
|
|
|
|
|
ExamineStatusForAgree
|
|
|
|
|
// ExamineStatusForRefuse 审核拒绝
|
|
|
|
|
ExamineStatusForRefuse
|
|
|
|
|
)
|
|
|
|
|
|
2021-09-30 16:20:00 +08:00
|
|
|
|
type Area struct {
|
2021-10-13 14:41:46 +08:00
|
|
|
|
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"`
|
2021-09-30 16:20:00 +08:00
|
|
|
|
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
2021-09-28 11:47:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-24 09:59:29 +08:00
|
|
|
|
func (m *Area) FormatBasic() string {
|
|
|
|
|
address := make([]string, 0)
|
|
|
|
|
address = append(address, config.SettingAreaInfo[config.DefaultChinaAreaCode][m.Province])
|
|
|
|
|
|
|
|
|
|
if m.City != "" {
|
|
|
|
|
address = append(address, config.SettingAreaInfo[m.Province][m.City])
|
|
|
|
|
}
|
|
|
|
|
if m.District != "" {
|
|
|
|
|
address = append(address, config.SettingAreaInfo[m.City][m.District])
|
|
|
|
|
}
|
|
|
|
|
return strings.Join(address, "-")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Area) FormatDetail() string {
|
|
|
|
|
return m.FormatBasic() + ";" + m.Address
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 16:25:56 +08:00
|
|
|
|
// Position 坐标信息
|
|
|
|
|
type Position struct {
|
|
|
|
|
Longitude float64 `json:"longitude"` // 经度
|
|
|
|
|
Latitude float64 `json:"latitude"` // 纬度
|
2021-09-28 11:47:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Format 格式化
|
2021-09-29 16:25:56 +08:00
|
|
|
|
func (m *Position) Format() string {
|
2021-09-28 11:47:19 +08:00
|
|
|
|
return utils.AnyToJSON(m)
|
|
|
|
|
}
|