diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index 77e277b..45d49cb 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -5,6 +5,7 @@ namespace app\api\controller; use think\Controller; use think\Db; use think\Queue; +use think\Validate; /** * @title 期刊web接口 @@ -35,6 +36,8 @@ class Journal extends Controller { protected $board_group_obj = ''; protected $base_topic_obj = ''; protected $subscribe_base_topic_obj = ''; + protected $footer_obj = ''; + protected $journal_for_author; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -59,6 +62,8 @@ class Journal extends Controller { $this->board_group_obj = Db::name('board_group'); $this->base_topic_obj = Db::name('base_topic'); $this->subscribe_base_topic_obj = Db::name('subscribe_base_topic'); + $this->footer_obj = Db::name('footer'); + $this->journal_for_author = Db::name('journal_for_author'); } /** @@ -128,6 +133,84 @@ class Journal extends Controller { return json(['code' => 0, 'msg' => 'success', 'data' => ['journal' => $journal_info, 'relats' => $relatelist, 'journalAbs' => $absList, 'journalStage' => $stageList]]); } + /** + * 获取所有底栏文章 + */ + public function getAllFooter(){ + $where['footer_state'] = 0; + $list = $this->footer_obj->where($where)->order('sort desc')->select(); + $frag = []; + $frag['Publishing Policy'] = []; + $frag['Join Us'] = []; + $frag['Products'] = []; + $frag['Cooperate with Us'] = []; + $frag['Publisher Information'] = []; + foreach ($list as $v) { + switch ($v['footer_group']) { + case 1: + $frag['Publishing Policy'][] = $v; + break; + case 2: + $frag['Join Us'][] = $v; + break; + case 3: + $frag['Products'][] = $v; + break; + case 4: + $frag['Cooperate with Us'][] = $v; + break; + case 5: + $frag['Publisher Information'][] = $v; + break; + } + } + $re['footers'] = $frag; + return jsonSuccess($re); + } + + /** + * 获取底栏文章详情 + */ + public function getFooterAtrNew(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'footer_id' => 'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $footer_detail = $this->footer_obj->where('footer_id',$data['footer_id'])->find(); + $re['footer'] = $footer_detail; + return jsonSuccess($re); + } + + /** + * 获取所有forAuthors + */ + public function getForAuthors(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'journal_id' => 'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $journals[]=0; + $journals[]=$data['journal_id']; + $list = $this->journal_for_author->where('journal_id','in',$journals)->where('pid',0)->where('jfa_state',0)->order("sort desc")->select(); + foreach($list as $k => $v){ + $cache_list = $this->journal_for_author->where('journal_id','in',$journals)->where('pid',$v['jfa_id'])->where('jfa_state',0)->order("sort desc")->select(); + $list[$k]['children'] = $cache_list; + } + $re['forAuthors'] = $list; + return jsonSuccess($re); + + + + } + /** * @title 获取期刊信息通过issn * @description 获取期刊信息通过issn @@ -501,6 +584,8 @@ class Journal extends Controller { return jsonSuccess($re); } + + /** * @title 获取期刊推广文章 * @description 获取期刊推广文章 diff --git a/application/master/controller/Footer.php b/application/master/controller/Footer.php index cbe73f3..9dc0780 100644 --- a/application/master/controller/Footer.php +++ b/application/master/controller/Footer.php @@ -1,15 +1,17 @@ admin_obj = Db::name('admin'); $this->journal_obj = Db::name('journal'); @@ -54,8 +59,106 @@ class Footer extends Controller $this->board_group_obj = Db::name('board_group'); $this->base_topic_obj = Db::name('base_topic'); $this->subscribe_base_topic_obj = Db::name('subscribe_base_topic'); + $this->footer_obj = Db::name('footer'); + $this->journal_for_author = Db::name('journal_for_author'); + } + + + /** + * 获取footer文章列表 + */ + public function getFooterList() + { + $where['footer_state'] = 0; + $list = $this->footer_obj->where($where)->order('sort desc')->select(); + $frag = []; + $frag['Publishing Policy'] = []; + $frag['Join Us'] = []; + $frag['Products'] = []; + $frag['Cooperate with Us'] = []; + $frag['Publisher Information'] = []; + foreach ($list as $v) { + switch ($v['footer_group']) { + case 1: + $frag['Publishing Policy'][] = $v; + break; + case 2: + $frag['Join Us'][] = $v; + break; + case 3: + $frag['Products'][] = $v; + break; + case 4: + $frag['Cooperate with Us'][] = $v; + break; + case 5: + $frag['Publisher Information'][] = $v; + break; + } + } + $re['footers'] = $frag; + return jsonSuccess($re); + } + + /** + * 增加底栏文章 + */ + public function addFooter() + { + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'footer_title' => 'require', + 'content' => 'require', + 'footer_group' => 'require', + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $insert['footer_title'] = trim($data['footer_title']); + $insert['content'] = trim($data['content']); + $insert['footer_group'] = $data['footer_group']; + $insert['sort'] = isset($data['sort'])?$data['sort']:0; + $insert['footer_ctime'] = time(); + $this->footer_obj->insert($insert); + return jsonSuccess([]); + } + + /** + * 编辑底栏文章 + */ + public function editFooter(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'footer_id' => 'require', + 'footer_title' => 'require', + 'content' => 'require', + 'sort' => 'require', + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $updata['footer_title'] = trim($data['footer_title']); + $updata['content'] = trim($data['content']); + $updata['sort'] = $data['sort']; + $this->footer_obj->where('footer_id',$data['footer_id'])->update($updata); + return jsonSuccess([]); + } + + /** + * 删除底部文章 + */ + public function delFooter(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'footer_id' => 'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $this->footer_obj->where('footer_id',$data['footer_id'])->update(['footer_state'=>1]); + return jsonSuccess([]); } - - - } diff --git a/application/master/controller/Journal.php b/application/master/controller/Journal.php index 27402d0..b9c037e 100644 --- a/application/master/controller/Journal.php +++ b/application/master/controller/Journal.php @@ -5,6 +5,7 @@ namespace app\master\controller; use think\Controller; use think\Db; use think\Queue; +use think\Validate; /** * @title 期刊接口 @@ -33,6 +34,7 @@ class Journal extends Controller { protected $board_group_obj = ''; protected $base_topic_obj = ''; protected $subscribe_base_topic_obj = ''; + protected $journal_for_author; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -56,6 +58,7 @@ class Journal extends Controller { $this->board_group_obj = Db::name('board_group'); $this->base_topic_obj = Db::name('base_topic'); $this->subscribe_base_topic_obj = Db::name('subscribe_base_topic'); + $this->journal_for_author = Db::name('journal_for_author'); } /** @@ -969,6 +972,95 @@ class Journal extends Controller { } } } + + /** + * 获取期刊forAuthor + */ + public function getForAuthorList(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'journal_id' => 'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $journals[]=0; + if($data['journal_id']!=0){ + $journals[]=$data['journal_id']; + } + $list = $this->journal_for_author->where('journal_id','in',$journals)->where('pid',0)->where('jfa_state',0)->order("sort desc")->select(); + foreach($list as $k => $v){ + $cache_list = $this->journal_for_author->where('journal_id','in',$journals)->where('pid',$v['jfa_id'])->where('jfa_state',0)->order("sort desc")->select(); + foreach($cache_list as $key => $val){ + $cache_list[$key]['p_title'] = $v['jfa_title']; + } + $list[$k]['children'] = $cache_list; + } + $re['forAuthors'] = $list; + return jsonSuccess($re); + } + + /** + * 添加forauthor + */ + public function addForAuthor(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'journal_id' => 'require', + 'pid'=>'require', + 'jfa_title'=>'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $insert['journal_id'] = $data['journal_id']; + $insert['pid'] = $data['pid']; + $insert['jfa_title'] = $data['jfa_title']; + $insert['content'] = $data['content']; + $insert['sort'] = isset($data['sort'])?$data['sort']:0; + $insert['jfa_ctime'] = time(); + $this->journal_for_author->insert($insert); + return jsonSuccess([]); + } + + /** + * 编辑forauthor + */ + public function editForAuthor(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'jfa_id' => 'require', + 'jfa_title'=>'require', + 'sort'=>'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $update['jfa_title'] = $data['jfa_title']; + $update['content'] = $data['content']; + $update['sort'] = $data['sort']; + $this->journal_for_author->where('jfa_id',$data['jfa_id'])->update($update); + return jsonSuccess([]); + } + + /** + * 删除forAuthor + */ + public function delForAuthor(){ + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'jfa_id' => 'require' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + $this->journal_for_author->where('jfa_id',$data['jfa_id'])->update(['jfa_state'=>1]); + return jsonSuccess([]); + } /** * @title line图片上传