user.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '正常',
  6. 2 => '冻结',
  7. );
  8. /*
  9. $level = function()
  10. {
  11. return Dever::db('passport/level')->state();
  12. };
  13. */
  14. $system = function()
  15. {
  16. $array = array();
  17. $info = Dever::db('passport/system')->state();
  18. if($info)
  19. {
  20. $array += $info;
  21. }
  22. return $array;
  23. };
  24. $sex = array
  25. (
  26. 1 => '男',
  27. 2 => '女',
  28. 3 => '未知',
  29. );
  30. $weixin = array
  31. (
  32. 1 => '已关注',
  33. 2 => '未关注',
  34. );
  35. $temp = array
  36. (
  37. 1 => '临时用户',
  38. 2 => '正式用户',
  39. );
  40. $bind = array
  41. (
  42. 1 => '已绑定',
  43. 2 => '未绑定',
  44. );
  45. $source_type = array (
  46. 'ios' => 'ios',
  47. 'android' => 'android',
  48. 'h5' => 'h5',
  49. 'applet' => '小程序',
  50. 'pc' => '网站',
  51. 'service' => '公众号',
  52. );
  53. $email = Dever::rule('email');
  54. $email = 'option';
  55. $mobile = Dever::rule('mobile');
  56. $mobile = 'option';
  57. return array
  58. (
  59. 'email' => $email,
  60. 'mobile' => $mobile,
  61. # 表名
  62. 'name' => 'user',
  63. # 显示给用户看的名称
  64. 'lang' => '用户管理',
  65. 'order' => 10,
  66. # 数据结构
  67. 'struct' => array
  68. (
  69. 'id' => array
  70. (
  71. 'type' => 'int-11',
  72. 'name' => '用户ID',
  73. 'default' => '',
  74. 'desc' => '',
  75. 'match' => 'is_numeric',
  76. 'search' => 'order',
  77. 'list' => true,
  78. ),
  79. 'username' => array
  80. (
  81. 'type' => 'varchar-50',
  82. 'name' => '用户名',
  83. 'default' => '',
  84. 'desc' => '请输入用户名',
  85. 'match' => 'is_string',
  86. 'update' => 'text',
  87. 'search' => 'fulltext',
  88. 'list' => true,
  89. ),
  90. 'mobile' => array
  91. (
  92. 'type' => 'varchar-32',
  93. 'name' => '手机号',
  94. 'default' => '',
  95. 'desc' => '请输入用户手机号',
  96. 'match' => $mobile,
  97. 'update' => 'text',
  98. 'search' => 'fulltext,exist',
  99. 'exist' => array
  100. (
  101. 'yes' => '有值',
  102. //'no' => '没有值',
  103. ),
  104. 'list' => true,
  105. ),
  106. 'system_id' => array
  107. (
  108. 'type' => 'int-11',
  109. 'name' => '所属项目',
  110. 'default' => '1',
  111. 'desc' => '所属项目',
  112. 'match' => 'is_numeric',
  113. 'option' => $system,
  114. //'update' => 'select',
  115. //'list' => true,
  116. ),
  117. 'source_type' => array
  118. (
  119. 'type' => 'varchar-100',
  120. 'name' => '用户来源',
  121. 'default' => '',
  122. 'desc' => '请选择用户来源',
  123. 'match' => 'is_string',
  124. 'update' => 'select',
  125. 'option' => $source_type,
  126. 'search' => 'select',
  127. 'list' => true,
  128. ),
  129. 'email' => array
  130. (
  131. 'type' => 'varchar-150',
  132. 'name' => '邮箱',
  133. 'default' => '',
  134. 'desc' => '请输入邮箱',
  135. 'match' => $email,
  136. 'update' => 'text',
  137. //'search' => 'fulltext',
  138. //'list' => true,
  139. ),
  140. 'password' => array
  141. (
  142. 'type' => 'varchar-50',
  143. 'name' => '密码',
  144. 'default' => '',
  145. 'desc' => '请输入密码',
  146. 'match' => 'option',
  147. 'update' => 'password',
  148. 'callback' => 'sha1',
  149. ),
  150. //search_exist_avatar=yes
  151. 'avatar' => array
  152. (
  153. 'type' => 'varchar-150',
  154. 'name' => '头像',
  155. 'default' => '',
  156. 'desc' => '请选择头像',
  157. 'match' => 'option',
  158. 'update' => 'image',
  159. 'key' => '1',
  160. 'place' => '150',
  161. 'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  162. ),
  163. 'country' => array
  164. (
  165. 'type' => 'varchar-100',
  166. 'name' => '国家',
  167. 'default' => '',
  168. 'desc' => '国家',
  169. 'match' => 'option',
  170. 'update' => 'text',
  171. ),
  172. 'province' => array
  173. (
  174. 'type' => 'varchar-100',
  175. 'name' => '省份',
  176. 'default' => '',
  177. 'desc' => '省份',
  178. 'match' => 'option',
  179. 'update' => 'text',
  180. ),
  181. 'city' => array
  182. (
  183. 'type' => 'varchar-100',
  184. 'name' => '城市',
  185. 'default' => '',
  186. 'desc' => '城市',
  187. 'match' => 'option',
  188. 'update' => 'text',
  189. ),
  190. 'area' => array
  191. (
  192. 'type' => 'varchar-800',
  193. 'name' => '地区',
  194. 'default' => '',
  195. 'desc' => '地区',
  196. 'match' => 'option',
  197. 'update' => 'text',
  198. 'list' => true,
  199. ),
  200. 'info' => array
  201. (
  202. 'type' => 'varchar-255',
  203. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  204. 'default' => '',
  205. 'desc' => '请输入介绍',
  206. 'match' => 'option',
  207. 'update' => 'editor',
  208. ),
  209. 'score' => array
  210. (
  211. 'type' => 'varchar-50',
  212. 'name' => '积分',
  213. 'default' => '',
  214. 'desc' => '请输入积分',
  215. 'match' => 'option',
  216. //'update' => 'text',
  217. //'list' => true,
  218. ),
  219. 'sex' => array
  220. (
  221. 'type' => 'tinyint-1',
  222. 'name' => '用户性别',
  223. 'default' => '3',
  224. 'desc' => '用户性别',
  225. 'match' => 'is_numeric',
  226. 'option' => $sex,
  227. 'update' => 'radio',
  228. //'list' => true,
  229. ),
  230. 'level' => array
  231. (
  232. 'type' => 'int-11',
  233. 'name' => '用户等级',
  234. 'default' => '1',
  235. 'desc' => '请选择用户等级',
  236. 'match' => 'is_numeric',
  237. //'option' => $level,
  238. //'update' => 'select',
  239. //'list' => true,
  240. ),
  241. 'temp' => array
  242. (
  243. 'type' => 'tinyint-1',
  244. 'name' => '是否临时用户',
  245. 'default' => '1',
  246. 'desc' => '是否临时用户',
  247. 'match' => 'is_numeric',
  248. 'search' => 'select',
  249. 'option' => $temp,
  250. //'update' => 'select',
  251. 'list' => true,
  252. ),
  253. 'login_date' => array
  254. (
  255. 'type' => 'int-11',
  256. 'name' => '最近登录',
  257. 'match' => array('is_numeric', time()),
  258. 'desc' => '',
  259. 'default' => '0',
  260. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  261. ),
  262. 'bind' => array
  263. (
  264. 'type' => 'tinyint-1',
  265. 'name' => '是否绑定手机',
  266. 'default' => '2',
  267. 'desc' => '请选择是否绑定手机',
  268. 'match' => 'is_numeric',
  269. //'option' => $bind,
  270. //'update' => 'radio',
  271. ),
  272. 'state' => array
  273. (
  274. 'type' => 'tinyint-1',
  275. 'name' => '状态',
  276. 'default' => '1',
  277. 'desc' => '请选择状态',
  278. 'match' => 'is_numeric',
  279. 'option' => $option,
  280. 'update' => 'radio',
  281. ),
  282. 'cdate' => array
  283. (
  284. 'type' => 'int-11',
  285. 'name' => '注册时间',
  286. 'match' => array('is_numeric', time()),
  287. 'desc' => '',
  288. # 只有insert时才生效
  289. 'insert' => true,
  290. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  291. ),
  292. ),
  293. 'manage' => array
  294. (
  295. 'excel' => true,
  296. ),
  297. # 更新表结构
  298. /*
  299. 'alter' => array
  300. (
  301. 1 => array
  302. (
  303. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  304. ),
  305. 'version' => 1,
  306. ),
  307. */
  308. # request 请求接口定义
  309. 'request' => array
  310. (
  311. # 此处定义是为跳出auth
  312. 'login' => array
  313. (
  314. 'option' => array
  315. (
  316. 'username' => 'yes',
  317. 'mobile' => 'yes',
  318. 'email' => 'yes',
  319. 'password' => 'yes',
  320. ),
  321. 'type' => 'one',
  322. ),
  323. # 验证手机号是否被使用
  324. 'checkMobile' => array
  325. (
  326. # 匹配的正则或函数 选填项
  327. 'where' => array
  328. (
  329. 'mobile' => 'yes',
  330. 'id' => array('yes', '!='),
  331. ),
  332. 'type' => 'one',
  333. ),
  334. ),
  335. );