diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php
index cf77307..cd2ed65 100644
--- a/application/api/controller/Journal.php
+++ b/application/api/controller/Journal.php
@@ -141,14 +141,14 @@ class Journal extends Controller {
$p_res = $this->journal_topic_obj
->where('journal_id', $data['journal_id'])
->where('state', 0)
- ->where('parent_id',0)
+ ->where('parent_id', 0)
->order('sort')
->select();
-
+
$res = $this->journal_topic_obj
->where('journal_id', $data['journal_id'])
->where('state', 0)
- ->where('parent_id','>',0)
+ ->where('parent_id', '>', 0)
->order('sort asc,journal_topic_id asc')
->select();
//处理数组
@@ -332,7 +332,7 @@ class Journal extends Controller {
->where('j_article.journal_stage_id', 'in', $stages)
->where('j_article.state', 0)
->order('j_article.sort desc')
- ->limit($limit_start,$data['pageSize'])
+ ->limit($limit_start, $data['pageSize'])
->select();
$count = $this->article_obj
->join('j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT')
@@ -359,7 +359,7 @@ class Journal extends Controller {
$list[$k]['authortitle'] = $this->getAuthor($v);
}
- return json(['code' => 0, 'msg' => 'success', 'data' => ['articlelist' => $list,'count'=>$count]]);
+ return json(['code' => 0, 'msg' => 'success', 'data' => ['articlelist' => $list, 'count' => $count]]);
}
/**
@@ -382,7 +382,7 @@ class Journal extends Controller {
->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_journal_stage.stage_year','>','2018')
+ ->where('j_journal_stage.stage_year', '>', '2018')
->where('j_article.type', ['like', 'News'], ['like', 'Comment'], 'or')
->order('j_journal_stage.stage_year desc,j_journal_stage.stage_vol desc,j_journal_stage.stage_no desc,j_article.article_id desc')
->select();
@@ -430,16 +430,16 @@ class Journal extends Controller {
->join('j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT')
->where('j_article.journal_id', $data['journal_id'])
->where('j_article.state', 0)
- ->where('j_journal_stage.is_publish',1)
+ ->where('j_journal_stage.is_publish', 1)
->orderRaw('j_article.cited+j_article.abs_num+j_article.pdf_num desc')
- ->limit($limit_start,$data['pageSize'])
+ ->limit($limit_start, $data['pageSize'])
->select();
-
+
$count = $this->article_obj
->join('j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT')
->where('j_article.journal_id', $data['journal_id'])
->where('j_article.state', 0)
- ->where('j_journal_stage.is_publish',1)
+ ->where('j_journal_stage.is_publish', 1)
->count();
//获取作者
@@ -461,7 +461,7 @@ class Journal extends Controller {
}
$list[$k]['title'] = $cache_title;
}
- return jsonSuccess(['articles' => $list,'count'=>$count]);
+ return jsonSuccess(['articles' => $list, 'count' => $count]);
}
/**
@@ -521,7 +521,7 @@ class Journal extends Controller {
->join(array(['j_article', 'j_article.article_id = j_article_to_topic.article_id', 'LEFT'], ['j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT']))
->where('j_article_to_topic.topic_id', $topic_info['journal_topic_id'])
->where('j_article_to_topic.state', 0)
- ->where('j_journal_stage.is_publish',1)
+ ->where('j_journal_stage.is_publish', 1)
->order('j_article.sort desc')
->select();
@@ -651,7 +651,7 @@ class Journal extends Controller {
$re['article'] = $article;
return jsonSuccess($re);
}
-
+
/**
* @title 获取期刊编委信息
* @description 获取期刊编委信息
@@ -663,25 +663,25 @@ class Journal extends Controller {
*
* @return boards:编委array#
*/
- public function getBoard(){
+ public function getBoard() {
$data = $this->request->post();
$list = $this->board_obj
->field('j_board.*,j_board_group.group_name')
- ->join('j_board_group','j_board.board_group_id = j_board_group.board_group_id','left')
- ->where('j_board.journal_id',$data['journal_id'])
- ->where('j_board.state',0)
+ ->join('j_board_group', 'j_board.board_group_id = j_board_group.board_group_id', 'left')
+ ->where('j_board.journal_id', $data['journal_id'])
+ ->where('j_board.state', 0)
->order('j_board_group.board_group_id,j_board.name')
->select();
$frag = [];
- foreach ($list as $k => $v){
- if($v['type']==0){
+ foreach ($list as $k => $v) {
+ if ($v['type'] == 0) {
$frag['main'][] = $v;
- }elseif($v['type']==1){
+ } elseif ($v['type'] == 1) {
$frag['remain'][] = $v;
- }else{
- if($v['board_group_id']==0){
+ } else {
+ if ($v['board_group_id'] == 0) {
$frag['member'][] = $v;
- }else{
+ } else {
$frag['member'][$v['group_name']][] = $v;
}
}
@@ -725,7 +725,7 @@ class Journal extends Controller {
$repeat = $this->subscribe_journal_obj
->where('journal_id', $data['journal_id'])
->where('email', $data['email'])
- ->where('state',0)
+ ->where('state', 0)
->find();
if ($repeat) {
return jsonError('repeat subscribe!');
@@ -736,7 +736,7 @@ class Journal extends Controller {
//发送邮件感谢
$tt = 'Dear Researcher,
';
$tt .= 'Welcome you to the email alert for the latest research and more. Thank you for your interest in our publications and topics.
';
- $tt .= 'Unsubscribe
';
+ $tt .= 'Unsubscribe
';
$tt .= 'This service is provided by TMR Publishing Group | New Zealand
';
$tt .= 'Telephone: +64 02108293806';
$tt .= 'Email: publisher@tmrjournals.com';
@@ -747,7 +747,7 @@ class Journal extends Controller {
$maidata['tmail'] = 'publicrelations@tmrjournals.com';
$maidata['tpassword'] = 'pRWU999999';
Queue::push('app\api\job\mail@fire', $maidata, "mail");
-
+
return jsonSuccess([]);
}
@@ -767,7 +767,7 @@ class Journal extends Controller {
$repeat = $this->subscribe_topic_obj
->where('topic_id', $data['topic_id'])
->where('email', $data['email'])
- ->where('state',0)
+ ->where('state', 0)
->find();
if ($repeat) {
return jsonError('repeat subscribe!');
@@ -778,7 +778,7 @@ class Journal extends Controller {
//发送邮件感谢
$tt = 'Dear Researcher,
';
$tt .= 'Welcome you to the email alert for the latest research and more. Thank you for your interest in our publications and topics.
';
- $tt .= 'Unsubscribe
';
+ $tt .= 'Unsubscribe
';
$tt .= 'This service is provided by TMR Publishing Group | New Zealand
';
$tt .= 'Telephone: +64 02108293806';
$tt .= 'Email: publisher@tmrjournals.com';
@@ -791,20 +791,21 @@ class Journal extends Controller {
Queue::push('app\api\job\mail@fire', $maidata, "mail");
return jsonSuccess([]);
}
-
- public function UnsubscribeTopic($snum){
- $this->subscribe_topic_obj->where('subscribe_topic_id',$snum)->update(['state'=>1]);
+
+ public function UnsubscribeTopic($snum) {
+ $this->subscribe_topic_obj->where('subscribe_topic_id', $snum)->update(['state' => 1]);
echo 'Unsubscribe successfully!';
}
- public function UnsubscribeJournal($snum){
- $this->subscribe_journal_obj->where('subscribe_journal_id',$snum)->update(['state'=>1]);
+
+ public function UnsubscribeJournal($snum) {
+ $this->subscribe_journal_obj->where('subscribe_journal_id', $snum)->update(['state' => 1]);
echo 'Unsubscribe successfully!';
}
public function testEmail() {
// phpinfo();die;
-
-
+
+
$tt = 'mytestemail.';
$maidata['email'] = '751475802@qq.com';
$maidata['title'] = '测试邮件1';
@@ -814,4 +815,336 @@ class Journal extends Controller {
Queue::push('app\api\job\mail@fire', $maidata, "mail");
}
+ /**
+ * @title 查找文章
+ * @description 查找文章
+ * @author wangjinlei
+ * @url /api/Journal/searchArticle
+ * @method POST
+ *
+ * @param name:keyword type:string require:1 desc:关键词
+ * @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:单页数据条数
+ *
+ * @return articles:文章信息#
+ * @return count:总数
+ */
+ public function searchArticle() {
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['keyword']) . '%')->column('article_id');
+ $list = $this->article_obj
+ ->where('journal_id', $data['journal_id'])
+ ->where('state', 0)
+ ->where(function($query)use($arts, $data) {
+ $query->where('article_id', 'in', $arts)
+ ->whereOr('title|abstract|keywords', 'like', '%' . trim($data['keyword']) . '%');
+ })
+ ->orderRaw("(CASE WHEN title LIKE '%" . trim($data['keyword']) . "%' THEN 1 ELSE 0 END) desc")
+ ->limit($limit_start, $data['pageSize'])
+ ->select();
+ $count = $this->article_obj
+ ->where('journal_id', $data['journal_id'])
+ ->where('state', 0)
+ ->where(function($query)use($arts, $data) {
+ $query->where('article_id', 'in', $arts)
+ ->whereOr('title|abstract|keywords', 'like', '%' . trim($data['keyword']) . '%');
+ })
+ ->count();
+
+ $has_list = []; //title含有关键字
+ $no_list = []; //title不含关键字
+ //补全信息,分期,作者
+ foreach ($list as $k => $v) {
+ $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find();
+ $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
+ $list[$k]['stage'] = $stage_info;
+ //组合cite信息
+ $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
+ $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
+ $list[$k]['cite'] = $cite;
+ $list[$k]['authortitle'] = $this->getAuthor($v);
+
+ //斜体变红
+ $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content');
+ $cache_title = $v['title'];
+ foreach ($caches as $val) {
+ $cache_title = str_replace($val, '' . $val . '', $cache_title);
+ }
+ $cache_title = str_replace(trim($data['keyword']), '' . $data['keyword'] . '', $cache_title);
+ $list[$k]['title'] = $cache_title;
+ }
+ $re['articles'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 查找文章出版集团
+ * @description 查找文章出版集团
+ * @author wangjinlei
+ * @url /api/Journal/searchArticleAll
+ * @method POST
+ *
+ * @param name:keyword type:string require:1 desc:关键词
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return articles:文章信息#
+ * @return count:总数
+ */
+ public function searchArticleAll() {
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['keyword']) . '%')->column('article_id');
+ $list = $this->article_obj
+ ->where(function($query)use($arts, $data) {
+ $query->where('article_id', 'in', $arts)
+ ->whereOr('title|abstract|keywords', 'like', '%' . trim($data['keyword']) . '%');
+ })
+ ->orderRaw("(CASE WHEN title LIKE '%" . trim($data['keyword']) . "%' THEN 1 ELSE 0 END) desc")
+ ->limit($limit_start, $data['pageSize'])
+ ->select();
+ $count = $this->article_obj
+ ->where(function($query)use($arts, $data) {
+ $query->where('article_id', 'in', $arts)
+ ->whereOr('title|abstract|keywords', 'like', '%' . trim($data['keyword']) . '%');
+ })
+ ->count();
+
+ //补全信息,分期,作者
+ foreach ($list as $k => $v) {
+ $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find();
+ $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
+ $list[$k]['stage'] = $stage_info;
+ $list[$k]['journal'] = $journal_info;
+ //组合cite信息
+ $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
+ $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
+ $list[$k]['cite'] = $cite;
+ $list[$k]['authortitle'] = $this->getAuthor($v);
+ //斜体变红
+ $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content');
+ $cache_title = $v['title'];
+ foreach ($caches as $val) {
+ $cache_title = str_replace($val, '' . $val . '', $cache_title);
+ }
+ $cache_title = str_replace(trim($data['keyword']), '' . $data['keyword'] . '', $cache_title);
+ $list[$k]['title'] = $cache_title;
+ }
+ $re['articles'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 查找文章精确查找
+ * @description 查找文章精确查找
+ * @author wangjinlei
+ * @url /api/Journal/searchDetail
+ * @method POST
+ *
+ * @param name:term type:string require:0 desc:关键词
+ * @param name:author type:string require:0 desc:作者
+ * @param name:title type:string require:0 desc:标题
+ * @param name:start_date type:string require:0 desc:开始时间
+ * @param name:end_date type:string require:0 desc:结束时间
+ * @param name:journal_id type:int require:1 desc:journal_id(如果不限期刊请填0)
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return articles:文章信息#
+ * @return count:总数
+ */
+ public function searchDetail() {
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+
+ //判断时间
+ $stages = [];
+ if (isset($data['start_date']) && $data['start_date'] != '') {
+ $date_where['stage_year'] = [['>=', $data['start_date']], ['<=', $data['end_date']]];
+ if ($data['journal_id'] != 0) {
+ $date_where['journal_id'] = $data['journal_id'];
+ }
+ $stages = $this->journal_stage_obj->where($date_where)->column('journal_stage_id');
+
+ if (count($stages) == 0) {
+ $re['articles'] = [];
+ $re['count'] = 0;
+ return jsonSuccess($re);
+ }
+ }
+ //组装作者
+ $arts = [];
+ if(isset($data['author']) && $data['author'] != ''){
+ $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['author']) . '%')->column('article_id');
+ if (count($arts) == 0) {
+ $re['articles'] = [];
+ $re['count'] = 0;
+ return jsonSuccess($re);
+ }
+ }
+
+ //构造查询语句
+ $where_str = '';
+ if (isset($data['term']) && $data['term'] != '') {
+ $where_str .= 'keywords like "%' . trim($data['term']) . '%" or abstract like "%' . trim($data['term']) . '%"';
+ }
+ if (isset($data['title']) && $data['title'] != '') {
+ $where_str .= $where_str == '' ? 'title like "%' . trim($data['title']) . '%"' : 'or title like "%' . trim($data['title']) . '%"';
+ }
+ if ($data['journal_id'] != 0) {
+ $where_str = $where_str == '' ? 'journal_id = ' . $data['journal_id'] : 'journal_id = ' . $data['journal_id'] . ' and (' . $where_str . ')';
+ }
+ if (count($stages) > 0) {
+ $c_str = '(' . implode(',', $stages) . ')';
+ $where_str = $where_str == '' ? 'journal_stage_id in ' . $c_str : 'journal_stage_id in ' . $c_str . ' and ' . $where_str;
+ }
+
+ if (count($arts) > 0) {
+ $a_str = '(' . implode(',', $arts) . ')';
+ $where_str = $where_str == '' ? 'article_id in ' . $a_str : 'article_id in ' . $a_str . ' and ' . $where_str;
+ }
+ $where_str = $where_str == '' ? 'state = 0' : 'state = 0 and ' . $where_str;
+
+ $list = $this->article_obj
+ ->where($where_str)
+ ->limit($limit_start, $data['pageSize'])
+ ->select();
+ $count = $this->article_obj
+ ->where($where_str)
+ ->count();
+ //补全信息,分期,作者
+ foreach ($list as $k => $v) {
+ $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find();
+ $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
+ $list[$k]['stage'] = $stage_info;
+ $list[$k]['journal'] = $journal_info;
+ //组合cite信息
+ $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
+ $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
+ $list[$k]['cite'] = $cite;
+ $list[$k]['authortitle'] = $this->getAuthor($v);
+ //斜体变红
+ $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content');
+ $cache_title = $v['title'];
+ foreach ($caches as $val) {
+ $cache_title = str_replace($val, '' . $val . '', $cache_title);
+ }
+ if (isset($data['title'])) {
+ $cache_title = str_replace(trim($data['title']), '' . $data['title'] . '', $cache_title);
+ }
+ $list[$k]['title'] = $cache_title;
+ }
+
+ $re['articles'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 查找文章精确查找(新)
+ * @description 查找文章精确查找(新)
+ * @author wangjinlei
+ * @url /api/Journal/searchArticleMenu
+ * @method POST
+ *
+ * @param name:key1 type:string require:1 desc:第一个条件(title,abstract,keywords,author)
+ * @param name:val1 type:string require:1 desc:第一个值
+ * @param name:oper type:string require:0 desc:运算符(and\or)
+ * @param name:key2 type:string require:0 desc:第二个条件(title,abstract,keywords,author)
+ * @param name:val2 type:string require:0 desc:第二个值
+ * @param name:journal_id type:int require:1 desc:journal_id(demo:1,2,3)
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return articles:文章信息#
+ * @return count:总数
+ */
+ public function searchArticleMenu(){
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+
+ //组合where语句
+ $where_str = '';
+
+ if($data['key1'] == 'author'){
+ $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val1']) . '%')->column('article_id');
+ $a_str = '(' . implode(',', $arts) . ')';
+ $where_str = '(article_id in '. $a_str;
+ }else{
+ $where_str = '('.$data['key1'].' like "%'.$data['val1'].'%"';
+ }
+ if(isset($data['key2'])&&$data['key2']!=''){
+ if($data['oper'] == 'and'){
+ $where_str = $where_str . ' and ';
+ }else{
+ $where_str = $where_str . ' or ';
+ }
+ if($data['key2'] == 'author'){
+ $arts = $this->article_author_obj->where('state', 0)->where('author_name', 'like', '%' . trim($data['val2']) . '%')->column('article_id');
+ $a_str = '(' . implode(',', $arts) . ')';
+ $where_str = $where_str.' article_id in '. $a_str;
+ }else{
+ $where_str = $where_str.' '.$data['key2'].' like "%'.$data['val2'].'%"';
+ }
+ }
+ //处理journal_id
+ $where_str = $where_str . ') and journal_id in ('.trim($data['journal_id']).') and state = 0 ';
+ //处理order
+ $order_str = '';
+ if($data['key1']=='title'&&(isset($data['key2'])&&$data['key2']=='title')){
+ $order_str = "((CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) + (CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END)) desc";
+ }elseif($data['key1']=='title'||(isset($data['key2'])&&$data['key2']=='title')){
+ if($data['key1']=='title'){
+ $order_str = "(CASE WHEN title LIKE '%" . trim($data['val1']) . "%' THEN 1 ELSE 0 END) desc";
+ }else{
+ $order_str = "(CASE WHEN title LIKE '%" . trim($data['val2']) . "%' THEN 1 ELSE 0 END) desc";
+ }
+ }else{
+ $order_str = "article_id desc";
+ }
+
+ $list = $this->article_obj
+ ->where($where_str)
+ ->orderRaw($order_str)
+ ->limit($limit_start,$data['pageSize'])
+ ->select();
+ $count = $this->article_obj
+ ->where($where_str)
+ ->count();
+ //补全信息,分期,作者
+ foreach ($list as $k => $v) {
+ $stage_info = $this->journal_stage_obj->where('journal_stage_id', $v['journal_stage_id'])->find();
+ $journal_info = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
+ $list[$k]['stage'] = $stage_info;
+ $list[$k]['journal'] = $journal_info;
+ //组合cite信息
+ $no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
+ $cite = $v['abbr'] . '. ' . $v['title'] . '. ' . $journal_info['jabbr'] . '. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
+ $list[$k]['cite'] = $cite;
+ $list[$k]['authortitle'] = $this->getAuthor($v);
+ //斜体变红
+ $caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content');
+ $cache_title = $v['title'];
+ foreach ($caches as $val) {
+ $cache_title = str_replace($val, '' . $val . '', $cache_title);
+ }
+ if ($data['key1']=='title') {
+ $cache_title = str_replace(trim($data['val1']), '' . $data['val1'] . '', $cache_title);
+ }
+ if (isset($data['key2'])&&$data['key2']=='title') {
+ $cache_title = str_replace(trim($data['val2']), '' . $data['val2'] . '', $cache_title);
+ }
+ $list[$k]['title'] = $cache_title;
+ }
+
+ $re['articles'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+
+ }
+
}
diff --git a/application/api/controller/Main.php b/application/api/controller/Main.php
index 993c88c..742f4df 100644
--- a/application/api/controller/Main.php
+++ b/application/api/controller/Main.php
@@ -6,6 +6,7 @@ use think\Controller;
use think\Db;
use ip\IpLocation;
use ipserv\iplimit;
+use think\Queue;
/**
* @title 前段web接口
@@ -354,10 +355,11 @@ class Main extends Controller {
// $push_url = 'http://www.journal.com/api/Main/getImgFile';
//定义需要查询同化的数组
- $list = ['articleCite','articlePDF','articleicon','articleSUB','articleSUB2','journalCfp','journalfooter','journalicon','journalline','journaltopic'];
+ $list = ['articleCite','articlePDF','articleicon','articleSUB','articleSUB2','journalCfp','journalfooter','journalicon','journalline','journaltopic','system'];
foreach ($list as $v){
- $dir = $root_url."public/".$v."/".date('Ymd');//"20201123";
+ $dir = $root_url."public/".$v."/".date('Ymd');
+// $dir = $root_url."public/".$v."/20210515";
$files = [];
//查询目前的文件情况
if(!is_dir($dir)){
@@ -385,14 +387,31 @@ class Main extends Controller {
$root_url = ROOT_PATH;
$base_url = 'http://journalapi.tmrjournals.com/public/';
$data = $this->request->post();
+
$dir = $root_url."public/".$data['dir'].'/'.date('Ymd');
- mkdir ($dir,0777,true);
+// $dir = $root_url."public/".$data['dir'].'/20210515';
+ if(!is_dir($dir)){
+ mkdir ($dir,0777,true);
+ }
+
$list = json_decode($data['files']);
foreach ($list as $v){
- file_put_contents($dir.'/'.$v, file_get_contents($base_url.$data['dir'].'/'.date('Ymd').'/'.$v));
+ $fileData['yum'] = $base_url.$data['dir'].'/'.date('Ymd').'/'.$v;
+// $fileData['yum'] = $base_url.$data['dir'].'/20210515/'.$v;
+ $fileData['mubiao'] = $dir.'/'.$v;
+ Queue::push( 'app\api\job\imgFile@fire' , $fileData , "file" );
+// file_put_contents($dir.'/'.$v, file_get_contents($base_url.$data['dir'].'/'.date('Ymd').'/'.$v));
}
}
+ public function qutest(){
+ $base_url = 'http://journalapi.tmrjournals.com/public/';
+ $dir = ROOT_PATH."public/articlePDF/20210514";
+ $fileData['yum'] = $base_url.'articlePDF/20210514/3714895481e8d2338c25c57bbcfba0b7.pdf';
+ $fileData['mubiao'] = $dir.'/3714895481e8d2338c25c57bbcfba0b7.pdf';
+ Queue::push( 'app\api\job\imgFile@fire' , $fileData , "file" );
+ }
+
/**
* @title 获取首页Highlights
* @description 获取首页Highlights
diff --git a/application/api/controller/Special.php b/application/api/controller/Special.php
index 1db2695..4b5c42e 100644
--- a/application/api/controller/Special.php
+++ b/application/api/controller/Special.php
@@ -166,7 +166,7 @@ class Special extends Controller {
->where('j_journal_special_to_editor.state',0)
->select();
foreach ($caches as $val){
- $frag .= $frag == ''?$val['first_name'].' '.$val['last_name']:','.$val['first_name'].' '.$val['last_name'];
+ $frag .= $frag == ''?$val['first_name'].' '.$val['last_name']:', '.$val['first_name'].' '.$val['last_name'];
}
$list[$k]['editor'] = $frag;
}
diff --git a/application/api/job/imgFile.php b/application/api/job/imgFile.php
new file mode 100644
index 0000000..e11d7a6
--- /dev/null
+++ b/application/api/job/imgFile.php
@@ -0,0 +1,41 @@
+send($data);
+ $job->delete();
+ if($res){
+ $job->delete();
+ }else{
+ if($job->attempts()>3){
+ // 第1种处理方式:重新发布任务,该任务延迟10秒后再执行
+ //$job->release(10);
+ // 第2种处理方式:原任务的基础上1分钟执行一次并增加尝试次数
+ //$job->failed();
+ // 第3种处理方式:删除任务
+ $job->delete();
+ }
+ }
+ }
+
+ /**
+ * 保存图片逻辑
+ * @param type $data
+ */
+ public function send($data){
+ $res = file_put_contents($data['mubiao'], file_get_contents($data['yum']));
+ if($res){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+}
diff --git a/application/api/job/mail.php b/application/api/job/mail.php
index 8e9d8e6..b0f6355 100644
--- a/application/api/job/mail.php
+++ b/application/api/job/mail.php
@@ -10,6 +10,7 @@ class mail {
public function fire(Job $job, $data) {
$res = $this->send($data);
+ $job->delete();
if($res){
$job->delete();
}else{
diff --git a/application/master/controller/Article.php b/application/master/controller/Article.php
index 2214c41..a740d93 100644
--- a/application/master/controller/Article.php
+++ b/application/master/controller/Article.php
@@ -141,7 +141,19 @@ class Article extends Controller {
$data = $this->request->post();
$insert_author['article_id'] = $data['article_id'];
- $insert_author['author_name'] = $data['author_name'];
+ $insert_author['author_name'] = trim($data['author_name']);
+ //处理名字
+ $ca = explode(' ', $insert_author['author_name']);
+ $caf = '';
+ $cal = '';
+ if(isset($ca[0])){
+ $caf = str_replace('-', '', $ca[0]);
+ }
+ if(isset($ca[1])){
+ $cal = $ca[1];
+ }
+ $insert_author['first_name'] = $caf;
+ $insert_author['last_name'] = $cal;
$insert_author['author_country'] = $data['author_country'];
$insert_author['is_first'] = $data['is_first'];
$insert_author['is_report'] = $data['is_report'];
@@ -195,7 +207,20 @@ class Article extends Controller {
// $data['organs'] = ['1','2','3'];
$old_article_author_info = $this->article_author_obj->where('article_author_id',$data['article_author_id'])->find();
- $update_author['author_name'] = $data['author_name'];
+ $update_author['author_name'] = trim($data['author_name']);
+ //处理名字
+ $ca = explode(' ', $update_author['author_name']);
+ $caf = '';
+ $cal = '';
+ if(isset($ca[0])){
+ $caf = str_replace('-', '', $ca[0]);
+ }
+ if(isset($ca[1])){
+ $cal = $ca[1];
+ }
+ $update_author['first_name'] = $caf;
+ $update_author['last_name'] = $cal;
+
$update_author['author_country'] = $data['author_country'];
$update_author['is_first'] = $data['is_first'];
$update_author['is_report'] = $data['is_report'];
@@ -698,6 +723,23 @@ class Article extends Controller {
return json(['code'=>1,'msg'=>'system error']);
}
}
+
+ public function mycc(){
+ $list = $this->article_author_obj->where('article_author_id','>',5126)->select();
+ foreach ($list as $v){
+ $ca = explode(' ', $v['author_name']);
+ $caf = '';
+ $cal = '';
+ if(isset($ca[0])){
+ $caf = str_replace('-', '', $ca[0]);
+ }
+ if(isset($ca[1])){
+ $cal = $ca[1];
+ }
+ $this->article_author_obj->where('article_author_id',$v['article_author_id'])->update(['first_name'=>$caf,'last_name'=>$cal]);
+ }
+ echo 'over';
+ }
/**
* @title 图片上传
diff --git a/application/master/controller/Mysystem.php b/application/master/controller/Mysystem.php
index eae065f..656a590 100644
--- a/application/master/controller/Mysystem.php
+++ b/application/master/controller/Mysystem.php
@@ -17,6 +17,8 @@ class Mysystem extends Controller {
protected $sys_scient_obj = '';
protected $sys_book_obj = '';
protected $sys_not_obj = '';
+ protected $de_topic_obj = '';
+ protected $de_topic_to_article = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
@@ -26,6 +28,8 @@ class Mysystem extends Controller {
$this->sys_scient_obj = Db::name('system_scient');
$this->sys_book_obj = Db::name('system_books');
$this->sys_not_obj = Db::name('system_notices');
+ $this->de_topic_obj = Db::name('de_topic');
+ $this->de_topic_to_article = Db::name('de_topic_to_article');
}
/**
@@ -452,6 +456,187 @@ class Mysystem extends Controller {
return jsonSuccess($re);
}
+ /**
+ * @title 增加总话题
+ * @description 增加总话题
+ * @author wangjinlei
+ * @url /master/Mysystem/addTopic
+ * @method POST
+ *
+ * @param name:title type:string require:1 desc:标题
+ * @param name:intro type:string require:0 desc:简介
+ * @param name:icon type:string require:1 desc:图片地址
+ *
+ */
+ public function addTopic(){
+ $data = $this->request->post();
+ $insert['title'] = trim($data['title']);
+ $insert['intro'] = isset($data['intro'])?trim($data['intro']):'';
+ $insert['icon'] = $data['icon'];
+ $this->de_topic_obj->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 删除总话题
+ * @description 删除总话题
+ * @author wangjinlei
+ * @url /master/Mysystem/delTopic
+ * @method POST
+ *
+ * @param name:de_topic_id type:int require:1 desc:主键id
+ *
+ */
+ public function delTopic(){
+ $data = $this->request->post();
+ $this->de_topic_obj->where('de_topic_id',$data['de_topic_id'])->update(['state'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 编辑总话题
+ * @description 编辑总话题
+ * @author wangjinlei
+ * @url /master/Mysystem/editTopic
+ * @method POST
+ *
+ * @param name:de_topic_id type:int require:1 desc:主键id
+ * @param name:title type:string require:1 desc:标题
+ * @param name:intro type:string require:0 desc:简介
+ * @param name:icon type:string require:1 desc:图片地址
+ *
+ */
+ public function editTopic(){
+ $data = $this->request->post();
+ $update['title'] = trim($data['title']);
+ $update['intro'] = isset($data['intro'])?trim($data['intro']):'';
+ $update['icon'] = $data['icon'];
+ $this->de_topic_obj->where('de_topic_id',$data['de_topic_id'])->update($update);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取总话题列表
+ * @description 获取总话题列表
+ * @author wangjinlei
+ * @url /master/Mysystem/getTopicList
+ * @method POST
+ *
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return topics:topic@
+ * @return count:总数
+ * @topics title:标题 intro:简介 icon:图片路径
+ */
+ public function getTopicList(){
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $list = $this->de_topic_obj->where('state',0)->limit($limit_start,$data['pageSize'])->select();
+ $count = $this->de_topic_obj->where('state',0)->count();
+
+ $re['topics'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 添加话题文章对应关系
+ * @description 添加话题文章对应关系
+ * @author wangjinlei
+ * @url /master/Mysystem/addTopicToArticle
+ * @method POST
+ *
+ * @param name:de_topic_id type:int require:1 desc:话题id
+ * @param name:article_id type:int require:1 desc:文章id
+ */
+ public function addTopicToArticle(){
+ $data = $this->request->post();
+ $insert['de_article_id'] = $data['de_article_id'];
+ $insert['article_id'] = $data['article_id'];
+ $this->de_topic_to_article->insert($insert);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 删除话题文章对应关系
+ * @description 删除话题文章对应关系
+ * @author wangjinlei
+ * @url /master/Mysystem/delTopicToArticle
+ * @method POST
+ *
+ * @param name:de_topic_to_article_id type:int require:1 desc:对应关系id
+ */
+ public function delTopicToArticle(){
+ $data = $this->request->post();
+ $this->de_topic_to_article->where('de_topic_to_article_id',$data['de_topic_to_article_id'])->update(['state'=>1]);
+ return jsonSuccess([]);
+ }
+
+ /**
+ * @title 获取话题通过文章
+ * @description 获取话题通过文章
+ * @author wangjinlei
+ * @url /master/Mysystem/getTopicByArticle
+ * @method POST
+ *
+ * @param name:article_id type:int require:1 desc:文章id
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return topics:topic@
+ * @return count:总数
+ * @topics title:标题 intro:简介 icon:图片路径
+ */
+ public function getTopicByArticle(){
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $list = $this->de_topic_to_article
+ ->field('j_de_topic.*')
+ ->join('j_de_topic','j_de_topic_to_article.de_topic_id = j_de_topic.de_topic_id','LEFT')
+ ->where('j_de_topic_to_article.article_id',$data['article_id'])
+ ->where('j_de_topic_to_article.state',0)
+ ->limit($limit_start,$data['pageSize'])
+ ->select();
+ $count = $this->de_topic_to_article->where('state',0)->where('article_id',$data['article_id'])->count();
+
+ $re['topics'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
+ /**
+ * @title 获取文章通过话题
+ * @description 获取文章通过话题
+ * @author wangjinlei
+ * @url /master/Mysystem/getArticleByTopic
+ * @method POST
+ *
+ * @param name:de_topic_id type:int require:1 desc:话题id
+ * @param name:pageIndex type:int require:1 desc:当前页码数
+ * @param name:pageSize type:int require:1 desc:单页数据条数
+ *
+ * @return articles:article@
+ * @return count:总数
+ * @articles title:标题 type:类型 icon:图片路径 doi:doi号
+ */
+ public function getArticleByTopic(){
+ $data = $this->request->post();
+ $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
+ $list = $this->de_topic_to_article
+ ->field('j_article.*')
+ ->join('j_article','j_de_topic_to_article.article_id = j_article.article_id','LEFT')
+ ->where('j_de_topic_to_article.de_topic_id',$data['de_topic_id'])
+ ->where('j_de_topic_to_article.state',0)
+ ->limit($limit_start,$data['pageSize'])
+ ->select();
+ $count = $this->de_topic_to_article->where('state',0)->where('de_topic_id',$data['de_topic_id'])->count();
+
+ $re['articles'] = $list;
+ $re['count'] = $count;
+ return jsonSuccess($re);
+ }
+
/**
* @title pdf上传
* @description pdf上传