package model import ( "gorm.io/gorm" ) // BusinessUserGroup 业务用户组:平台用户的业务分类。 // 只用于店铺负责人的分组推导、筛选与批量维护,不进入登录、角色权限或数据范围判定; // 不设上级组、层级与组管理员,所属组始终由店铺当前负责人实时推导。 type BusinessUserGroup struct { gorm.Model BaseModel `gorm:"embedded"` // Code 是创建时必填的稳定编码,未删除组内唯一,创建后不可修改。 Code string `gorm:"column:code;type:varchar(64);not null;uniqueIndex:uk_business_user_group_code,where:deleted_at IS NULL;comment:创建时必填的稳定编码,创建后不可修改" json:"code"` Name string `gorm:"column:name;type:varchar(100);not null;comment:用户组名称" json:"name"` // BusinessLine 是三枚举单值,空字符串表示未设置业务线。 BusinessLine string `gorm:"column:business_line;type:varchar(20);not null;default:'';comment:所属业务线单值 standard/smart/other,空值未设置" json:"business_line"` SortOrder int64 `gorm:"column:sort_order;type:bigint;not null;default:0;comment:排序值,非负整数" json:"sort_order"` Status int `gorm:"column:status;type:smallint;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"` Remark string `gorm:"column:remark;type:varchar(500);not null;default:'';comment:备注" json:"remark"` } // TableName 指定业务用户组表名。 func (BusinessUserGroup) TableName() string { return "tb_business_user_group" } // BusinessUserGroupMember 平台用户与业务用户组的唯一归属关系。 // 一个账号至多一条未删除记录;改组直接更新组 ID,账号软删后关系保留并继续参与店铺推导。 type BusinessUserGroupMember struct { gorm.Model BaseModel `gorm:"embedded"` BusinessUserGroupID uint `gorm:"column:business_user_group_id;not null;index:idx_business_user_group_member_group,where:deleted_at IS NULL;comment:所属业务用户组ID" json:"business_user_group_id"` AccountID uint `gorm:"column:account_id;not null;uniqueIndex:uk_business_user_group_member_account,where:deleted_at IS NULL;comment:平台用户账号ID" json:"account_id"` } // TableName 指定平台用户分组关系表名。 func (BusinessUserGroupMember) TableName() string { return "tb_business_user_group_member" }