diff --git a/go.mod b/go.mod index 98b1fcf1a0..8524b4e287 100644 --- a/go.mod +++ b/go.mod @@ -22,8 +22,8 @@ require ( github.com/robertkrimen/otto v0.0.0-20210927222213-f9375a256948 // indirect github.com/spf13/cobra v1.2.1 // indirect github.com/stretchr/testify v1.7.0 - github.com/yaoapp/gou v0.0.0-20210929002807-fbe45c391f18 // indirect - github.com/yaoapp/kun v0.6.2 + github.com/yaoapp/gou v0.0.0-20210929042348-e322f26e3a51 // indirect + github.com/yaoapp/kun v0.6.3 github.com/yaoapp/xun v0.5.2 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b // indirect diff --git a/go.sum b/go.sum index 7358e978d6..49dcc0045f 100644 --- a/go.sum +++ b/go.sum @@ -357,10 +357,14 @@ github.com/yaoapp/gou v0.0.0-20210928160401-c3e8f1c2162c h1:LCT2RmkbuNht0hm9ed1V github.com/yaoapp/gou v0.0.0-20210928160401-c3e8f1c2162c/go.mod h1:KwCRZDnEKLCxUNgMQ2acU7WI5zpt5SGOt1sBKqNAiaE= github.com/yaoapp/gou v0.0.0-20210929002807-fbe45c391f18 h1:diVG7thFYgqhttHbiGxXsrz/mndaFePLib1saFQBkyg= github.com/yaoapp/gou v0.0.0-20210929002807-fbe45c391f18/go.mod h1:KwCRZDnEKLCxUNgMQ2acU7WI5zpt5SGOt1sBKqNAiaE= +github.com/yaoapp/gou v0.0.0-20210929042348-e322f26e3a51 h1:LlWIuWmbEETkY91qP/yg4mP0VzGde5xO2DmgRGVJfxQ= +github.com/yaoapp/gou v0.0.0-20210929042348-e322f26e3a51/go.mod h1:mJj2wa3oXVlk/WOHazW8eEZTyva98zDVjIur9lj8aiA= github.com/yaoapp/kun v0.6.1 h1:gbjP5wmAuJLe1RGZ2evH4rPCVWykf0iqbksaHikF/GI= github.com/yaoapp/kun v0.6.1/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA= github.com/yaoapp/kun v0.6.2 h1:QbtdZpVIklRDGEvL5YYRf/eR05YFZVFk/8rX2vy2K0Q= github.com/yaoapp/kun v0.6.2/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA= +github.com/yaoapp/kun v0.6.3 h1:0wD0lo0Cl78O+CoKi+DRVp6AeQFSrFInF+ghu+mww8M= +github.com/yaoapp/kun v0.6.3/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA= github.com/yaoapp/xun v0.5.2 h1:DedZ26FpcXfkLnPKXzJsrbVmpWDRx9adUo8AvOcNT+g= github.com/yaoapp/xun v0.5.2/go.mod h1:y107NMHO635nhqJxMt582i1iqLjnNxAoeYr5/500UBw= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/xiang/models/user.json b/xiang/models/user.json index 68e77fc361..5aeb44bdc8 100644 --- a/xiang/models/user.json +++ b/xiang/models/user.json @@ -8,34 +8,34 @@ "columns": [ { "label": "ID", "name": "id", "type": "ID" }, { - "label": "厂商", - "name": "manu_id", - "type": "bigInteger", - "length": 50, - "comment": "所属厂商", - "nullable": true, + "label": "类型", + "name": "type", + "type": "enum", + "option": ["admin", "staff", "user", "robot"], + "comment": "账号类型 admin 管理员, staff 员工, user 用户, robot 机器人", + "default": "user", "index": true, "validations": [ { "method": "typeof", - "args": ["integer"], - "message": "{{input}}类型错误, {{label}}应为数字" + "args": ["string"], + "message": "{{input}}类型错误, {{label}}应该为字符串" }, { - "method": "min", - "args": [0], - "message": "{{label}}应大于0" + "method": "enum", + "args": ["admin", "staff", "user", "robot"], + "message": "{{input}}不在许可范围, {{label}}应该为 admin/staff/user/robot" } ] }, { - "label": "类型", - "name": "type", - "type": "enum", - "option": ["admin", "staff", "user"], - "comment": "账号类型 admin 管理员, staff 员工, user 用户", - "default": "staff", + "label": "邮箱", + "name": "email", + "type": "string", + "length": 50, + "comment": "邮箱", "index": true, + "nullable": true, "validations": [ { "method": "typeof", @@ -43,9 +43,9 @@ "message": "{{input}}类型错误, {{label}}应该为字符串" }, { - "method": "enum", - "args": ["admin", "staff", "user"], - "message": "{{input}}不在许可范围, {{label}}应该为 admin/staff/user" + "method": "email", + "args": [], + "message": "{{input}}不是邮箱地址" } ] }, @@ -56,28 +56,72 @@ "length": 50, "comment": "手机号", "index": true, + "nullable": true, "crypt": "AES", + "validations": [ + { + "method": "mobile", + "args": [], + "message": "{{input}}格式错误" + } + ] + }, + { + "label": "登录密码", + "name": "password", + "type": "string", + "length": 256, + "comment": "登录密码", + "crypt": "PASSWORD", + "index": true, + "nullable": 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": ["^1[3-9]\\d{9}$"], - "message": "{{input}}格式错误" + "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": "password", + "label": "操作密码", + "name": "password2nd", "type": "string", "length": 256, - "comment": "登录密码", + "comment": "操作密码", "crypt": "PASSWORD", "index": true, + "nullable": true, "validations": [ { "method": "typeof", @@ -111,7 +155,7 @@ }, { "method": "pattern", - "args": ["[@#$&*]+"], + "args": ["[@#$&*\\+]+"], "message": "{{label}}应该至少包含一个符号" } ] @@ -123,6 +167,7 @@ "length": 80, "comment": "姓名", "index": true, + "nullable": true, "validations": [ { "method": "typeof", @@ -163,27 +208,6 @@ } ] }, - { - "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", @@ -195,13 +219,13 @@ "validations": [ { "method": "typeof", - "args": ["string"], - "message": "{{input}}类型错误, {{label}}应该为字符串" + "args": ["integer"], + "message": "{{input}}类型错误, {{label}}应该为数字" }, { "method": "pattern", - "args": ["^[0-9A-Za-z@#$&*]{8}$"], - "message": " {{label}}应该由8位,大小写字母、数字和符号构成" + "args": ["^[0-9]{10}$"], + "message": " {{label}}应该由10位数字构成" } ] }, @@ -227,13 +251,6 @@ } ] }, - { - "label": "简历", - "name": "resume", - "type": "text", - "comment": "简历", - "nullable": true - }, { "label": "扩展信息", "name": "extra", @@ -267,36 +284,44 @@ "values": [ { "name": "管理员", - "manu_id": 1, "type": "admin", - "idcard": "230624198301170015", - "mobile": "13900001111", - "password": "cvSK@RY6", - "key": "FB3fxCeQ", + "email": "xiang@iqka.com", + "mobile": null, + "password": "A123456p+", + "key": "8304925176", "secret": "XMTdNRVigbgUiAPdiJCfaWgWcz2PaQXw", "status": "enabled", "extra": { "sex": "男" } }, { "name": "员工", - "manu_id": 1, "type": "staff", - "idcard": "23082619820207024X", - "mobile": "13900002222", - "password": "qV@uT1DI", - "key": "JDh2ZiUt", - "secret": "wBeYjL7FjbcvpAdBrxtDFfjydsoPKhRN", + "email": "staff@iqka.com", + "mobile": null, + "password": "S123456p+", + "key": null, + "secret": null, "status": "enabled", "extra": { "sex": "女" } }, { "name": "用户", - "manu_id": 2, "type": "user", - "idcard": "23082619820207004X", - "mobile": "13900003333", - "password": "qV@uT1DI", - "key": "XZ12MiPz", + "email": null, + "mobile": "13900001111", + "password": "U123456p+", + "key": null, + "secret": null, + "status": "enabled", + "extra": { "sex": "女" } + }, + { + "name": "机器人", + "type": "robot", + "email": null, + "mobile": null, + "password": null, + "key": "3845196072", "secret": "wBeYjL7FjbcvpAdBrxtDFfjydsoPKhRN", "status": "enabled", "extra": { "sex": "女" } @@ -304,16 +329,16 @@ ], "indexes": [ { - "comment": "厂商用户", - "name": "manu_id_mobile_unique", - "columns": ["manu_id", "mobile"], + "comment": "类型邮箱唯一", + "name": "type_email_unique", + "columns": ["type", "email"], "type": "unique" }, { - "comment": "简历全文检索", - "name": "resume_fulltext", - "columns": ["resume"], - "type": "fulltext" + "comment": "类型手机号唯一", + "name": "type_mobile_unique", + "columns": ["type", "mobile"], + "type": "unique" } ], "option": { "timestamps": true, "soft_deletes": true }