This commit is contained in:
wangjinlei
2021-01-05 10:58:23 +08:00
parent 201843817a
commit 6784f78323
2 changed files with 52 additions and 62 deletions

View File

@@ -350,7 +350,6 @@ class Journal extends Controller {
->where('j_article.type', ['like', 'News'], ['like', 'Comment'], 'or')
->order('j_article.article_id')
->select();
//获取作者
foreach ($list as $k => $v) {
$stage_info = $this->journal_stage_obj->where('journal_stage_id',$v['journal_stage_id'])->find();

View File

@@ -10,7 +10,8 @@ use think\Db;
* @description 前段web接口
* @group 前段web接口
*/
class Main extends Controller{
class Main extends Controller {
//put your code here
protected $admin_obj = '';
protected $journal_obj = '';
@@ -48,8 +49,8 @@ class Main extends Controller{
*
* @return scients:array#
*/
public function getScients(){
$list = $this->sys_scient_obj->where('state',0)->select();
public function getScients() {
$list = $this->sys_scient_obj->where('state', 0)->select();
$re['scients'] = $list;
return jsonSuccess($re);
}
@@ -65,9 +66,9 @@ class Main extends Controller{
*
* @return scient:array#
*/
public function getScientDetail(){
public function getScientDetail() {
$data = $this->request->post();
$info = $this->sys_scient_obj->where('system_scient_id',$data['system_scient_id'])->find();
$info = $this->sys_scient_obj->where('system_scient_id', $data['system_scient_id'])->find();
$re['scient'] = $info;
return jsonSuccess($re);
@@ -82,8 +83,8 @@ class Main extends Controller{
*
* @return books:array#
*/
public function getBooks(){
$list = $this->sys_book_obj->where('state',0)->select();
public function getBooks() {
$list = $this->sys_book_obj->where('state', 0)->select();
$re['books'] = $list;
return jsonSuccess($re);
}
@@ -99,9 +100,9 @@ class Main extends Controller{
*
* @return book:array#
*/
public function getBookDetail(){
public function getBookDetail() {
$data = $this->request->post();
$info = $this->sys_book_obj->where('system_book_id',$data['system_book_id'])->find();
$info = $this->sys_book_obj->where('system_book_id', $data['system_book_id'])->find();
$re['book'] = $info;
return jsonSuccess($re);
@@ -118,17 +119,17 @@ class Main extends Controller{
*
* @return Highlights:array#
*/
public function getMainhl(){
public function getMainhl() {
$data = $this->request->post();
$topic_info = $this->journal_topic_obj->where('journal_id',$data['journal_id'])->where('position','highlights')->where('state',0)->find();
if($topic_info){
$topic_info = $this->journal_topic_obj->where('journal_id', $data['journal_id'])->where('position', 'highlights')->where('state', 0)->find();
if ($topic_info) {
$list = $this->article_to_topic_obj->field('j_article.*,j_journal_stage.*')
->join(array(['j_article','j_article.article_id = j_article_to_topic.article_id','LEFT'],['j_journal_stage','j_journal_stage.journal_stage_id = j_article.journal_stage_id','LEFT']))
->where('j_article_to_topic.topic_id',$topic_info['journal_topic_id'])
->where('j_article_to_topic.state',0)
->join(array(['j_article', 'j_article.article_id = j_article_to_topic.article_id', 'LEFT'], ['j_journal_stage', 'j_journal_stage.journal_stage_id = j_article.journal_stage_id', 'LEFT']))
->where('j_article_to_topic.topic_id', $topic_info['journal_topic_id'])
->where('j_article_to_topic.state', 0)
->select();
return jsonSuccess(['topic_info'=>$topic_info,'articlelist'=>$list]);
}else{
return jsonSuccess(['topic_info' => $topic_info, 'articlelist' => $list]);
} else {
return jsonError('no highlights');
}
}
@@ -142,19 +143,13 @@ class Main extends Controller{
*
* @return journals:array#
*/
public function getJournals(){
$list = $this->journal_obj->where('state',0)->select();
public function getJournals() {
$list = $this->journal_obj->where('state', 0)->select();
$re['journals'] = $list;
return jsonSuccess($re);
}
public function test(){
echo 'ookkjjhhgg';
}
/**
* @title 获取查找文章列表
* @description 获取查找文章列表
@@ -174,36 +169,27 @@ class Main extends Controller{
* @return count:总数
* @return journals:array#
*/
public function getSearchArt(){
public function getSearchArt() {
$data = $this->request->post();
// $data['journals'] = '1,2,3';
// $data['condition1'] = 'title';
// $data['condition1_text'] = '1';
// $data['relation'] = 'or';
// $data['condition2'] = 'keywords';
// $data['condition2_text'] = '1';
// $data['pageIndex'] = 1;
// $data['pageSize'] = 12;
$where = "j_article.journal_id in (".$data['journals'].")";
if($data['condition2_text']!=''){
if($data['relation']=='and'){
$where .= ' and j_article.'.$data['condition1'] .' like "%'.$data['condition1_text'].'%" and j_article.'.$data['condition2'] .' like "%'.$data['condition2_text'].'%"';
}else{
$where .= ' and (j_article.'.$data['condition1'] .' like "%'.$data['condition1_text'].'%" or j_article.'.$data['condition2'] .' like "%'.$data['condition2_text'].'%")';
$where = "j_article.journal_id in (" . $data['journals'] . ")";
if ($data['condition2_text'] != '') {
if ($data['relation'] == 'and') {
$where .= ' and j_article.' . $data['condition1'] . ' like "%' . $data['condition1_text'] . '%" and j_article.' . $data['condition2'] . ' like "%' . $data['condition2_text'] . '%"';
} else {
$where .= ' and (j_article.' . $data['condition1'] . ' like "%' . $data['condition1_text'] . '%" or j_article.' . $data['condition2'] . ' like "%' . $data['condition2_text'] . '%")';
}
}else{
$where .= 'and j_article.'.$data['condition1'] .' like "%'.$data['condition1_text'].'%"';
} else {
$where .= 'and j_article.' . $data['condition1'] . ' like "%' . $data['condition1_text'] . '%"';
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$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')
->join('j_journal_stage', 'j_article.journal_stage_id=j_journal_stage.journal_stage_id', 'LEFT')
->where($where)
->order('j_article.article_id')
->limit($limit_start,$data['pageSize'])
->limit($limit_start, $data['pageSize'])
->select();
foreach ($list as $k => $v){
foreach ($list as $k => $v) {
$list[$k]['authortitle'] = $this->getAuthor($v);
}
$count = $this->article_obj->where($where)->count();
@@ -211,15 +197,20 @@ class Main extends Controller{
$re['journals'] = $list;
return jsonSuccess($re);
}
private function getAuthor($article){
private function getAuthor($article) {
$where['article_id'] = $article['article_id'];
$where['state'] = 0;
$list = $this->article_author_obj->where($where)->select();
$frag = '';
foreach ($list as $k=>$v){
$frag = $frag==''?''.$v['author_name']:$frag.', '.$v['author_name'];
foreach ($list as $k => $v) {
$frag = $frag == '' ? '' . $v['author_name'] : $frag . ', ' . $v['author_name'];
}
return $frag;
}
public function test() {
echo md5('123456');
}
}