1
This commit is contained in:
140
application/akszadmin/controller/Article.php
Executable file
140
application/akszadmin/controller/Article.php
Executable file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://demo.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库3:https://gitee.com/zoujingli/ThinkAdmin
|
||||
// | github 代码仓库3:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\akszadmin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 文章管理
|
||||
* Class Item
|
||||
* @package app\akszadmin\controller
|
||||
*/
|
||||
class Article extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'LcArticle';
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '文章列表';
|
||||
$query = $this->_query($this->table)->alias('i')->field('i.*,t.name');
|
||||
$query->join('lc_article_type t','i.type=t.id')->equal('i.type#i_type')->like('i.title#i_title')->dateBetween('i.time#i_time')->order('i.sort asc,i.id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
$this->mlist = Db::name('LcArticleType')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @auth true
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->title = '添加文章';
|
||||
$this->assign('langss', [
|
||||
['name' => '中文', 'value' => 'zh-cn'],
|
||||
['name' => '英文', 'value' => 'en'],
|
||||
['name' => '法文', 'value' => 'fr'],
|
||||
['name' => '德文', 'value' => 'de'],
|
||||
['name' => '西班牙文', 'value' => 'es'],
|
||||
['name' => '意大利文', 'value' => 'it'],
|
||||
['name' => '葡萄牙文', 'value' => 'pt'],
|
||||
['name' => '俄文', 'value' => 'ru'],
|
||||
['name' => '阿拉伯文', 'value' => 'ar'],
|
||||
]);
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑文章
|
||||
* @auth true
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->title = '编辑文章';
|
||||
$this->assign('langss', [
|
||||
['name' => '中文', 'value' => 'zh-cn'],
|
||||
['name' => '英文', 'value' => 'en'],
|
||||
['name' => '法文', 'value' => 'fr'],
|
||||
['name' => '德文', 'value' => 'de'],
|
||||
['name' => '西班牙文', 'value' => 'es'],
|
||||
['name' => '意大利文', 'value' => 'it'],
|
||||
['name' => '葡萄牙文', 'value' => 'pt'],
|
||||
['name' => '俄文', 'value' => 'ru'],
|
||||
['name' => '阿拉伯文', 'value' => 'ar'],
|
||||
]);
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* @auth true
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $vo
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
protected function _form_filter(&$vo){
|
||||
if ($this->request->isGet()) {
|
||||
$this->class = Db::name("LcArticleType")->order('id asc')->select();
|
||||
if(!isset($vo['show'])) $vo['show'] = '1';
|
||||
}
|
||||
if (empty($vo['time'])) $vo['time'] = date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user