...
|
...
|
@@ -85,23 +85,179 @@ class Index extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (首页今日推荐列表)
|
|
|
* @ApiSummary (首页今日推荐列表)
|
|
|
* @ApiTitle (咨询分类更多列表)
|
|
|
* @ApiSummary (咨询分类更多列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/index/moreList)
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1571492001",
|
|
|
"data": {
|
|
|
"id": //id,
|
|
|
"title"://标题,
|
|
|
"type"://1经营管理2职业发展
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function moreList(){
|
|
|
$data = Db::name('contype')
|
|
|
->field('updatetime,createtime',true)
|
|
|
->order('id desc')
|
|
|
->select();
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (首页今日推荐/更多老师列表)
|
|
|
* @ApiSummary (首页今日推荐/更多老师列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/index/today)
|
|
|
*
|
|
|
* @ApiParams (name="type", type="int", required=false, description="类型(如果为空或者为1是今日推荐列表 2是更多老师列表)")
|
|
|
* @ApiParams (name="keyword", type="string", required=false, description="关键字")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1571492001",
|
|
|
"data": {
|
|
|
"id": //老师id,
|
|
|
"title"://标题,
|
|
|
"id": //老师id,
|
|
|
"user_id"://用户ID
|
|
|
"name"://老师名字
|
|
|
"sex"://性别
|
|
|
"birth"://出生日期
|
|
|
"idcard"://身份证号
|
|
|
"before"://身份证正面照
|
|
|
"behind"://身份证反面照
|
|
|
"phone"://手机号
|
|
|
"thumbnail"://头像
|
|
|
"address"://常住地
|
|
|
"honor"://头衔
|
|
|
"content"://个人履历
|
|
|
"show"://展示在最前
|
|
|
"desc"://个人简历
|
|
|
"online"://在线时段
|
|
|
"territory_id"://擅长领域ID
|
|
|
"help_num"://帮助人数
|
|
|
"level"://星级
|
|
|
"createtime"://创建时间
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function today()
|
|
|
{
|
|
|
$token = $this->request->header('token');
|
|
|
if(empty($token)){
|
|
|
$type = $this->request->param('type');
|
|
|
$keyword = $this->request->param('keyword');
|
|
|
if($type == '' || $type == 1){
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->where('is_recommend',1)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}else{
|
|
|
if(!empty($keyword)){
|
|
|
|
|
|
$contype = Db::name('contype')
|
|
|
->where('title',$keyword)
|
|
|
->field('id,title')
|
|
|
->find();
|
|
|
$territory = Db::name('territory')
|
|
|
->where('contype_id',$contype['id'])
|
|
|
->column('user_id');
|
|
|
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->where('name','Like',"%$keyword%")
|
|
|
->whereOr('honor','Like',"%$keyword%")
|
|
|
->whereOr('user_id','In',$territory)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}else{
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}
|
|
|
}
|
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
foreach ($data as &$v){
|
|
|
if($v['sex'] == 1){
|
|
|
$v['sex'] = '男';
|
|
|
}else{
|
|
|
$v['sex'] = '女';
|
|
|
}
|
|
|
$v['before'] = $http.$v['before'];
|
|
|
$v['behind'] = $http.$v['behind'];
|
|
|
$v['thumbnail'] = $http.$v['thumbnail'];
|
|
|
$v['territory_id'] = explode(',',$v['territory_id']);
|
|
|
foreach ($v['territory_id'] as &$val){
|
|
|
$val = Db::name('territory')
|
|
|
->alias('a')
|
|
|
->join('contype b','a.contype_id = b.id')
|
|
|
->where('a.id',$val)
|
|
|
->column('b.title');
|
|
|
}
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
$type = $this->request->param('type');
|
|
|
$keyword = $this->request->param('keyword');
|
|
|
if($type == '' || $type == 1){
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->where('is_recommend',1)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}else{
|
|
|
if(!empty($keyword)){
|
|
|
|
|
|
$contype = Db::name('contype')
|
|
|
->where('title',$keyword)
|
|
|
->field('id,title')
|
|
|
->find();
|
|
|
$territory = Db::name('territory')
|
|
|
->where('contype_id',$contype['id'])
|
|
|
->column('user_id');
|
|
|
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->where('name','Like',"%$keyword%")
|
|
|
->whereOr('honor','Like',"%$keyword%")
|
|
|
->whereOr('user_id','In',$territory)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}else{
|
|
|
$data = Db::name('teacher')
|
|
|
->where('status',1)
|
|
|
->field('status,updatetime',true)
|
|
|
->select();
|
|
|
}
|
|
|
}
|
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
foreach ($data as &$v){
|
|
|
if($v['sex'] == 1){
|
|
|
$v['sex'] = '男';
|
|
|
}else{
|
|
|
$v['sex'] = '女';
|
|
|
}
|
|
|
$v['before'] = $http.$v['before'];
|
|
|
$v['behind'] = $http.$v['behind'];
|
|
|
$v['thumbnail'] = $http.$v['thumbnail'];
|
|
|
$v['territory_id'] = explode(',',$v['territory_id']);
|
|
|
foreach ($v['territory_id'] as &$val){
|
|
|
$val = Db::name('territory')
|
|
|
->alias('a')
|
|
|
->join('contype b','a.contype_id = b.id')
|
|
|
->where('a.id',$val)
|
|
|
->column('b.title');
|
|
|
}
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
} |
...
|
...
|
|