20 KiB
For AI assistants: Read this entire file before writing any code. All decisions here are final. Do not suggest alternatives unless asked.
Fonrey — 统一枚举字典(ENUMS)
定位:本文件是 Fonrey 全局枚举标准(Public + Tenant)的统一实现基线。
版本:v2.2
日期:2026-04-28
适用范围:DATA_MODEL_PUBLIC.md、DATA_MODEL_LOGIN.md、DATA_MODEL_ORG.md、DATA_MODEL_COMPLEX.md、DATA_MODEL_PROPERTY.md、DATA_MODEL_CLIENT.md、DATA_MODEL_PERMISSION.md、DATA_MODEL_SETTING.md
⚠️ 枚举值命名规范:所有枚举值统一使用
lower_snake_case(全小写+下划线)。
历史遗留大写值(SUCCESS/FAILED、BOOLEAN/SCOPE/INTEGER、REPLACE/RESTRICT/GRANT、A_urgent/A_app/B_schema/C_feature)在 v2.2 中已统一迁移为小写。
DBCHECK约束、enum_labels种子数据、前端代码须同步更新为新值;迁移脚本须包含历史数据 UPDATE。
一、枚举分层标准(必须遵守)
Fonrey 采用两层枚举体系:
-
固定枚举(Fixed Enum)
- 值域固定,受
CHECK或强业务约束保护 - 作为系统契约,不能随意改值
- 可落地到
public.enum_labels(用于统一标签)
- 值域固定,受
-
可配置枚举(Configurable Enum)
- 值域由租户自行维护
- 存储在 Tenant Schema:
lookup_groups+lookup_items - 禁止对业务表字段加固定
CHECK IN (...)
二、全局固定枚举(Public / 平台级)
2.1 tenant 生命周期
domain: public.tenant.plan
basic:基础版professional:专业版enterprise:企业版
domain: public.tenant.status
creating:创建中active:正常suspended:已挂起pending_delete:待删除deleted:已删除failed:创建/初始化失败
domain: public.tenant.suspended_reason
overdue:欠费violation:违规requested:客户申请other:其他
2.2 平台管理员
domain: public.platform_admin.role
super_admin:超级管理员ops_operator:运营管理员read_only_auditor:只读审计员
2.3 平台审计与备份导出
domain: public.platform_audit.result
success:成功failed:失败
domain: public.backup_schedule.frequency
hourly:每小时daily:每日weekly:每周
domain: public.backup_schedule.storage_target
local:本地存储s3:Amazon S3r2:Cloudflare R2gcs:Google Cloud Storage
domain: public.backup_record.trigger_type
auto:自动触发manual:手动触发pre_upgrade:升级前触发pre_restore:恢复前触发
domain: public.backup_record.status
pending:待执行in_progress:执行中success:成功failed:失败
domain: public.export_task.format
csv:CSVjson:JSONsql_dump:SQL 导出
domain: public.export_task.status
pending:待执行in_progress:执行中success:成功(语义等价原done,与backup_record.status对齐)failed:失败
2.4 升级与发布(Public)
domain: public.upgrade_event.event_type
upgrade:升级rollback:回滚
domain: public.upgrade_event.upgrade_type
app:A类-应用升级(原A_app)schema:B类-数据库结构升级(原B_schema)feature:C类-功能开关升级(原C_feature)
domain: public.upgrade_event.strategy
full:全量发布canary:灰度发布
domain: public.upgrade_event.status
draft:草稿pre_check:预检查pre_backup:预备份batch_running:批次执行中batch_done:批次完成halted:已暂停succeeded:已成功failed:失败rollback_running:回滚中rolled_back:已回滚
domain: public.upgrade_event.failure_policy
halt_batch:失败即停止批次continue:失败继续
domain: public.client_release.platform
win32:Windows 客户端
domain: public.client_release.arch
x64:x64 架构arm64:ARM64 架构
domain: public.client_release.release_type
normal:普通更新force:强制更新
domain: public.client_release.status
draft:草稿published:已发布archived:已归档
三、Tenant 固定枚举(模块级,值域统一)
说明:以下字段在 Tenant Schema 中存储,但值域为系统统一标准,属于“全局实现标准”。
3.1 登录认证(account/login)
domain: login.user_account.status
active:启用disabled:停用locked:锁定
domain: login.login_attempt.failure_reason
wrong_password:用户名或密码错误wrong_captcha:验证码错误account_locked:账号锁定account_disabled:账号停用tenant_not_found:租户不存在
3.2 组织人事(org)
domain: org.org_unit.type
company:公司division:事业部region:大区area:区域district:片区store:门店group:店组functional:职能部门
domain: org.org_unit.attribute
direct:直营franchise:加盟
domain: org.staff.role
agent:经纪人store_manager:店长area_manager:区域经理admin:系统管理员operator:运营/行政system:系统账号
domain: org.staff.status
active:在职probation:试用resigned:离职frozen:冻结
domain: org.staff_personal_info.gender
male:男female:女unknown:未知
domain: org.staff_personal_info.id_type
id_card:身份证passport:护照other:其他
domain: org.staff_transfer.transfer_type
onboard:入职transfer:调动resign:离职rejoin:复职supervisor_change:上级变更role_change:角色变更freeze:冻结账号unfreeze:恢复账号
domain: org.staff_account.platform
fonrey:房睿主账号58anjuke:58安居客cnreic:中国网络经纪人wechat_mp:微信公众号
3.3 权限系统(permission)
domain: permission.module
home:首页property:房源new_house:新房client:客源transaction:交易data:数据marketing:营销hr:人事OAcontract:合同trinet:三网system:系统mobile:移动端smart_store:智能门店recharge:在线充值
domain: permission.value_type
boolean:开关型(原BOOLEAN)scope:范围型(原SCOPE)integer:数值型(原INTEGER)
domain: permission.role_category
agent:置业顾问store_manager:店管director:总经operator:运营/行政custom:自定义
domain: permission.scope_level
none:无self:本人group:本组store:本门店area:本区域region:本大区company:全公司
domain: permission.override_mode
replace:覆盖(原REPLACE)restrict:限制(原RESTRICT)grant:授予(原GRANT)
domain: permission.data_scope_type
self:本人group:本组store:本门店area:本区域region:本大区company:全公司custom_unit:自定义组织单元
domain: permission.change_log.target_type
role:角色role_permission:角色权限staff_role:员工角色staff_override:员工权限覆盖staff_scope:员工数据范围
domain: permission.change_log.action
create:创建update:更新delete:删除assign:分配revoke:撤销
3.4 楼盘区域(complex)
domain: complex.school.type
primary:小学middle:初中high:高中k9:九年一贯制k12:十二年一贯制
domain: complex.school.nature
public:公立private:私立international:国际
domain: complex.school.level
normal:普通key:重点top:名校
domain: complex.building_type
slab:板楼tower:塔楼slab_tower:板塔结合
domain: complex.water_type
civil:民水commercial:商水
domain: complex.electricity_type
civil:民电commercial:商电
domain: complex.school_zone_type
guaranteed:对口reference:参考lottery:摇号
domain: complex.photo.category
complex:楼盘图layout:户型图vr:VR图other:其他
3.5 房源(property)
domain: property.property_type
residential:住宅villa:别墅commercial_residential:商住shop:商铺office:写字楼other:其他
domain: property.status
for_sale:出售for_rent:出租for_sale_rent:租售suspended:暂缓sold_elsewhere:他售rented_elsewhere:他租sold:成交unlisted:未挂牌
domain: property.attribute
public:公盘private:私盘special:特盘sealed:封盘
domain: property.orientation
east:东south:南west:西north:北southeast:东南northeast:东北east_west:东西south_north:南北northwest:西北southwest:西南
domain: property.decoration
rough:毛坯plain:清水simple:简装medium:中装fine:精装luxury:豪装
domain: property.house_status
owner_occupied:业主自住vacant:空置tenant_occupied:租客在住unknown:未知
domain: property.viewing_time
anytime:随时看房by_appointment:预约看房inconvenient:不便看房
domain: property.grade
a:A(急迫)b:B(较强)c:C(一般)d:D(较弱)
domain: property.contact.gender
male:先生female:女士
domain: property.contact.identity
owner:业主contact:联系人subletter:转租人tenant:租客agent:代理人corporate:企业法人
domain: property.listing_history.listing_type
for_sale:出售挂牌for_rent:出租挂牌
domain: property.listing_history.status
active:生效中ended:已结束
domain: property.follow_log.log_type
written:手写跟进modified:修改跟进sensitive_op:敏感操作sensitive_view:敏感查看other:其他system:系统
domain: property.follow_log.ai_tag
ai_for_sale:AI判断可售ai_not_for_sale:AI判断不可售
domain: property.follow_attachment.file_type
bmp:BMPjpg:JPGpng:PNGsvg:SVGgif:GIF
domain: property.key.key_type
mechanical:机械钥匙password:密码钥匙
domain: property.commission.owner_type
owner:产权人本人authorized_third:授权第三方
domain: property.commission.status
active:有效expired:过期cancelled:取消
domain: property.commission_attachment.category
id_card:身份证件property_cert:产权证明commission_letter:委托书other:其他
domain: property.field_survey.status
draft:草稿submitted:已提交
domain: property.survey_photo.category
layout:户型图living_room:客厅dining_room:餐厅bedroom:卧室bathroom:卫生间kitchen:厨房entrance:入户balcony:阳台study:书房indoor_other:室内其他outdoor:室外
domain: property.photo.category
cover:封面entrance:入户living_room:客厅dining_room:餐厅bedroom:卧室bathroom:卫生间kitchen:厨房balcony:阳台study:书房indoor_other:室内其他outdoor:室外panorama:全景
domain: property.attachment.category
id_card:身份证件property_cert:产权证明commission_letter:委托书other:其他
domain: property.number_holder_approval.status
pending:待审批approved:已通过rejected:已驳回
3.6 客源(client)
domain: client.client_type
private:私客public:公客transacted:成交客
domain: client.status
buying:求购renting:求租buy_or_rent:租购suspended:暂缓bought:已购rented_done:已租public:公客invalid:无效
⚠️ 合法组合约束(
client_type×client.status)
client_type表示客源的"身份类别",status表示客源的"当前业务状态",两者是不同维度。
合法组合矩阵如下:
client_type允许的 status值禁止的 status值private(私客)buying/renting/buy_or_rent/suspended/invalidpublic、bought、rented_done(未成交不可用终态)public(公客)public/buying/renting/buy_or_rent/suspended/invalidbought、rented_donetransacted(成交客)bought/rented_done其他所有值(终态不可逆) 实施要求:
- 服务层(
ClientService)在状态变更时必须校验组合合法性- DB 侧可用触发器或
CHECK约束覆盖最关键禁止项(如transacted+ 非终态)private → public转换须调用专用方法transfer_to_public(),同时修改client_type和status
domain: client.grade
A:A(急迫)B:B(较强)C:C(一般)D:D(较弱)E:E(暂不关注)
domain: client.property_usage
residential:住宅villa:别墅commercial_residential:商住shop:商铺office:写字楼other:其他
domain: client.buying_purpose
rigid:刚需investment:投资school_district:学区upgrade:改善commercial:商用other:其他
domain: client.payment_method
full:全额mortgage:商业贷款mortgage_fund:商贷+公积金fund:公积金
domain: client.properties_owned
none:无local_none:本地无/外地有local_has:本地有
domain: client.id_type
id_card:身份证passport:护照hk_macao:港澳通行证other:其他
domain: client.transfer_to_public_type
manual:手动转公auto:自动转公marketing_jump:营销客跳公resource_public:资料客素公
domain: client.invalid_reason
invalid_phone:号码无效peer_agent:同行ad:广告推销no_intent:无意向other:其他
domain: client.transacted_type
bought:我购rented:我租
domain: client.transacted_property_type
second_hand:二手new_house:新房
domain: client.activity_level
new_matched:新配对active_7d:7日活跃active_30d:30日活跃active_90d:90日活跃expiring:即将过期frozen:暂缓中invalid:无效
domain: client.contact.gender
male:先生female:女士
domain: client.requirement_type
second_hand:二手new_house:新房rental:租房
domain: client.floor_preference
no_first:不要一楼low:低楼层mid:中楼层high:高楼层no_top:不要顶楼
domain: client.orientation
east:东south:南west:西north:北
domain: client.decoration
rough:毛坯plain:清水simple:简装medium:中装fine:精装luxury:豪装
domain: client.building_age_range
within_5y:5年内5_10y:5-10年10_15y:10-15年15_20y:15-20年over_20y:20年以上
domain: client.follow_log.log_type
written:写入跟进modified:修改跟进sensitive_view:敏感查看other:其他system:系统
domain: client.viewing.viewing_type
appointment:预约viewing:带看revisit:复看empty:空看
domain: client.viewing.client_intent
interested:感兴趣not_interested:不感兴趣negotiating:谈判中cancelled:取消
domain: client.property_match.match_source
recorded:录客配房system:系统配房
domain: client.property_match.match_group
quality_layout:优质户型price_reduced:降价hot:热门newly_listed:新上
domain: client.property_match.status
suggested:待推送shared:已分享rejected:已反馈不合适viewed:客户已查看
domain: client.status_log.change_type
status_change:改状态grade_change:改等级to_public:转公客to_transacted:转成交to_invalid:转无效owner_change:改归属人source_change:改来源merge:合并客源
3.7 系统配置(setting)
domain: setting.tenant_setting.value_type
bool:布尔int:整数string:字符串enum:枚举
domain: setting.field_rule.module
property:房源client:客源(预留)
domain: setting.field_rule.entity_type(与 property.property_type 对齐)
residential:住宅villa:别墅commercial_residential:商住shop:商铺office:写字楼other:其他
domain: setting.field_rule.trade_status
sale:出售rent:出租sale_rent:租售all:全部(原设计为*,因 SQL/URL/权限表达式通配误解风险已统一改为all;DB CHECK 约束、前端筛选器须同步)
domain: setting.field_rule.requirement
required:必填optional:选填hidden:隐藏
四、Tenant 可配置枚举字段清单(lookup_items 权威)
以下字段值域由
lookup_items维护,属于租户级配置,不在业务表中写死CHECK。
| domain(统一命名) | 对应字段 | 当前状态 | 说明 |
|---|---|---|---|
client.source |
clients.source |
✅ 已落地 | 客源来源 |
client.follow_purpose |
client_follow_logs.purpose |
✅ 已落地 | 客源跟进目的 |
property.source |
properties.source |
✅ 已落地 | 房源来源 |
property.follow_purpose |
follow_logs.purpose |
🔄 建议统一 | 房源跟进目的(建议与 client.follow_purpose 共享或独立分组) |
property.commission_type |
commissions.commission_type |
🔄 待入组 | 委托类型(独家/非独家等) |
client.match_feedback |
client_property_matches.feedback |
🔄 待入组 | 配房反馈原因 |
org.reward_punish_category |
staff_reward_punish.category |
🔄 待入组 | 人事奖惩类别 |
4.1 lookup_groups 规范(Tenant Schema)
module: 业务模块标识(如client/property/org)key: 领域键(如source/follow_purpose)- 同一组内
value不可重复(UNIQUE(group_id, value)) is_system = TRUE的项禁止物理删除(仅可停用)
五、统一实现约束
- 固定枚举值不可改名:只能新增或停用,禁止修改既有 value。
- 中文展示从字典取值:前端/UI 不得硬编码中文。
- 可配置枚举不得加固定 CHECK:防止租户自定义被数据库约束阻断。
- 跨模块同名枚举必须复用语义:如
status在不同领域必须使用 domain 区分,不允许混用。 - 缓存规范:
- 固定枚举:
public:enum_labels:{domain}(建议 TTL 24h) - 可配置枚举:
{schema}:setting:lookup:{module}.{key}(TTL 300s)
- 固定枚举:
六、变更流程(必须同步)
新增或修改任一枚举时,必须同时更新:
- 本文档
ENUMS.md - 对应
DATA_MODEL_*.md字段定义(CHECK / 注释 / 业务规则) enum_labels种子数据(若为固定枚举)或lookup_groups/itemsfixture(若为可配置枚举)- 服务层缓存失效逻辑(Redis key)
七、与 ADR 的一致性说明
本文件已对齐以下冻结决策:
- 固定枚举与可配置枚举双轨并存
- 状态机和值域以文档为权威来源
- Tenant 级可配置枚举统一由
setting模块托管 - Agent 编码前先读枚举标准,禁止各模块自行定义“影子枚举”