作者 开飞机的舒克

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

@@ -9,6 +9,8 @@ use EasyWeChat\Factory; @@ -9,6 +9,8 @@ use EasyWeChat\Factory;
9 use fast\Http; 9 use fast\Http;
10 use think\Config; 10 use think\Config;
11 use think\Db; 11 use think\Db;
  12 +use think\Exception;
  13 +use think\exception\PDOException;
12 14
13 /** 15 /**
14 * 个人中心 16 * 个人中心
@@ -251,7 +253,34 @@ class User extends Api @@ -251,7 +253,34 @@ class User extends Api
251 } 253 }
252 254
253 /** 255 /**
254 - * 退出登录 256 + * @ApiTitle (解除绑定)
  257 + * @ApiSummary (积分明细)
  258 + * @ApiMethod (POST)
  259 + * @ApiReturn ({
  260 + "code": 0
  261 + "msg": "解除绑定成功"
  262 + })
  263 + */
  264 + public function closeBind(){
  265 + $user = $this->auth->getUserinfo();
  266 + $list = \db('user')->where('id',$user['id'])->field('is_teach,bind_study')->find();
  267 + if ($list['bind_study'] == 0){
  268 + $this->error('您当前还未绑定学生');
  269 + }
  270 + Db::startTrans();
  271 + try {
  272 + \db('user')->where('id', $user['id'])->update(['bind_study' => 0]);
  273 + \db('study')->where('id',$user['id'])->update(['user_id'=>null]);
  274 + Db::commit();
  275 + } catch (Exception $e) {
  276 + $this->error('连接错误',$e->getMessage());
  277 + Db::rollback();
  278 + }
  279 + $this->success('解除绑定成功');
  280 + }
  281 +
  282 + /**
  283 + * @ApiTitle (退出登录)
255 * @ApiMethod (POST) 284 * @ApiMethod (POST)
256 */ 285 */
257 public function logout() 286 public function logout()
@@ -177,7 +177,11 @@ @@ -177,7 +177,11 @@
177 <a href="javascript:;" data-id="36" class="list-group-item">获取测试token <span class="tag"> 177 <a href="javascript:;" data-id="36" class="list-group-item">获取测试token <span class="tag">
178 </span> 178 </span>
179 </a> 179 </a>
180 - <a href="javascript:;" data-id="37" class="list-group-item">退出登录 <span class="tag"> 180 + <a href="javascript:;" data-id="37" class="list-group-item">解除绑定 <span class="tag">
  181 + <span class="label label-success pull-right noneedlogin"></span>
  182 + </span>
  183 + </a>
  184 + <a href="javascript:;" data-id="38" class="list-group-item">退出登录 <span class="tag">
181 <span class="label label-success pull-right noneedlogin"></span> 185 <span class="label label-success pull-right noneedlogin"></span>
182 </span> 186 </span>
183 </a> 187 </a>
@@ -1137,7 +1141,7 @@ @@ -1137,7 +1141,7 @@
1137 <div class="panel-heading" id="heading-37"> 1141 <div class="panel-heading" id="heading-37">
1138 <h4 class="panel-title"> 1142 <h4 class="panel-title">
1139 <span class="label label-primary">POST</span> 1143 <span class="label label-primary">POST</span>
1140 - <a data-toggle="collapse" data-parent="#accordion37" href="#collapseOne37"> 退出登录 <span class="text-muted">/api/user/logout</span></a> 1144 + <a data-toggle="collapse" data-parent="#accordion37" href="#collapseOne37"> 解除绑定 <span class="text-muted">/api/user/closeBind</span></a>
1141 </h4> 1145 </h4>
1142 </div> 1146 </div>
1143 <div id="collapseOne37" class="panel-collapse collapse"> 1147 <div id="collapseOne37" class="panel-collapse collapse">
@@ -1155,7 +1159,7 @@ @@ -1155,7 +1159,7 @@
1155 1159
1156 <div class="tab-pane active" id="info37"> 1160 <div class="tab-pane active" id="info37">
1157 <div class="well"> 1161 <div class="well">
1158 - 退出登录 </div> 1162 + 积分明细 </div>
1159 <div class="panel panel-default"> 1163 <div class="panel panel-default">
1160 <div class="panel-heading"><strong>权限</strong></div> 1164 <div class="panel-heading"><strong>权限</strong></div>
1161 <div class="panel-body"> 1165 <div class="panel-body">
@@ -1202,7 +1206,7 @@ @@ -1202,7 +1206,7 @@
1202 </div> 1206 </div>
1203 </div> 1207 </div>
1204 <div class="panel-body"> 1208 <div class="panel-body">
1205 - <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/logout" method="POST" name="form37" id="form37"> 1209 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/closeBind" method="POST" name="form37" id="form37">
1206 <div class="form-group"> 1210 <div class="form-group">
1207 1211
1208 </div> 1212 </div>
@@ -1237,7 +1241,123 @@ @@ -1237,7 +1241,123 @@
1237 <div class="tab-pane" id="sample37"> 1241 <div class="tab-pane" id="sample37">
1238 <div class="row"> 1242 <div class="row">
1239 <div class="col-md-12"> 1243 <div class="col-md-12">
1240 - <pre id="sample_response37"></pre> 1244 + <pre id="sample_response37">{
  1245 + "code": 0
  1246 + "msg": "解除绑定成功"
  1247 + }</pre>
  1248 + </div>
  1249 + </div>
  1250 + </div><!-- #sample -->
  1251 +
  1252 + </div><!-- .tab-content -->
  1253 + </div>
  1254 + </div>
  1255 + </div>
  1256 + <div class="panel panel-default">
  1257 + <div class="panel-heading" id="heading-38">
  1258 + <h4 class="panel-title">
  1259 + <span class="label label-primary">POST</span>
  1260 + <a data-toggle="collapse" data-parent="#accordion38" href="#collapseOne38"> 退出登录 <span class="text-muted">/api/user/logout</span></a>
  1261 + </h4>
  1262 + </div>
  1263 + <div id="collapseOne38" class="panel-collapse collapse">
  1264 + <div class="panel-body">
  1265 +
  1266 + <!-- Nav tabs -->
  1267 + <ul class="nav nav-tabs" id="doctab38">
  1268 + <li class="active"><a href="#info38" data-toggle="tab">基础信息</a></li>
  1269 + <li><a href="#sandbox38" data-toggle="tab">在线测试</a></li>
  1270 + <li><a href="#sample38" data-toggle="tab">返回示例</a></li>
  1271 + </ul>
  1272 +
  1273 + <!-- Tab panes -->
  1274 + <div class="tab-content">
  1275 +
  1276 + <div class="tab-pane active" id="info38">
  1277 + <div class="well">
  1278 + 退出登录 </div>
  1279 + <div class="panel panel-default">
  1280 + <div class="panel-heading"><strong>权限</strong></div>
  1281 + <div class="panel-body">
  1282 + <table class="table table-hover">
  1283 + <tbody>
  1284 + <tr>
  1285 + <td>登录</td>
  1286 + <td></td>
  1287 + </tr>
  1288 + <tr>
  1289 + <td>鉴权</td>
  1290 + <td></td>
  1291 + </tr>
  1292 + </tbody>
  1293 + </table>
  1294 + </div>
  1295 + </div>
  1296 + <div class="panel panel-default">
  1297 + <div class="panel-heading"><strong>Headers</strong></div>
  1298 + <div class="panel-body">
  1299 +
  1300 + </div>
  1301 + </div>
  1302 + <div class="panel panel-default">
  1303 + <div class="panel-heading"><strong>参数</strong></div>
  1304 + <div class="panel-body">
  1305 +
  1306 + </div>
  1307 + </div>
  1308 + <div class="panel panel-default">
  1309 + <div class="panel-heading"><strong>正文</strong></div>
  1310 + <div class="panel-body">
  1311 +</div>
  1312 + </div>
  1313 + </div><!-- #info -->
  1314 +
  1315 + <div class="tab-pane" id="sandbox38">
  1316 + <div class="row">
  1317 + <div class="col-md-12">
  1318 + <div class="panel panel-default">
  1319 + <div class="panel-heading"><strong>参数</strong>
  1320 + <div class="pull-right">
  1321 + <a href="javascript:" class="btn btn-xs btn-info btn-append">追加</a>
  1322 + </div>
  1323 + </div>
  1324 + <div class="panel-body">
  1325 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/logout" method="POST" name="form38" id="form38">
  1326 + <div class="form-group">
  1327 +
  1328 + </div>
  1329 + <div class="form-group form-group-submit">
  1330 + <button type="submit" class="btn btn-success send" rel="38">提交</button>
  1331 + <button type="reset" class="btn btn-info" rel="38">重置</button>
  1332 + </div>
  1333 + </form>
  1334 + </div>
  1335 + </div>
  1336 + <div class="panel panel-default">
  1337 + <div class="panel-heading"><strong>响应输出</strong></div>
  1338 + <div class="panel-body">
  1339 + <div class="row">
  1340 + <div class="col-md-12" style="overflow-x:auto">
  1341 + <pre id="response_headers38"></pre>
  1342 + <pre id="response38"></pre>
  1343 + </div>
  1344 + </div>
  1345 + </div>
  1346 + </div>
  1347 + <div class="panel panel-default">
  1348 + <div class="panel-heading"><strong>返回参数</strong></div>
  1349 + <div class="panel-body">
  1350 +
  1351 + </div>
  1352 + </div>
  1353 + </div>
  1354 + </div>
  1355 + </div><!-- #sandbox -->
  1356 +
  1357 + <div class="tab-pane" id="sample38">
  1358 + <div class="row">
  1359 + <div class="col-md-12">
  1360 + <pre id="sample_response38"></pre>
1241 </div> 1361 </div>
1242 </div> 1362 </div>
1243 </div><!-- #sample --> 1363 </div><!-- #sample -->
@@ -5634,7 +5754,7 @@ @@ -5634,7 +5754,7 @@
5634 5754
5635 </div> 5755 </div>
5636 <div class="col-md-6" align="right"> 5756 <div class="col-md-6" align="right">
5637 - Generated on 2023-03-24 16:09:11 <a href="./" target="_blank">校园活动</a> 5757 + Generated on 2023-03-28 15:06:11 <a href="./" target="_blank">校园活动</a>
5638 </div> 5758 </div>
5639 </div> 5759 </div>
5640 5760