更新功能

This commit is contained in:
2020-03-28 20:39:39 +08:00
parent 5ef77bb8f4
commit 4893580b70
9 changed files with 149 additions and 119 deletions

View File

@@ -10,6 +10,7 @@ namespace app\controller\admin;
use app\model\AuthGroup;
use app\model\AuthRule;
use app\model\Model;
/**
* @title 用户组管理
@@ -40,20 +41,20 @@ class Group extends Base {
*/
public function add($type = 'admin') {
if ($this->request->isPost()) {
$result = $this->group->change();
if ($result) {
return $this->success("添加成功!", url('admin/group/index'));
$data = $this->request->param();
$result = AuthGroup::create($data);
if (false !== $result) {
return $this->success("添加成功!", url('/admin/group/index'));
} else {
return $this->error("添加失败!");
}
} else {
$data = array(
'info' => array('module' => $type, 'status' => 1),
'keyList' => $this->group->keyList,
$this->data = array(
'info' => ['module' => $type, 'status' => 1],
'keyList' => (new AuthGroup())->keyList,
);
$this->assign($data);
$this->setMeta('添加用户组');
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -61,25 +62,24 @@ class Group extends Base {
* @title 编辑用户组
*/
public function edit($id) {
if (!$id) {
return $this->error("非法操作!");
}
if ($this->request->isPost()) {
$result = $this->group->change();
if ($result) {
return $this->success("编辑成功!", url('admin/group/index'));
$data = $this->request->param();
$result = AuthGroup::update($data);
if (false !== $result) {
return $this->success("编辑成功!", url('/admin/group/index'));
} else {
return $this->error("编辑失败!");
}
} else {
$info = $this->group->where(array('id' => $id))->find();
$data = array(
if (!$id) {
return $this->error("非法操作!");
}
$info = AuthGroup::find($id);
$this->data = array(
'info' => $info,
'keyList' => $this->group->keyList,
'keyList' => (new AuthGroup())->keyList,
);
$this->assign($data);
$this->setMeta('编辑用户组');
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -87,14 +87,13 @@ class Group extends Base {
* @title 编辑用户组单字段
*/
public function editable() {
$pk = input('pk', '', 'trim,intval');
$name = input('name', '', 'trim');
$value = input('value', '', 'trim');
$result = $this->group->where(array('id' => $pk))->setField($name, $value);
if ($result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
$name = $this->request->param('name', '');
$value = $this->request->param('value', '');
$pk = $this->request->param('pk', '');
if ($name && $value && $pk) {
$save[$name] = $value;
AuthGroup::update($save, ['id' => $pk]);
}
}
@@ -102,12 +101,16 @@ class Group extends Base {
* @title 删除用户组
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
$id = $this->request->param('id', 0);
$map = [];
if (!$id) {
return $this->error("非法操作!");
}
$result = $this->group->where(array('id' => array('IN', $id)))->delete();
if ($result) {
$map[] = is_array($id) ? ['id', 'IN', $id] : ['id', '=', $id];
$result = AuthGroup::where($map)->delete();
if (false !== $result) {
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
@@ -136,9 +139,12 @@ class Group extends Base {
* @title 更新权限
*/
public function upnode($type) {
//$rule = model('Menu')->getAuthNodes($type);
$reuslt = $this->rule->uprule($type);
return $this->success("更新成功!");
$reuslt = AuthRule::uprule($type);
if (false !== $result) {
return $this->success("更新成功!");
}else{
return $this->error("更新失败!");
}
}
/**
@@ -174,31 +180,28 @@ class Group extends Base {
return $this->error("授权失败!");
}
} else {
$group = $this->group->where(array('id' => $id))->find();
$group = AuthGroup::find($id);
$map['module'] = $group['module'];
$row = db('AuthRule')->where($map)->order('id desc')->select();
$map[] = ['module', '=', $group['module']];
$row = AuthRule::where($map)->order('id desc')->select();
$list = array();
foreach ($row as $key => $value) {
foreach ($row as $value) {
$list[$value['group']][] = $value;
}
//模块
$model = db('model')->field('id,title,name')
->where(array('status' => array('gt', 0)))
->select();
$model = Model::where('status', '>', 0)->field('id,title,name')->select();
//扩展权限
$extend_auth = db('AuthExtend')->where(array('group_id' => $id, 'type' => 2))->column('extend_id');
$data = array(
// $extend_auth = db('AuthExtend')->where(array('group_id' => $id, 'type' => 2))->column('extend_id');
$this->data = array(
'list' => $list,
'model' => $model,
'extend_auth' => $extend_auth,
// 'extend_auth' => $extend_auth,
'extend_auth' => [],
'auth_list' => explode(',', $group['rules']),
'id' => $id,
);
$this->assign($data);
$this->setMeta('授权');
return $this->fetch();
}
}
@@ -208,20 +211,19 @@ class Group extends Base {
*/
public function addnode($type = 'admin') {
if ($this->request->isPost()) {
$result = $this->rule->change();
$data = $this->request->post();
$result = AuthRule::create($data);
if ($result) {
return $this->success("创建成功!", url('admin/group/access'));
return $this->success("创建成功!", url('/admin/group/access'));
} else {
return $this->error($this->rule->getError());
return $this->error('添加失败!');
}
} else {
$data = array(
'info' => array('module' => $type, 'status' => 1),
'keyList' => $this->rule->keyList,
);
$this->assign($data);
$this->setMeta('添加节点');
return $this->fetch('public/edit');
$this->data = [
'info' => ['module' => $type, 'status' => 1],
'keyList' => (new AuthRule())->keyList,
];
return $this->fetch('admin/public/edit');
}
}
@@ -230,9 +232,10 @@ class Group extends Base {
*/
public function editnode($id) {
if ($this->request->isPost()) {
$result = $this->rule->change();
$data = $this->request->post();
$result = AuthRule::update($data);
if (false !== $result) {
return $this->success("更新成功!", url('admin/group/access'));
return $this->success("更新成功!", url('/admin/group/access'));
} else {
return $this->error("更新失败!");
}
@@ -240,14 +243,12 @@ class Group extends Base {
if (!$id) {
return $this->error("非法操作!");
}
$info = $this->rule->find($id);
$data = array(
$info = AuthRule::find($id);
$this->data = [
'info' => $info,
'keyList' => $this->rule->keyList,
);
$this->assign($data);
$this->setMeta('编辑节点');
return $this->fetch('public/edit');
'keyList' => (new AuthRule())->keyList,
];
return $this->fetch('admin/public/edit');
}
}

View File

@@ -133,24 +133,10 @@ class Wechat extends Base {
}
/**
* @title 行为日志列表
* @title 小程序列表
* @author huajie <banhuajie@163.com>
*/
public function log() {
//获取列表数据
$map['status'] = array('gt', -1);
$order = "id desc";
//获取列表数据
$list = model('ActionLog')->where($map)->order($order)->paginate(10);
$data = array(
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta('行为日志');
public function miniapp() {
return $this->fetch();
}
/**