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

bug修改

... ... @@ -169,7 +169,7 @@ class Topic extends Api
//$matches[1] 为图片路径数组
preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
// 不小于3张就显示3张,小于3张就显示1张图片
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
// 显示数据
$v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
$v->getRelation('user')->visible(['id','image','nickname']);
... ... @@ -302,7 +302,7 @@ class Topic extends Api
//$matches[1] 为图片路径数组
preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
// 不小于3张就显示3张,小于3张就显示1张图片
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
// 显示数据
$v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
$v->getRelation('user')->visible(['id','image','nickname']);
... ...
... ... @@ -1230,7 +1230,7 @@ class User extends Api
//$matches[1] 为图片路径数组
preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
// 不小于3张就显示3张,小于3张就显示1张图片
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
$v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
// 显示数据
$v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
$v->getRelation('user')->visible(['id','image','nickname']);
... ... @@ -1265,6 +1265,19 @@ class User extends Api
{
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$topic_id_arr = Topic::where('user_id',$this->auth->id)->column('id');
$topic_appraise_id_arr = db('topic_appraise')
->alias('ta')
->join('topic t','t.id = ta.topic_id')
->where('ta.pid',0)
->where('ta.is_replied','0')
->column('ta.id');
$topic_appraise_id_arr = db('topic_appraise')
->alias('ta')
->join('topic_appraise ta1','ta1.id = ta.cue_appraise_id')
->where('ta1.user_id',$this->auth->id)
->where('ta.is_replied','0')
->column('ta.id');
$data = Topic::with(['user'])
->where('user_id',$this->auth->id)
->order('createtime desc')
... ... @@ -1284,7 +1297,7 @@ class User extends Api
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="problem_id", type="inter", required=true, description="问题ID")
* @ApiParams (name="flag", type="inter", required=true, description="0=我发布的,1=我投递的")
*
* @ApiReturn({
"code": 1,
... ... @@ -1303,11 +1316,40 @@ class User extends Api
*/
public function userJob()
{
$problem_id = $this->request->param('problem_id');
empty($problem_id) && $this->error('缺少必需参数');
$info = Problem::get($problem_id);
empty($info) && $this->error('问题不存在');
$this->success('成功', $info);
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$keyword = $this->request->param('keyword');
$type = $this->request->param('type');
$user_job_ability_id = $this->request->param('user_job_ability_id');
$where = [];
// 搜索关键词
if(!empty($keyword)){
$where[] = ['name', 'like', "%{$keyword}%"];
}
// 求职类型
if(!empty($type)){
$where[] = ['type', $type];
}
// 求职类型
if(!empty($user_job_ability_id)){
$where[] = "FIND_IN_SET('{$user_job_ability_id}',user_job_ability_ids)";
}
// 整合where
$where = function ($query) use ($where) {
foreach ($where as $k => $v) {
if (is_array($v)) {
call_user_func_array([$query, 'where'], $v);
} else {
$query->where($v);
}
}
};
$data = UserJob::where($where)
->field('id,name,type,salary,address,mobile')
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
->toArray();
$this->success('成功', $data);
}
/**
... ...