修改 NodeAnnotation 命名标准
This commit is contained in:
@@ -6,7 +6,7 @@ use app\admin\model\MallCate;
|
||||
use app\admin\traits\Curd;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ use app\admin\model\MallGoods;
|
||||
use app\admin\traits\Curd;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ class Goods extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -59,7 +59,7 @@ class Goods extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="入库")
|
||||
* @NodeAnnotation(title="入库")
|
||||
*/
|
||||
public function stock($id)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ use app\admin\service\TriggerService;
|
||||
use app\common\constants\AdminConstant;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -63,7 +63,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="添加")
|
||||
* @NodeAnnotation(title="添加")
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="编辑")
|
||||
* @NodeAnnotation(title="编辑")
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="编辑")
|
||||
* @NodeAnnotation(title="编辑")
|
||||
*/
|
||||
public function password($id)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="删除")
|
||||
* @NodeAnnotation(title="删除")
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="属性修改")
|
||||
* @NodeAnnotation(title="属性修改")
|
||||
*/
|
||||
public function modify()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ use app\admin\model\SystemAuthNode;
|
||||
use app\admin\service\TriggerService;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ class Auth extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="授权")
|
||||
* @NodeAnnotation(title="授权")
|
||||
*/
|
||||
public function authorize($id)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class Auth extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="授权保存")
|
||||
* @NodeAnnotation(title="授权保存")
|
||||
*/
|
||||
public function saveAuthorize()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use app\admin\model\SystemConfig;
|
||||
use app\admin\service\TriggerService;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
@@ -24,7 +24,7 @@ class Config extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -32,7 +32,7 @@ class Config extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="保存")
|
||||
* @NodeAnnotation(title="保存")
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace app\admin\controller\system;
|
||||
use app\admin\model\SystemLog;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\PDOException;
|
||||
@@ -25,7 +25,7 @@ class Log extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use app\admin\service\TriggerService;
|
||||
use app\admin\traits\Curd;
|
||||
use app\common\constants\MenuConstant;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use app\common\controller\AdminController;
|
||||
use think\App;
|
||||
|
||||
@@ -34,7 +34,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -56,7 +56,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="添加")
|
||||
* @NodeAnnotation(title="添加")
|
||||
*/
|
||||
public function add($id = null)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="编辑")
|
||||
* @NodeAnnotation(title="编辑")
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="删除")
|
||||
* @NodeAnnotation(title="删除")
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="属性修改")
|
||||
* @NodeAnnotation(title="属性修改")
|
||||
*/
|
||||
public function modify()
|
||||
{
|
||||
@@ -188,7 +188,7 @@ class Menu extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="添加菜单提示")
|
||||
* @NodeAnnotation(title="添加菜单提示")
|
||||
*/
|
||||
public function getMenuTips()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use app\admin\model\SystemNode;
|
||||
use app\admin\service\TriggerService;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use app\admin\service\NodeService;
|
||||
use think\App;
|
||||
|
||||
@@ -27,7 +27,7 @@ class Node extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -51,13 +51,13 @@ class Node extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="系统节点更新")
|
||||
* @NodeAnnotation(title="系统节点更新")
|
||||
*/
|
||||
public function refreshNode($force = 0)
|
||||
public function refreshNode($force = 0): void
|
||||
{
|
||||
|
||||
$this->checkPostRequest();
|
||||
$nodeList = (new NodeService())->getNodelist();
|
||||
$nodeList = (new NodeService())->getNodeList();
|
||||
empty($nodeList) && $this->error('暂无需要更新的系统节点');
|
||||
$model = new SystemNode();
|
||||
|
||||
@@ -67,10 +67,12 @@ class Node extends AdminController
|
||||
$formatNodeList = array_format_key($nodeList, 'node');
|
||||
foreach ($updateNodeList as $vo) {
|
||||
isset($formatNodeList[$vo['node']])
|
||||
&& $model->where('id', $vo['id'])->update([
|
||||
'title' => $formatNodeList[$vo['node']]['title'],
|
||||
'is_auth' => $formatNodeList[$vo['node']]['is_auth'],
|
||||
]);
|
||||
&& $model->where('id', $vo['id'])->update(
|
||||
[
|
||||
'title' => $formatNodeList[$vo['node']]['title'],
|
||||
'is_auth' => $formatNodeList[$vo['node']]['is_auth'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
$existNodeList = $model->field('node,title,type,is_auth')->select();
|
||||
@@ -91,12 +93,12 @@ class Node extends AdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="清除失效节点")
|
||||
* @NodeAnnotation(title="清除失效节点")
|
||||
*/
|
||||
public function clearNode()
|
||||
public function clearNode(): void
|
||||
{
|
||||
$this->checkPostRequest();
|
||||
$nodeList = (new NodeService())->getNodelist();
|
||||
$nodeList = (new NodeService())->getNodeList();
|
||||
$model = new SystemNode();
|
||||
try {
|
||||
$existNodeList = $model->field('id,node,title,type,is_auth')->select()->toArray();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace app\admin\controller\system;
|
||||
use app\admin\model\SystemQuick;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace app\admin\controller\system;
|
||||
use app\admin\model\SystemUploadfile;
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,11 +14,11 @@ class NodeService
|
||||
* @throws \Doctrine\Common\Annotations\AnnotationException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getNodelist()
|
||||
public function getNodeList()
|
||||
{
|
||||
$basePath = base_path() . 'admin' . DIRECTORY_SEPARATOR . 'controller';
|
||||
$baseNamespace = "app\admin\controller";
|
||||
$nodeList = (new Node($basePath, $baseNamespace))->getNodelist();
|
||||
$nodeList = (new Node($basePath, $baseNamespace))->getNodeList();
|
||||
return $nodeList;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ use Doctrine\Common\Annotations\Annotation\Attributes;
|
||||
* @Attribute("time", type = "int")
|
||||
* })
|
||||
*/
|
||||
final class NodeAnotation
|
||||
final class NodeAnnotation
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -21,13 +21,13 @@ final class NodeAnotation
|
||||
* @Required()
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
public string $title;
|
||||
|
||||
/**
|
||||
* 是否开启权限控制
|
||||
* @Enum({true,false})
|
||||
* @var bool
|
||||
*/
|
||||
public $auth = true;
|
||||
public bool $auth = true;
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\Annotations\DocParser;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use app\admin\service\tool\CommonTool;
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@ class Node
|
||||
/**
|
||||
* 构造方法
|
||||
* Node constructor.
|
||||
* @param string $basePath 读取的文件夹
|
||||
* @param string $baseNamespace 读取的命名空间前缀
|
||||
* @param string $basePath 读取的文件夹
|
||||
* @param string $baseNamespace 读取的命名空间前缀
|
||||
*/
|
||||
public function __construct($basePath, $baseNamespace)
|
||||
{
|
||||
@@ -46,12 +46,12 @@ class Node
|
||||
* @throws \Doctrine\Common\Annotations\AnnotationException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getNodelist()
|
||||
public function getNodeList(): array
|
||||
{
|
||||
list($nodeList, $controllerList) = [[], $this->getControllerList()];
|
||||
|
||||
if (!empty($controllerList)) {
|
||||
AnnotationRegistry::registerLoader('class_exists');
|
||||
AnnotationRegistry::loadAnnotationClass('class_exists');
|
||||
$parser = new DocParser();
|
||||
$parser->setIgnoreNotImportedAnnotations(true);
|
||||
$reader = new AnnotationReader($parser);
|
||||
@@ -65,8 +65,8 @@ class Node
|
||||
|
||||
// 遍历读取所有方法的注释的参数信息
|
||||
foreach ($methods as $method) {
|
||||
// 读取NodeAnotation的注解
|
||||
$nodeAnnotation = $reader->getMethodAnnotation($method, NodeAnotation::class);
|
||||
// 读取NodeAnnotation的注解
|
||||
$nodeAnnotation = $reader->getMethodAnnotation($method, NodeAnnotation::class);
|
||||
if (!empty($nodeAnnotation) && !empty($nodeAnnotation->title)) {
|
||||
$actionTitle = !empty($nodeAnnotation) && !empty($nodeAnnotation->title) ? $nodeAnnotation->title : null;
|
||||
$actionAuth = !empty($nodeAnnotation) && !empty($nodeAnnotation->auth) ? $nodeAnnotation->auth : false;
|
||||
@@ -78,7 +78,6 @@ class Node
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 方法非空才读取控制器注解
|
||||
if (!empty($actionList)) {
|
||||
// 读取Controller的注解
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace {{controllerNamespace}};
|
||||
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace app\admin\traits;
|
||||
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use app\admin\service\tool\CommonTool;
|
||||
use jianyan\excel\Excel;
|
||||
use think\facade\Db;
|
||||
@@ -17,7 +17,7 @@ trait Curd
|
||||
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
* @NodeAnnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -46,7 +46,7 @@ trait Curd
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="添加")
|
||||
* @NodeAnnotation(title="添加")
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@@ -65,7 +65,7 @@ trait Curd
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="编辑")
|
||||
* @NodeAnnotation(title="编辑")
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ trait Curd
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="删除")
|
||||
* @NodeAnnotation(title="删除")
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ trait Curd
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="导出")
|
||||
* @NodeAnnotation(title="导出")
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
@@ -130,7 +130,7 @@ trait Curd
|
||||
}
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="属性修改")
|
||||
* @NodeAnnotation(title="属性修改")
|
||||
*/
|
||||
public function modify()
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class Node extends Command
|
||||
|
||||
protected function refresh($force)
|
||||
{
|
||||
$nodeList = (new NodeService())->getNodelist();
|
||||
$nodeList = (new NodeService())->getNodeList();
|
||||
if (empty($nodeList)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user