20201112
This commit is contained in:
137
application/api/controller/Article.php
Normal file
137
application/api/controller/Article.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* @title 文章web接口
|
||||
* @description 文章web相关操作
|
||||
* @group 文章web相关
|
||||
*/
|
||||
class Article extends Controller{
|
||||
//put your code here
|
||||
protected $admin_obj = '';
|
||||
protected $journal_obj = '';
|
||||
protected $article_obj = '';
|
||||
protected $article_author_obj = '';
|
||||
protected $article_organ_obj = '';
|
||||
protected $article_author_to_organ_obj = '';
|
||||
protected $journal_topic_obj = '';
|
||||
protected $journal_stage_obj = '';
|
||||
protected $journal_notices_obj = '';
|
||||
protected $journal_abs_obj = '';
|
||||
protected $article_to_topic_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
$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->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'];
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -206,6 +206,23 @@ class Journal extends Controller {
|
||||
return json(['code'=>0,'msg'=>'success','data'=>['articlelist'=>$list]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取top前4条article
|
||||
* @description 获取top前4条article
|
||||
* @author wangjinlei
|
||||
* @url /api/Journal/getTopArticle
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return articles:文章列表array#
|
||||
*/
|
||||
public function getTopArticle(){
|
||||
$data = $this->request->post();
|
||||
$list = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',0)->orderRaw('cited+abs_num+pdf_num desc')->limit(4)->select();
|
||||
return jsonSuccess(['articles'=>$list]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取消息列表
|
||||
* @description 获取消息列表
|
||||
@@ -224,26 +241,53 @@ class Journal extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取话题文章
|
||||
* @description 获取话题文章
|
||||
* @title 获取highl话题文章
|
||||
* @description 获取highl话题文章
|
||||
* @author wangjinlei
|
||||
* @url /api/Journal/getTopicArticle
|
||||
* @url /api/Journal/getHighTopicArticle
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_topic_id type:int require:1 desc:期刊话题id
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
*
|
||||
* @return topic_info:话题详情
|
||||
* @return articlelist:文章列表array#
|
||||
*/
|
||||
public function getTopicArticle(){
|
||||
public function getHighTopicArticle(){
|
||||
$data = $this->request->post();
|
||||
$topic_info = $this->journal_topic_obj->where('journal_topic_id',$data['journal_topic_id'])->find();
|
||||
$list = $this->article_to_topic_obj->field('j_article.*')
|
||||
->join('j_article','j_article.article_id = j_article_to_topic.article_id','LEFT')
|
||||
->where('j_article_to_topic.topic_id',$data['journal_topic_id'])
|
||||
->where('j_article_to_topic.state',0)
|
||||
->select();
|
||||
return json(['code'=>0,'msg'=>'success','data'=>['topic_info'=>$topic_info,'articlelist'=>$list]]);
|
||||
$topic_info = $this->journal_topic_obj->where('journal_id',$data['journal_id'])->where('position','highlights')->where('state',0)->find();
|
||||
if($topic_info){
|
||||
$list = $this->article_to_topic_obj->field('j_article.*')
|
||||
->join('j_article','j_article.article_id = j_article_to_topic.article_id','LEFT')
|
||||
->where('j_article_to_topic.topic_id',$topic_info['journal_topic_id'])
|
||||
->where('j_article_to_topic.state',0)
|
||||
->select();
|
||||
return jsonSuccess(['topic_info'=>$topic_info,'articlelist'=>$list]);
|
||||
}else{
|
||||
return jsonError('no highlights');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 获取话题列表
|
||||
* @description 获取话题列表
|
||||
* @author wangjinlei
|
||||
* @url /api/Journal/getTopicList
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_topic_id type:int require:1 desc:期刊话题id
|
||||
*
|
||||
* @return oldJournal:父期刊信息 Description
|
||||
* @return journalList:话题列表array#
|
||||
*/
|
||||
public function getTopicList(){
|
||||
$data = $this->request->post();
|
||||
$journal_info = $this->journal_topic_obj->where('journal_topic_id',$data['journal_topic_id'])->find();
|
||||
$list = $this->journal_topic_obj->where('parent_id',$data['journal_topic_id'])->where('state',0)->select();
|
||||
|
||||
$re['oldJournal'] = $journal_info;
|
||||
$re['journalList'] = $list;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user