作者 开飞机的舒克

新增解除绑定接口和退出登录接口

... ... @@ -9,6 +9,8 @@ use EasyWeChat\Factory;
use fast\Http;
use think\Config;
use think\Db;
use think\Exception;
use think\exception\PDOException;
/**
* 个人中心
... ... @@ -251,7 +253,34 @@ class User extends Api
}
/**
* 退出登录
* @ApiTitle (解除绑定)
* @ApiSummary (积分明细)
* @ApiMethod (POST)
* @ApiReturn ({
"code": 0
"msg": "解除绑定成功"
})
*/
public function closeBind(){
$user = $this->auth->getUserinfo();
$list = \db('user')->where('id',$user['id'])->field('is_teach,bind_study')->find();
if ($list['bind_study'] == 0){
$this->error('您当前还未绑定学生');
}
Db::startTrans();
try {
\db('user')->where('id', $user['id'])->update(['bind_study' => 0]);
\db('study')->where('id',$user['id'])->update(['user_id'=>null]);
Db::commit();
} catch (Exception $e) {
$this->error('连接错误',$e->getMessage());
Db::rollback();
}
$this->success('解除绑定成功');
}
/**
* @ApiTitle (退出登录)
* @ApiMethod (POST)
*/
public function logout()
... ...
... ... @@ -177,7 +177,11 @@
<a href="javascript:;" data-id="36" class="list-group-item">获取测试token <span class="tag">
</span>
</a>
<a href="javascript:;" data-id="37" class="list-group-item">退出登录 <span class="tag">
<a href="javascript:;" data-id="37" class="list-group-item">解除绑定 <span class="tag">
<span class="label label-success pull-right noneedlogin"></span>
</span>
</a>
<a href="javascript:;" data-id="38" class="list-group-item">退出登录 <span class="tag">
<span class="label label-success pull-right noneedlogin"></span>
</span>
</a>
... ... @@ -1137,7 +1141,7 @@
<div class="panel-heading" id="heading-37">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion37" href="#collapseOne37"> 退出登录 <span class="text-muted">/api/user/logout</span></a>
<a data-toggle="collapse" data-parent="#accordion37" href="#collapseOne37"> 解除绑定 <span class="text-muted">/api/user/closeBind</span></a>
</h4>
</div>
<div id="collapseOne37" class="panel-collapse collapse">
... ... @@ -1155,7 +1159,7 @@
<div class="tab-pane active" id="info37">
<div class="well">
退出登录 </div>
积分明细 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>权限</strong></div>
<div class="panel-body">
... ... @@ -1202,7 +1206,7 @@
</div>
</div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/logout" method="POST" name="form37" id="form37">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/closeBind" method="POST" name="form37" id="form37">
<div class="form-group">
</div>
... ... @@ -1237,7 +1241,123 @@
<div class="tab-pane" id="sample37">
<div class="row">
<div class="col-md-12">
<pre id="sample_response37"></pre>
<pre id="sample_response37">{
"code": 0
"msg": "解除绑定成功"
}</pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-38">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion38" href="#collapseOne38"> 退出登录 <span class="text-muted">/api/user/logout</span></a>
</h4>
</div>
<div id="collapseOne38" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab38">
<li class="active"><a href="#info38" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox38" data-toggle="tab">在线测试</a></li>
<li><a href="#sample38" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info38">
<div class="well">
退出登录 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>权限</strong></div>
<div class="panel-body">
<table class="table table-hover">
<tbody>
<tr>
<td>登录</td>
<td></td>
</tr>
<tr>
<td>鉴权</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>正文</strong></div>
<div class="panel-body">
</div>
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox38">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong>
<div class="pull-right">
<a href="javascript:" class="btn btn-xs btn-info btn-append">追加</a>
</div>
</div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/logout" method="POST" name="form38" id="form38">
<div class="form-group">
</div>
<div class="form-group form-group-submit">
<button type="submit" class="btn btn-success send" rel="38">提交</button>
<button type="reset" class="btn btn-info" rel="38">重置</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>响应输出</strong></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers38"></pre>
<pre id="response38"></pre>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>返回参数</strong></div>
<div class="panel-body">
</div>
</div>
</div>
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample38">
<div class="row">
<div class="col-md-12">
<pre id="sample_response38"></pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -5634,7 +5754,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-03-24 16:09:11 <a href="./" target="_blank">校园活动</a>
Generated on 2023-03-28 15:06:11 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...