api.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. # 数据结构
  37. 'struct' => array
  38. (
  39. 'id' => array
  40. (
  41. 'type' => 'int-11',
  42. 'name' => 'ID',
  43. 'default' => '',
  44. 'desc' => '',
  45. 'match' => 'is_numeric',
  46. 'order' => 'desc',
  47. ),
  48. 'name' => array
  49. (
  50. 'type' => 'varchar-30',
  51. 'name' => '接口名称',
  52. 'default' => '',
  53. 'desc' => '请输入接口名称',
  54. 'match' => 'is_string',
  55. 'update' => 'text',
  56. 'search' => 'order,fulltext',
  57. 'list' => true,
  58. ),
  59. 'type' => array
  60. (
  61. 'type' => 'tinyint-1',
  62. 'name' => '接口类型',
  63. 'default' => '1',
  64. 'desc' => '请选择接口类型',
  65. 'match' => 'is_numeric',
  66. 'option' => $type,
  67. //'update' => 'radio',
  68. 'search' => 'select',
  69. 'list' => true,
  70. ),
  71. 'project' => array
  72. (
  73. 'type' => 'varchar-30',
  74. 'name' => '所属项目',
  75. 'default' => '',
  76. 'desc' => '请输入所属项目',
  77. 'match' => 'is_string',
  78. ),
  79. 'site' => array
  80. (
  81. 'type' => 'varchar-500',
  82. 'name' => '接口地址',
  83. 'default' => '',
  84. 'desc' => '请输入接口地址',
  85. 'match' => 'is_string',
  86. 'update' => 'text',
  87. 'search' => 'fulltext',
  88. 'list' => 'Dever::load("manage/api.getHtml", "{name}", "{site}", "'.$html.'", {id}, "{project}")',
  89. 'modal' => '点此查看',
  90. //'bind' => array('onclick', 'checking', array('url' => Dever::url("manage/api.load?json=1"))),
  91. ),
  92. 'reorder' => array
  93. (
  94. 'type' => 'int-11',
  95. 'name' => '排序',
  96. 'default' => '1',
  97. 'desc' => '请输入排序',
  98. 'match' => 'option',
  99. 'update' => 'text',
  100. //'search' => 'order',
  101. //'list' => true,
  102. 'order' => 'desc',
  103. ),
  104. 'cdate' => array
  105. (
  106. 'type' => 'int-11',
  107. 'name' => '录入时间',
  108. 'match' => array('is_numeric', DEVER_TIME),
  109. 'desc' => '',
  110. # 只有insert时才生效
  111. 'insert' => true,
  112. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  113. ),
  114. ),
  115. # 更新表结构
  116. /*
  117. 'alter' => array
  118. (
  119. 1 => array
  120. (
  121. array('update', 'request', 'request', 'text-255 请求'),
  122. array('update', 'response', 'response', 'text-255 返回参数'),
  123. ),
  124. 'version' => 1,
  125. ),
  126. */
  127. 'manage' => array
  128. (
  129. # 后台banner
  130. 'banner' => array
  131. (
  132. 'img' => '"http://css.selfimg.com.cn/vogue/mobile-v2/vip/images/index-logo.png"',
  133. 'name' => '"项目名称"',
  134. ),
  135. 'button' => array
  136. (
  137. '更新接口' => 'manage/api.update',
  138. '加密说明' => 'modal|' . $doc,
  139. '生成接口文档' => Dever::url('doc/view?type=api', 'manage'),
  140. ),
  141. 'delete' => false,
  142. //'insert' => false,
  143. 'edit' => false,
  144. ),
  145. # request 请求接口定义
  146. 'request' => array
  147. (
  148. 'site' => array
  149. (
  150. 'where' => array
  151. (
  152. 'site' => 'yes',
  153. ),
  154. 'type' => 'one',
  155. ),
  156. # 取所有
  157. 'all' => array
  158. (
  159. 'type' => 'all',
  160. 'order' => array('reorder` desc,`id', 'desc'),
  161. 'col' => '*|id',
  162. ),
  163. # 取所有
  164. 'getAll' => array
  165. (
  166. 'type' => 'all',
  167. 'order' => array('reorder` desc,`id', 'desc'),
  168. 'col' => '*|project|id|',
  169. ),
  170. ),
  171. );