From e244529d34de5698d8492367e89d13ccb1f434c6 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Thu, 28 Jan 2021 16:41:37 +0800 Subject: [PATCH] 20201112 --- application/api/controller/Article.php | 2 + application/api/controller/Special.php | 153 ++++++++++++++++++++----- 2 files changed, 125 insertions(+), 30 deletions(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index a8af614..9e42e16 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -952,6 +952,8 @@ class Article extends Controller { return true; }else if($type_name=='coverLetter' && $url == ''){ return true; + }else if($type_name=='totalpage' && $url = ''){ + return true; } $insert_data['article_id'] = $article_id; $insert_data['user_id'] = $user_id; diff --git a/application/api/controller/Special.php b/application/api/controller/Special.php index e0b60dd..713504e 100644 --- a/application/api/controller/Special.php +++ b/application/api/controller/Special.php @@ -14,10 +14,14 @@ class Special extends Controller { protected $article_obj = ''; protected $user_reviewer_obj = ''; protected $journal_obj = ''; + protected $country_obj = ''; + protected $article_author_obj = ''; protected $reviewer_major_obj = ''; protected $reviewer_to_journal_obj = ''; protected $user_reviewer_info_obj = ''; protected $user_msg_obj = ''; + protected $article_file_obj = ''; + protected $user_log_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -32,6 +36,10 @@ class Special extends Controller { $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); $this->user_reviewer_info_obj = Db::name('user_reviewer_info'); $this->user_msg_obj = Db::name('user_msg'); + $this->country_obj = Db::name('country'); + $this->article_author_obj = Db::name('article_author'); + $this->article_file_obj = Db::name('article_file'); + $this->user_log_obj = Db::name('user_log'); } /** @@ -111,7 +119,10 @@ class Special extends Controller { */ public function getArticles(){ $data = $this->request->post(); - $list = $this->article_obj->where('special_num',$data['special_id'])->where('state',0)->select(); + $list = $this->article_obj + ->where('special_num',$data['special_id']) + ->where('user_id',$data['user_id']) + ->where('state',0)->select(); $re['articles'] = $list; return json(['code'=>0,'data'=>['articles'=>$re]]); @@ -125,31 +136,49 @@ class Special extends Controller { //接受参数,查询信息 $data = $this->request->post(); -// return json($data); - -// $data['abstrart'] = '大萨达撒多'; // $data['authorList'] = [ // [ -// 'address'=>'dsadsa', -// 'company'=>'dasdsa', +// 'address'=>'111', +// 'company'=>'111', // 'country'=>'china', -// 'department'=>'dsadsa', +// 'department'=>'', // 'email'=>'6541654@qq.com', -// 'firstname'=>'dsadsa', +// 'firstname'=>'2222222', // 'isReport'=>'true', +// 'isSuper'=>'false', +// 'lastname'=>'2222222', +// 'title'=>'Ph.D.' +// ], +// [ +// 'address'=>'', +// 'company'=>'112221', +// 'country'=>'china', +// 'department'=>'', +// 'email'=>'2254@qq.com', +// 'firstname'=>'22212222', +// 'isReport'=>'false', // 'isSuper'=>'true', -// 'lastname'=>'dsadsa', +// 'lastname'=>'2222222', // 'title'=>'Ph.D.' // ] // ]; +// $data['abstrart'] = '1111'; // $data['coverLetter'] = ''; -// $data['fund'] = 'dsads'; -// $data['journal'] = 1; -// $data['keyWords'] = 'dsads'; -// $data['manuscirpt'] = "manuscirpt/20200727/cd67d8e8f944b5f1589cceb8e1aa967c.pdf"; -// $data['picturesAndTables'] = []; -// $data['title'] = "大萨达撒多"; -// $data['username'] = "wangjinlei"; +// $data['fund'] = ''; +// $data['journal_issn'] = '2538-015X'; +// $data['keyWords'] = '111,1111,1111'; +// $data['title'] = "111"; +// $data['major'] = '1'; +// $data['cmajor'] = '26'; +// $data['type'] = 'A'; +// $data['approval'] = 'true'; +// $data['username'] = "user1"; +// $data['coverLetter'] = ''; +// $data['picturesAndTables'] = ''; +// $data['totalpage'] = ''; +// $data['manuscirpt'] = '20210122/e08e82edcabe5dc9d9409d1947fccc82.png'; + + $user_res = $this->user_obj->where('account', $data['username'])->find(); $journal_info = $this->journal_obj->where('issn', $data['journal_issn'])->find(); @@ -162,6 +191,8 @@ class Special extends Controller { $inset_data['title'] = $data['title']; $inset_data['keywords'] = $data['keyWords']; $inset_data['fund'] = $data['fund']; + $inset_data['special_num'] = $data['special_id']; + $inset_data['special_title'] = $data['special_title']; $inset_data['accept_sn'] = getArticleSN($journal_info['abbr'],$data['type']); $inset_data['type'] = $data['type']; $inset_data['major_id'] = $data['major']; @@ -195,23 +226,18 @@ class Special extends Controller { //增加转投信息 $transr = true; - if($data['istransfer']=='true'){ - foreach ($data['checkedjours'] as $val){ - $trans_insert['article_id'] = $res; - $trans_insert['journal_id'] = $val; - $trans_insert['ctime'] = time(); - $transr = $transr?$this->article_transfer_obj->insert($trans_insert):false; - } - } +// if($data['istransfer']=='true'){ +// foreach ($data['checkedjours'] as $val){ +// $trans_insert['article_id'] = $res; +// $trans_insert['journal_id'] = $val; +// $trans_insert['ctime'] = time(); +// $transr = $transr?$this->article_transfer_obj->insert($trans_insert):false; +// } +// } //增加articlefile表的信息 $res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter'); - $res_file2 = true; - if(isset($data['picturesAndTables'])){ - foreach ($data['picturesAndTables'] as $v){ - $res_file2 = $res_file2?self::save_article_file($res, $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables'):false; - } - } + $res_file2 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['picturesAndTables'], 'picturesAndTables'); $res_file4 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage'); $res_file3 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt'); @@ -239,6 +265,73 @@ class Special extends Controller { return json(['code' => 1]); } } + + /** + * 上传文章的文件 + */ + public function up_file($type) { + $file = request()->file($type); + if ($file) { + $info = $file->move(ROOT_PATH . 'public' . DS . $type); + if ($info) { + return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]); + } else { + return json(['code' => 1, 'msg' => $file->getError()]); + } + } + } + + /** + * 获取领域分类 + */ + public function getMajor(){ + $majors = $this->reviewer_major_obj->where('pid',0)->select(); + return json(['code'=>0,'data'=>$majors]); + } + + /** + * 获取major子项目 + */ + public function majorChild(){ + $majorid = $this->request->post('majorid'); + $ds = $this->reviewer_major_obj->where('pid',$majorid)->select(); + return json(['code'=>0,'data'=>$ds]); + } + + /** + * 获取城市 + */ + public function getCountrys() { + $res = $this->country_obj->order('en_name')->select(); + return json($res); + } + + public function test(){ + echo strtotime('2021-1-1'); + } + /** + * 存储article文件历史信息 + */ + private function save_article_file($article_id, $user_id, $username, $url, $type_name) { + //首先确定数据库里面是否存在此数据 + $res = $this->article_file_obj->where(['file_url' => $url])->find(); + if ($res) { + return true; + }else if($type_name=='picturesAndTables' && $url == ''){ + return true; + }else if($type_name=='coverLetter' && $url == ''){ + return true; + }else if($type_name=='totalpage' && $url = ''){ + return true; + } + $insert_data['article_id'] = $article_id; + $insert_data['user_id'] = $user_id; + $insert_data['username'] = $username; + $insert_data['file_url'] = $url; + $insert_data['type_name'] = $type_name; + $insert_data['ctime'] = time(); + return $this->article_file_obj->insert($insert_data); + } }