核心功能: - 实现 7 级店铺层级体系(Shop 模型 + 层级校验) - 实现企业管理模型(Enterprise 模型) - 实现个人客户管理模型(PersonalCustomer 模型) - 重构 Account 模型关联关系(基于 EnterpriseID 而非 ParentID) - 完整的 Store 层和 Service 层实现 - 递归查询下级店铺功能(含 Redis 缓存) - 全面的单元测试覆盖(Shop/Enterprise/PersonalCustomer Store + Shop Service) 技术要点: - 显式指定所有 GORM 模型的数据库字段名(column: 标签) - 统一的字段命名规范(数据库用 snake_case,Go 用 PascalCase) - 完整的中文字段注释和业务逻辑说明 - 100% 测试覆盖(20+ 测试用例全部通过) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
25 lines
825 B
Go
25 lines
825 B
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Permission 权限模型
|
|
type Permission struct {
|
|
gorm.Model
|
|
BaseModel `gorm:"embedded"`
|
|
|
|
PermName string `gorm:"column:perm_name;not null;size:50" json:"perm_name"`
|
|
PermCode string `gorm:"column:perm_code;uniqueIndex:idx_permission_code,where:deleted_at IS NULL;not null;size:100" json:"perm_code"`
|
|
PermType int `gorm:"column:perm_type;not null;index" json:"perm_type"` // 1=菜单, 2=按钮
|
|
URL string `gorm:"column:url;size:255" json:"url,omitempty"`
|
|
ParentID *uint `gorm:"column:parent_id;index" json:"parent_id,omitempty"`
|
|
Sort int `gorm:"column:sort;not null;default:0" json:"sort"`
|
|
Status int `gorm:"column:status;not null;default:1" json:"status"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (Permission) TableName() string {
|
|
return "tb_permission"
|
|
}
|