<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use Think\Config;
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021 http://115cms.com.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 作者@梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class Content extends Common
{

    //内容
    public function index()
    {
        hook('phpadmincontenta');
        //权限
        if (socha(user('tid'), 38) != 1) {
            $this->error('权限不足');
        }
        return md5Qm();
    }
    //添加编辑
    public function add()
    {
        hook('phpadmincontentb');
        //权限
        if (socha(user('tid'), 39) != 1) {
            $this->error('权限不足');
        }
		$c=Db::name('html')->find(get('id',0));
        $this->assign('c',$c);
        if(config_m(muban(),'admin_add')){
            return md5Qm(config_m(muban(),'admin_add'));
        } else {
            return md5Qm();
        }
    }
    //评论管理
    public function comment()
    {
        hook('phpadmincontentc');
        //权限
        if (socha(user('tid'), 40) != 1) {
            $this->error('权限不足');
        }
        return md5Qm();
    }
    //评论查看
    public function comment_add()
    {
        hook('phpadmincontentd');
		$c=Db::name('comment')->find(input('id'));
        $this->assign('c',$c);
        return md5Qm();
    }
    //模型管理
    public function model()
    {
        hook('phpadmincontente');
        return md5Qm();
    }
    // 创建模型
    public function modeladd()
    {
        hook('phpadmincontentf');
        return view();
    }
    //模型内容
    public function model_index()
    {
        hook('phpadmincontenti');
        return md5Qm();
    }
    // 模型分类
    public function cate_m()
    {
        hook('phpadmincontentg');
        return view();
    }
    //分类添加编辑
    public function cate_add()
    {
        hook('phpadmincontenth');
        $c=Db::name('cate_m')->where(array('id' => get('id',0)))->find();
        $this->assign('c',$c);
        return view();
    }
    //模型配置
    public function model_config()
    {
        hook('phpadmincontentj');
        $c=Db::name('model')->where(array('id' => get('id',0)))->find();
        $this->assign('c',$c);
        $sql=sql("select *from information_schema.columns where table_name='my_".$c['name']."' ORDER BY ORDINAL_POSITION");
        $this->assign('sql',$sql);
        return view();
    }
    //模型内容添加编辑
    public function model_index_add()
    {
        hook('phpadmincontenth');
        //权限
		$c=Db::name(get('model'))->find(get('id',0));
        $this->assign('c',$c);
        return md5Qm();
    }
}