diff --git a/application/wechat/controller/Article.php b/application/wechat/controller/Article.php index 837b199..0cd83da 100644 --- a/application/wechat/controller/Article.php +++ b/application/wechat/controller/Article.php @@ -74,7 +74,7 @@ class Article extends Controller */ private function _journal($iJournalId = 0){ $aWhere = ['journal_id' => $iJournalId,'state' => 0]; - $aJournal = Db::name('journal')->field('journal_id,title as journal_title,icon as journal_icon,usx as journal_usx,abstract as journal_content_english, abstract_chinese as journal_content,jabbr,email as journal_email,issn')->where($aWhere)->find(); + $aJournal = Db::name('journal')->field('journal_id,title as journal_title,icon as journal_icon,usx as journal_usx,abstract as journal_content_english, abstract_chinese as journal_content,jabbr,email as journal_email,issn,publish_author,editor_qrcode')->where($aWhere)->find(); return $aJournal; } @@ -137,4 +137,42 @@ class Article extends Controller // return $aAuthorInfo; } + /** + * 更新期刊内容 + * @param article_id 文章ID + */ + public function updateJournal(){ + + //获取参数 + $aParam = $this->request->post(); + $sIssn = empty($aParam['issn']) ? '' :$aParam['issn'] ; + if(empty($sIssn)){ + return json_encode(array('status' => 2,'msg' => 'Please select an journal')); + } + + //查询期刊是否存在 + $aJournal = Db::name('journal')->where('issn',$sIssn)->find(); + if(empty($aJournal)){ + return json_encode(array('status' => 4,'msg' => 'The journal does not exist')); + } + $iJournalId = $aJournal['journal_id']; + + //更新字段 + $aFileds = ['journal_topic','abstract_chinese','publish_author','editor_qrcode']; + + foreach ($aFileds as $key => $value) { + if(isset($aParam[$value])){ + $aUpdate[$value] = empty($aParam[$value]) ? '' : addslashes(trim(htmlspecialchars($aParam[$value]))); + } + } + if(empty($aUpdate)){ + return json_encode(array('status' => 5,'msg' => 'update success')); + } + $result = Db::name('journal')->where('journal_id',$iJournalId)->limit(1)->update($aUpdate); + if($result === false){ + return json_encode(array('status' => 6,'msg' => 'Update failed')); + } + return json_encode(array('status' => 1,'msg' => 'update success')); + } + }