{
  "name": "用户",
  "table": {
    "name": "xiang_user",
    "comment": "用户表",
    "engine": "InnoDB"
  },
  "columns": [
    { "label": "ID", "name": "id", "type": "ID" },
    {
      "label": "厂商",
      "name": "manu_id",
      "type": "bigInteger",
      "length": 50,
      "comment": "所属厂商",
      "nullable": true,
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["integer"],
          "message": "{{input}}类型错误, {{label}}应为数字"
        },
        {
          "method": "min",
          "args": [0],
          "message": "{{label}}应大于0"
        }
      ]
    },
    {
      "label": "类型",
      "name": "type",
      "type": "enum",
      "option": ["admin", "staff", "user"],
      "comment": "账号类型 admin 管理员, staff 员工, user 用户",
      "default": "staff",
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "enum",
          "args": ["admin", "staff", "user"],
          "message": "{{input}}不在许可范围, {{label}}应该为 admin/staff/user"
        }
      ]
    },
    {
      "label": "手机号",
      "name": "mobile",
      "type": "string",
      "length": 50,
      "comment": "手机号",
      "index": true,
      "crypt": "AES",
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "pattern",
          "args": ["^1[3-9]\\d{9}$"],
          "message": "{{input}}格式错误"
        }
      ]
    },
    {
      "label": "登录密码",
      "name": "password",
      "type": "string",
      "length": 256,
      "comment": "登录密码",
      "crypt": "PASSWORD",
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "minLength",
          "args": [6],
          "message": "{{label}}应该由6-18位，大小写字母、数字和符号构成"
        },
        {
          "method": "maxLength",
          "args": [18],
          "message": "{{label}}应该由6-18位，大小写字母、数字和符号构成"
        },
        {
          "method": "pattern",
          "args": ["[0-9]+"],
          "message": "{{label}}应该至少包含一个数字"
        },
        {
          "method": "pattern",
          "args": ["[A-Z]+"],
          "message": "{{label}}应该至少包含一个大写字母"
        },
        {
          "method": "pattern",
          "args": ["[a-z]+"],
          "message": "{{label}}应该至少包含一个小写字母"
        },
        {
          "method": "pattern",
          "args": ["[@#$&*]+"],
          "message": "{{label}}应该至少包含一个符号"
        }
      ]
    },
    {
      "label": "姓名",
      "name": "name",
      "type": "string",
      "length": 80,
      "comment": "姓名",
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "minLength",
          "args": [2],
          "message": "{{label}}至少需要2个字"
        },
        {
          "method": "maxLength",
          "args": [40],
          "message": "{{label}}不能超过20个字"
        }
      ]
    },
    {
      "label": "身份证号码",
      "name": "idcard",
      "type": "string",
      "length": 256,
      "comment": "身份证号码",
      "crypt": "AES",
      "nullable": true,
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "pattern",
          "args": ["^(\\d{18})|(\\d{14}X)$"],
          "message": "{{label}}格式错误"
        }
      ]
    },
    {
      "label": "账户余额",
      "name": "balance",
      "type": "integer",
      "length": 20,
      "comment": "账户余额(冗余)",
      "default": 0,
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["integer"],
          "message": "{{input}}类型错误, {{label}}应为数字"
        },
        {
          "method": "min",
          "args": [0],
          "message": "{{label}}应大于0"
        }
      ]
    },
    {
      "label": "API Key",
      "name": "key",
      "type": "string",
      "length": 256,
      "comment": "API Key",
      "nullable": true,
      "unique": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "pattern",
          "args": ["^[0-9A-Za-z@#$&*]{8}$"],
          "message": " {{label}}应该由8位，大小写字母、数字和符号构成"
        }
      ]
    },
    {
      "label": "API 密钥",
      "name": "secret",
      "type": "string",
      "length": 256,
      "nullable": true,
      "crypt": "AES",
      "comment": "API 密钥",
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "pattern",
          "args": ["^[0-9A-Za-z@#$&*]{32}$"],
          "message": "{{label}}应该由32位，大小写字母、数字和符号构成"
        }
      ]
    },
    {
      "label": "简历",
      "name": "resume",
      "type": "text",
      "comment": "简历",
      "nullable": true
    },
    {
      "label": "扩展信息",
      "name": "extra",
      "type": "json",
      "comment": "扩展信息",
      "nullable": true
    },
    {
      "label": "状态",
      "comment": "用户状态 enabled 有效, disabled 无效",
      "name": "status",
      "type": "enum",
      "default": "enabled",
      "option": ["enabled", "disabled"],
      "index": true,
      "validations": [
        {
          "method": "typeof",
          "args": ["string"],
          "message": "{{input}}类型错误, {{label}}应该为字符串"
        },
        {
          "method": "enum",
          "args": ["enabled", "disabled"],
          "message": "{{input}}不在许可范围, {{label}}应该为 enabled/disabled"
        }
      ]
    }
  ],
  "relations": {},
  "values": [
    {
      "name": "管理员",
      "manu_id": 1,
      "type": "admin",
      "idcard": "230624198301170015",
      "mobile": "13900001111",
      "password": "cvSK@RY6",
      "key": "FB3fxCeQ",
      "secret": "XMTdNRVigbgUiAPdiJCfaWgWcz2PaQXw",
      "status": "enabled",
      "extra": { "sex": "男" }
    },
    {
      "name": "员工",
      "manu_id": 1,
      "type": "staff",
      "idcard": "23082619820207024X",
      "mobile": "13900002222",
      "password": "qV@uT1DI",
      "key": "JDh2ZiUt",
      "secret": "wBeYjL7FjbcvpAdBrxtDFfjydsoPKhRN",
      "status": "enabled",
      "extra": { "sex": "女" }
    },
    {
      "name": "用户",
      "manu_id": 2,
      "type": "user",
      "idcard": "23082619820207004X",
      "mobile": "13900003333",
      "password": "qV@uT1DI",
      "key": "XZ12MiPz",
      "secret": "wBeYjL7FjbcvpAdBrxtDFfjydsoPKhRN",
      "status": "enabled",
      "extra": { "sex": "女" }
    }
  ],
  "indexes": [
    {
      "comment": "厂商用户",
      "name": "manu_id_mobile_unique",
      "columns": ["manu_id", "mobile"],
      "type": "unique"
    },
    {
      "comment": "简历全文检索",
      "name": "resume_fulltext",
      "columns": ["resume"],
      "type": "fulltext"
    }
  ],
  "option": { "timestamps": true, "soft_deletes": true }
}
