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->article_organ_obj = Db::name('article_organ'); $this->article_author_to_organ_obj = Db::name('article_author_to_organ'); $this->journal_topic_obj = Db::name('journal_topic'); $this->journal_stage_obj = Db::name('journal_stage'); $this->journal_notices_obj = Db::name('journal_notices'); $this->journal_abs_obj = Db::name('journal_abstracting'); $this->article_to_topic_obj = Db::name('article_to_topic'); } /** * @title 获取文章详情 * @description 获取文章详情 * @author wangjinlei * @url /api/Article/getArticleDetail * @method POST * * @param name:article_id type:int require:1 desc:文章id * * @return articleInfo:文章信息# * @return journalInfo:期刊信息# * @return stageInfo:分期信息# * @return author:作者信息# * @return cite:引用# * */ public function getArticleDetail(){ $data = $this->request->post(); $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); $stage_info = $this->journal_stage_obj->where('journal_stage_id',$article_info['journal_stage_id'])->find(); //获取文章作者相关 $authors = $this->article_author_obj->where('article_id',$article_info['article_id'])->where('state',0)->select(); $organs = $this->article_organ_obj->where('article_id',$article_info['article_id'])->where('state',0)->select(); $atto = $this->article_author_to_organ_obj->where('article_id',$article_info['article_id'])->where('state',0)->select(); $author = $this->sys_author($authors,$organs,$atto); //组合cite信息 $no = $stage_info['stage_no']==0?':':'('.$stage_info['stage_no'].'):'; $cite = $article_info['abbr'].' '.$article_info['title'].' '.$journal_info['jabbr'].'. '.$stage_info['stage_year'].';'.$stage_info['stage_vol'].$no.$article_info['npp'].'. doi:'.$article_info['doi']; //修改keywords $article_info['keywords'] = str_replace(',','    ', $article_info['keywords']); //返回数据 $re['articleInfo'] = $article_info; $re['journalInfo'] = $journal_info; $re['stageInfo'] = $stage_info; $re['author'] = $author; $re['cite'] = $cite; return jsonSuccess($re); } private function sys_author($authors,$organs,$atto){ $cache = []; foreach ($organs as $k => $v){ $cache[$v['article_organ_id']] = $k+1; $organs[$k]['alias'] = $k+1; } foreach ($authors as $key => $val){ $authors[$key]['ors'] = ''; foreach ($atto as $vv){ if($vv['article_author_id']==$val['article_author_id']){ $authors[$key]['ors'] = $authors[$key]['ors']==''?''.$cache[$vv['article_organ_id']]:$authors[$key]['ors'].', '.$cache[$vv['article_organ_id']]; } } } return ['authors'=>$authors,'organs'=>$organs]; } /** * @title 获取话题文章列表 * @description 获取话题文章列表 * @author wangjinlei * @url /api/Article/getTopicArticles * @method POST * * @param name:topic_id type:int require:1 desc:文章id * * @return topicInfo:话题信息# * @return articleList:文章信息# * */ public function getTopicArticles(){ $data = $this->request->post(); $topic_info = $this->journal_topic_obj->where('journal_topic_id',$data['topic_id'])->find(); $list = $this->article_to_topic_obj->field('j_article.*,j_journal_stage.*') ->join(array(['j_article','j_article_to_topic.article_id = j_article.article_id','LEFT'],['j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT'])) ->where('j_article_to_topic.topic_id',$data['topic_id']) ->where('j_article_to_topic.state',0) ->select(); //获取作者 foreach($list as $k=>$v){ $list[$k]['authortitle'] = $this->getAuthor($v); } $re['topicInfo'] = $topic_info; $re['articleList'] = $list; return jsonSuccess($re); } 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 获取stage文章列表 * @description 获取stage文章列表 * @author wangjinlei * @url /api/Article/getStageArticles * @method POST * * @param name:stage_id type:int require:1 desc:分期id * * @return stageInfo:分期# * @return articleList:文章信息# * */ public function getStageArticles(){ $data = $this->request->post(); $stage_info = $this->journal_stage_obj->where('journal_stage_id',$data['stage_id'])->find(); $list = $this->article_obj->field('j_article.*,j_journal_stage.*')->join('j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT')->where('j_article.journal_stage_id',$data['stage_id'])->where('_article.state',0)->select(); // $topic_info = $this->journal_topic_obj->where('journal_topic_id',$data['topic_id'])->find(); // $list = $this->article_to_topic_obj->field('j_article.*,j_journal_stage.*') // ->join(array(['j_article','j_article_to_topic.article_id = j_article.article_id','LEFT'],['j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT'])) // ->where('j_article_to_topic.topic_id',$data['topic_id']) // ->where('j_article_to_topic.state',0) // ->select(); //获取作者 foreach($list as $k=>$v){ $list[$k]['authortitle'] = $this->getAuthor($v); } $re['stageInfo'] = $stage_info; $re['articleList'] = $list; return jsonSuccess($re); } }