作者 何书鹏
1 个管道 的构建 通过 耗费 8 秒

加入学习计划-批量

... ... @@ -456,6 +456,68 @@ class User extends Api
}
/**
* @ApiTitle (加入学习计划-批量)
* @ApiSummary (加入学习计划-批量)
* @ApiMethod (POST)
* @ApiRoute (/api/user/joinBatch)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="ids", type="string", required=true, description="培训课程id集合(多个id用英文逗号隔开)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": null
})
*/
public function joinBatch()
{
$ids = $this->request->param('ids');
empty($ids) && $this->error('缺少必要参数');
$list = Db::name('classes')->where('id','in',$ids)->field('id,study_id,duration')->select();
count($list) <= 0 && $this->error('传入参数不合法');
$data = [];
$third_id = $this->auth->id;
$time = time();
foreach($list as $v){
$is_have = Db::name('study_class')
->where('third_id',$third_id)
->where('study_id',$v['study_id'])
->where('class_id',$v['id'])
->find();
if(empty($is_have)){
$add_data = [
'third_id' => $third_id,
'study_id' => $v['study_id'],
'class_id' => $v['id'],
'createtime' => $time
];
//查询用户是否已经播放完毕该视频
$video = Db::name('class_detail')
->where('user_id',$third_id)
->where('class_id',$v['id'])
->find();
if(empty($video)){
$add_data['playtime'] = 0;
}else{
if($video['is_end'] == 2){
$add_data['playtime'] = $video['duration'];
}else{
$add_data['playtime'] = $v['duration'];
$add_data['status'] = 2;
}
}
$data[] = $add_data;
}
}
if(!empty($data)){
Db::name('study_class')->insertAll($data);
}
$this->success('添加成功');
}
/**
* @ApiTitle (移除学习计划)
* @ApiSummary (移除学习计划)
* @ApiMethod (POST)
... ...
... ... @@ -210,10 +210,11 @@
<a href="javascript:;" data-id="52" class="list-group-item">培训课程详情</a>
<a href="javascript:;" data-id="53" class="list-group-item">记录播放时间</a>
<a href="javascript:;" data-id="54" class="list-group-item">加入学习计划</a>
<a href="javascript:;" data-id="55" class="list-group-item">移除学习计划</a>
<a href="javascript:;" data-id="56" class="list-group-item">我的考试</a>
<a href="javascript:;" data-id="57" class="list-group-item">查看证书</a>
<a href="javascript:;" data-id="58" class="list-group-item"></a>
<a href="javascript:;" data-id="55" class="list-group-item">加入学习计划-批量</a>
<a href="javascript:;" data-id="56" class="list-group-item">移除学习计划</a>
<a href="javascript:;" data-id="57" class="list-group-item">我的考试</a>
<a href="javascript:;" data-id="58" class="list-group-item">查看证书</a>
<a href="javascript:;" data-id="59" class="list-group-item"></a>
</div>
</div>
</div>
... ... @@ -7360,7 +7361,7 @@
<div class="panel-heading" id="heading-55">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion55" href="#collapseOne55"> 移除学习计划 <span class="text-muted">/api/user/del_join</span></a>
<a data-toggle="collapse" data-parent="#accordion55" href="#collapseOne55"> 加入学习计划-批量 <span class="text-muted">/api/user/joinBatch</span></a>
</h4>
</div>
<div id="collapseOne55" class="panel-collapse collapse">
... ... @@ -7378,7 +7379,7 @@
<div class="tab-pane active" id="info55">
<div class="well">
移除学习计划 </div>
加入学习计划-批量 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
... ... @@ -7416,10 +7417,10 @@
</thead>
<tbody>
<tr>
<td>id</td>
<td>int</td>
<td>ids</td>
<td>string</td>
<td></td>
<td>培训课程id</td>
<td>培训课程id集合(多个id用英文逗号隔开)</td>
</tr>
</tbody>
</table>
... ... @@ -7449,10 +7450,10 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/del_join" method="POST" name="form55" id="form55">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/joinBatch" method="POST" name="form55" id="form55">
<div class="form-group">
<label class="control-label" for="id">id</label>
<input type="int" class="form-control input-sm" id="id" required placeholder="培训课程id" name="id">
<label class="control-label" for="ids">ids</label>
<input type="string" class="form-control input-sm" id="ids" required placeholder="培训课程id集合(多个id用英文逗号隔开)" name="ids">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="55">提交</button>
... ... @@ -7486,11 +7487,10 @@
<div class="row">
<div class="col-md-12">
<pre id="sample_response55">{
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": null
}</pre>
</div>
</div>
... ... @@ -7504,7 +7504,7 @@
<div class="panel-heading" id="heading-56">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion56" href="#collapseOne56"> 我的考试 <span class="text-muted">/api/user/myexam</span></a>
<a data-toggle="collapse" data-parent="#accordion56" href="#collapseOne56"> 移除学习计划 <span class="text-muted">/api/user/del_join</span></a>
</h4>
</div>
<div id="collapseOne56" class="panel-collapse collapse">
... ... @@ -7522,7 +7522,7 @@
<div class="tab-pane active" id="info56">
<div class="well">
我的考试 </div>
移除学习计划 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
... ... @@ -7563,7 +7563,7 @@
<td>id</td>
<td>int</td>
<td></td>
<td>学习系统id</td>
<td>培训课程id</td>
</tr>
</tbody>
</table>
... ... @@ -7593,10 +7593,10 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/myexam" method="POST" name="form56" id="form56">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/del_join" method="POST" name="form56" id="form56">
<div class="form-group">
<label class="control-label" for="id">id</label>
<input type="int" class="form-control input-sm" id="id" required placeholder="学习系统id" name="id">
<input type="int" class="form-control input-sm" id="id" required placeholder="培训课程id" name="id">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="56">提交</button>
... ... @@ -7634,6 +7634,150 @@
"msg": "成功",
"time": "1571492001",
"data": {
}
}</pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-57">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion57" href="#collapseOne57"> 我的考试 <span class="text-muted">/api/user/myexam</span></a>
</h4>
</div>
<div id="collapseOne57" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab57">
<li class="active"><a href="#info57" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox57" data-toggle="tab">在线测试</a></li>
<li><a href="#sample57" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info57">
<div class="well">
我的考试 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>token</td>
<td>string</td>
<td></td>
<td>请求的Token</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>int</td>
<td></td>
<td>学习系统id</td>
</tr>
</tbody>
</table>
</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="sandbox57">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<div class="headers">
<div class="form-group">
<label class="control-label" for="token">token</label>
<input type="string" class="form-control input-sm" id="token" required placeholder="请求的Token - Ex: " name="token">
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/myexam" method="POST" name="form57" id="form57">
<div class="form-group">
<label class="control-label" for="id">id</label>
<input type="int" class="form-control input-sm" id="id" required placeholder="学习系统id" name="id">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="57">提交</button>
<button type="reset" class="btn btn-info" rel="57">重置</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_headers57"></pre>
<pre id="response57"></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="sample57">
<div class="row">
<div class="col-md-12">
<pre id="sample_response57">{
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"exam":[
"id"://id,
"examname"://考试名称
... ... @@ -7666,26 +7810,26 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-57">
<div class="panel-heading" id="heading-58">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion57" href="#collapseOne57"> 查看证书 <span class="text-muted">/api/user/certificate</span></a>
<a data-toggle="collapse" data-parent="#accordion58" href="#collapseOne58"> 查看证书 <span class="text-muted">/api/user/certificate</span></a>
</h4>
</div>
<div id="collapseOne57" class="panel-collapse collapse">
<div id="collapseOne58" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab57">
<li class="active"><a href="#info57" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox57" data-toggle="tab">在线测试</a></li>
<li><a href="#sample57" data-toggle="tab">返回示例</a></li>
<ul class="nav nav-tabs" id="doctab58">
<li class="active"><a href="#info58" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox58" data-toggle="tab">在线测试</a></li>
<li><a href="#sample58" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info57">
<div class="tab-pane active" id="info58">
<div class="well">
查看证书 </div>
<div class="panel panel-default">
... ... @@ -7741,7 +7885,7 @@
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox57">
<div class="tab-pane" id="sandbox58">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
... ... @@ -7758,14 +7902,14 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/certificate" method="POST" name="form57" id="form57">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/certificate" method="POST" name="form58" id="form58">
<div class="form-group">
<label class="control-label" for="id">id</label>
<input type="int" class="form-control input-sm" id="id" required placeholder="考试记录id" name="id">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="57">提交</button>
<button type="reset" class="btn btn-info" rel="57">重置</button>
<button type="submit" class="btn btn-success send" rel="58">提交</button>
<button type="reset" class="btn btn-info" rel="58">重置</button>
</div>
</form>
</div>
... ... @@ -7775,8 +7919,8 @@
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers57"></pre>
<pre id="response57"></pre>
<pre id="response_headers58"></pre>
<pre id="response58"></pre>
</div>
</div>
</div>
... ... @@ -7791,10 +7935,10 @@
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample57">
<div class="tab-pane" id="sample58">
<div class="row">
<div class="col-md-12">
<pre id="sample_response57">{
<pre id="sample_response58">{
"code": 1,
"msg": "成功",
"time": "1571492001",
... ... @@ -7812,26 +7956,26 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-58">
<div class="panel-heading" id="heading-59">
<h4 class="panel-title">
<span class="label label-success">GET</span>
<a data-toggle="collapse" data-parent="#accordion58" href="#collapseOne58"> <span class="text-muted">/api/user/get_video_first_image</span></a>
<a data-toggle="collapse" data-parent="#accordion59" href="#collapseOne59"> <span class="text-muted">/api/user/get_video_first_image</span></a>
</h4>
</div>
<div id="collapseOne58" class="panel-collapse collapse">
<div id="collapseOne59" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab58">
<li class="active"><a href="#info58" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox58" data-toggle="tab">在线测试</a></li>
<li><a href="#sample58" data-toggle="tab">返回示例</a></li>
<ul class="nav nav-tabs" id="doctab59">
<li class="active"><a href="#info59" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox59" data-toggle="tab">在线测试</a></li>
<li><a href="#sample59" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info58">
<div class="tab-pane active" id="info59">
<div class="well">
</div>
<div class="panel panel-default">
... ... @@ -7853,19 +7997,19 @@
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox58">
<div class="tab-pane" id="sandbox59">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/get_video_first_image" method="get" name="form58" id="form58">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/get_video_first_image" method="get" name="form59" id="form59">
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="58">提交</button>
<button type="reset" class="btn btn-info" rel="58">重置</button>
<button type="submit" class="btn btn-success send" rel="59">提交</button>
<button type="reset" class="btn btn-info" rel="59">重置</button>
</div>
</form>
</div>
... ... @@ -7875,8 +8019,8 @@
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers58"></pre>
<pre id="response58"></pre>
<pre id="response_headers59"></pre>
<pre id="response59"></pre>
</div>
</div>
</div>
... ... @@ -7891,10 +8035,10 @@
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample58">
<div class="tab-pane" id="sample59">
<div class="row">
<div class="col-md-12">
<pre id="sample_response58"></pre>
<pre id="sample_response59"></pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -7909,7 +8053,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2021-04-12 18:01:50 </div>
Generated on 2021-12-20 16:16:43 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">企智帮</a>
</div>
... ...