123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\store\controller;
- use library\Controller;
- use think\Db;
- use app\common\model\User;
- /**
- * 文章管理
- * Class Article
- * @package app\store\controller
- */
- class Article extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'Article';
- /**
- * 文章信息管理
- * @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 = '文章管理';
- $type = $this->request->get('type');
- $cate = $this->request->get('cate');
- $this->_query($this->table)->like('title')->equal('type,cate,status')->dateBetween('create_at')
- ->where('is_del',1)
- ->order('id desc')
- ->page();
- }
- /**
- * 列表数据处理
- * @param array $data
- */
- protected function _index_page_filter(&$data)
- {
- //dump($data);
- }
- /**
- * 禁用
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function forbid()
- {
- $this->_save($this->table, ['status' => '0']);
- }
- /**
- * 启用
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function resume()
- {
- $this->_save($this->table, ['status' => '1']);
- }
- /**
- * 添加
- * @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->create_at = date('Y-m-d H:i:s');
- $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->_form($this->table, 'form');
- }
- /**
- * 表单数据处理
- * @param array $data
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- protected function _form_filter(&$data)
- {
- if ($this->request->isGet()) {
- if (!empty($data)){
- $catelist = Db::name('cate')->where('type',$data['type'])->where('is_del',1)->where('status',1)->select();
- }else{
- $catelist = Db::name('cate')->where('type',1)->where('is_del',1)->where('status',1)->select();
- }
- $this->catelist = $catelist;
- }else{
- if (!isset($data['icon']) || $data['icon']==''){
- $this->error('请上传图标');
- }
- if (!isset($data['content']) || $data['content']==''){
- $this->error('请填写内容');
- }
- }
- }
- /**
- * 处理成功回调
- */
- public function _form_result($result,$data){
- if ($result) {
- $this->success('成功',url('/#/store/article/index'));
- }
- }
- /**
- * 删除
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function del()
- {
- $this->_save($this->table, ['is_del' => '0']);
- }
- /**
- * 获取类别
- */
- public function getcate(){
- $id=input('id');
- $add = Db::name('cate')->where('is_del',1)->where('status',1)->where('type', $id)->select();
- return $add;
- }
- }
|