This commit is contained in:
wangjinlei
2020-11-18 11:06:53 +08:00
parent b6456b3833
commit 9dc5cf3609

View File

@@ -13,6 +13,7 @@ class Article extends Controller {
//put your code here //put your code here
protected $admin_obj = ''; protected $admin_obj = '';
protected $journal_obj = ''; protected $journal_obj = '';
protected $article_obj = '';
protected $journal_topic_obj = ''; protected $journal_topic_obj = '';
protected $journal_stage_obj = ''; protected $journal_stage_obj = '';
@@ -20,20 +21,60 @@ class Article extends Controller {
parent::__construct($request); parent::__construct($request);
$this->admin_obj = Db::name('admin'); $this->admin_obj = Db::name('admin');
$this->journal_obj = Db::name('journal'); $this->journal_obj = Db::name('journal');
$this->article_obj = Db::name('article');
$this->journal_topic_obj = Db::name('journal_topic'); $this->journal_topic_obj = Db::name('journal_topic');
$this->journal_stage_obj = Db::name('journal_stage');
} }
/** /**
* @title 添加文章 * @title 获取期刊和分期
* @description 添加文章 * @description 获取期刊和分期
* @author wangjinleichang * @author wangjinleichang
* @url /master/Article/addArticle * @url /master/Article/getJournalAndStage
* @method POST * @method POST
* *
* @param name:journal_topic_id type:int require:1 desc:主键 * @param name:editor_id type:int require:1 desc:编辑id
*
* @return joutaglist:array#
*
*/ */
public function addArticle(){ public function getJournalAndStage(){
$data = $this->request->post();
$journal_list = $this->journal_obj->where('editor_id',$data['editor_id'])->select();
$frag = [];
foreach ($journal_list as $v){
$cache_list = $this->journal_stage_obj->where('journal_id',$v['journal_id'])->select();
$v['children'] = $cache_list;
$frag[] = $v;
}
return json(['code'=>0,'msg'=>'success','data'=>['joutaglist'=>$frag]]);
}
/**
* @title 添加文章基本信息
* @description 添加文章基本信息
* @author wangjinleichang
* @url /master/Article/addArticleBase
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:journal_stage_id type:int require:1 desc:分期id
* @param name:sort type:int require:1 default:0 desc:权重
* @param name:title type:string require:1 desc:标题
*/
public function addArticleBase(){
$data = $this->request->post();
$insert_data['journal_id'] = $data['journal_id'];
$insert_data['journal_stage_id'] = $data['journal_stage_id'];
$insert_data['title'] = $data['title'];
$insert_data['sort'] =
$insert_data['ctime'] = time();
$res = $this->article_obj->insert($insert_data);
if($res){
return json(['code'=>0,'msg'=>'success']);
}else{
return json(['code'=>1,'msg'=>'system error']);
}
} }
/** /**
@@ -43,10 +84,31 @@ class Article extends Controller {
* @url /master/Article/getArticleList * @url /master/Article/getArticleList
* @method POST * @method POST
* *
* @param name:journal_topic_id type:int require:1 desc:主键 * @param name:journal_id type:int default:0 require:1 desc:主键
* @param name:journal_stage_id type:int default:0 require:1 desc:主键
* @param name:seach type:string require:0 desc:关键词
* @param name:pageIndex type:int require:1 desc:当前页码数
* @param name:pageSize type:int require:1 desc:单页数据条数
*
* @return count:总数据数
* @return articleList:array#
*/ */
public function getArticleList(){ public function getArticleList(){
$data = $this->request->post();
$where['state'] = 0;
if($data['journal_id']!==0){
$where['journal_id'] = $data['journal_id'];
}
if($data['journal_stage_id']!==0){
$where['journal_stage_id'] = $data['journal_stage_id'];
}
if(isset($data['seach'])&&$data['seach']!=''){
$where['title'] = ['like','%'.$data['seach'].'%'];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$article_list = $this->article_obj->where($where)->order('sort desc')->limit($limit_start,$data['pageSize'])->select();
$count = $this->article_obj->where($where)->count();
return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'articleList'=>$article_list]]);
} }