From 5c5143166cb6d5ced04d78525c870f98ce2bdf62 Mon Sep 17 00:00:00 2001
From: wangjinlei <751475802@qq.com>
Date: Tue, 24 Aug 2021 14:58:13 +0800
Subject: [PATCH] 20201112
---
application/api/controller/Admin.php | 19 +-
application/api/controller/Article.php | 43 +-
application/api/controller/Board.php | 144 +++++
application/api/controller/Chief.php | 795 ++++++++++++++++++++++++
application/api/controller/Reviewer.php | 134 +++-
application/api/controller/User.php | 250 ++++++--
6 files changed, 1333 insertions(+), 52 deletions(-)
create mode 100644 application/api/controller/Board.php
create mode 100644 application/api/controller/Chief.php
diff --git a/application/api/controller/Admin.php b/application/api/controller/Admin.php
index 8ec63df..50f38bd 100644
--- a/application/api/controller/Admin.php
+++ b/application/api/controller/Admin.php
@@ -40,6 +40,12 @@ class Admin extends Controller {
$this->article_author_obj = Db::name('article_author');
$this->country_obj = Db::name('country');
}
+
+
+ public function YLtest(){
+ $data = $this->request->post();
+ return jsonSuccess(['mycode'=>md5($data['mmm'])]);
+ }
/**
* 获取编辑人员列表(分页)
@@ -100,7 +106,7 @@ class Admin extends Controller {
$where['t_article.state'] = $data['state'];
} else {
if ($data['act'] == 1) {
- $where['t_article.state'] = array('in', [0, 1, 2, 4]);
+ $where['t_article.state'] = array('in', [0, 1, 2, 4, 6]);
} else if ($data['act'] == 2) {
$where['t_article.state'] = array('in', [3, 5]);
}
@@ -326,8 +332,8 @@ class Admin extends Controller {
//接收信息
$data = $this->request->post();
-// $data['journal'] = 7;
-// $data['url'] = 'reviewer/import/20200826/a8c03d7f9ac899c0a590ff26663402f2.xlsx';
+ $data['journal'] = 5;
+ $data['url'] = 'reviewer/import/20210819/beb6de5c69e4878d995fd8de192d17af.xlsx';
$journal = $data['journal'];
$journal_info = $this->journal_obj->where('journal_id', $journal)->find();
@@ -340,6 +346,11 @@ class Admin extends Controller {
$su_data = [];
$er_data = [];
foreach ($frag as $v) {
+
+ if($v['username']==''){
+ continue;
+ }
+
//验证数据完整性
if ($v['username'] == '' || $v['email'] == '' || $v['realname'] == '' || $v['major'] == '' || $v['username'] == null || $v['email'] == null || $v['realname'] == null || $v['major'] == null) {
$er_data[] = [
@@ -531,7 +542,7 @@ class Admin extends Controller {
* 获取对应关系
*/
private function get_retojo($reviewer_id, $journal_id) {
- return $this->reviewer_to_journal_obj->where('reviewer_id', $reviewer_id)->where('journal_id', $journal_id)->find();
+ return $this->reviewer_to_journal_obj->where('reviewer_id', $reviewer_id)->where('journal_id', $journal_id)->where('state',0)->find();
}
/**
diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php
index 12a869e..45017c5 100644
--- a/application/api/controller/Article.php
+++ b/application/api/controller/Article.php
@@ -20,6 +20,8 @@ class Article extends Controller {
protected $article_reviewer_obj = '';
protected $article_author_obj = '';
protected $article_transfer_obj = '';
+ protected $chief_to_journal_obj = '';
+ protected $login_auto_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
@@ -36,6 +38,7 @@ class Article extends Controller {
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->article_author_obj = Db::name('article_author');
$this->article_transfer_obj = Db::name('article_transfer');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
}
/**
@@ -90,7 +93,7 @@ class Article extends Controller {
$where['t_article.state'] = $data['state'];
}else{
if($data['act']==1){
- $where['t_article.state'] = array('in',[0,1,2,4]);
+ $where['t_article.state'] = array('in',[0,1,2,4,6]);
}else if($data['act']==2){
$where['t_article.state'] = array('in',[3,5]);
}
@@ -502,6 +505,9 @@ class Article extends Controller {
$tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.
';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.
';
$tt .= 'Sincerely,
Editorial Office
';
+ }else if($data['state']==6){//终审
+ $tt = 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',
';
+ $tt .= 'Manuscript status: Your manuscript "'.$article_info['title'].'" is under reviewing by editorial member team of '.$journal_info['title'].'.';
}else{
$tt = '"'.$article_info['title'].'"
';
$tt .= $article_info['accept_sn'].'
';
@@ -515,6 +521,30 @@ class Article extends Controller {
if($data['state']!=5||$journal_info['journal_id']!=9){
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
}
+ if($data['state']==6){//进入终审,通知主编邮件
+ $chiefs = $this->chief_to_journal_obj->join('t_user','t_user.user_id = t_chief_to_journal.user_id','left')->where('t_chief_to_journal.journal_id',$journal_info['journal_id'])->where('t_chief_to_journal.state',0)->select();
+ foreach ($chiefs as $v){
+ $tts = $article_info['accept_sn'].'
';
+ $tts .= 'Dear Editor-in-Chief '.($v['realname']==''?'':$v['realname']).',
';
+ $tts .= 'The manuscript entitled “'.$article_info['title'].'”is under fininal decision status of the journal '.$journal_info['title'].'.
';
+ $tts .= '(The manuscripit in fininal decision status has been peer-reviewed, and the authors had revised all review opinions.)
';
+ $tts .= 'The editorial office would be most grateful if you could offer an opinion regarding its suitability for publication in the journal Traditional Medicine Research. You can also invite 2-3 editorial board members to give their own '
+ . 'comments on the manuscript by submission system.(Plese click here)
';
+ $tts .= 'Any comments and decisions you make will be valued by the editorial board and the editor in chief. If you choose not to make a decision on this article, you need not to reply and log in the submission system, we will refer to the opinions of other experts.
';
+ $tts .= 'Please bring into our knowledge if there is any potential Conflict of Interest.
';
+ $tts .= 'Thank you for your consideration.
';
+ $tts .= 'Look forward for your reply.
';
+ $tts .= 'Reviewer Center
';
+ $tts .= 'Your username:'.$v['account'].'
';
+ $tts .= 'Sincerely,
';
+ $tts .= 'Editorial Office
';
+ $tts .= $journal_info['title'].'
';
+ $tts .= 'Email: '.$journal_info['email'].'
';
+ $tts .= 'Website: '.$journal_info['website'];
+ }
+ sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tts, $journal_info['email'], $journal_info['epassword']);
+ }
+
//转投操作
if($data['trsjournal']!=0){
$tran_data['article_id'] = $data['articleId'];
@@ -537,6 +567,17 @@ class Article extends Controller {
return json(['code' => 0]);
}
+ private function creatLoginUrlForChief($user){
+ $code = md5(time().rand(1000,9999).'thinkphp');
+ $insert['user_id'] = $user['user_id'];
+ $insert['code'] = $code;
+ $insert['ctime'] = time();
+ $this->login_auto_obj->insert($insert);
+ $url = 'https://submission.tmrjournals.com/man_text?Art_id=336&act='.$code;
+ return $url;
+ }
+
+
/**
* 编辑文章备注
*/
diff --git a/application/api/controller/Board.php b/application/api/controller/Board.php
new file mode 100644
index 0000000..0a8173c
--- /dev/null
+++ b/application/api/controller/Board.php
@@ -0,0 +1,144 @@
+user_obj = Db::name('user');
+ $this->user_act_obj = Db::name('user_act');
+ $this->article_obj = Db::name('article');
+ $this->journal_obj = Db::name('journal');
+ $this->user_log_obj = Db::name('user_log');
+ $this->reviewer_major_obj = Db::name('reviewer_major');
+ $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
+ $this->article_msg_obj = Db::name('article_msg');
+ $this->article_file_obj = Db::name('article_file');
+ $this->article_reviewer_obj = Db::name('article_reviewer');
+ $this->article_author_obj = Db::name('article_author');
+ $this->article_transfer_obj = Db::name('article_transfer');
+ $this->staff_obj = Db::name('staff');
+ $this->staff_level_obj = Db::name('staff_level');
+ $this->staff_log_obj = Db::name('staff_log');
+ $this->staff_to_journal_obj = Db::name('staff_to_journal');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->board_to_journal_obj = Db::name('board_to_journal');
+ $this->chief_msg_obj = Db::name('chief_msg');
+ $this->article_to_board_obj = Db::name('article_to_board');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->login_auto_obj = Db::name('login_auto');
+ }
+
+ /**
+ * @title 编委主页--获取进行中的文章
+ * @description 编委主页--获取进行中的文章
+ * @author wangjinlei
+ * @url /api/Board/getBoardPendArticle
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:编委用户id
+ * @param name:journal_id type:int require:1 desc:期刊id
+ *
+ * @return articles:文章列表#
+ */
+ public function getBoardPendArticle() {
+ $data = $this->request->post();
+ $list = $this->article_obj->where('journal_id', $data['journal_id'])->where('state', 6)->select();
+ foreach ($list as $k => $v) {
+ $auts = $this->article_author_obj->where('article_id', $v['article_id'])->where('state', 0)->select();
+ $au = '';
+ foreach ($auts as $vv) {
+ $au .= $vv['firstname'] . ' ' . $vv['lastname'] . ';';
+ }
+ $list[$k]['author'] = substr($au, 0, -1);
+ }
+
+ $re['articles'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 编委主页--获取历史文章
+ * @description 编委主页--获取历史文章
+ * @author wangjinlei
+ * @url /api/Board/getBoardHistArticles
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:编委用户id
+ * @param name:journal_id type:int require:1 desc:期刊id
+ *
+ * @return articles:文章列表#
+ */
+ public function getBoardHistArticles(){
+ $data = $this->request->post();
+ $list = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',5)->select();
+ foreach ($list as $k => $v) {
+ $auts = $this->article_author_obj->where('article_id', $v['article_id'])->where('state', 0)->select();
+ $au = '';
+ foreach ($auts as $vv) {
+ $au .= $vv['firstname'] . ' ' . $vv['lastname'] . ';';
+ }
+ $list[$k]['author'] = substr($au, 0, -1);
+ }
+
+ $re['articles'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 编委主页--获取编委期刊列表
+ * @description 编委主页--获取编委期刊列表
+ * @author wangjinlei
+ * @url /api/Board/getBoardJournals
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:编委用户id
+ *
+ * @return journals:期刊列表#
+ */
+ public function getBoardJournals(){
+ $data = $this->request->post();
+ $list = $this->board_to_journal_obj->field('t_journal.*,t_board_to_journal.btj_id')
+ ->join('t_journal','t_board_to_journal.journal_id = t_journal.journal_id','left')
+ ->where('t_board_to_journal.user_id',$data['user_id'])
+ ->where('t_board_to_journal.state',0)
+ ->select();
+ $re['journals'] = $list;
+
+ return jsonSuccess($re);
+ }
+
+
+
+}
diff --git a/application/api/controller/Chief.php b/application/api/controller/Chief.php
new file mode 100644
index 0000000..bf01700
--- /dev/null
+++ b/application/api/controller/Chief.php
@@ -0,0 +1,795 @@
+user_obj = Db::name('user');
+ $this->user_act_obj = Db::name('user_act');
+ $this->article_obj = Db::name('article');
+ $this->journal_obj = Db::name('journal');
+ $this->user_log_obj = Db::name('user_log');
+ $this->reviewer_major_obj = Db::name('reviewer_major');
+ $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
+ $this->article_msg_obj = Db::name('article_msg');
+ $this->article_file_obj = Db::name('article_file');
+ $this->article_reviewer_obj = Db::name('article_reviewer');
+ $this->article_author_obj = Db::name('article_author');
+ $this->article_transfer_obj = Db::name('article_transfer');
+ $this->staff_obj = Db::name('staff');
+ $this->staff_level_obj = Db::name('staff_level');
+ $this->staff_log_obj = Db::name('staff_log');
+ $this->staff_to_journal_obj = Db::name('staff_to_journal');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->board_to_journal_obj = Db::name('board_to_journal');
+ $this->chief_msg_obj = Db::name('chief_msg');
+ $this->article_to_board_obj = Db::name('article_to_board');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->login_auto_obj = Db::name('login_auto');
+ }
+
+ /**
+ * @title 获取主编列表
+ * @description 获取主编列表
+ * @author wangjinlei
+ * @url /api/Chief/getChiefList
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id(0为全部)
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return chiefs:主编列表#
+ * @return count:总数#
+ */
+ public function getChiefList(){
+ $data = $this->request->post();
+ $where['t_chief_to_journal.state'] = 0;
+ if($data['journal_id']!=0){
+ $where['t_chief_to_journal.journal_id'] = $data['journal_id'];
+ }
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $chiefs = $this->chief_to_journal_obj
+ ->join('t_user','t_user.user_id = t_chief_to_journal.user_id','left')
+ ->where($where)
+ ->limit($limit_start,$data['pageSize'])
+ ->select();
+ $count = $this->chief_to_journal_obj->where($where)->count();
+ foreach ($chiefs as $k => $v){
+ $chiefs[$k]['journal'] = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
+ }
+
+ $re['chiefs'] = $chiefs;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取全部期刊
+ * @description 获取全部期刊
+ * @author wangjinlei
+ * @url /api/Chief/getAllJournals
+ * @method POST
+ *
+ * @return journals:期刊列表#
+ */
+ public function getAllJournals(){
+ $journals = $this->journal_obj->where('state',0)->select();
+
+ $re['journals'] = $journals;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 添加主编
+ * @description 添加主编
+ * @author wangjinlei
+ * @url /api/Chief/addChief
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ * @param name:account type:string require:1 desc:主编账号
+ * @param name:email type:string require:1 desc:邮箱
+ * @param name:realname type:string require:0 desc:真实姓名
+ * @param name:password type:string require:1 desc:密码
+ * @param name:phone type:string require:0 desc:电话
+ */
+ public function addChief(){
+ $data = $this->request->post();
+ $check = $this->user_obj->where('account',trim($data['account']))->whereOr('email',trim($data['email']))->find();
+ if($check){
+ return jsonError('Account or Email occupy!');
+ }
+ //存入数据
+ $insert['account'] = trim($data['account']);
+ $insert['email'] = trim($data['email']);
+ $insert['realname'] = isset($data['realname'])?trim($data['realname']):'';
+ $insert['password'] = md5(trim($data['password']));
+ $insert['phone'] = isset($data['phone'])?trim($data['phone']):'';
+ $insert['type'] = 3;
+ $insert['ctime'] = time();
+ $uid = $this->user_obj->insertGetId($insert);
+ //添加对应关系
+ $insert1['user_id'] = $uid;
+ $insert1['journal_id'] = $data['journal_id'];
+ $this->chief_to_journal_obj->insert($insert1);
+
+ return jsonSuccess([]);
+ }
+
+
+
+ /**
+ * @title 获取文章信息
+ * @description 获取文章信息
+ * @author wangjinlei
+ * @url /api/Chief/getArticleDetail
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ */
+ public function getArticleDetail(){
+ $data = $this->request->post();
+ $article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
+ $aus = $this->article_author_obj->where('article_id',$article_info['article_id'])->where('state',0)->select();
+ $au = '';
+ foreach ($aus as $k => $v){
+ $au .= $v['firstname'].' '.$v['lastname'].';';
+ }
+ $article_info['author'] = substr($au, 0,-1);
+ $files = $this->article_file_obj->where('article_id',$article_info['article_id'])->where('type_name','manuscirpt')->select();
+ $article_info['file'] = $files;
+ $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
+ $article_info['journal'] = $journal_info;
+ $re['article'] = $article_info;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 主编自适应登录
+ * @description 主编自适应登录
+ * @author wangjinlei
+ * @url /api/Chief/autoLoginForChief
+ * @method POST
+ *
+ * @param name:code type:string require:1 desc:code码
+ *
+ * @return roles:身份列表#
+ * @return user:用户信息#
+ */
+ public function autoLoginForChief(){
+ $data = $this->request->post();
+ $info = $this->login_auto_obj->where('code',$data['code'])->find();
+ if($info == null){
+ return jsonError('system error!');
+ }
+ $user_info = $this->user_obj->where('user_id',$info['user_id'])->find();
+ $roles = $this->getUserRoles($user_info['account']);
+
+ $re['roles'] = $roles;
+ $re['user'] = $user_info;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取主编主页进行中的文章列表
+ * @description 获取主编主页进行中的文章列表
+ * @author wangjinlei
+ * @url /api/Chief/getPArticlesForChief
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function getPArticlesForChief() {
+ $data = $this->request->post();
+ $list = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',6)->select();
+ foreach ($list as $k => $v){
+ $auts = $this->article_author_obj->where('article_id',$v['article_id'])->where('state',0)->select();
+ $au = '';
+ foreach ($auts as $vv){
+ $au .= $vv['firstname'].' '.$vv['lastname'].';';
+ }
+ $list[$k]['author'] = substr($au, 0,-1);
+ }
+ $re['articles'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取主编主页历史的文章列表
+ * @description 获取主编主页历史的文章列表
+ * @author wangjinlei
+ * @url /api/Chief/getHArticlesForChief
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ */
+ public function getHArticlesForChief(){
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $list = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',5)->limit($limit_start,$data['pageSize'])->select();
+ foreach ($list as $k => $v){
+ $auts = $this->article_author_obj->where('article_id',$v['article_id'])->where('state',0)->select();
+ $au = '';
+ foreach ($auts as $vv){
+ $au .= $vv['firstname'].' '.$vv['lastname'].';';
+ }
+ $list[$k]['author'] = substr($au, 0,-1);
+ }
+ $count = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',5)->count();
+
+ $re['count'] = $count;
+ $re['articles'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取主编期刊列表
+ * @description 获取主编期刊列表
+ * @author wangjinlei
+ * @url /api/Chief/getJournalsFromChief
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:主编userid
+ */
+ public function getJournalsFromChief() {
+ $data = $this->request->post();
+ $journals = $this->chief_to_journal_obj->field('t_journal.*')->join('t_journal','t_journal.journal_id = t_chief_to_journal.journal_id','left')->where('t_chief_to_journal.user_id',$data['user_id'])->where('t_chief_to_journal.state',0)->select();
+
+ $re['journals'] = $journals;
+ return jsonSuccess($re);
+ }
+
+
+ /**
+ * @title 添加主编已注册
+ * @description 添加主编已注册
+ * @author wangjinlei
+ * @url /api/Chief/addChiefHas
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户id
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function addChiefHas(){
+ $data = $this->request->post();
+ $check = $this->chief_to_journal_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find();
+ if($check!=null){
+ return jsonError('has register!');
+ }
+ $insert['user_id'] = $data['user_id'];
+ $insert['journal_id'] = $data['journal_id'];
+ $this->chief_to_journal_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 编辑主编信息
+ * @description 编辑主编信息
+ * @author wangjinlei
+ * @url /api/Chief/editChief
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户id
+ * @param name:email type:email require:1 desc:邮箱
+ * @param name:realname type:string require:0 desc:真实姓名
+ * @param name:phone type:string require:0 desc:电话
+ */
+ public function editChief(){
+ $data = $this->request->post();
+ //存入数据
+ $insert['email'] = trim($data['email']);
+ $insert['realname'] = isset($data['realname'])?trim($data['realname']):'';
+ $insert['phone'] = isset($data['phone'])?trim($data['phone']):'';
+ $this->user_obj->where('user_id',$data['user_id'])->update($insert);
+ return jsonSuccess([]);
+
+ }
+
+ /**
+ * @title 主编期刊对应关系添加
+ * @description 主编期刊对应关系添加
+ * @author wangjinlei
+ * @url /api/Chief/addChiefToJournal
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户id
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function addChiefToJournal(){
+ $data = $this->request->post();
+ $insert['user_id'] = $data['user_id'];
+ $insert['journal_id'] = $data['journal_id'];
+ $this->chief_to_journal_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 删除主编期刊对应关系
+ * @description 删除主编期刊对应关系
+ * @author wangjinlei
+ * @url /api/Chief/delChiefToJournal
+ * @method POST
+ *
+ * @param name:ctj_id type:int require:1 desc:关系表id
+ */
+ public function delChiefToJournal(){
+ $data = $this->request->post();
+ $this->chief_to_journal_obj->where('ctj_id',$data['ctj_id'])->update(['state'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取期刊列表for主编
+ * @description 获取期刊列表for主编
+ * @author wangjinlei
+ * @url /api/Chief/getJournalForChief
+ * @method POST
+ */
+ public function getJournalForChief(){
+ $list = $this->journal_obj->where('state',0)->select();
+ foreach ($list as $k => $v){
+ //获取期刊对应主编
+ $ca = $this->chief_to_journal_obj->field('t_user.*,t_chief_to_journal.*')->join('t_user','t_user.user_id = t_chief_to_journal.user_id','LEFT')->where('t_chief_to_journal.journal_id',$v['journal_id'])->where('t_chief_to_journal.state',0)->select();
+ $list[$k]['chief'] = $ca;
+ }
+
+ $re['journals'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 增加期刊编委
+ * @description 增加期刊编委
+ * @author wangjinlei
+ * @url /api/Chief/addJournalBoard
+ * @method POST
+ *
+ * @param name:account type:string require:1 desc:主编账号
+ * @param name:journal_id type:int require:1 desc:期刊id
+ * @param name:password type:string require:1 desc:密码
+ * @param name:email type:string require:1 desc:邮箱
+ * @param name:realname type:string require:0 desc:真实姓名
+ * @param name:phone type:string require:0 desc:电话
+ */
+ public function addJournalBoard(){
+ $data = $this->request->post();
+ $check = $this->user_obj->where('account',trim($data['account']))->where('email',trim($data['email']))->where('state',0)->find();
+ if($check){
+ return jsonError('Account or Email has been register!');
+ }
+ $insert['account'] = trim($data['account']);
+ $insert['password'] = md5(trim($data['password']));
+ $insert['realname'] = isset($data['realname'])?trim($data['realname']):'';
+ $insert['phone'] = isset($data['phone'])?trim($data['phone']):'';
+ $insert['type'] = 4;
+ $insert['ctime'] = time();
+ $uid = $this->user_obj->insertGetId($insert);
+ //添加对应关系
+ $to_insert['user_id'] = $uid;
+ $to_insert['journal_id'] = $data['journal_id'];
+ $this->board_to_journal_obj->insert($to_insert);
+
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 增加期刊编委对应关系
+ * @description 增加期刊编委对应关系
+ * @author wangjinlei
+ * @url /api/Chief/addJournalBoardHas
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户id
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function addJournalBoardHas(){
+ $data = $this->request->post();
+ $check = $this->board_to_journal_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find();
+ if($check!=null){
+ return jsonError('has register!');
+ }
+ $insert['journal_id'] = $data['journal_id'];
+ $insert['user_id'] = $data['user_id'];
+ $this->board_to_journal_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取编辑对应的期刊列表
+ * @description 获取编辑对应的期刊列表
+ * @author wangjinlei
+ * @url /api/Chief/getJournalsByEditor
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户表id
+ *
+ * @return journals:期刊列表#
+ */
+ public function getJournalsByEditor(){
+ $data = $this->request->post();
+ $list = $this->journal_obj->where('editor_id',$data['user_id'])->where('state',0)->select();
+ $re['journals'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 验证用户邮箱是否已注册
+ * @description 验证用户邮箱是否已注册
+ * @author wangjinlei
+ * @url /api/Chief/checkEmailForUser
+ * @method POST
+ *
+ * @param name:email type:string require:1 desc:用户名或邮箱
+ *
+ * @return user_info:用户详情#
+ */
+ public function checkEmailForUser(){
+ $data = $this->request->post();
+ $user_info = $this->user_obj->where('account|email',$data['email'])->find();
+ $re['user_info'] = $user_info;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 删除期刊编委
+ * @description 删除期刊编委
+ * @author wangjinlei
+ * @url /api/Chief/delJournalBoard
+ * @method POST
+ *
+ * @param name:btj_id type:int require:1 desc:关系表id
+ */
+ public function delJournalBoard(){
+ $data = $this->request->post();
+ $this->board_to_journal_obj->where('btj_id',$data['btj_id'])->update(['state'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 升级审稿人至青年编委
+ * @description 升级审稿人至青年编委
+ * @author wangjinlei
+ * @url /api/Chief/upgradeReviewer
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:用户id
+ */
+ public function upgradeReviewer(){
+ $data = $this->request->post();
+ $has = $this->user_obj->where('user_id',$data['user_id'])->find();
+ if($has['is_reviewer']!=1){
+ return jsonError('Only reviewer can become young board!');
+ }
+ $this->user_obj->where('user_id',$data['user_id'])->update(['is_yboard'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取待审文章列表
+ * @description 获取待审文章列表
+ * @author wangjinlei
+ * @url /api/Chief/getBerevArticle
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function getBerevArticle(){
+ $data = $this->request->post();
+ //获取送审状态的文章
+ $article_list = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',2)->select();
+
+ $re['article_list'] = $article_list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 添加文章消息
+ * @description 添加文章消息
+ * @author wangjinlei
+ * @url /api/Chief/addMsgForArticle
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ * @param name:content type:string require:1 desc:内容
+ * @param name:user_id type:int require:1 desc:发送用户的id
+ */
+ public function addMsgForArticle(){
+ $data = $this->request->post();
+ $insert['article_id'] = $data['article_id'];
+ $insert['user_id'] = $data['user_id'];
+ $insert['content'] = trim($data['content']);
+ $insert['ctime'] = time();
+ $this->chief_msg_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取文章消息列表
+ * @description 获取文章消息列表
+ * @author wangjinlei
+ * @url /api/Chief/getMsgList
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ */
+// public function getMsgList(){
+// $data = $this->request->post();
+// $list = $this->chief_msg_obj->join('t_user','t_user.user_id = t_chief_msg.user_id','LEFT')
+// ->where('t_chief_msg.article_id',$data['article_id'])
+// ->where('t_chief_msg.state',0)
+// ->order('t_chief_msg.ctime desc')
+// ->select();
+// $re['msgs'] = $list;
+//
+// return jsonSuccess($re);
+// }
+
+ /**
+ * @title 发送文章信息
+ * @description 发送文章信息
+ * @author wangjinlei
+ * @url /api/Chief/pushChiefMsg
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ * @param name:user_id type:int require:1 desc:发送者用户id
+ * @param name:content type:string require:1 desc:发送的内容
+ */
+ public function pushChiefMsg(){
+ $data = $this->request->post();
+ $insert['article_id'] = $data['article_id'];
+ $insert['user_id'] = $data['user_id'];
+ $insert['content'] = trim($data['content']);
+ $insert['ctime'] = time();
+ $this->chief_msg_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取主编详情信息列表
+ * @description 获取主编详情信息列表
+ * @author wangjinlei
+ * @url /api/Chief/getAllChiefMsg
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ *
+ * @return msgs:消息列表#
+ */
+ public function getAllChiefMsg(){
+ $data = $this->request->post();
+ $msg = $this->chief_msg_obj
+ ->where('t_chief_msg.article_id',$data['article_id'])
+ ->where('t_chief_msg.state',0)
+ ->order('t_chief_msg.chief_msg_id desc')
+ ->select();
+ foreach ($msg as $k => $v){
+ $uinfo = $this->user_obj->where('user_id',$v['user_id'])->find();
+ $msg[$k]['user'] = $uinfo;
+ $msg[$k]['role'] = $this->getRoleForJournal($uinfo,$data['article_id']);
+ }
+ $re['msgs'] = $msg;
+ return jsonSuccess($re);
+ }
+
+ private function getRoleForJournal($uinfo,$article_id){
+ $article_info = $this->article_obj->where('article_id',$article_id)->find();
+ if($uinfo['type']==2){
+ return 'editor';
+ }
+ $reviewer_res = $this->reviewer_to_journal_obj->where('journal_id',$article_info['journal_id'])->where('reviewer_id',$uinfo['user_id'])->where('state',0)->find();
+ if($reviewer_res!=null){
+ return 'yboard';
+ }
+// $yboard_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('is_yboard',1)->where('state',0)->find();
+// if($yboard_res!=null){
+// $roles[] = 'yboard';
+// }
+ $chief_res = $this->chief_to_journal_obj->where('journal_id',$article_info['journal_id'])->where('user_id',$uinfo['user_id'])->where('state',0)->find();
+ if($chief_res != null){
+ return 'chief';
+ }
+ $board_res = $this->board_to_journal_obj->where('journal_id',$article_info['journal_id'])->where('user_id',$uinfo['user_id'])->where('state',0)->find();
+ if($board_res != null){
+ return 'board';
+ }
+ return 'author';
+ }
+
+
+ /**
+ * @title 增加文章编委
+ * @description 增加文章编委
+ * @author wangjinlei
+ * @url /api/Chief/addArticleBoard
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ * @param name:board_id type:int require:1 desc:user_id用户id
+ */
+ public function addArticleBoard(){
+ $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();
+ $board_info = $this->user_obj->where('user_id',$data['board_id'])->find();
+ $check = $this->article_to_board_obj->where('article_id',$data['article_id'])->where('board_id',$data['board_id'])->find();
+ if($check!=null){
+ return jsonError('Applied!');
+ }
+ $insert['article_id'] = $data['article_id'];
+ $insert['board_id'] = $data['board_id'];
+ $this->article_to_board_obj->insert($insert);
+
+ //发送邮件给编委,并创造直连链接
+
+ $tt = $article_info['accept_sn'].'
';
+ $tt .= 'Dear '.($board_info['realname']==''?'':$board_info['realname']).',
';
+ $tt .= 'The manuscript entitled “'.$article_info['title'].'”is under fininal decision status of the journal '.$journal_info['title'].'.
';
+ $tt .= '(The manuscripit in fininal decision status has been peer-reviewed, and the authors had revised all review opinions.)
';
+ $tt .= 'The Editor-in-Chief would be most grateful if you could offer an opinion regarding its suitability for publication in the journal '.$journal_info['title'].'.
';
+ $tt .= 'Any comments and decisions you make will be valued by the editorial board and the editor in chief. If you choose not to make a decision on this article, you need not to reply and log in the submission system, we will refer to the opinions of other experts.'
+ . '(Plese click here)
';
+ $tt .= 'Please bring into our knowledge if there is any potential Conflict of Interest.
';
+ $tt .= 'Thank you for your consideration.
';
+ $tt .= 'Look forward for your reply.
';
+ $tt .= 'Reviewer Center
';
+ $tt .= 'Your username:'.$board_info['realname'].'
';
+ $tt .= 'Sincerely,
';
+ $tt .= 'Editorial Office
';
+ $tt .= $journal_info['title'].'
';
+ $tt .= 'Email: '.$journal_info['email'].'
';
+ $tt .= 'Website: '.$journal_info['website'];
+
+ $maidata['email'] = $board_info['email'];
+ $maidata['title'] = $journal_info['title'];
+ $maidata['content'] = $tt;
+ $maidata['tmail'] = $journal_info['email'];
+ $maidata['tpassword'] = $journal_info['epassword'];
+ Queue::push( 'app\api\job\mail@fire' , $maidata , "tmail" );
+
+ return jsonSuccess([]);
+ }
+
+ private function creatLoginUrlForBoard($user,$article_id){
+ $code = md5(time().rand(1000,9999).'thinkphp');
+ $insert['user_id'] = $user['user_id'];
+ $insert['code'] = $code;
+ $insert['ctime'] = time();
+ $this->login_auto_obj->insert($insert);
+ $url = 'https://submission.tmrjournals.com/edit_text?Art_id='.$article_id.'&act='.$code;
+ return $url;
+ }
+
+ /**
+ * @title 删除文章编委
+ * @description 删除文章编委
+ * @author wangjinlei
+ * @url /api/Chief/delArticleBoard
+ * @method POST
+ *
+ * @param name:article_board_id type:int require:1 desc:id号
+ */
+ public function delArticleBoard(){
+ $data = $this->request->post();
+ $this->article_to_board_obj->where('article_board_id',$data['article_board_id'])->update(['state'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取文章编委列表
+ * @description 获取文章编委列表
+ * @author wangjinlei
+ * @url /api/Chief/getArticleBoard
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ */
+ public function getArticleBoard(){
+ $data = $this->request->post();
+ $list = $this->article_to_board_obj->where('article_id',$data['article_id'])->where('state',0)->select();
+
+ $re['boards'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取文章编委池
+ * @description 获取文章编委池
+ * @author wangjinlei
+ * @url /api/Chief/getAllArticleBoards
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ *
+ * @return boards:编委池#
+ */
+ public function getAllArticleBoards(){
+ $data = $this->request->post();
+ $list = $this->board_to_journal_obj->join('t_user','t_user.user_id = t_board_to_journal.user_id')
+ ->where('t_board_to_journal.journal_id',$data['journal_id'])
+ ->where('t_board_to_journal.state',0)->select();
+
+ $re['boards'] = $list;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取期刊编委列表
+ * @description 获取期刊编委列表
+ * @author wangjinlei
+ * @url /api/Chief/getJournalBoard
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ */
+ public function getJournalBoard(){
+ $data = $this->request->post();
+ $boards = $this->board_to_journal_obj->join('t_user','t_user.user_id = t_board_to_journal.user_id','LEFT')->where('t_board_to_journal.journal_id',$data['journal_id'])->where('t_board_to_journal.state',0)->select();
+
+ $re['boards']=$boards;
+ return jsonSuccess($re);
+ }
+
+ private function getUserRoles($account) {
+ $user_info = $this->user_obj->where('account',$account)->find();
+ if($user_info['type']==2){
+ $ros[] = 'editor';
+ return $ros;
+ }
+ $roles[] = 'author';
+ $reviewer_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
+ if($reviewer_res!=null){
+ $roles[] = 'reviewer';
+ }
+ $yboard_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('is_yboard',1)->where('state',0)->find();
+ if($yboard_res!=null){
+ $roles[] = 'yboard';
+ }
+ $chief_res = $this->chief_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
+ if($chief_res != null){
+ $roles[] = 'chief';
+ }
+ $board_res = $this->board_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
+ if($board_res != null){
+ $roles[] = 'board';
+ }
+ return $roles;
+ }
+
+}
diff --git a/application/api/controller/Reviewer.php b/application/api/controller/Reviewer.php
index 9504b48..0c71751 100644
--- a/application/api/controller/Reviewer.php
+++ b/application/api/controller/Reviewer.php
@@ -6,6 +6,10 @@ use think\Controller;
use think\Db;
use TCPDF;
+/**
+ * @title 审稿人接口
+ * @description 审稿人接口
+ */
class Reviewer extends Controller {
protected $user_obj = '';
@@ -20,6 +24,8 @@ class Reviewer extends Controller {
protected $article_reviewer_obj = '';
protected $article_reviewer_file_obj = '';
protected $article_reviewer_question_obj = '';
+ protected $chief_to_journal_obj = '';
+ protected $board_to_journal_obj = '';
//put your code here
public function __construct(\think\Request $request = null) {
@@ -36,6 +42,8 @@ class Reviewer extends Controller {
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->article_reviewer_file_obj = Db::name('article_reviewer_file');
$this->article_reviewer_question_obj = Db::name('article_reviewer_question');
+ $this->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->board_to_journal_obj = Db::name('board_to_journal');
}
/**
@@ -56,8 +64,66 @@ class Reviewer extends Controller {
return json(['code' => 0, 'data' => $res, 'total' => $count]);
}
+ /**
+ * @title 获取待审审稿实例列表
+ * @description 获取待审审稿实例列表
+ * @author wangjinlei
+ * @url /api/Reviewer/getReviewerListPending
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:审稿人id
+ *
+ * @return lists:数据列表#
+ */
+ public function getReviewerListPending(){
+ $data = $this->request->post();
+ //获取审稿人基本信息
+ $reviewer_info = $this->user_obj->where('user_id',$data['user_id'])->find();
+ $res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_journal.title journal_title,t_article.accept_sn accept_sn')
+ ->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
+ ->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
+ ->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
+ ->where('t_article_reviewer.state',0)
+ ->select();
+
+ $re['lists'] = $res;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取历史审稿实例列表
+ * @description 获取历史审稿实例列表
+ * @author wangjinlei
+ * @url /api/Reviewer/getReviewerListHistory
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:审稿人id
+ * @param name:pageIndex type:int require:1 desc:当前页码
+ * @param name:pageSize type:int require:1 desc:每个页面的数据条数
+ *
+ * @return lists:数据列表#
+ */
+ public function getReviewerListHistory(){
+ $data = $this->request->post();
+
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $reviewer_info = $this->user_obj->where('user_id',$data['user_id'])->find();
+ $res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_journal.title journal_title,t_article.accept_sn accept_sn')
+ ->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
+ ->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
+ ->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
+ ->where('t_article_reviewer.state','>',0)
+ ->order('t_article_reviewer.state')
+ ->limit($limit_start, $data['pageSize'])
+ ->select();
+
+ $re['lists'] = $res;
+ return jsonSuccess($re);
+ }
+
/**
* 获取审稿人详情
+ *
*/
public function getReviewerDetail(){
$uid = $this->request->post('rid');
@@ -72,6 +138,54 @@ class Reviewer extends Controller {
return json(['data'=>$base_info]);
}
+ /**
+ * @title 获取审稿人详情
+ * @description 获取审稿人详情
+ * @author wangjinlei
+ * @url /api/Reviewer/getReviewerDetail1
+ * @method POST
+ *
+ * @param name:user_id type:int require:1 desc:审稿人id
+ */
+ public function getReviewerDetail1(){
+ $data = $this->request->post();
+ //获取基本信息
+ $base_info = $this->user_obj->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id')->where('t_user.user_id',$data['user_id'])->find();
+ //增加major
+ $major_res = $this->reviewer_major_obj->where('major_id',$base_info['major'])->column('title');
+ $base_info['major_title'] = $major_res?$major_res[0]:'';
+ $cmajor_res = $this->reviewer_major_obj->where('major_id',$base_info['cmajor'])->column('title');
+ $base_info['cmajor_title'] = $cmajor_res?$cmajor_res[0]:'';
+
+ //获取审稿人期刊与对应身份
+ $frag = [];
+ $revs = $this->reviewer_to_journal_obj->join('t_journal','t_reviewer_to_journal.journal_id = t_journal.journal_id','left')->where('t_reviewer_to_journal.reviewer_id',$data['user_id'])->where('t_reviewer_to_journal.state',0)->select();
+ $chiefs = $this->chief_to_journal_obj->join('t_journal','t_chief_to_journal.journal_id = t_journal.journal_id','left')->where('t_chief_to_journal.user_id',$data['user_id'])->where('t_chief_to_journal.state',0)->select();
+ $boards = $this->board_to_journal_obj->join('t_journal','t_board_to_journal.journal_id = t_journal.journal_id','left')->where('t_board_to_journal.user_id',$data['user_id'])->where('t_board_to_journal.state',0)->select();
+ foreach ($revs as $v){
+ $frag[] = array(
+ 'journal'=>$v,
+ 'type'=>'reviewer'
+ );
+ }
+ foreach ($chiefs as $v){
+ $frag[] = array(
+ 'journal'=>$v,
+ 'type'=>'chief'
+ );
+ }
+ foreach ($boards as $v){
+ $frag[] = array(
+ 'journal'=>$v,
+ 'type'=>'board'
+ );
+ }
+
+ $re['journals'] = $frag;
+ $re['reviewer'] = $base_info;
+ return jsonSuccess($re);
+ }
+
/**
* 更改审稿人信息
*/
@@ -145,8 +259,16 @@ class Reviewer extends Controller {
return json($frag);
}
+
/**
- * 获取文章信息列表
+ * @title 获取文章文件列表
+ * @description 获取文章文件列表
+ * @author wangjinlei
+ * @url /api/Reviewer/getAFilelistByID
+ * @method POST
+ *
+ * @param name:revid type:int require:1 desc:art_rev_id文章审稿实例id
+ *
*/
public function getAFilelistByID(){
$rev_id = $this->request->post('revid');
@@ -162,8 +284,16 @@ class Reviewer extends Controller {
return json(['data'=>$file_list]);
}
+
/**
- * 获取文章审稿实例详情(审稿人,编辑)
+ * @title 获取文章审稿实例详情(审稿人,编辑)
+ * @description 获取文章审稿实例详情(审稿人,编辑)
+ * @author wangjinlei
+ * @url /api/Reviewer/getartrevdate
+ * @method POST
+ *
+ * @param name:revid type:int require:1 desc:art_rev_id文章审稿实例id
+ * @param name:human type:string require:1 desc:(reviewer/editor)
*/
public function getartrevdate() {
//接受参数
diff --git a/application/api/controller/User.php b/application/api/controller/User.php
index ed54705..154c28a 100644
--- a/application/api/controller/User.php
+++ b/application/api/controller/User.php
@@ -7,6 +7,10 @@ use think\Db;
use think\captcha;
use think\Cache;
+/**
+ * @title 用户相关接口
+ * @description 用户相关接口
+ */
class User extends Controller {
protected $user_obj = '';
@@ -19,6 +23,8 @@ class User extends Controller {
protected $reviewer_to_journal_obj = '';
protected $user_reviewer_info_obj = '';
protected $user_msg_obj = '';
+ protected $chief_to_journal_obj = '';
+ protected $board_to_journal_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
@@ -32,11 +38,22 @@ class User 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->chief_to_journal_obj = Db::name('chief_to_journal');
+ $this->board_to_journal_obj = Db::name('board_to_journal');
}
/**
- * 登录功能
- * @return type
+ * @title 登录功能
+ * @description 登录功能
+ * @author wangjinlei
+ * @url /api/User/checkLogin
+ * @method POST
+ *
+ * @param name:username type:string require:1 desc:用户名
+ * @param name:password type:string require:1 desc:密码
+ *
+ * @return userinfo:用户信息#
+ * @return roles:角色列表#
*/
public function checkLogin() {
$data = $this->request->post();
@@ -64,11 +81,126 @@ class User extends Controller {
$up_data['last_login_time'] = time();
$up_data['last_login_ip'] = $this->request->ip();
$this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
- return json(['code' => 0, 'userinfo' => $user_info]);
+ $roles = $this->getUserRoles($user_info['account']);
+
+ $re['roles'] = $roles;
+ $re['userinfo'] = $user_info;
+ return jsonSuccess($re);
}
}
}
+ /**
+ * @title 审稿系统登录功能
+ * @description 审稿系统登录功能
+ * @author wangjinlei
+ * @url /api/User/reviewer_login
+ * @method POST
+ *
+ * @param name:username type:string require:1 desc:用户名
+ * @param name:password type:string require:1 desc:密码
+ *
+ * @return userinfo:用户信息#
+ */
+// public function reviewer_login() {
+// $data = $this->request->post();
+// $user_info = $this->user_obj
+// ->where('account|email', $data['username'])
+// ->where('password', md5($data['password']))
+// ->find();
+// if ($user_info == null) {//登陆失败
+// return json(['code' => 1]);
+// } else {//登陆成功
+// $up_data['last_login_time'] = time();
+// $up_data['last_login_ip'] = $this->request->ip();
+// $this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
+// return json(['code' => 0, 'userinfo' => $user_info]);
+// }
+// }
+
+ /**
+ * @title 获取用户身份列表
+ * @description 获取用户身份列表
+ * @author wangjinlei
+ * @url /api/User/getUserRole
+ * @method POST
+ *
+ * @param name:account type:string require:1 desc:用户名
+ *
+ * @return roles:角色列表#
+ *
+ */
+ public function getUserRole(){
+ $data = $this->request->post();
+ $roles = $this->getUserRoles($data['account']);
+ $re['roles'] = $roles;
+ return jsonSuccess($re);
+ }
+
+ private function getUserRoles($account) {
+ $user_info = $this->user_obj->where('account',$account)->find();
+ if($user_info['type']==2){
+ $ros[] = 'editor';
+ return $ros;
+ }
+ $roles[] = 'author';
+ $reviewer_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
+ if($reviewer_res!=null){
+ $roles[] = 'reviewer';
+ }
+ $yboard_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('is_yboard',1)->where('state',0)->find();
+ if($yboard_res!=null){
+ $roles[] = 'yboard';
+ }
+ $chief_res = $this->chief_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
+ if($chief_res != null){
+ $roles[] = 'chief';
+ }
+ $board_res = $this->board_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
+ if($board_res != null){
+ $roles[] = 'board';
+ }
+ return $roles;
+ }
+
+ /**
+ * @title 升级审稿人至青年编委
+ * @description 升级审稿人至青年编委
+ * @author wangjinlei
+ * @url /api/User/upReviewerToYboard
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ * @param name:user_id type:int require:1 desc:审稿人userid
+ *
+ * @return roles:角色列表#
+ *
+ */
+ public function upReviewerToYboard(){
+ $data = $this->request->post();
+ $this->reviewer_to_journal_obj->where('journal_id',$data['journal_id'])->where('reviewer_id',$data['user_id'])->where('state',0)->update(['is_yboard'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 降级青年编委至审稿人
+ * @description 降级青年编委至审稿人
+ * @author wangjinlei
+ * @url /api/User/downReviewerToYboard
+ * @method POST
+ *
+ * @param name:journal_id type:int require:1 desc:期刊id
+ * @param name:user_id type:int require:1 desc:审稿人userid
+ *
+ * @return roles:角色列表#
+ *
+ */
+ public function downReviewerToYboard(){
+ $data = $this->request->post();
+ $this->reviewer_to_journal_obj->where('journal_id',$data['journal_id'])->where('reviewer_id',$data['user_id'])->where('state',0)->update(['is_yboard'=>0]);
+ return jsonSuccess([]);
+ }
+
/**
* 获取orcid
*/
@@ -132,7 +264,6 @@ class User extends Controller {
return json($inser_data);
}
-
/**
* 获取验证码图片(用户注册)
*/
@@ -240,56 +371,88 @@ class User extends Controller {
return $nowcode == $mbcode ? true : false;
}
+
/**
- * 获取审稿人列表
+ * @title 获取审稿人列表
+ * @description 获取审稿人列表
+ * @author wangjinlei
+ * @url /api/User/getreviewerList
+ * @method POST
+ *
+ * @param name:username type:string require:1 desc:用户名
+ * @param name:journalId type:int require:1 desc:期刊id当全选时为0
+ * @param name:pageIndex type:int require:1 desc:开始页码
+ * @param name:pageSize type:int require:1 desc:每页是数据条数
+ *
*/
public function getreviewerList() {
$data = $this->request->post();
+ $editor_info = $this->user_obj->where('account',$data['username'])->where('state',0)->find();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
- $where['t_user.is_reviewer'] = 1;
- if ($data['journalId'] == 0) {
- $subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
- $journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
- $uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('state',0)->column('reviewer_id');
- $where['t_user.user_id'] = ['in', $uids];
- } else {
- $uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->where('state',0)->column('reviewer_id');
- $where['t_user.user_id'] = ['in', $uids];
+ $jous = [];
+ if($data['journalId'] == 0){
+ $jous = $this->journal_obj->where('editor_id',$editor_info['user_id'])->where('state',0)->column('journal_id');
+ }else{
+ $jous[] = $data['journalId'];
}
- $res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
- ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')
- ->where($where)
- ->limit($limit_start, $data['pageSize'])
+ $res = $this->reviewer_to_journal_obj
+ ->field('t_reviewer_to_journal.is_yboard,t_user.*,t_user_reviewer_info.*,t_journal.*')
+ ->join('t_journal','t_journal.journal_id = t_reviewer_to_journal.journal_id','left')
+ ->join('t_user','t_user.user_id = t_reviewer_to_journal.reviewer_id','left')
+ ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_reviewer_to_journal.reviewer_id', 'LEFT')
+ ->where('t_reviewer_to_journal.journal_id','in',$jous)
+ ->where('t_reviewer_to_journal.state',0)
+ ->limit($limit_start,$data['pageSize'])
->select();
- $total = $this->user_obj->where($where)->count();
- if ($res) {
- return json(['code' => 0, 'data' => $res, 'total' => $total]);
- } else {
- return json(['code' => 1]);
- }
+ $count = $this->reviewer_to_journal_obj->where('t_reviewer_to_journal.journal_id','in',$jous)->where('t_reviewer_to_journal.state',0)->count();
+ return json(['code' => 0, 'data' => $res, 'total' => $count]);
+
+
+
+// $where['t_user.is_reviewer'] = 1;
+// if ($data['journalId'] == 0) {
+// $subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
+// $journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
+// $uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('state', 0)->column('reviewer_id');
+// $where['t_user.user_id'] = ['in', $uids];
+// } else {
+// $uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->where('state', 0)->column('reviewer_id');
+// $where['t_user.user_id'] = ['in', $uids];
+// }
+// $res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
+// ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')
+// ->where($where)
+// ->limit($limit_start, $data['pageSize'])
+// ->select();
+// $total = $this->user_obj->where($where)->count();
+// if ($res) {
+// return json(['code' => 0, 'data' => $res, 'total' => $total]);
+// } else {
+// return json(['code' => 1]);
+// }
}
-
+
/**
*
*/
- public function deleteArticleReviewer(){
+ public function deleteArticleReviewer() {
$data = $this->request->post();
- $this->reviewer_to_journal_obj->where('reviewer_id',$data['reviewer_id'])->where('journal_id',$data['journal_id'])->update(['state'=>1]);
+ $this->reviewer_to_journal_obj->where('reviewer_id', $data['reviewer_id'])->where('journal_id', $data['journal_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
-
+
/**
*
*/
- public function getReviewerForDel(){
+ public function getReviewerForDel() {
$data = $this->request->post();
$user_info = $this->user_obj->where('user_id', $data['reviewer_id'])->find();
- $editor_info = $this->user_obj->where('account',$data['editor_account'])->find();
- $journals = $this->journal_obj->where("editor_id",$editor_info['user_id'])->column('journal_id');
- $rtjs = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('reviewer_id',$data['reviewer_id'])->where('state',0)->select();
- foreach($rtjs as $k => $v){
+ $editor_info = $this->user_obj->where('account', $data['editor_account'])->find();
+ $journals = $this->journal_obj->where("editor_id", $editor_info['user_id'])->column('journal_id');
+ $rtjs = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('reviewer_id', $data['reviewer_id'])->where('state', 0)->select();
+ foreach ($rtjs as $k => $v) {
$rtjs[$k]['reviewer'] = $user_info;
- $rtjs[$k]['journal'] = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
+ $rtjs[$k]['journal'] = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
}
return jsonSuccess($rtjs);
}
@@ -386,7 +549,7 @@ class User extends Controller {
. "At present, you have passed our examination
";
$content .= 'Submission System
';
$content .= '
username:' . $apply_info['name'] . '
'; - $content .= 'Original Password: 123456qwe
';//$has_res ? '' : 'password:123456qwe
'; + $content .= 'Original Password: 123456qwe
'; //$has_res ? '' : 'password:123456qwe
'; sendEmail($apply_info['email'], $journal_info['title'], $journal_info['title'], $content, $journal_info['email'], $journal_info['epassword']); $update_res = $this->user_reviewer_obj->where($where)->update(['state' => 1]); if ($res && $add_res && $addinfo_res && $update_res) { @@ -485,11 +648,11 @@ class User extends Controller { $re['orcid'] = $r->orcid; return jsonSuccess($re); } - + /** * 登陆后绑定orcid账号 */ - public function OrcidBinding(){ + public function OrcidBinding() { $data = $this->request->post(); $url = 'https://orcid.org/oauth/token'; $param['client_id'] = "APP-PKF0BGRP6DWM6FUB"; @@ -499,14 +662,13 @@ class User extends Controller { $param['redirect_uri'] = "https://submission.tmrjournals.com/orcidBind"; $res = $this->myUrl($url, $param); $r = json_decode($res); - - + + $update['orcid'] = $r->orcid; $update['orcid_code'] = $res; - - $this->user_obj->where('account',$data['account'])->update($update); + + $this->user_obj->where('account', $data['account'])->update($update); return jsonSuccess([]); - } /** @@ -557,11 +719,10 @@ class User extends Controller { return jsonSuccess($re); } - /** * 授权码转化成令牌,并存贮 */ - public function sq_to_lp(){ + public function sq_to_lp() { $url = 'https://orcid.org/oauth/token'; $param['client_id'] = "APP-PKF0BGRP6DWM6FUB"; $param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab"; @@ -572,7 +733,6 @@ class User extends Controller { $r = json_decode($res); echo $r->orcid; } - private function myUrl($url, $param) { $header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded');