接口说明文档
<h1>一、注意事项</h1>
<ul>
<li>如在调试中遇到任何问题,请联系接口开发者</li>
<li>接口文档中的地址为路由地址,请使用公共请求url拼接接口路由地址进行访问</li>
</ul>
<h1>二、测试环境地址</h1>
<ul>
<li>后台登录:<code>http://tgcadmin.hxeduonline.com/admin/login</code></li>
<li>后台管理员:admin/111111</li>
<li>API:<code>http://tgc.hxeduonline.com/api/</code></li>
</ul>
<h1>三、接口请求(request)</h1>
<h2>1、Headers</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">Content-Type</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>固定值 <code>application/json</code></td>
</tr>
<tr>
<td style="text-align: left;">Authorization</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>从 <code>/api/auth/login</code> 获取的 <code>access_token</code></td>
</tr>
</tbody>
</table>
<h1>四、接口返回(response)</h1>
<h2>1、成功返回示例</h2>
<pre><code>{
&quot;status_code&quot;: 200,
&quot;message&quot;: &quot;&quot;,
&quot;data&quot;: {}
}</code></pre>
<h2>2、失败返回示例</h2>
<pre><code>{
&quot;status_code&quot;: 401,
&quot;message&quot;: &quot;消息&quot;,
&quot;errors&quot;: {}
}</code></pre>
<h2>3、表单验证失败返回</h2>
<pre><code>{
&quot;status_code&quot;: 422,
&quot;message&quot;: &quot;错误的提交参数&quot;,
&quot;errors&quot;: {
&quot;mobile&quot;: [
&quot;用户名不能为空&quot;
],
&quot;password&quot;: [
&quot;密码不能为空&quot;
]
}
}</code></pre>
<h2>4、返回参数说明</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">status</td>
<td style="text-align: left;">int</td>
<td>状态码,0代表成功,其他代表不同含义的失败,具体请看各个接口的含义</td>
</tr>
<tr>
<td style="text-align: left;">message</td>
<td style="text-align: left;">string</td>
<td>消息</td>
</tr>
<tr>
<td style="text-align: left;">data</td>
<td style="text-align: left;">object</td>
<td>数据包,仅在未出错时存在</td>
</tr>
<tr>
<td style="text-align: left;">errors</td>
<td style="text-align: left;">object</td>
<td>错误详细,仅在出错时存在</td>
</tr>
</tbody>
</table>
<h2>5、常用 status 说明</h2>
<ul>
<li>401(Unauthorized):认证错误,一般情况是Authorization没传或者错误</li>
<li>403(AccessDenied):无操作权限</li>
<li>400(BadRequest):错误的请求,表单提交参数错误或者其它请求错误</li>
<li>404(NotFound):请求的资源不存在</li>
<li>500(InternalError):内部服务错误</li>
</ul>
<h1>五、常例:分页返回结果</h1>
<h2>1、示例</h2>
<pre><code>{
&quot;data&quot;:[
{
&quot;id&quot;:1,
&quot;erp_id&quot;:&quot;e001&quot;,
&quot;isbn&quot;:&quot;24545&quot;,
&quot;clc_id&quot;:14,
&quot;clc_no&quot;:&quot;shx&quot;,
&quot;dc_id&quot;:38,
&quot;dc_name&quot;:&quot;历史唯物主义&quot;
},
{
&quot;id&quot;:2,
&quot;erp_id&quot;:&quot;e002&quot;,
&quot;isbn&quot;:&quot;123123&quot;,
&quot;clc_id&quot;:141,
&quot;clc_no&quot;:&quot;sh23x&quot;,
&quot;dc_id&quot;:31238,
&quot;dc_name&quot;:&quot;辩证唯物主义&quot;
}
],
&quot;current_page&quot;:1,
&quot;first_page_url&quot;:&quot;http://yuedaguancang.my/api/goods?page=1&quot;,
&quot;from&quot;:1,
&quot;last_page&quot;:1,
&quot;last_page_url&quot;:&quot;http://yuedaguancang.my/api/goods?page=1&quot;,
&quot;links&quot;:[
{
&quot;url&quot;:null,
&quot;label&quot;:&quot;« Previous&quot;,
&quot;active&quot;:false
},
{
&quot;url&quot;:&quot;http://yuedaguancang.my/api/goods?page=1&quot;,
&quot;label&quot;:&quot;1&quot;,
&quot;active&quot;:true
},
{
&quot;url&quot;:null,
&quot;label&quot;:&quot;Next »&quot;,
&quot;active&quot;:false
}
],
&quot;next_page_url&quot;:null,
&quot;path&quot;:&quot;http://yuedaguancang.my/api/goods&quot;,
&quot;per_page&quot;:15,
&quot;prev_page_url&quot;:null,
&quot;to&quot;:1,
&quot;total&quot;:1
}</code></pre>
<h2>2、请求参数说明</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">page</td>
<td style="text-align: left;">int</td>
<td>页码</td>
</tr>
<tr>
<td style="text-align: left;">limit</td>
<td style="text-align: left;">int</td>
<td>每页数据数量</td>
</tr>
</tbody>
</table>
<h2>3、返回值说明</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">data</td>
<td style="text-align: left;">array[object]</td>
<td>列表数据</td>
</tr>
<tr>
<td style="text-align: left;">current_page</td>
<td style="text-align: left;">int</td>
<td>当前页码</td>
</tr>
<tr>
<td style="text-align: left;">first_page_url</td>
<td style="text-align: left;">string</td>
<td>第一页的链接</td>
</tr>
<tr>
<td style="text-align: left;">last_page</td>
<td style="text-align: left;">int</td>
<td>最后一页的页码</td>
</tr>
<tr>
<td style="text-align: left;">last_page_url</td>
<td style="text-align: left;">string</td>
<td>最后一页的链接</td>
</tr>
<tr>
<td style="text-align: left;">links</td>
<td style="text-align: left;">array</td>
<td>当前需要显示的页码</td>
</tr>
<tr>
<td style="text-align: left;">next_page_url</td>
<td style="text-align: left;">string</td>
<td>下一页的链接</td>
</tr>
<tr>
<td style="text-align: left;">path</td>
<td style="text-align: left;">string</td>
<td>url</td>
</tr>
<tr>
<td style="text-align: left;">per_page</td>
<td style="text-align: left;">int</td>
<td>每页数据数量</td>
</tr>
<tr>
<td style="text-align: left;">total</td>
<td style="text-align: left;">int</td>
<td>数据总数</td>
</tr>
</tbody>
</table>