diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index 2a0bae4..5cc2364 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -15,6 +15,7 @@ class Journal extends Controller { protected $admin_obj = ''; protected $journal_obj = ''; protected $article_obj = ''; + protected $article_author_obj = ''; protected $journal_topic_obj = ''; protected $journal_stage_obj = ''; protected $journal_abs_obj = ''; @@ -25,6 +26,7 @@ class Journal extends Controller { $this->admin_obj = Db::name('admin'); $this->journal_obj = Db::name('journal'); $this->article_obj = Db::name('article'); + $this->article_author_obj = Db::name('article_author'); $this->journal_topic_obj = Db::name('journal_topic'); $this->journal_stage_obj = Db::name('journal_stage'); $this->journal_abs_obj = Db::name('journal_abstracting'); @@ -135,9 +137,25 @@ class Journal extends Controller { ->order('article_id desc') ->select(); $stage_info = $this->journal_stage_obj->where('journal_stage_id',$journal_info['publish_stage_id'])->find(); + //获取作者 + foreach($list as $k=>$v){ + $list[$k]['authortitle'] = $this->getAuthor($v); + } return json(['code'=>0,'msg'=>'success','data'=>['stage'=>$stage_info,'articleList'=>$list]]); } + private function getAuthor($article){ + $where['article_id'] = $article['article_id']; + $where['state'] = 0; + $list = $this->article_author_obj->where($where)->select(); + $frag = ''; + foreach ($list as $k=>$v){ + $frag .= $v['author_name'].','; + } + return substr($frag,0, -1); + } + + /** * @title 获取onlinefirst文章 * @description 获取onlinefirst文章 @@ -152,7 +170,7 @@ class Journal extends Controller { public function getOnlineArticle(){ $data = $this->request->post(); $stages = $this->journal_stage_obj->where('journal_id',$data['journal_id'])->where('is_publish',0)->where('state',0)->column('journal_stage_id'); - $list = $this->article_obj->where('journal_stage_id','in',$stages)->where('state',0)->select(); + $list = $this->article_obj->field('j_article.*,j_journal_stage.stage_year stage_year')->join('j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT')->where('j_article.journal_stage_id','in',$stages)->where('j_article.state',0)->select(); return json(['code'=>0,'msg'=>'success','data'=>['articlelist'=>$list]]); } @@ -170,7 +188,12 @@ class Journal extends Controller { public function getNewsArticle(){ $data = $this->request->post(); $stages = $this->journal_stage_obj->where('journal_id',$data['journal_id'])->where('is_publish',0)->where('state',0)->column('journal_stage_id'); - $list = $this->article_obj->where('journal_stage_id','in',$stages)->where('state',0)->where('type','News','Comment','or')->order('article_id')->select(); + $list = $this->article_obj + ->where('journal_stage_id','in',$stages) + ->where('state',0) + ->where('type',['like','News'],['like','Comment'],'or') + ->order('article_id') + ->select(); return json(['code'=>0,'msg'=>'success','data'=>['articlelist'=>$list]]); }