api.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. $platform = include('platform.php');
  3. $config = array
  4. (
  5. 'list' => array
  6. (
  7. 'field' => array
  8. (
  9. 'id',
  10. 'name',
  11. 'uri',
  12. 'env_type',
  13. 'cate' => array
  14. (
  15. 'show' => 'Dever::call("content/cate.getInfo", array("api", "{cate}"))',
  16. ),
  17. 'platform_id',
  18. 'status' => array
  19. (
  20. 'type' => 'switch',
  21. 'show' => '{status}',
  22. 'active_value' => 1,
  23. 'inactive_value' => 2,
  24. ),
  25. ),
  26. 'data_button' => array
  27. (
  28. '设置' => 'edit',
  29. '删除' => 'delete',
  30. ),
  31. 'button' => array
  32. (
  33. '新增' => array('fastadd', 'name,env_type,cate,platform_id,uri'),
  34. ),
  35. 'search' => array
  36. (
  37. 'platform_id',
  38. 'cate' => array
  39. (
  40. 'type' => 'cascader',
  41. 'option' => 'Dever::call("content/cate.getList", array("api"))',
  42. ),
  43. 'name',
  44. 'uri',
  45. 'status',
  46. ),
  47. ),
  48. 'update' => array
  49. (
  50. 'desc' => $platform['update']['desc'],
  51. 'end' => 'content/info.update',
  52. 'tab' => array
  53. (
  54. '基本设置' => 'name,env_type,cate,sign_col,uri,api/api_uri',
  55. '价格设置' => 'spec_type,api/sku,api/sku#',
  56. '请求参数' => 'method,post_method,api/api_request_header,api/api_request_body',
  57. '响应参数' => 'api/api_response_header,api/api_response_body',
  58. '输入输出' => 'api/api_request_input,api/api_request_output',
  59. '存储设置' => 'api/api_save',
  60. '回调设置' => 'notify_type,notify_success,notify_error,api/api_notify_code',
  61. ),
  62. 'field' => array
  63. (
  64. 'name',
  65. 'env_type' => 'radio',
  66. 'cate' => array
  67. (
  68. 'type' => 'cascader',
  69. 'option' => 'Dever::call("content/cate.getList", array("api"))',
  70. ),
  71. 'platform_id' => array
  72. (
  73. 'desc' => '【提交后不能更改】',
  74. ),
  75. 'sign_col' => array
  76. (
  77. 'type' => 'textarea',
  78. 'autosize' => array('minRows' => 2),
  79. 'desc' => '按顺序做加密,用+号隔开,为空则所有字段均参与加密,这里填写后,将替换平台中的签名加密参数',
  80. ),
  81. 'uri',
  82. 'api/api_uri' => array
  83. (
  84. 'name' => '接口地址生成',
  85. 'where' => array('api_id' => 'id'),
  86. 'desc' => '如果需要动态生成接口地址,这里填写参数即可,同样支持变量',
  87. ),
  88. 'method' => array
  89. (
  90. 'type' => 'radio',
  91. 'control' => true,
  92. ),
  93. 'post_method' => array
  94. (
  95. 'type' => 'radio',
  96. 'show' => false,
  97. ),
  98. 'api/api_request_input' => array
  99. (
  100. 'name' => '参数输入',
  101. 'where' => array('api_id' => 'id'),
  102. 'desc' => '[默认值/可选项:可以多行输入,默认值为第一行,其他行为可选项]',
  103. ),
  104. 'api/api_request_output' => array
  105. (
  106. 'name' => '参数输出',
  107. 'where' => array('api_id' => 'id'),
  108. ),
  109. 'api/api_request_body' => array
  110. (
  111. 'name' => '请求体',
  112. 'where' => array('api_id' => 'id'),
  113. ),
  114. 'api/api_request_header' => array
  115. (
  116. 'name' => '请求头',
  117. 'where' => array('api_id' => 'id'),
  118. ),
  119. 'api/api_response_body' => array
  120. (
  121. 'name' => '响应体',
  122. 'desc' => '填写后,平台中的标准响应体将失效,并且只保留填写后的响应体,格式:data[].name,不是列表则为data.name',
  123. 'where' => array('api_id' => 'id'),
  124. ),
  125. 'api/api_response_header' => array
  126. (
  127. 'name' => '响应头',
  128. 'desc' => '填写后,平台中的标准响应头将失效,不填写不保留响应头,格式:data[].name,不是列表则为data.name',
  129. 'where' => array('api_id' => 'id'),
  130. ),
  131. 'api/api_save' => array
  132. (
  133. 'name' => '存储设置',
  134. 'desc' => '用于将响应数据保存到数据表中,该数据表最好有api_id(int)和request_id(varchar)字段,用于区分是哪个接口哪次请求,当然也可以没有',
  135. 'where' => array('api_id' => 'id'),
  136. ),
  137. 'notify_type' => array
  138. (
  139. 'type' => 'radio',
  140. 'control' => true,
  141. ),
  142. 'notify_success' => array
  143. (
  144. 'desc' => '填写回调成功后,返回给渠道的信息',
  145. ),
  146. 'notify_error' => array
  147. (
  148. 'desc' => '填写回调失败后,返回给渠道的信息,如果填写500,则会返回HTTP Status Code 500,默认返回HTTP Status Code 200',
  149. ),
  150. 'notify_sign_col' => array
  151. (
  152. 'desc' => '回调签名参数,不填写则使用接口的回调签名参数',
  153. ),
  154. 'api/api_notify_code' => array
  155. (
  156. 'name' => '回调状态码',
  157. 'where' => array('api_id' => 'id'),
  158. ),
  159. 'spec_type' => array
  160. (
  161. 'type' => 'radio',
  162. 'control' => true,
  163. ),
  164. 'api/sku' => array
  165. (
  166. 'name' => '单规格设置',
  167. 'where' => array('api_id' => 'id', 'key' => '-1'),
  168. # 默认值,如果有默认值则无法添加和删除
  169. 'default' => array
  170. (
  171. # 默认值
  172. array
  173. (
  174. 'price' => '',
  175. 'num' => '',
  176. 'day_num' => '',
  177. ),
  178. ),
  179. ),
  180. 'api/sku#' => array
  181. (
  182. 'name' => '多规格设置',
  183. 'where' => array('api_id' => 'id', 'key' => array('!=', '-1')),
  184. 'type' => 'sku',
  185. # 设置规格表名
  186. 'spec' => 'api/spec',
  187. # 设置规格表关联字段
  188. 'spec_field' => 'api_id',
  189. # 获取规格数据的接口
  190. 'spec_data' => 'api/spec.manage',
  191. ),
  192. ),
  193. 'control' => array
  194. (
  195. 'post_method' => array
  196. (
  197. 'method' => 2,
  198. ),
  199. 'notify_success' => array
  200. (
  201. 'notify_type' => 1,
  202. ),
  203. 'notify_error' => array
  204. (
  205. 'notify_type' => 1,
  206. ),
  207. 'api/api_notify_code' => array
  208. (
  209. 'notify_type' => 1,
  210. ),
  211. /*
  212. 'api/api_notify' => array
  213. (
  214. 'notify_type' => 1,
  215. ),*/
  216. 'api/sku' => array
  217. (
  218. 'spec_type' => 1,
  219. ),
  220. 'api/sku#' => array
  221. (
  222. 'spec_type' => 2,
  223. ),
  224. ),
  225. ),
  226. );
  227. $id = Dever::input('id');
  228. if (!$id) {
  229. unset($config['update']['tab']);
  230. }
  231. return $config;