jingganjiaoyu b841e63f13 opt some
2024-09-01 23:44:29 +08:00

177 lines
5.0 KiB
Go

package model
import "shylinux.com/x/mysql-story/src/db"
const (
ID = "id"
UID = "uid"
NAME = "name"
INFO = "info"
TYPE = "type"
ROLE = "role"
STATUS = "status"
TITLE = "title"
CONTENT = "content"
CREATOR = "creator"
OPERATOR = "operator"
CREATED_AT = "created_at"
UPDATED_AT = "updated_at"
DELETED_AT = "deleted_at"
USER_UID = "user_uid"
USER_NAME = "user_name"
USER_AVATAR = "user_avatar"
USER_PLACE_ROLE = "user_place_role"
PLACE_UID = "place_uid"
PLACE_NAME = "place_name"
PLACE_TYPE = "place_type"
PLACE_INIT = "place_init"
PLACE_ADDRESS = "place_address"
STREET_UID = "street_uid"
STREET_NAME = "street_name"
COMPANY_NAME = "company_name"
CITY_UID = "city_uid"
CITY_NAME = "city_name"
AUTH_UID = "auth_uid"
AUTH_NAME = "auth_name"
AUTH_TYPE = "auth_type"
AUTH_STATUS = "auth_status"
QRCODE_TYPE = "qrcode_type"
APPLY_UID = "apply_uid"
APPLY_STATUS = "apply_status"
ALLOW_UID = "allow_uid"
ALLOW_STATUS = "allow_status"
EVENT_UID = "event_uid"
COMMAND_UID = "command_uid"
MESSAGE_UID = "message_uid"
MESSAGE_STATUS = "message_status"
SERVICE_UID = "service_uid"
SERVICE_ICON = "service_icon"
SERVICE_NAME = "service_name"
SERVICE_TYPE = "service_type"
SERVICE_STATUS = "service_status"
FROM_UID = "from_uid"
FROM_USER_UID = "from_user_uid"
TO_USER_UID = "to_user_uid"
BEGIN_TIME = "begin_time"
END_TIME = "end_time"
OPEN_ID = "open_id"
EMAIL = "email"
AVATAR = "avatar"
ADDRESS = "address"
TABLES = "tables"
SCORE = "score"
NODE_NAME = "node_name"
NODENAME = "nodename"
SPACE = "space"
OPERATE = "operate"
INDEX = "index"
ARGS = "args"
INIT = "init"
)
type Sess struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
Agent string `gorm:"type:varchar(255)"`
IP string `gorm:"type:varchar(16)"`
}
type User struct {
db.ModelWithAuth
OpenID string `gorm:"type:char(32);index"`
Avatar string `gorm:"type:varchar(255)"`
Name string `gorm:"type:varchar(32)"`
Email string `gorm:"type:varchar(64)"`
}
type UserPlace struct {
db.ModelUserPlace
PlaceUID string `gorm:"type:char(32);index"`
BeginTime db.Time
EndTime db.Time
}
type Place struct {
db.ModelPlace
StreetUID string `gorm:"type:char(32);index"`
Address string `gorm:"type:varchar(255)"`
}
type Street struct {
db.ModelStreet
}
type City struct {
db.ModelWithAuth
Name string `gorm:"type:varchar(64);index"`
}
type Apply struct {
db.ModelWithUID
PlaceUID string `gorm:"type:char(32);index:idx_place"`
UserUID string `gorm:"type:char(32);index:idx_place"`
Status uint8 `gorm:default:0`
Role uint8 `gorm:default:0`
BeginTime db.Time
EndTime db.Time
}
type Allow struct {
db.ModelWithUID
ApplyUID string `gorm:"type:char(32)"`
PlaceUID string `gorm:"type:char(32);index:idx_place"`
UserUID string `gorm:"type:char(32);index:idx_place"`
Status uint8 `gorm:"default:0"`
}
type Event struct {
db.ModelCommand
CommandUID string `gorm:"type:char(32)"`
PlaceUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32)"`
Info string `gorm:"type:varchar(255)"`
}
type Message struct {
db.ModelCommand
CommandUID string `gorm:"type:char(32)"`
FromUserUID string `gorm:"type:char(32)"`
ToUserUID string `gorm:"type:char(32);index"`
Status uint `gorm:"default:0"`
Score uint `gorm:"default:0"`
}
type Recent struct {
db.ModelCommand
UserUID string `gorm:"type:char(32);index"`
ServiceUID string `gorm:"type:char(32)"`
AuthStatus uint8 `gorm:"default:0"`
Score uint8 `gorm:"default:0"`
}
type Command struct {
db.ModelWithUID
ServiceUID string `gorm:"type:char(32);index:idx_service"`
Index string `gorm:"type:varchar(64);index:idx_service"`
Name string `gorm:"type:varchar(32)"`
Icon string `gorm:"type:varchar(128)"`
}
type Service struct {
db.ModelWithUID
Icon string `gorm:"type:varchar(128)"`
Name string `gorm:"type:varchar(32)"`
Index string `gorm:"type:varchar(64)"`
Module string `gorm:"type:varchar(32)"`
Version string `gorm:"type:varchar(32)"`
Domain string `gorm:"type:varchar(255)"`
Portal string `gorm:"type:varchar(255)"`
Nodename string `gorm:"type:varchar(32)"`
Nodetype string `gorm:"type:varchar(32)"`
Pathname string `gorm:"type:varchar(255)"`
Hostname string `gorm:"type:varchar(32)"`
}
type Support struct {
db.ModelWithUID
FromUserUID string `gorm:"type:char(32);index"`
ToUserUID string `gorm:"type:char(32);index"`
Title string `gorm:"type:varchar(64)"`
Content string
}
func init() {
db.CmdModels("",
&Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, &City{},
&Apply{}, &Allow{}, &Event{}, &Message{}, &Recent{}, &Command{}, &Service{}, &Support{},
)
}