1
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\master\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* @title 管理员接口
|
||||
* @description 管理员相关操作
|
||||
* @group 管理员相关
|
||||
*/
|
||||
class Footer extends Controller
|
||||
class Footer extends Controller
|
||||
{
|
||||
protected $admin_obj = '';
|
||||
protected $journal_obj = '';
|
||||
@@ -31,8 +33,11 @@ class Footer 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) {
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
parent::__construct($request);
|
||||
$this->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([]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user