...
|
...
|
@@ -9,10 +9,15 @@ |
|
|
namespace api\index\controller;
|
|
|
|
|
|
|
|
|
use api\common\model\ActivityNews;
|
|
|
use api\common\model\ClassModel;
|
|
|
use api\common\model\ClassQuestionModel;
|
|
|
use api\common\model\LevelModel;
|
|
|
use api\common\model\NewsTypeMode;
|
|
|
use api\common\model\TeamModel;
|
|
|
use api\common\model\VolunteerModel;
|
|
|
use cmf\controller\RestBaseController;
|
|
|
use think\console\output\formatter\Style;
|
|
|
|
|
|
/**
|
|
|
* @title 志愿者二开接口
|
...
|
...
|
@@ -61,6 +66,247 @@ class SecondController extends RestBaseController |
|
|
$this->success('',$return);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 志愿动态栏目类型
|
|
|
* @description 志愿动态栏目类型
|
|
|
* @author sgj
|
|
|
* @url /index/second/getNewsType
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @return id:栏目id
|
|
|
* @return name:名称
|
|
|
* @throws
|
|
|
*/
|
|
|
|
|
|
public function getNewsType(){
|
|
|
$newType=new NewsTypeMode();
|
|
|
$list=$newType->getNewsType();
|
|
|
foreach ($list as $k=>$v){
|
|
|
$return[$k]['id']=$v['id'];
|
|
|
$return[$k]['name']=$v['type_name'];
|
|
|
}
|
|
|
$this->success('',$return);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取志愿动态列表
|
|
|
* @description 获取志愿动态列表
|
|
|
* @author sgj
|
|
|
* @url /index/second/getNewsList
|
|
|
* @method GET
|
|
|
*
|
|
|
* @param name:type_id type:int require:1 other: desc:类型id
|
|
|
* @param name:page type:int require:1 other: desc:页数
|
|
|
*
|
|
|
* @return id:栏目type_id
|
|
|
* @return name:名称
|
|
|
* @return create_time:创建时间
|
|
|
* @return thumbnail:封面图
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getNewsList(){
|
|
|
$type_id=input('type_id',1);
|
|
|
$news=new ActivityNews();
|
|
|
$map['activity_type']=$type_id;
|
|
|
$list=$news
|
|
|
->where($map)
|
|
|
->field('id,activity_name,thumbnail,create_time')
|
|
|
->paginate(10,true);
|
|
|
foreach ($list as $k=>$v) {
|
|
|
$list[$k]['create_time']=date('Y-m-d',$v['create_time']);
|
|
|
$list[$k]['thumbnail']=cmf_get_image_url($v['thumbnail']);
|
|
|
}
|
|
|
$this->success('',$list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取志愿动态详情
|
|
|
* @description 获取志愿动态详情
|
|
|
* @author sgj
|
|
|
* @url /index/second/getNewsInfo
|
|
|
* @method GET
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:文章id
|
|
|
*
|
|
|
* @return id:文章id
|
|
|
* @return activity_name:文章名称
|
|
|
* @return abstract:简介
|
|
|
* @return thumbnail:头图
|
|
|
* @return content:内容
|
|
|
* @return create_time:发布时间
|
|
|
* @return author:作者
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getNewsInfo(){
|
|
|
$news_id=input('news_id');
|
|
|
$news= new ActivityNews();
|
|
|
$info=$news->getInfo($news_id);
|
|
|
$this->success('',$info);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 在线培训列表
|
|
|
* @description 在线培训列表
|
|
|
* @author sgj
|
|
|
* @url /index/second/tranOnlineList
|
|
|
* @method GET
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @return id:文章id
|
|
|
* @return pic:图片
|
|
|
* @return num:题目数量
|
|
|
* @return author:作者
|
|
|
* @return content:内容
|
|
|
* @return user_status:用户状态0,未完成1,已完成
|
|
|
* @return author:作者
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function tranOnlineList(){
|
|
|
$userId=$this->getUserId();
|
|
|
$map1['user_id']=$userId;
|
|
|
$pass_array=db('user_pass')->where($map1)->column('class_id');
|
|
|
if (empty($pass_array)){
|
|
|
$pass_array=[];
|
|
|
}
|
|
|
$Class=new ClassModel();
|
|
|
$map['status']=1;
|
|
|
$list=$Class->where($map)->paginate('10');
|
|
|
$data=$list->items();
|
|
|
|
|
|
foreach ($data as $k=>$v) {
|
|
|
if (in_array($v['id'],$pass_array)){
|
|
|
$data[$k]['user_status']=1;
|
|
|
}else{
|
|
|
$data[$k]['user_status']=0;
|
|
|
}
|
|
|
$data[$k]['pic']=cmf_get_image_url($v['pic']);
|
|
|
}
|
|
|
|
|
|
$this->success('',$list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 检查志愿者状态
|
|
|
* @description 检查志愿者状态
|
|
|
* @author sgj
|
|
|
* @url /index/second/checkTranStatus
|
|
|
* @method GET
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function checkTranStatus(){
|
|
|
$userId=$this->getUserId();
|
|
|
if (!$this->isVolunteer($userId)){
|
|
|
$this->error('申请成为志愿者后才能答题');
|
|
|
}else{
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取班级详情信息
|
|
|
* @description 获取班级详情信息
|
|
|
* @author sgj
|
|
|
* @url /index/second/getClassInfo
|
|
|
* @method GET
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*@param name:id type:int require:1 other: desc:课程id
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getClassInfo(){
|
|
|
$userId=$this->getUserId();
|
|
|
$id=input('id');
|
|
|
if (!$this->isVolunteer($userId)){
|
|
|
$this->error('申请成为志愿者后才能答题');
|
|
|
}
|
|
|
$Class=new ClassModel();
|
|
|
$map['id']=$id;
|
|
|
$classInfo=$Class->where($map)->find();
|
|
|
$classInfo['pic']=cmf_get_image_url($classInfo['pic']);
|
|
|
$this->success('',$classInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取班级问题
|
|
|
* @description 获取班级详情信息
|
|
|
* @author sgj
|
|
|
* @url /index/second/getClassQuestion
|
|
|
* @method GET
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*@param name:class_id type:int require:1 other: desc:课程id
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getClassQuestion(){
|
|
|
$class_id=input('class_id');
|
|
|
$ClassQuesion=new ClassQuestionModel();
|
|
|
$question=$ClassQuesion->getClassQuesion($class_id);
|
|
|
$this->success('',$question);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 提交答案
|
|
|
* @description 提交答案
|
|
|
* @author sgj
|
|
|
* @url /index/second/commitAnswer
|
|
|
* @method GET
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*@param name:class_id type:int require:1 other: desc:课程id
|
|
|
*@param name:answer_info type:int require:1 other: desc:回答详情{"1":"0","2":"1","id"=>'答案索引'}
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function commitAnswer(){
|
|
|
$class_id=input('class_id');
|
|
|
$answer_info=input('answer_info');
|
|
|
$answer_info1= htmlspecialchars_decode($answer_info);
|
|
|
$answer_array=json_decode($answer_info1,true);
|
|
|
$ClassQuesion=new ClassQuestionModel();
|
|
|
$question=$ClassQuesion->getClassQuesion($class_id);
|
|
|
foreach ($question as $k=>$v){
|
|
|
$answer[$v['id']]=$v['answer'];
|
|
|
}
|
|
|
if (!empty($answer_array)){
|
|
|
foreach ($answer_array as $k=>$v){
|
|
|
if ($answer[$k]==$v){
|
|
|
unset($answer[$k]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (empty($answer)){
|
|
|
/*添加信息*/
|
|
|
/*添加用户时长*/
|
|
|
|
|
|
/*添加到完成*/
|
|
|
|
|
|
$this->success('回答成功');
|
|
|
}else{
|
|
|
$this->error('问题回答错误');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|