This commit is contained in:
wangjinlei
2021-02-19 11:25:27 +08:00
parent 4712826e8b
commit c6e41c6035
3 changed files with 70 additions and 16 deletions

View File

@@ -122,20 +122,28 @@ class Article extends Controller {
* @method POST
*
* @param name: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 topicInfo:话题信息#
* @return articleList:文章信息#
*
* @return count:总数
*/
public function getTopicArticles() {
$data = $this->request->post();
$topic_info = $this->journal_topic_obj->where('journal_topic_id', $data['topic_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$topic_info['journal_id'])->find();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->article_to_topic_obj->field('j_article.*,j_journal_stage.*')
->join(array(['j_article', 'j_article_to_topic.article_id = j_article.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', $data['topic_id'])
->where('j_article_to_topic.state', 0)
->limit($limit_start,$data['pageSize'])
->select();
$count = $this->article_to_topic_obj
->where('j_article_to_topic.topic_id', $data['topic_id'])
->where('j_article_to_topic.state', 0)
->count();
//获取作者
foreach ($list as $k => $v) {
$stage_info = $this->journal_stage_obj->where('journal_stage_id',$v['journal_stage_id'])->find();
@@ -156,6 +164,7 @@ class Article extends Controller {
}
$re['topicInfo'] = $topic_info;
$re['articleList'] = $list;
$re['count'] = $count;
return jsonSuccess($re);
}
private function getAuthor($article) {
@@ -261,6 +270,7 @@ class Article extends Controller {
*/
public function getTopArt() {
$data = $this->request->post();
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$list = [];
if ($data['type'] == 'cited') {
$list = $this->article_obj->field('j_article.*,j_journal_stage.*')
@@ -284,6 +294,16 @@ class Article extends Controller {
->orderRaw('j_article.html_num+j_article.pdf_num desc')
->select();
}
//获取作者
foreach ($list as $k => $v) {
$stage_info = $this->journal_stage_obj->where('journal_stage_id',$v['journal_stage_id'])->find();
//组合cite信息
$no = $stage_info['stage_no'] == 0 ? ':' : '(' . $stage_info['stage_no'] . '):';
$cite = $v['abbr'] . '. ' . $v['title'] . '. <i>' . $journal_info['jabbr'] . '</i>. ' . $stage_info['stage_year'] . ';' . $stage_info['stage_vol'] . $no . $v['npp'] . '. doi:' . $v['doi'];
$list[$k]['cite'] = $cite;
$list[$k]['authortitle'] = $this->getAuthor($v);
}
//标题斜体
foreach ($list as $k => $v) {
$caches = $this->article_ltai_obj->where('article_id', $v['article_id'])->where('state', 0)->column('content');
@@ -394,7 +414,6 @@ class Article extends Controller {
$ris .= 'JF - '.$journal['title']."\n";
$kws = explode(', ', $article_info['keywords']);
foreach ($kws as $vvv){
$ris .= 'KW - '.str_replace('</i>','',str_replace('<i>','',$vvv))."\n";
}
$abs = str_replace('Abstract','',strip_tags(str_replace("&nbsp;","",htmlspecialchars_decode($article_info['abstract']))));

View File

@@ -134,17 +134,26 @@ class Journal extends Controller {
*/
public function getJournalTopic() {
$data = $this->request->post();
$p_res = $this->journal_topic_obj
->where('journal_id', $data['journal_id'])
->where('state', 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)
->order('sort asc,journal_topic_id asc')
->select();
//处理数组
$frag = [];
foreach ($res as $v) {
if ($v['parent_id'] == 0) {
$frag[] = $v;
}
}
$frag = $p_res;
// foreach ($res as $v) {
// if ($v['parent_id'] == 0) {
// $frag[] = $v;
// }
// }
foreach ($frag as $kk => $vv) {
$frag[$kk] = $this->getChieldarr($vv, $res);
}
@@ -650,6 +659,7 @@ class Journal extends Controller {
$repeat = $this->subscribe_journal_obj
->where('journal_id', $data['journal_id'])
->where('email', $data['email'])
->where('state',0)
->find();
if ($repeat) {
return jsonError('repeat subscribe!');
@@ -691,6 +701,7 @@ class Journal extends Controller {
$repeat = $this->subscribe_topic_obj
->where('topic_id', $data['topic_id'])
->where('email', $data['email'])
->where('state',0)
->find();
if ($repeat) {
return jsonError('repeat subscribe!');

File diff suppressed because one or more lines are too long