AdminStatusController.php 4.7 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\ConditionModel;
use app\portal\model\VehicleModel;
use cmf\controller\AdminBaseController;
use app\portal\model\PortalPostModel;
use app\portal\service\PostService;
use app\portal\model\PortalCategoryModel;
use think\Db;
use app\admin\model\ThemeModel;
use think\Loader;

//   over

class AdminStatusController extends AdminBaseController
{
    /**
     * 商品状态设置
     * @adminMenu(
     *     'name'   => '商品状态设置',
     *     'parent' => 'portal/AdminCommodityCate/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '商品状态设置',
     *     'param'  => ''
     * )
     */
    public function index()
    {
        $data = $this->request->param();
        $return = $this->adminIndex($data);
        $where_vehicle = $return['where_arr'];
        $where_vehicle['status'] = array('neq',9);
        $list = Db::name('Condition')
            ->where($where_vehicle)
            ->order('score desc,create_time desc')
            ->paginate(10,false,['query'=>$return['page_arr']]);
        $page = $list->render();
        $this->assign('page', $page);
        $this->assign('list', $list);
        return $this->fetch();
    }



    /**
     * 添加商品状态
     * @adminMenu(
     *     'name'   => '添加商品状态',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '添加商品状态',
     *     'param'  => ''
     * )
     */
    public function add()
    {
        if ($this->request->isPost()) {
            $model = new ConditionModel();
            $data   = $this->request->param();
            if(empty($data['content'])){
                $this->error('商品状态不能为空');
            }
            $res_save = $model->save($data);
            if($res_save){
                $this->success('添加成功',url('index'));
            }else{
                $this->error('添加失败');
            }
        }else{
            return $this->fetch();
        }
    }

    /**
     * 编辑商品状态
     * @adminMenu(
     *     'name'   => '编辑商品状态',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑商品状态',
     *     'param'  => ''
     * )
     */
    public function edit()
    {
        $id = $this->request->param('id', 0, 'intval');

        $where_vehicle['id'] = $id;
        $post = Db::name('Condition')->where($where_vehicle)->find();
        if($post){
            $post['content'] = htmlspecialchars_decode($post['content']);
        }
        $this->assign('post', $post);
        return $this->fetch();
    }

    /**
     * 编辑商品状态提交
     * @adminMenu(
     *     'name'   => '编辑商品状态提交',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑商品状态提交',
     *     'param'  => ''
     * )
     */
    public function editPost()
    {
        if ($this->request->isPost()) {
            $data   = $this->request->param();
            $model = new ConditionModel();
            if(empty($data['content'])){
                $this->error('商品状态不能为空');
            }
            $res_save = $model->isUpdate(true)->save($data);
            if($res_save){
                $this->success('添加成功',url('index'));
            }else{
                $this->error('添加失败');
            }
        }
    }

    /**
     * 商品状态删除
     * @adminMenu(
     *     'name'   => '商品状态删除',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '商品状态删除',
     *     'param'  => ''
     * )
     */
    public function delete()
    {
       $model = new ConditionModel();
       $this->adminDel($model);
    }



}