From a0d5dfa0f18f10a4a530f3b123dafd8f63352610 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Tue, 24 Nov 2020 17:04:10 +0800 Subject: [PATCH] 20201112 --- application/master/controller/Article.php | 105 ++++++++++++++++++++-- 1 file changed, 98 insertions(+), 7 deletions(-) diff --git a/application/master/controller/Article.php b/application/master/controller/Article.php index cd393bf..f807443 100644 --- a/application/master/controller/Article.php +++ b/application/master/controller/Article.php @@ -17,6 +17,7 @@ class Article extends Controller { protected $article_author_obj = ''; protected $article_organ_obj = ''; protected $author_to_organ_obj = ''; + protected $article_to_topic_obj = ''; protected $journal_topic_obj = ''; protected $journal_stage_obj = ''; protected $country_obj = ''; @@ -29,6 +30,7 @@ class Article extends Controller { $this->article_author_obj = Db::name('article_author'); $this->article_organ_obj = Db::name('article_organ'); $this->author_to_organ_obj = Db::name('article_author_to_organ'); + $this->article_to_topic_obj = Db::name('article_to_topic'); $this->journal_topic_obj = Db::name('journal_topic'); $this->journal_stage_obj = Db::name('journal_stage'); $this->country_obj = Db::name('country'); @@ -48,7 +50,6 @@ class Article extends Controller { */ public function getJournalAndStage(){ $data = $this->request->post(); - $data['editor_id'] = 6; $journal_list = $this->journal_obj->where('editor_id',$data['editor_id'])->select(); $frag = []; foreach ($journal_list as $v){ @@ -59,6 +60,8 @@ class Article extends Controller { } if(count($cache_list)>0){ $v['children'] = $cache_list; + }else{ + $v['children'] = []; } $frag[] = $v; } @@ -335,6 +338,7 @@ class Article extends Controller { * @param name:doi type:string require:1 desc:doi * @param name:abstract type:string require:1 desc:简介 * @param name:keywords type:string require:1 desc:关键字 + * @param name:sort type:int require:1 desc:权重 * @param name:fund type:string require:1 desc:fund * @param name:pub_date type:string require:1 desc:发表日期 * @@ -348,6 +352,7 @@ class Article extends Controller { $updata['abstract'] = $data['abstract']; $updata['keywords'] = $data['keywords']; $updata['fund'] = $data['fund']; + $updata['sort'] = $data['sort']; $updata['pub_date'] = $data['pub_date']; $res = $this->article_obj->where('article_id',$data['article_id'])->update($updata); if($res){ @@ -409,25 +414,111 @@ class Article extends Controller { // $data['seach'] = ''; // $data['pageIndex'] = 1; // $data['pageSize'] = 80; - $where['state'] = 0; + $where['j_article.state'] = 0; if(intval($data['journal_id'])!==0){ - $where['journal_id'] = $data['journal_id']; + $where['j_article.journal_id'] = $data['journal_id']; }else{ $journals = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id'); - $where['journal_id'] = ['in',$journals]; + $where['j_article.journal_id'] = ['in',$journals]; } if(intval($data['journal_stage_id'])!==0){ - $where['journal_stage_id'] = $data['journal_stage_id']; + $where['j_article.journal_stage_id'] = $data['journal_stage_id']; } if(isset($data['seach'])&&$data['seach']!=''){ - $where['title'] = ['like','%'.$data['seach'].'%']; + $where['j_article.title'] = ['like','%'.$data['seach'].'%']; } $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; - $article_list = $this->article_obj->where($where)->order('sort desc')->limit($limit_start,$data['pageSize'])->select(); + $article_list = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title')->join(array(['j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT'],['j_journal','j_journal.journal_id=j_article.journal_id','LEFT']))->where($where)->order('sort desc')->limit($limit_start,$data['pageSize'])->select(); $count = $this->article_obj->where($where)->count(); return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'articleList'=>$article_list]]); } + /** + * @title 获取文章对应期刊话题 + * @description 获取文章对应期刊话题 + * @author wangjinlei + * @url /master/Article/getTopicByArticle + * @method POST + * + * @param name:article_id type:int require:1 desc:期刊id + * + * @return topics:array# + * @return nowtopic:array# + */ + public function getTopicByArticle(){ + $data = $this->request->post(); + $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); + $topic_res = $this->journal_topic_obj->where('journal_id',$article_info['journal_id'])->where('state',0)->select(); + $frag = []; + foreach ($topic_res as $v){ + if($v['is_final']==1){ + $frag[] = $v; + } + } + foreach ($frag as $k => $val){ + $frag[$k]['tname'] = $this->getTname($val, $topic_res); + } + //获取初始话题 + $now_list = $this->article_to_topic_obj->where('article_id',$data['article_id'])->where('state',0)->select(); + return json(['code'=>0,'msg'=>'success','data'=>['nowtopic'=>$now_list,'topics'=>$frag]]); + } + private function getTname($now,$arr){ + if($now['parent_id']==0){ + return $now['title']; + }else{ + $frag = '>'.$now['title']; + foreach ($arr as $v){ + if($v['journal_topic_id']==$now['parent_id']){ + $frag = $this->getTname($v, $arr).$frag; + } + } + return $frag; + } + } + + /** + * @title 增加文章话题 + * @description 增加文章话题 + * @author wangjinlei + * @url /master/Article/addTopicByArticle + * @method POST + * + * @param name:article_id type:int require:1 desc:期刊id + * @param name:topic_id type:int require:1 desc:话题id + * + */ + public function addTopicByArticle(){ + $data = $this->request->post(); + $insert['article_id'] = $data['article_id']; + $insert['topic_id'] = $data['topic_id']; + $res = $this->article_to_topic_obj->insert($insert); + if($res){ + return json(['code'=>0,'msg'=>'success']); + }else{ + return json(['code'=>1,'msg'=>'system error']); + } + } + + /** + * @title 删除文章话题 + * @description 删除文章话题 + * @author wangjinlei + * @url /master/Article/delTopic + * @method POST + * + * @param name:article_to_topic_id type:int require:1 desc:主键id + * + */ + public function delTopic(){ + $data = $this->request->post(); + $res = $this->article_to_topic_obj->where('article_to_topic_id',$data['article_to_topic_id'])->update(['state'=>1]); + if($res){ + return json(['code'=>0,'msg'=>'success']); + }else{ + return json(['code'=>1,'msg'=>'system error']); + } + } + /** * @title 图片上传 * @description 图片上传