• 请不要在回答技术问题时复制粘贴 AI 生成的内容
xoxo419
V2EX  ›  程序员

对于一些类似用户状态、订单状态的值是用常量还是写在配置中或是数据库中呢?

  •  
  •   xoxo419 · May 8, 2018 · 2529 views
    This topic created in 2952 days ago, the information mentioned may be changed or developed.

    数据库字段 user_status 1 正常 -1 删除 -2 禁用

    • 方式 1: 直接在程序中写字段的值.
    • 方式 2: 写到配置文件中.
    • 方式 3: 写到常量类中.
    • 方式 4: 有一个表来存这种数据.

    是那种方式更好呢? 为什么?

    3 replies    2018-05-08 14:24:55 +08:00
    jjianwen68
        1
    jjianwen68  
       May 8, 2018
    我觉得数据库可以有个常量表,程序中用枚举
    night98
        2
    night98  
       May 8, 2018
    1.enum
    2.常量
    nowheretogogo
        3
    nowheretogogo  
       May 8, 2018
    常量表+枚举
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2732 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 15:22 · PVG 23:22 · LAX 08:22 · JFK 11:22
    ♥ Do have faith in what you're doing.