8403646aabe5c0f6d1926de5312767f7d48b2288.svn-base 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. $type = array
  3. (
  4. 1 => '获取',
  5. 2 => '更新',
  6. 3 => '删除',
  7. );
  8. $doc = 'token:<br />' . Maze\Security\Api::token() . '<br /><br />加密步骤:<br />1、将所有参数(包括公共请求参数和token)进行字符串字典序排序<br />2、将所有参数字符串拼接成一个字符串进行sha1加密,得到signature<br />3、将所有参数(不包括token)和signature一起传输过来即可';
  9. $request = array
  10. (
  11. 'time' => '时间戳',
  12. 'nonce' => '唯一值',
  13. 'signature' => '加密字符串',
  14. 'json' => '1(返回json格式数据)',
  15. 'maze_api_test' => 'test_yes(测试参数)',
  16. );
  17. $html = '<br />公共请求参数:<br />'.Maze::table($request).'<br />';
  18. $response = array
  19. (
  20. 'status' => '1请求成功2请求失败',
  21. 'msg' => '提示信息',
  22. 'data' => '数据,详见下述输出参数',
  23. );
  24. $html .= '公共返回参数:<br />'.Maze::table($response).'<br />';
  25. return array
  26. (
  27. # 表名
  28. 'name' => 'api',
  29. # 显示给用户看的名称
  30. 'lang' => '接口列表',
  31. # 数据结构
  32. 'struct' => array
  33. (
  34. 'id' => array
  35. (
  36. 'type' => 'int-11',
  37. 'name' => 'ID',
  38. 'default' => '',
  39. 'desc' => '',
  40. 'match' => 'is_numeric',
  41. 'order' => 'desc',
  42. ),
  43. 'name' => array
  44. (
  45. 'type' => 'varchar-30',
  46. 'name' => '接口名称',
  47. 'default' => '',
  48. 'desc' => '请输入接口名称',
  49. 'match' => 'is_string',
  50. 'update' => 'text',
  51. 'search' => 'order,fulltext',
  52. 'list' => true,
  53. ),
  54. 'request' => array
  55. (
  56. 'type' => 'text-255',
  57. 'name' => '请求参数',
  58. 'default' => '',
  59. 'desc' => '请输入请求参数',
  60. 'match' => 'is_string',
  61. //'update' => 'text',
  62. 'search' => 'fulltext',
  63. 'list' => true,
  64. ),
  65. 'response' => array
  66. (
  67. 'type' => 'text-255',
  68. 'name' => '返回参数',
  69. 'default' => '',
  70. 'desc' => '请输入返回参数',
  71. 'match' => 'is_string',
  72. //'update' => 'text',
  73. 'search' => 'fulltext',
  74. 'list' => true,
  75. ),
  76. 'type' => array
  77. (
  78. 'type' => 'tinyint-1',
  79. 'name' => '接口类型',
  80. 'default' => '1',
  81. 'desc' => '请选择接口类型',
  82. 'match' => 'is_numeric',
  83. 'option' => $type,
  84. //'update' => 'radio',
  85. 'search' => 'select',
  86. 'list' => true,
  87. ),
  88. 'project' => array
  89. (
  90. 'type' => 'varchar-30',
  91. 'name' => '所属项目',
  92. 'default' => '',
  93. 'desc' => '请输入所属项目',
  94. 'match' => 'is_string',
  95. ),
  96. 'site' => array
  97. (
  98. 'type' => 'varchar-150',
  99. 'name' => '接口地址',
  100. 'default' => '',
  101. 'desc' => '请输入接口地址',
  102. 'match' => 'is_string',
  103. 'update' => 'text',
  104. 'search' => 'fulltext',
  105. 'list' => '"接口名称:{name}<br />接口地址:<br />{site}<br />'.$html.'请求参数(请添加api_前缀):<br />{request}<br />输出参数:<br />{response}"',
  106. 'modal' => '点此查看',
  107. ),
  108. 'reorder' => array
  109. (
  110. 'type' => 'int-11',
  111. 'name' => '排序',
  112. 'default' => '1',
  113. 'desc' => '请输入排序',
  114. 'match' => 'option',
  115. 'update' => 'text',
  116. //'search' => 'order',
  117. //'list' => true,
  118. 'order' => 'desc',
  119. ),
  120. 'cdate' => array
  121. (
  122. 'type' => 'int-11',
  123. 'name' => '录入时间',
  124. 'match' => array('is_numeric', time()),
  125. 'desc' => '',
  126. # 只有insert时才生效
  127. 'insert' => true,
  128. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  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. 'manage' => array
  142. (
  143. //'list_button' => array(1 => array('日志', '"api_log&option_site={id}"'), 6 => '删除'),
  144. 'list_button' => array(6 => '删除'),
  145. 'button' => array
  146. (
  147. '更新接口' => 'manage/api.update',
  148. '加密说明' => 'modal|' . $doc,
  149. )
  150. ),
  151. # request 请求接口定义
  152. 'request' => array
  153. (
  154. 'site' => array
  155. (
  156. 'where' => array
  157. (
  158. 'site' => 'yes',
  159. ),
  160. 'type' => 'one',
  161. ),
  162. # 取所有
  163. 'all' => array
  164. (
  165. 'type' => 'all',
  166. 'order' => array('reorder` desc,`id', 'desc'),
  167. 'col' => '*|id',
  168. ),
  169. ),
  170. );