api.php 5.6 KB

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