api.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. $type = array
  3. (
  4. 1 => '获取',
  5. 2 => '更新',
  6. 3 => '删除',
  7. );
  8. $doc = 'token:<br />' . Dever\Http\Api::token() . '<br /><br />加密步骤:<br />a、将所有参数(包括公共请求参数和token)进行字符串字典序排序<br />b、将所有参数字符串拼接成一个字符串进行sha1加密,得到signature<br />c、将所有参数(不包括token)和signature一起传输过来即可';
  9. $request = array
  10. (
  11. 'time' => '时间戳(登录加密请忽略此参数)',
  12. 'nonce' => '唯一值(登录加密请忽略此参数)',
  13. 'signature' => '加密字符串',
  14. 'json' => '1(返回json格式数据)',
  15. 'dever_api_test' => 'test_yes(测试参数,请忽略)',
  16. );
  17. $html = '<br />公共请求参数:<br />'.Dever::table($request).'<br />';
  18. $response = array
  19. (
  20. 'status' => '1请求成功2请求失败',
  21. 'msg' => '提示信息',
  22. 'data' => '数据,详见下述输出参数',
  23. 'code' => '状态码,一般不定义',
  24. );
  25. $html .= '公共返回参数:<br />'.Dever::table($response).'<br />';
  26. return array
  27. (
  28. # 表名
  29. 'name' => 'api',
  30. # 显示给用户看的名称
  31. 'lang' => '接口列表',
  32. //'menu' => false,
  33. 'html' => $html,
  34. 'doc' => $doc,
  35. 'gettype' => $type,
  36. 'menu' => false,
  37. # 数据结构
  38. 'struct' => array
  39. (
  40. 'id' => array
  41. (
  42. 'type' => 'int-11',
  43. 'name' => 'ID',
  44. 'default' => '',
  45. 'desc' => '',
  46. 'match' => 'is_numeric',
  47. 'order' => 'desc',
  48. 'list' => true,
  49. ),
  50. 'name' => array
  51. (
  52. 'type' => 'varchar-30',
  53. 'name' => '接口名称',
  54. 'default' => '',
  55. 'desc' => '请输入接口名称',
  56. 'match' => 'is_string',
  57. 'update' => 'text',
  58. 'search' => 'order,fulltext',
  59. 'list' => true,
  60. ),
  61. 'type' => array
  62. (
  63. 'type' => 'tinyint-1',
  64. 'name' => '接口类型',
  65. 'default' => '1',
  66. 'desc' => '请选择接口类型',
  67. 'match' => 'is_numeric',
  68. 'option' => $type,
  69. //'update' => 'radio',
  70. 'search' => 'select',
  71. 'list' => true,
  72. ),
  73. 'project' => array
  74. (
  75. 'type' => 'varchar-30',
  76. 'name' => '所属项目',
  77. 'default' => '',
  78. 'desc' => '请输入所属项目',
  79. 'match' => 'is_string',
  80. ),
  81. 'site' => array
  82. (
  83. 'type' => 'varchar-500',
  84. 'name' => '接口地址',
  85. 'default' => '',
  86. 'desc' => '请输入接口地址',
  87. 'match' => 'is_string',
  88. 'update' => 'text',
  89. 'search' => 'fulltext',
  90. 'list' => 'Dever::load("manage/api.getHtml", "{name}", "{site}", {id}, "{project}")',
  91. 'modal' => '点此查看',
  92. //'bind' => array('onclick', 'checking', array('url' => Dever::url("manage/api.load?json=1"))),
  93. ),
  94. 'reorder' => array
  95. (
  96. 'type' => 'int-11',
  97. 'name' => '排序',
  98. 'default' => '1',
  99. 'desc' => '请输入排序',
  100. 'match' => 'option',
  101. 'update' => 'text',
  102. 'search' => 'order',
  103. 'list' => true,
  104. 'order' => 'desc',
  105. 'edit' => true,
  106. ),
  107. 'state' => array
  108. (
  109. 'type' => 'tinyint-1',
  110. 'name' => '数据状态',
  111. 'default' => '1',
  112. 'desc' => '请选择状态',
  113. 'match' => 'is_numeric',
  114. //'option' => $option,
  115. //'update' => 'radio',
  116. //'list' => true,
  117. //'extend' => true,//扩展功能,该字段为虚拟字段,只在数据库中建立extend字段来保存 后续实现
  118. ),
  119. 'cdate' => array
  120. (
  121. 'type' => 'int-11',
  122. 'name' => '录入时间',
  123. 'match' => array('is_numeric', DEVER_TIME),
  124. 'desc' => '',
  125. # 只有insert时才生效
  126. 'insert' => true,
  127. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  128. ),
  129. ),
  130. # 更新表结构
  131. /*
  132. 'alter' => array
  133. (
  134. 1 => array
  135. (
  136. array('update', 'request', 'request', 'text-255 请求'),
  137. array('update', 'response', 'response', 'text-255 返回参数'),
  138. ),
  139. 'version' => 1,
  140. ),
  141. */
  142. 'manage' => array
  143. (
  144. # 后台banner
  145. 'banner' => array
  146. (
  147. 'img' => '"http://css.selfimg.com.cn/vogue/mobile-v2/vip/images/index-logo.png"',
  148. 'name' => '"项目名称"',
  149. ),
  150. 'button' => array
  151. (
  152. '更新接口' => 'manage/api.update',
  153. '加密说明' => 'modal|' . $doc,
  154. '生成接口文档' => Dever::url('doc/view?type=api', 'manage'),
  155. ),
  156. 'delete' => false,
  157. //'insert' => false,
  158. 'edit' => false,
  159. ),
  160. # request 请求接口定义
  161. 'request' => array
  162. (
  163. 'site' => array
  164. (
  165. 'where' => array
  166. (
  167. 'site' => 'yes',
  168. 'project' => 'yes',
  169. ),
  170. 'type' => 'one',
  171. ),
  172. # 取所有
  173. 'all' => array
  174. (
  175. 'type' => 'all',
  176. 'order' => array('reorder` desc,`id', 'desc'),
  177. 'col' => '*|id',
  178. ),
  179. # 取所有
  180. 'getAll' => array
  181. (
  182. 'type' => 'all',
  183. 'order' => array('reorder` desc,`id', 'desc'),
  184. 'col' => '*|project|id|',
  185. ),
  186. ),
  187. );