api.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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}", {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. 'state' => array
  105. (
  106. 'type' => 'tinyint-1',
  107. 'name' => '数据状态',
  108. 'default' => '1',
  109. 'desc' => '请选择状态',
  110. 'match' => 'is_numeric',
  111. //'option' => $option,
  112. //'update' => 'radio',
  113. //'list' => true,
  114. //'extend' => true,//扩展功能,该字段为虚拟字段,只在数据库中建立extend字段来保存 后续实现
  115. ),
  116. 'cdate' => array
  117. (
  118. 'type' => 'int-11',
  119. 'name' => '录入时间',
  120. 'match' => array('is_numeric', DEVER_TIME),
  121. 'desc' => '',
  122. # 只有insert时才生效
  123. 'insert' => true,
  124. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  125. ),
  126. ),
  127. # 更新表结构
  128. /*
  129. 'alter' => array
  130. (
  131. 1 => array
  132. (
  133. array('update', 'request', 'request', 'text-255 请求'),
  134. array('update', 'response', 'response', 'text-255 返回参数'),
  135. ),
  136. 'version' => 1,
  137. ),
  138. */
  139. 'manage' => array
  140. (
  141. # 后台banner
  142. 'banner' => array
  143. (
  144. 'img' => '"http://css.selfimg.com.cn/vogue/mobile-v2/vip/images/index-logo.png"',
  145. 'name' => '"项目名称"',
  146. ),
  147. 'button' => array
  148. (
  149. '更新接口' => 'manage/api.update',
  150. '加密说明' => 'modal|' . $doc,
  151. '生成接口文档' => Dever::url('doc/view?type=api', 'manage'),
  152. ),
  153. 'delete' => false,
  154. //'insert' => false,
  155. 'edit' => false,
  156. ),
  157. # request 请求接口定义
  158. 'request' => array
  159. (
  160. 'site' => array
  161. (
  162. 'where' => array
  163. (
  164. 'site' => 'yes',
  165. ),
  166. 'type' => 'one',
  167. ),
  168. # 取所有
  169. 'all' => array
  170. (
  171. 'type' => 'all',
  172. 'order' => array('reorder` desc,`id', 'desc'),
  173. 'col' => '*|id',
  174. ),
  175. # 取所有
  176. 'getAll' => array
  177. (
  178. 'type' => 'all',
  179. 'order' => array('reorder` desc,`id', 'desc'),
  180. 'col' => '*|project|id|',
  181. ),
  182. ),
  183. );