api.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. $type = array
  3. (
  4. 1 => '获取',
  5. 2 => '更新',
  6. 3 => '删除',
  7. );
  8. $doc = 'token:<br />' . Dever\Security\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. );
  24. $html .= '公共返回参数:<br />'.Dever::table($response).'<br />';
  25. return array
  26. (
  27. # 表名
  28. 'name' => 'api',
  29. # 显示给用户看的名称
  30. 'lang' => '接口列表',
  31. 'html' => $html,
  32. 'doc' => $doc,
  33. 'gettype' => $type,
  34. # 数据结构
  35. 'struct' => array
  36. (
  37. 'id' => array
  38. (
  39. 'type' => 'int-11',
  40. 'name' => 'ID',
  41. 'default' => '',
  42. 'desc' => '',
  43. 'match' => 'is_numeric',
  44. 'order' => 'desc',
  45. ),
  46. 'name' => array
  47. (
  48. 'type' => 'varchar-30',
  49. 'name' => '接口名称',
  50. 'default' => '',
  51. 'desc' => '请输入接口名称',
  52. 'match' => 'is_string',
  53. 'update' => 'text',
  54. 'search' => 'order,fulltext',
  55. 'list' => true,
  56. ),
  57. 'request' => array
  58. (
  59. 'type' => 'text-255',
  60. 'name' => '请求参数',
  61. 'default' => '',
  62. 'desc' => '请输入请求参数',
  63. 'match' => 'is_string',
  64. //'update' => 'text',
  65. 'search' => 'fulltext',
  66. 'list' => true,
  67. ),
  68. 'response' => array
  69. (
  70. 'type' => 'text-255',
  71. 'name' => '返回参数',
  72. 'default' => '',
  73. 'desc' => '请输入返回参数',
  74. 'match' => 'is_string',
  75. //'update' => 'text',
  76. 'search' => 'fulltext',
  77. 'list' => true,
  78. ),
  79. 'type' => array
  80. (
  81. 'type' => 'tinyint-1',
  82. 'name' => '接口类型',
  83. 'default' => '1',
  84. 'desc' => '请选择接口类型',
  85. 'match' => 'is_numeric',
  86. 'option' => $type,
  87. //'update' => 'radio',
  88. 'search' => 'select',
  89. 'list' => true,
  90. ),
  91. 'project' => array
  92. (
  93. 'type' => 'varchar-30',
  94. 'name' => '所属项目',
  95. 'default' => '',
  96. 'desc' => '请输入所属项目',
  97. 'match' => 'is_string',
  98. ),
  99. 'site' => array
  100. (
  101. 'type' => 'varchar-150',
  102. 'name' => '接口地址',
  103. 'default' => '',
  104. 'desc' => '请输入接口地址',
  105. 'match' => 'is_string',
  106. 'update' => 'text',
  107. 'search' => 'fulltext',
  108. 'list' => '"接口名称:{name}<br />接口地址:<br />{site}<br />'.$html.'请求参数(请添加api_前缀):<br />{request}<br />输出参数:<br />{response}"',
  109. 'modal' => '点此查看',
  110. ),
  111. 'reorder' => array
  112. (
  113. 'type' => 'int-11',
  114. 'name' => '排序',
  115. 'default' => '1',
  116. 'desc' => '请输入排序',
  117. 'match' => 'option',
  118. 'update' => 'text',
  119. //'search' => 'order',
  120. //'list' => true,
  121. 'order' => 'desc',
  122. ),
  123. 'cdate' => array
  124. (
  125. 'type' => 'int-11',
  126. 'name' => '录入时间',
  127. 'match' => array('is_numeric', DEVER_TIME),
  128. 'desc' => '',
  129. # 只有insert时才生效
  130. 'insert' => true,
  131. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  132. ),
  133. ),
  134. # 更新表结构
  135. 'alter' => array
  136. (
  137. 1 => array
  138. (
  139. array('update', 'request', 'request', 'text-255 请求'),
  140. array('update', 'response', 'response', 'text-255 返回参数'),
  141. ),
  142. 'version' => 1,
  143. ),
  144. 'manage' => array
  145. (
  146. # 后台banner
  147. 'banner' => array
  148. (
  149. 'img' => '"http://css.selfimg.com.cn/vogue/mobile-v2/vip/images/index-logo.png"',
  150. 'name' => '"项目名称"',
  151. ),
  152. //'list_button' => array(1 => array('日志', '"api_log&option_site={id}"'), 6 => '删除'),
  153. 'list_button' => array(6 => '删除'),
  154. 'button' => array
  155. (
  156. '更新接口' => 'manage/api.update',
  157. '加密说明' => 'modal|' . $doc,
  158. '生成接口文档' => Dever::url('doc/view?type=api', 'manage'),
  159. )
  160. ),
  161. # request 请求接口定义
  162. 'request' => array
  163. (
  164. 'site' => array
  165. (
  166. 'where' => array
  167. (
  168. 'site' => '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. );