更新
This commit is contained in:
@@ -7,11 +7,15 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Category as CategoryM;
|
||||
use app\model\Attribute;
|
||||
use app\model\Module;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 分类管理
|
||||
* @title 栏目管理
|
||||
* @description 分类管理
|
||||
*/
|
||||
class Category extends Admin {
|
||||
@@ -22,26 +26,34 @@ class Category extends Admin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 分类列表
|
||||
* @title 栏目列表
|
||||
*/
|
||||
public function index($model_id = '') {
|
||||
$map = array('status' => array('gt', -1));
|
||||
if ($model_id) {
|
||||
$map['model_id'] = $model_id;
|
||||
public function index(CategoryM $category, Attribute $attr, Module $medule) {
|
||||
$param = $this->request->param();
|
||||
$map = [];
|
||||
|
||||
$map[] = ['status', '>', -1];
|
||||
if (isset($param['model_id']) && $param['model_id']) {
|
||||
$map[] = ['model_id', '=', $model_id];
|
||||
}
|
||||
$list = db('Category')->where($map)->order('sort asc,id asc')->column('*', 'id');
|
||||
$list = $category->where($map)->order('sort asc,id asc')->select();
|
||||
|
||||
if (!empty($list)) {
|
||||
$tree = new \com\Tree();
|
||||
$list = $tree->toFormatTree($list);
|
||||
$tree = new \sent\tree\Tree();
|
||||
$list = $tree->toFormatTree($list->toArray());
|
||||
}
|
||||
$subsql = db('Attribute')->where('name', 'category_id')->fetchSql(true)->column('model_id');
|
||||
$model_list = model('Model')->where('id IN ('. $subsql.')')->select();
|
||||
// $subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id');
|
||||
// $model_list = $medule->where('id IN ('. $subsql.')')->select();
|
||||
|
||||
$this->assign('tree', $list);
|
||||
$this->assign('model_list', $model_list);
|
||||
$this->assign('model_id', $model_id);
|
||||
$this->setMeta('栏目列表');
|
||||
$this->data = [
|
||||
'tree' => $list,
|
||||
'module_id' => isset($param['module_id']) ? $param['module_id'] : 0,
|
||||
'model_list' => []
|
||||
];
|
||||
// $this->assign('tree', $list);
|
||||
// $this->assign('model_list', $model_list);
|
||||
// $this->assign('model_id', $model_id);
|
||||
// $this->setMeta('栏目列表');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,10 @@ class Config extends Admin {
|
||||
* @title 配置管理
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index() {
|
||||
public function index(ConfigM $config) {
|
||||
$param = $this->request->param();
|
||||
|
||||
|
||||
$group = input('group', 0, 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
/* 查询条件初始化 */
|
||||
@@ -38,13 +41,13 @@ class Config extends Admin {
|
||||
$map['name'] = array('like', '%' . $name . '%');
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order('id desc')->paginate(25, false, array(
|
||||
$list = $config->where($map)->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$data = array(
|
||||
$this->data = array(
|
||||
'group' => config('config_group_list'),
|
||||
'config_type' => config('config_config_list'),
|
||||
'page' => $list->render(),
|
||||
@@ -52,32 +55,28 @@ class Config extends Admin {
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
$this->setMeta('配置管理');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 信息配置
|
||||
*/
|
||||
public function group($id = 1) {
|
||||
public function group(ConfigM $config, $id = 1) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
$model = model('Config');
|
||||
foreach ($config as $key => $value) {
|
||||
$model->where(array('name' => $key))->setField('value', $value);
|
||||
$data = $this->request->post();
|
||||
|
||||
foreach ($data['config'] as $key => $value) {
|
||||
ConfigM::update(['value' => $value], ['name' => $key]);
|
||||
}
|
||||
//清除db_config_data缓存
|
||||
cache('db_config_data', null);
|
||||
cache('system_config_data', null);
|
||||
return $this->success("更新成功!");
|
||||
} else {
|
||||
$type = config('config_group_list');
|
||||
$list = (new ConfigM())->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
$list = $config->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
if ($list) {
|
||||
$this->data['list'] = $list;
|
||||
}
|
||||
// $this->assign('id', $id);
|
||||
// $this->setMeta($type[$id] . '设置');
|
||||
$this->data['id'] = $id;
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -86,17 +85,14 @@ class Config extends Admin {
|
||||
* @title 新增配置
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
public function add(ConfigM $config) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $config->validate(true)->save($data);
|
||||
$id = $config->save($data);
|
||||
if ($id) {
|
||||
cache('db_config_data', null);
|
||||
//记录行为
|
||||
action_log('update_config', 'config', $id, session('user_auth.uid'));
|
||||
return $this->success('新增成功', url('index'));
|
||||
cache('system_config_data', null);
|
||||
return $this->success('新增成功', url('/admin/config/index'));
|
||||
} else {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
@@ -104,8 +100,7 @@ class Config extends Admin {
|
||||
return $this->error($config->getError());
|
||||
}
|
||||
} else {
|
||||
$this->setMeta('新增配置');
|
||||
$this->assign('info', null);
|
||||
$this->data['info'] = [];
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use sent\tree\Tree;
|
||||
use app\controller\Admin;
|
||||
use app\model\Menu as MenuM;
|
||||
|
||||
/**
|
||||
* @title 菜单管理
|
||||
@@ -22,21 +24,19 @@ class Menu extends Admin {
|
||||
/**
|
||||
* @title 菜单列表
|
||||
*/
|
||||
public function index() {
|
||||
public function index(MenuM $menu) {
|
||||
$map = array();
|
||||
$title = trim(input('get.title'));
|
||||
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
|
||||
int_to_string($list, array('hide' => array(1 => '是', 0 => '否'), 'is_dev' => array(1 => '是', 0 => '否')));
|
||||
$list = $menu->where($map)->field(true)->order('sort asc,id asc')->select();
|
||||
// int_to_string($list, array('hide' => array(1 => '是', 0 => '否'), 'is_dev' => array(1 => '是', 0 => '否')));
|
||||
|
||||
if (!empty($list)) {
|
||||
$tree = new \com\Tree();
|
||||
$list = $tree->toFormatTree($list);
|
||||
$list = (new Tree())->toFormatTree($list->append(['is_dev_text', 'hide_text'])->toArray());
|
||||
}
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
// Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$this->setMeta('菜单列表');
|
||||
$this->assign('list', $list);
|
||||
$this->data['list'] = $list;
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,20 +21,7 @@ class User extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index(Member $member) {
|
||||
$param = $this->request->param();
|
||||
$map[] = ['status', '>=', 0];
|
||||
if (isset($param['nickname']) && $param['nickname']) {
|
||||
$map['nickname'] = array('like', '%' . $param['nickname'] . '%');
|
||||
}
|
||||
if (isset($param['username']) && $param['username']) {
|
||||
$map['username'] = array('like', '%' . (string) $param['nickname'] . '%');
|
||||
}
|
||||
|
||||
$order = "uid desc";
|
||||
$list = $member->where($map)->order($order)
|
||||
->paginate(15, false, array(
|
||||
'param' => $param,
|
||||
));
|
||||
$list = $member->getUserList($this->request);
|
||||
|
||||
$this->data['list'] = $list;
|
||||
$this->data['page'] = $list->render();
|
||||
@@ -46,24 +33,18 @@ class User extends Admin {
|
||||
* @title 添加用户
|
||||
* @author colin <molong@tensent.cn>
|
||||
*/
|
||||
public function add() {
|
||||
$model = \think\Loader::model('Member');
|
||||
public function add(Member $member) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->param();
|
||||
//创建注册用户
|
||||
$result = $model->register($data['username'], $data['password'], $data['repassword'], $data['email'], false);
|
||||
$result = $member->register($data['username'], $data['password'], $data['repassword'], $data['email'], false);
|
||||
if ($result) {
|
||||
return $this->success('用户添加成功!', url('admin/user/index'));
|
||||
} else {
|
||||
return $this->error($model->getError());
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $model->addfield,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加用户");
|
||||
return $this->fetch('public/edit');
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user