AdminBusinessmanController.php 8.3 KB
<?php
/**
 * 展商服务
 * Author : xiaojie
 * DateTime: 2018/11/29 13:09
 */
namespace app\portal\controller;

use app\portal\model\PageModel;
use app\portal\model\ShowModel;
use cmf\controller\AdminBaseController;

/**
 * Class AdminBusinessmanController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'展商服务',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'展商服务'
 * )
 */

class AdminBusinessmanController extends AdminBaseController
{
    /**
     * 展商名录
     * @adminMenu(
     *     'name'   => '展商名录',
     *     'parent' => 'portal/AdminBusinessman/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '展商名录',
     *     'param'  => ''
     * )
     */
    public function directories()
    {
        $cate_id = 24;
        $param = $this->request->param();
        $map = $this->search($param,'create_time','title');
        $map['cate_id'] = $cate_id;
        $showModel = new ShowModel();
        $list = $showModel
            ->where($map)
            ->paginate(30);

        $this->assign('list',$list);
        $this->assign('page',$list->render());
        return $this->fetch();
    }

    /**
     * 添加展商名录
     * @adminMenu(
     *     'name'   => '添加展商名录',
     *     'parent' => 'portal/AdminBusinessman/directories_add',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '添加展商名录',
     *     'param'  => ''
     * )
     */
    public function directories_add()
    {
        $cate_id = 24;
        if($this->request->isPost()){
            $showModel = new ShowModel();
            $param = $this->request->param();
            $param['cate_id'] = $cate_id;
            if(empty($param['thumb'])){
                $this->error('请上传缩略图');
            }
            $res = $showModel->save($param);
            if($res){
                $this->success('添加成功');
            }
        }else{
            return $this->fetch();
        }
    }

    /**
     * 编辑展商名录
     * @adminMenu(
     *     'name'   => '编辑展商名录',
     *     'parent' => 'portal/AdminBusinessman/directories_detail',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑展商名录',
     *     'param'  => ''
     * )
     */
    public function directories_detail()
    {
        $showModel = new ShowModel();
        $id = $this->request->param('id','','intval');
        if($this->request->isPost()){
            $param = $this->request->param();
            if(empty($param['thumb'])){
                $this->error('请上传缩略图');
            }
            $res = $showModel->isUpdate(true)->save($param);
            if($res){
                $this->success('更新成功');
            }
        }else{
            $info = $showModel->where('id',$id)->find();

            $this->assign('info',$info);
            return $this->fetch();
        }
    }

    /**
     * show表通用删除
     * @adminMenu(
     *     'name'   => '通用删除',
     *     'parent' => 'portal/AdminBusinessman/delete',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '通用删除',
     *     'param'  => ''
     * )
     */
    public function delete()
    {
        $showModel = new ShowModel();
        $id = $this->request->param('id','','intval');
        $res = $showModel->where('id',$id)->delete();
        if($res){
            $this->success('删除成功');
        }
    }

    /**
     * 参展手册(参展流程)
     * @adminMenu(
     *     'name'   => '参展手册',
     *     'parent' => 'portal/AdminBusinessman/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '参展手册',
     *     'param'  => ''
     * )
     */
    public function manual()
    {
        $cate_id = 25;
        $pageModel = new PageModel();
        if($this->request->isPost()){
            $param = $this->request->param();
            $res = $pageModel->isUpdate(true)->save($param);
            if($res){
                $this->success('更新成功');
            }
            $this->error('请稍后重试');
        }else{
            $info = $pageModel->where('cate_id',$cate_id)->find();

            $this->assign('info',$info);
            return $this->fetch();
        }
    }

    /**
     * 特装搭建
     * @adminMenu(
     *     'name'   => '特装搭建',
     *     'parent' => 'portal/AdminBusinessman/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '特装搭建',
     *     'param'  => ''
     * )
     */
    public function build()
    {
        $cate_id = 26;
        $pageModel = new PageModel();
        if($this->request->isPost()){
            $param = $this->request->param();
            $res = $pageModel->isUpdate(true)->save($param);
            if($res){
                $this->success('更新成功');
            }
            $this->error('请稍后重试');
        }else{
            $info = $pageModel->where('cate_id',$cate_id)->find();

            $this->assign('info',$info);
            return $this->fetch();
        }
    }

    /**
     * 展商心声
     * @adminMenu(
     *     'name'   => '展商心声',
     *     'parent' => 'portal/AdminBusinessman/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '展商心声',
     *     'param'  => ''
     * )
     */
    public function aspirations()
    {
        $cate_id = 27;
        $param = $this->request->param();
        $map = $this->search($param,'create_time','title');
        $map['cate_id'] = $cate_id;
        $showModel = new ShowModel();
        $list = $showModel
            ->where($map)
            ->order('sort desc')
            ->paginate(30);

        $this->assign('list',$list);
        $this->assign('page',$list->render());
        return $this->fetch();
    }

    /**
     * 添加展商心声
     * @adminMenu(
     *     'name'   => '添加展商心声',
     *     'parent' => 'portal/AdminBusinessman/aspirations_add',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '添加展商心声',
     *     'param'  => ''
     * )
     */
    public function aspirations_add()
    {
        $cate_id = 27;
        if($this->request->isPost()){
            $showModel = new ShowModel();
            $param = $this->request->param();
            $param['cate_id'] = $cate_id;
            if(empty($param['thumb'])){
                $this->error('请上传缩略图');
            }
            $res = $showModel->save($param);
            if($res){
                $this->success('添加成功','AdminBusinessman/aspirations');
            }
        }else{
            return $this->fetch();
        }
    }

    /**
     * 编辑展商心声
     * @adminMenu(
     *     'name'   => '编辑展商心声',
     *     'parent' => 'portal/AdminBusinessman/aspirations_detail',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑展商心声',
     *     'param'  => ''
     * )
     */
    public function aspirations_detail()
    {
        $showModel = new ShowModel();
        $id = $this->request->param('id','','intval');
        if($this->request->isPost()){
            $param = $this->request->param();
            if(empty($param['thumb'])){
                $this->error('请上传缩略图');
            }
            $res = $showModel->isUpdate(true)->save($param);
            if($res){
                $this->success('更新成功','AdminBusinessman/aspirations');
            }
        }else{
            $info = $showModel->where('id',$id)->find();

            $this->assign('info',$info);
            return $this->fetch();
        }
    }

}