优化后台UI
This commit is contained in:
@@ -33,23 +33,64 @@ class AuthRule extends Model{
|
||||
];
|
||||
|
||||
public static function uprule($type){
|
||||
foreach ($data as $value) {
|
||||
$data = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $value['url'],
|
||||
'title' => $value['title'],
|
||||
'group' => $value['group'],
|
||||
'status' => 1,
|
||||
);
|
||||
// $id = $this->where(array('name' => $data['name']))->value('id');
|
||||
// if ($id) {
|
||||
// $data['id'] = $id;
|
||||
// $this->save($data, array('id' => $id));
|
||||
// } else {
|
||||
// self::create($data);
|
||||
// }
|
||||
$path = app()->getAppPath() . 'controller' . DIRECTORY_SEPARATOR . $type;
|
||||
$list = [];
|
||||
|
||||
$classname = self::scanFile($path);
|
||||
foreach ($classname as $value) {
|
||||
if($value == 'Base'){
|
||||
continue;
|
||||
}
|
||||
$class = "app\\controller\\" . $type . "\\" . $value;
|
||||
if (class_exists($class)) {
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$group_doc = self::Parser($reflection->getDocComment());
|
||||
$method = $reflection->getMethods(\ReflectionMethod::IS_FINAL | \ReflectionMethod::IS_PUBLIC);
|
||||
$group_doc['name'] = $value;
|
||||
foreach ($method as $key => $v) {
|
||||
if (!in_array($v->name, ['__construct'])) {
|
||||
$title_doc = self::Parser($v->getDocComment());
|
||||
if (isset($title_doc['title']) && $title_doc['title']) {
|
||||
$list[] = array(
|
||||
'module' => $type,
|
||||
'type' => 2,
|
||||
'name' => $type . '/' . strtolower($value) . '/' . strtolower($v->name),
|
||||
'title' => trim($title_doc['title']),
|
||||
'group' => $group_doc['title'],
|
||||
'status' => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
foreach ($list as $key => $value) {
|
||||
$id = self::where('name', $value['name'])->value('id');
|
||||
if ($id) {
|
||||
$value['id'] = $id;
|
||||
}
|
||||
$list[$key] = $value;
|
||||
}
|
||||
return (new self())->saveAll($list);
|
||||
}
|
||||
|
||||
protected static function scanFile($path) {
|
||||
$result = array();
|
||||
$files = scandir($path);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir($path . '/' . $file)) {
|
||||
self::scanFile($path . '/' . $file);
|
||||
} else {
|
||||
$result[] = substr(basename($file), 0, -4);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected static function Parser($text) {
|
||||
$doc = new \doc\Doc();
|
||||
return $doc->parse($text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user