first commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Package model 定义领域模型。
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// MiniProgram 是被后台纳管的微信小程序配置。
|
||||
// 一个租户/运营方可在此登记多个小程序,AppID 全局唯一。
|
||||
type MiniProgram struct {
|
||||
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null" json:"name"`
|
||||
Description string `gorm:"type:varchar(512)" json:"description"`
|
||||
AppID string `gorm:"column:app_id;type:varchar(64);uniqueIndex;not null" json:"app_id"`
|
||||
AppSecret string `gorm:"column:app_secret;type:varchar(128);not null" json:"-"`
|
||||
Status int8 `gorm:"type:tinyint;not null;default:1" json:"status"`
|
||||
Ext string `gorm:"type:text" json:"ext"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (MiniProgram) TableName() string { return "mini_programs" }
|
||||
|
||||
// 小程序状态。
|
||||
const (
|
||||
MiniProgramStatusDisabled int8 = 0 // 停用
|
||||
MiniProgramStatusEnabled int8 = 1 // 启用
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
// Package model 定义领域模型。
|
||||
// common 下为跨小程序共享的物理表结构;用户数据通过 MiniID 列关联所属小程序,
|
||||
// 各小程序用户互不关联(open_id 在不同 appid 下天然互不冲突,故无需额外隔离键)。
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// User 是小程序端用户。MiniID 关联被纳管的小程序(mini_programs.id),
|
||||
// 与 open_id 共同唯一标识一个用户:(mini_id, open_id)。
|
||||
type User struct {
|
||||
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
MiniID uint64 `gorm:"column:mini_id;index:idx_mini_openid" json:"mini_id"`
|
||||
OpenID string `gorm:"type:varchar(64);index:idx_mini_openid" json:"openid"`
|
||||
UnionID string `gorm:"type:varchar(64);index" json:"union_id"`
|
||||
Nickname string `gorm:"type:varchar(128)" json:"nickname"`
|
||||
Avatar string `gorm:"type:varchar(512)" json:"avatar"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (User) TableName() string { return "users" }
|
||||
Reference in New Issue
Block a user