ApiDoc.md.tp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. {if condition="array_key_exists('select',$crud)"}
  2. # 查询{$menuName}
  3. 接口地址:/api/{$underLineName}/index
  4. 请求方式:get / post
  5. 请求数据:
  6. ```
  7. id | 指定ID,则只返回一条数据 | int |
  8. page | 第几页,默认1 | int |
  9. pagenum | 每页几条,默认20 | int,<=:1000 |
  10. ```
  11. 响应数据:(json格式)
  12. ```
  13. code int 状态,1代表成功,0代表失败
  14. msg string 消息
  15. time int 时间戳
  16. data json 返回数据
  17. ```
  18. {/if}
  19. {if condition="array_key_exists('create',$crud)"}
  20. # 新增{$menuName}
  21. 接口地址:/api/{$underLineName}/create
  22. 请求方式:get / post
  23. 请求数据:
  24. ```
  25. {volist name="$fieldsInfo" id="vo"}
  26. {php}
  27. $field_key = $vo['Field'];
  28. if(in_array($field_key,['id','create_time','update_time'])){
  29. continue;
  30. }
  31. if(!empty($vo['Comment'])){
  32. $comment = $vo['Comment'];
  33. $field_key.= " | " . $comment;
  34. }
  35. $field_val = "";
  36. if($vo['Default'] === null){
  37. $field_val.= "require";
  38. }
  39. if(startWith($vo["Type"],'int') || startWith($vo["Type"],'tinyint')){
  40. $field_val .= empty($field_val) ? "int" : ",int";
  41. }
  42. if(startWith($vo["Type"],'varchar')){
  43. $maxLen = str_replace(['varchar(',')'],['',''],$vo["Type"]);
  44. $field_val .= empty($field_val) ? "max:".$maxLen : ",max:".$maxLen;
  45. }
  46. {/php}
  47. {notempty name="$field_val"}
  48. {$field_key} | {$field_val} |
  49. {/notempty}
  50. {/volist}
  51. ```
  52. 响应数据:(json格式)
  53. ```
  54. code int 状态,1代表成功,0代表失败
  55. msg string 消息
  56. time int 时间戳
  57. data json 返回数据
  58. ```
  59. {/if}
  60. {if condition="array_key_exists('delete',$crud)"}
  61. # 删除{$menuName}
  62. 接口地址:/api/{$underLineName}/delete
  63. 请求方式:get / post
  64. 请求数据:
  65. ```
  66. id | 数据ID | int |
  67. ```
  68. 响应数据:(json格式)
  69. ```
  70. code int 状态,1代表成功,0代表失败
  71. msg string 消息
  72. time int 时间戳
  73. data json 返回数据
  74. ```
  75. {/if}
  76. {if condition="array_key_exists('update',$crud)"}
  77. # 修改{$menuName}
  78. 接口地址:/api/{$underLineName}/update
  79. 请求方式:get / post
  80. 请求数据:
  81. ```
  82. id | 数据ID | int |
  83. {volist name="$fieldsInfo" id="vo"}
  84. {php}
  85. $field_key = $vo['Field'];
  86. if(in_array($field_key,['id','create_time','update_time'])){
  87. continue;
  88. }
  89. if($vo['Default'] === null){
  90. continue;
  91. }
  92. if(!empty($vo['Comment'])){
  93. $comment = $vo['Comment'];
  94. $field_key.= " | " . $comment;
  95. }
  96. $field_val = "";
  97. if(startWith($vo["Type"],'int') || startWith($vo["Type"],'tinyint')){
  98. $field_val .= empty($field_val) ? "int" : ",int";
  99. }
  100. if(startWith($vo["Type"],'varchar')){
  101. $maxLen = str_replace(['varchar(',')'],['',''],$vo["Type"]);
  102. $field_val .= empty($field_val) ? "max:".$maxLen : ",max:".$maxLen;
  103. }
  104. {/php}
  105. {notempty name="$field_val"}
  106. {$field_key} | {$field_val} |
  107. {/notempty}
  108. {/volist}
  109. ```
  110. 响应数据:(json格式)
  111. ```
  112. code int 状态,1代表成功,0代表失败
  113. msg string 消息
  114. time int 时间戳
  115. data json 返回数据
  116. ```
  117. {/if}