api.php 4.5 KB

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