api.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. $platform_id = Dever::input('set')['platform_id'] ?? 0;
  3. if (!$platform_id) {
  4. $platform_id = Dever::input('field')['platform_id'] ?? 0;
  5. }
  6. $platform = include('platform.php');
  7. $config = array
  8. (
  9. 'list' => array
  10. (
  11. 'where' => array('platform_id' => $platform_id),
  12. 'field' => array
  13. (
  14. //'id',
  15. 'sort' => 'input',
  16. 'name',
  17. 'uri',
  18. 'env',
  19. 'platform_id',
  20. 'status' => array
  21. (
  22. 'type' => 'switch',
  23. 'show' => '{status}',
  24. 'active_value' => 1,
  25. 'inactive_value' => 2,
  26. ),
  27. ),
  28. 'data_button' => array
  29. (
  30. '设置' => array('edit', array('platform_id' => $platform_id)),
  31. '删除' => 'delete',
  32. ),
  33. 'button' => array
  34. (
  35. '新增' => array('fastadd', array('platform_id' => $platform_id, 'field' => 'name,env,platform_id,uri')),
  36. ),
  37. 'search' => array
  38. (
  39. 'platform_id' => array
  40. (
  41. 'type' => 'hidden',
  42. 'default' => $platform_id,
  43. ),
  44. 'name',
  45. 'uri',
  46. 'status',
  47. ),
  48. ),
  49. 'update' => array
  50. (
  51. 'end' => 'api/app.updateApi',
  52. 'desc' => $platform['update']['desc'],
  53. 'tab' => array
  54. (
  55. '基本设置' => 'name,env,api/api_setting',
  56. '请求地址' => 'uri,method,post_method,api/api_path,api/api_query',
  57. '请求参数' => 'api/api_request_header,api/api_request_body',
  58. '响应参数' => 'api/api_response_header,api/api_response_body',
  59. '存储设置' => 'api/api_save',
  60. '回调设置' => 'notify,api/api_notify,api/api_notify_body,api/api_notify_code',
  61. //'价格设置' => 'spec_type,api/sku,api/sku#',
  62. //'输入输出' => 'api/api_request_input,api/api_request_output',
  63. ),
  64. 'field' => array
  65. (
  66. 'name',
  67. 'env' => 'radio',
  68. 'platform_id' => array
  69. (
  70. 'desc' => '【提交后不能更改】',
  71. ),
  72. 'uri',
  73. 'api/api_path' => array
  74. (
  75. 'name' => '接口路径',
  76. 'where' => array('api_id' => 'id'),
  77. 'desc' => '填写接口上的路径path参数',
  78. ),
  79. 'api/api_query' => array
  80. (
  81. 'name' => '接口查询参数',
  82. 'where' => array('api_id' => 'id'),
  83. 'desc' => '填写接口上的query参数',
  84. ),
  85. 'api/api_setting' => array
  86. (
  87. 'name' => '基础参数',
  88. 'where' => array('api_id' => 'id'),
  89. 'desc' => '设置仅限该接口使用的参数,用于定义一些特殊的参数',
  90. ),
  91. 'method' => array
  92. (
  93. 'type' => 'radio',
  94. 'control' => true,
  95. ),
  96. 'post_method' => array
  97. (
  98. 'type' => 'radio',
  99. 'show' => false,
  100. ),
  101. 'api/api_request_body' => array
  102. (
  103. 'name' => '请求体',
  104. 'where' => array('api_id' => 'id'),
  105. ),
  106. 'api/api_request_header' => array
  107. (
  108. 'name' => '请求头',
  109. 'where' => array('api_id' => 'id'),
  110. ),
  111. 'api/api_response_body' => array
  112. (
  113. 'name' => '响应体',
  114. 'desc' => '填写后,平台中的标准响应体将失效,并且只保留填写后的响应体,格式:data[].name,不是列表则为data.name',
  115. 'where' => array('api_id' => 'id'),
  116. ),
  117. 'api/api_response_header' => array
  118. (
  119. 'name' => '响应头',
  120. 'desc' => '填写后,平台中的标准响应头将失效,不填写不保留响应头,格式:data[].name,不是列表则为data.name',
  121. 'where' => array('api_id' => 'id'),
  122. ),
  123. 'api/api_save' => array
  124. (
  125. 'name' => '存储设置',
  126. 'desc' => '用于将响应数据保存到数据表中,该数据表最好有api_id(int)和request_id(varchar)字段,用于区分是哪个接口哪次请求,当然也可以没有',
  127. 'where' => array('api_id' => 'id'),
  128. ),
  129. 'notify' => array
  130. (
  131. 'type' => 'radio',
  132. 'control' => true,
  133. ),
  134. /*
  135. #也可以这样设置
  136. 'api/api_notify#' => array
  137. (
  138. 'field' => 'sign_arg',
  139. 'name' => '签名参数',
  140. 'where' => array('api_id' => 'id'),
  141. ),
  142. 'api/api_notify##' => array
  143. (
  144. 'field' => 'sign_id',
  145. 'name' => '签名',
  146. 'where' => array('api_id' => 'id'),
  147. ),*/
  148. 'api/api_notify' => array
  149. (
  150. 'name' => '基本设置',
  151. 'where' => array('api_id' => 'id'),
  152. 'default' => array(array()),
  153. # 默认使用表格形式展示,可以改成每行展示
  154. #'type' => 'line',
  155. ),
  156. 'api/api_notify_body' => array
  157. (
  158. 'name' => '参数设置',
  159. 'where' => array('api_id' => 'id'),
  160. ),
  161. 'api/api_notify_code' => array
  162. (
  163. 'name' => '状态码',
  164. 'where' => array('api_id' => 'id'),
  165. ),
  166. ),
  167. 'control' => array
  168. (
  169. 'post_method' => array
  170. (
  171. 'method' => 2,
  172. ),
  173. 'api/api_notify' => array
  174. (
  175. 'notify' => 1,
  176. ),
  177. 'api/api_notify_body' => array
  178. (
  179. 'notify' => 1,
  180. ),
  181. 'api/api_notify_code' => array
  182. (
  183. 'notify' => 1,
  184. ),
  185. ),
  186. ),
  187. );
  188. $id = Dever::input('id');
  189. if (!$id) {
  190. unset($config['update']['tab']);
  191. }
  192. return $config;