This commit is contained in:
wangjinlei
2020-12-22 14:21:20 +08:00
parent 39e0ad84c2
commit 097698a36f
4 changed files with 302 additions and 185 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace app\api\controller;
use think\Controller;
@@ -10,12 +11,14 @@ use think\Db;
* @group 文章web相关
*/
class Article extends Controller {
//put your code here
protected $admin_obj = '';
protected $journal_obj = '';
protected $article_obj = '';
protected $article_author_obj = '';
protected $article_organ_obj = '';
protected $article_ltai_obj = '';
protected $article_author_to_organ_obj = '';
protected $journal_topic_obj = '';
protected $journal_stage_obj = '';
@@ -30,6 +33,7 @@ class Article extends Controller{
$this->article_obj = Db::name('article');
$this->article_author_obj = Db::name('article_author');
$this->article_organ_obj = Db::name('article_organ');
$this->article_ltai_obj = Db::name('article_ltai');
$this->article_author_to_organ_obj = Db::name('article_author_to_organ');
$this->journal_topic_obj = Db::name('journal_topic');
$this->journal_stage_obj = Db::name('journal_stage');
@@ -81,6 +85,7 @@ class Article extends Controller{
$re['cite'] = $cite;
return jsonSuccess($re);
}
private function sys_author($authors, $organs, $atto) {
$cache = [];
foreach ($organs as $k => $v) {
@@ -123,10 +128,21 @@ class Article extends Controller{
foreach ($list as $k => $v) {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
$re['topicInfo'] = $topic_info;
$re['articleList'] = $list;
return jsonSuccess($re);
}
private function getAuthor($article) {
$where['article_id'] = $article['article_id'];
$where['state'] = 0;
@@ -137,6 +153,7 @@ class Article extends Controller{
}
return $frag;
}
// private function getAuthor($article){
// $where['article_id'] = $article['article_id'];
// $where['state'] = 0;
@@ -148,7 +165,6 @@ class Article extends Controller{
// return substr($frag,0, -1);
// }
/**
* @title 获取stage文章列表
* @description 获取stage文章列表
@@ -166,16 +182,20 @@ class Article extends Controller{
$data = $this->request->post();
$stage_info = $this->journal_stage_obj->where('journal_stage_id', $data['stage_id'])->find();
$list = $this->article_obj->field('j_article.*,j_journal_stage.*')->join('j_journal_stage', 'j_article.journal_stage_id = j_journal_stage.journal_stage_id', 'LEFT')->where('j_article.journal_stage_id', $data['stage_id'])->where('j_article.state', 0)->select();
// $topic_info = $this->journal_topic_obj->where('journal_topic_id',$data['topic_id'])->find();
// $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)
// ->select();
//获取作者
foreach ($list as $k => $v) {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
$re['stageInfo'] = $stage_info;
$re['articleList'] = $list;
return jsonSuccess($re);
@@ -219,6 +239,15 @@ class Article extends Controller{
->orderRaw('j_article.html_num+j_article.pdf_num desc')
->select();
}
//标题斜体
foreach ($list as $k => $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, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
$re['articleList'] = $list;
return jsonSuccess($re);

View File

@@ -11,11 +11,13 @@ use think\Db;
* @group 期刊web相关
*/
class Journal extends Controller {
//put your code here
protected $admin_obj = '';
protected $journal_obj = '';
protected $article_obj = '';
protected $article_author_obj = '';
protected $article_ltai_obj = '';
protected $journal_topic_obj = '';
protected $journal_stage_obj = '';
protected $journal_notices_obj = '';
@@ -31,6 +33,7 @@ class Journal extends Controller {
$this->journal_obj = Db::name('journal');
$this->article_obj = Db::name('article');
$this->article_author_obj = Db::name('article_author');
$this->article_ltai_obj = Db::name('article_ltai');
$this->journal_topic_obj = Db::name('journal_topic');
$this->journal_stage_obj = Db::name('journal_stage');
$this->journal_notices_obj = Db::name('journal_notices');
@@ -113,6 +116,7 @@ class Journal extends Controller {
}
return json(['code' => 0, 'msg' => 'success', 'data' => ['topicList' => $frag]]);
}
private function getChieldarr($vv, $res) {
if ($vv['is_final'] == 1) {
return $vv;
@@ -154,6 +158,16 @@ class Journal extends Controller {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
return json(['code' => 0, 'msg' => 'success', 'data' => ['stage' => $stage_info, 'articleList' => $list]]);
}
@@ -168,7 +182,6 @@ class Journal extends Controller {
return $frag;
}
/**
* @title 获取onlinefirst文章
* @description 获取onlinefirst文章
@@ -190,6 +203,15 @@ class Journal extends Controller {
->where('j_article.state', 0)
->select();
//标题斜体
foreach ($list as $k => $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, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
//获取作者
foreach ($list as $k => $v) {
@@ -226,6 +248,15 @@ class Journal extends Controller {
foreach ($list as $k => $v) {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
return json(['code' => 0, 'msg' => 'success', 'data' => ['articlelist' => $list]]);
}
@@ -243,14 +274,22 @@ class Journal extends Controller {
*/
public function getTopArticle() {
$data = $this->request->post();
$list = $this->article_obj->field('j_article.*,j_journal_stage.*')->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)->orderRaw('j_article.cited+j_article.abs_num+j_article.pdf_num desc')->limit(4)->select();
$list = $this->article_obj->field('j_article.*,j_journal_stage.*')->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)->orderRaw('j_article.cited+j_article.abs_num+j_article.pdf_num desc')->select();
//获取作者
foreach ($list as $k => $v) {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
return jsonSuccess(['articles' => $list]);
}
@@ -316,12 +355,20 @@ class Journal extends Controller {
foreach ($list as $k => $v) {
$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');
$cache_title = $v['title'];
foreach ($caches as $val) {
$cache_title = str_replace($val, '<i>' . $val . '</i>', $cache_title);
}
$list[$k]['title'] = $cache_title;
}
return jsonSuccess(['topic_info' => $topic_info, 'articlelist' => $list]);
} else {
return jsonError('no highlights');
}
}
/**

View File

@@ -215,4 +215,5 @@ class Main extends Controller{
}
return $frag;
}
}

View File

@@ -16,6 +16,7 @@ class Article extends Controller {
protected $article_obj = '';
protected $article_author_obj = '';
protected $article_organ_obj = '';
protected $article_ltai_obj = '';
protected $author_to_organ_obj = '';
protected $article_to_topic_obj = '';
protected $journal_topic_obj = '';
@@ -29,6 +30,7 @@ class Article extends Controller {
$this->article_obj = Db::name('article');
$this->article_author_obj = Db::name('article_author');
$this->article_organ_obj = Db::name('article_organ');
$this->article_ltai_obj = Db::name('article_ltai');
$this->author_to_organ_obj = Db::name('article_author_to_organ');
$this->article_to_topic_obj = Db::name('article_to_topic');
$this->journal_topic_obj = Db::name('journal_topic');
@@ -343,6 +345,9 @@ class Article extends Controller {
public function getArticleBase(){
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$ltais = $this->article_ltai_obj->where('article_id',$article_info['article_id'])->where('state',0)->column('content');
$article_info['ltai'] = implode(',', $ltais);
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$list = scandir(ROOT_PATH.'public/articleHTML/'.$journal_info['sx']);
$frag = [];
@@ -398,6 +403,7 @@ class Article extends Controller {
* @param name:abs_num type:int require:1 desc:简介数量
* @param name:pdf_num type:int require:1 desc:pdf数量
* @param name:html_num type:int require:1 desc:html数量
* @param name:ltai type:string require:0 desc:标题斜体(demo1,demo2)
* @param name:npp type:strng require:1 desc:文章页码
* @param name:type type:string require:1 desc:类型
* @param name:cited type:int require:1 desc:引用数
@@ -410,6 +416,9 @@ class Article extends Controller {
*/
public function editArticleBase(){
$data = $this->request->post();
if(isset($data['ltai'])){
$this->editArticleLtai($data['ltai'],$data['article_id']);
}
$updata['icon'] = $data['icon'];
$updata['title'] = $data['title'];
$updata['journal_stage_id'] = $data['journal_stage_id'];
@@ -430,12 +439,35 @@ class Article extends Controller {
$updata['sort'] = $data['sort'];
$updata['pub_date'] = $data['pub_date'];
$res = $this->article_obj->where('article_id',$data['article_id'])->update($updata);
if($res){
// if($res){
return json(['code'=>0,'msg'=>'success']);
// }else{
// return json(['code'=>1,'msg'=>'system error']);
// }
}
private function editArticleLtai($ltai,$article_id){
$list = explode(',', $ltai);
$has = $this->article_ltai_obj->where('article_id',$article_id)->where('state',0)->select();
foreach ($has as $val){
if(in_array($val['content'], $list)){
foreach( $list as $k=>$v) {
if($val['content'] == $v) {
unset($list[$k]);
}
}
}else{
return json(['code'=>1,'msg'=>'system error']);
//删除
$this->article_ltai_obj->where('article_ltai_id',$val['article_ltai_id'])->update(['state'=>1]);
}
}
//增加
foreach ($list as $value){
$cache['article_id'] = $article_id;
$cache['content'] = $value;
$this->article_ltai_obj->insert($cache);
}
}
/**
* @title 编辑文章文件信息
@@ -508,6 +540,14 @@ class Article extends Controller {
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$article_list = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title')->join(array(['j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT'],['j_journal','j_journal.journal_id=j_article.journal_id','LEFT']))->where($where)->order(['j_article.sort desc','j_article.article_id'])->limit($limit_start,$data['pageSize'])->select();
foreach ($article_list as $k => $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, '<i>'.$val.'</i>', $cache_title);
}
$article_list[$k]['title'] = $cache_title;
}
$count = $this->article_obj->where($where)->count();
return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'articleList'=>$article_list]]);
}