api.php 5.3 KB

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