From efbe9e40db1fcc27cdc0f4a0545d239c2c0a0b10 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Mon, 7 Dec 2020 14:25:31 +0800 Subject: [PATCH] 20201112 --- application/api/controller/Journal.php | 61 +++++++++++++++-- application/master/controller/Journal.php | 79 +++++++++++++++++++++++ 2 files changed, 134 insertions(+), 6 deletions(-) diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index 5cc2364..491e7dc 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -18,6 +18,7 @@ class Journal extends Controller { protected $article_author_obj = ''; protected $journal_topic_obj = ''; protected $journal_stage_obj = ''; + protected $journal_notices_obj = ''; protected $journal_abs_obj = ''; protected $article_to_topic_obj = ''; @@ -29,6 +30,7 @@ class Journal extends Controller { $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_notices_obj = Db::name('journal_notices'); $this->journal_abs_obj = Db::name('journal_abstracting'); $this->article_to_topic_obj = Db::name('article_to_topic'); } @@ -170,7 +172,12 @@ 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->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(); + $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]]); } @@ -187,14 +194,56 @@ 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'); + $stages = $this->journal_stage_obj->where('journal_id',$data['journal_id'])->where('is_publish',1)->where('state',0)->column('journal_stage_id'); $list = $this->article_obj - ->where('journal_stage_id','in',$stages) - ->where('state',0) - ->where('type',['like','News'],['like','Comment'],'or') - ->order('article_id') + ->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) + ->where('j_article.type',['like','News'],['like','Comment'],'or') + ->order('j_article.article_id') ->select(); return json(['code'=>0,'msg'=>'success','data'=>['articlelist'=>$list]]); } + /** + * @title 获取消息列表 + * @description 获取消息列表 + * @author wangjinlei + * @url /api/Journal/getNotices + * @method POST + * + * @param name:journal_id type:int require:1 desc:期刊id + * + * @return notices:消息列表array# + */ + public function getNotices(){ + $data = $this->request->post(); + $list = $this->journal_notices_obj->where('journal_id',$data['journal_id'])->where('state',0)->select(); + return jsonSuccess(['notices'=>$list]); + } + + /** + * @title 获取话题文章 + * @description 获取话题文章 + * @author wangjinlei + * @url /api/Journal/getTopicArticle + * @method POST + * + * @param name:journal_topic_id type:int require:1 desc:期刊话题id + * + * @return topic_info:话题详情 + * @return articlelist:文章列表array# + */ + public function getTopicArticle(){ + $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]]); + } + } diff --git a/application/master/controller/Journal.php b/application/master/controller/Journal.php index 70a2a91..e6529ad 100644 --- a/application/master/controller/Journal.php +++ b/application/master/controller/Journal.php @@ -17,6 +17,7 @@ class Journal extends Controller { protected $article_obj = ''; protected $journal_topic_obj = ''; protected $journal_stage_obj = ''; + protected $journal_notices_obj = ''; protected $journal_abs_obj = ''; protected $article_to_topic_obj = ''; @@ -27,6 +28,7 @@ class Journal extends Controller { $this->article_obj = Db::name('article'); $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'); } @@ -705,5 +707,82 @@ class Journal extends Controller { } } + /** + * @title 增加期刊消息 + * @description 增加期刊消息 + * @author wangjinlei + * @url /master/Journal/addNotices + * @method POST + * + * @param name:journal_id type:int require:1 desc:期刊id + * @param name:title type:string require:1 desc:消息标题 + * @param name:content type:string require:1 desc:内容 + * + */ + public function addNotices(){ + $data = $this->request->post(); + $insert['journal_id'] = $data['journal_id']; + $insert['title'] = $data['title']; + $insert['content'] = $data['content']; + $insert['ctime'] = time(); + $res = $this->journal_notices_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/Journal/delNotices + * @method POST + * + * @param name:journal_notices_id type:int require:1 desc:期刊id + * + */ + public function delNotices(){ + $data = $this->request->post(); + $this->journal_notices_obj->where('journal_notices_id',$data['journal_notices_id'])->update(['state'=>1]); + return json(['code'=>0,'msg'=>'success']); + } + + /** + * @title 更改期刊消息 + * @description 更改期刊消息 + * @author wangjinlei + * @url /master/Journal/changeNotices + * @method POST + * + * @param name:journal_notices_id type:int require:1 desc:期刊消息id + * @param name:title type:string require:1 desc:消息标题 + * @param name:content type:string require:1 desc:内容 + * + */ + public function changeNotices(){ + $data = $this->request->post(); + $this->journal_notices_obj->where('journal_notices_id',$data['journal_notices_id'])->update(['title'=>$data['title'],'content'=>$data['content']]); + return json(['code'=>0,'msg'=>'success']); + } + + /** + * @title 获取期刊消息 + * @description 获取期刊消息 + * @author wangjinlei + * @url /master/Journal/getNotices + * @method POST + * + * @param name:journal_id type:int require:1 desc:期刊id + * + * @return notices:消息list + * + */ + public function getNotices(){ + $data = $this->request->post(); + $list = $this->journal_notices_obj->where('journal_id',$data['journal_id'])->where('state',0)->select(); + return jsonSuccess(['notices'=>$list]); + } }