Commit 8688737a authored by 侯贺政's avatar 侯贺政

权限节点详情,更新权限节点

Signed-off-by: 侯贺政's avatarhouhezheng <houhezheng@romens.cn>
parent 19bdda2e
...@@ -301,7 +301,7 @@ return [ ...@@ -301,7 +301,7 @@ return [
'extraPatterns' => [ 'extraPatterns' => [
'GET,OPTIONS node-list' => 'node-list', 'GET,OPTIONS node-list' => 'node-list',
'GET,OPTIONS node-details' => 'node-details', 'GET,OPTIONS node-details' => 'node-details',
'put,OPTIONS node-update' => 'node-update', 'PUT,OPTIONS node-update' => 'node-update',
'POST,OPTIONS node-add' => 'node-add', 'POST,OPTIONS node-add' => 'node-add',
'DELETE,OPTIONS node-del' => 'node-del', 'DELETE,OPTIONS node-del' => 'node-del',
] ]
......
...@@ -142,14 +142,14 @@ class AuthorityNodeController extends BaseController ...@@ -142,14 +142,14 @@ class AuthorityNodeController extends BaseController
* @OA\Property(property="NAME" ,type="string", description="菜单地址"), * @OA\Property(property="NAME" ,type="string", description="菜单地址"),
* @OA\Property(property="TITLE" ,type="string", description="菜单名称"), * @OA\Property(property="TITLE" ,type="string", description="菜单名称"),
* @OA\Property(property="LOGO" ,type="string",description="菜单前面的图标url"), * @OA\Property(property="LOGO" ,type="string",description="菜单前面的图标url"),
* @OA\Property(property="STATUS", type="int",description="菜单状态(默认1启用,0禁用)"), * @OA\Property(property="STATUS", type="int",description="菜单状态(默认1启用,0禁用)",example="1"),
* @OA\Property(property="IS_MENU", type="int",description="是否菜单(默认0否,1是)"), * @OA\Property(property="IS_MENU", type="int",description="是否菜单(默认0否,1是)",example="0"),
* @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(默认0否,1是)"), * @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(默认0否,1是)",example="0"),
* @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(默认0否,1是)"), * @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(默认0否,1是)",example="0"),
* @OA\Property(property="REMARK", type="string",description="描述"), * @OA\Property(property="REMARK", type="string",description="描述"),
* @OA\Property(property="SORT", type="int",description="菜单排序序号"), * @OA\Property(property="SORT", type="int",description="菜单排序序号"),
* @OA\Property(property="PID", type="string",description="父级菜单ID(默认无:0)"), * @OA\Property(property="PID", type="string",description="父级菜单ID(默认无:0)",example="0"),
* @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)") * @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)",example="0")
* ) * )
* ) * )
* ), * ),
...@@ -192,9 +192,9 @@ class AuthorityNodeController extends BaseController ...@@ -192,9 +192,9 @@ class AuthorityNodeController extends BaseController
* summary="删除权限节点(侯贺政)", * summary="删除权限节点(侯贺政)",
* description="删除权限节点", * description="删除权限节点",
* @OA\Parameter( * @OA\Parameter(
* description="要删除的节点GUID", * description="要删除的节点ID",
* in="query", * in="query",
* name="GUID", * name="ID",
* required=true, * required=true,
* @OA\Schema( * @OA\Schema(
* type="string", * type="string",
...@@ -209,9 +209,9 @@ class AuthorityNodeController extends BaseController ...@@ -209,9 +209,9 @@ class AuthorityNodeController extends BaseController
*/ */
public function actionNodeDel() public function actionNodeDel()
{ {
$guid = Yii::$app->request->get('GUID'); $id = Yii::$app->request->get('ID');
$model = new $this->modelClass(); $model = new $this->modelClass();
$_model = $model::findOne($guid); $_model = $model::findOne($id);
if (!$_model) { if (!$_model) {
throw new BadRequestHttpException('Requested resource does not exist !'); throw new BadRequestHttpException('Requested resource does not exist !');
} }
...@@ -221,4 +221,105 @@ class AuthorityNodeController extends BaseController ...@@ -221,4 +221,105 @@ class AuthorityNodeController extends BaseController
throw new HttpException(200, "删除成功!"); throw new HttpException(200, "删除成功!");
} }
/**
* @OA\GET(
* path="/backend/web/v1/authority/authority-nodes/node-details",
* tags={"权限管理"},
* summary="权限节点详情(侯贺政)",
* description="权限节点详情",
* @OA\Parameter(
* description="节点ID",
* name="ID",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="
* ID:节点id,
* NAME:菜单地址,
* TITLE:菜单名称,
* LOGO:logo地址,
* STATUS:菜单状态 0禁用 1启用,
* IS_MENU:是否为菜单(1:是,0:不是),
* IS_TOP_MENU:是否顶部菜单 1是 0否,
* IS_DEFAULT_SHOW:是否进入默认显示页面 1是0否,
* REMARK:描述,
* SORT:菜单排序序号,
* PID:父级菜单ID,
* LEVEL:菜单层级等级(类型-0:项目,1:模块,2:操作)")
* ),
* security={{"Authorization":{}}}
* )
*/
public function actionNodeDetails()
{
$id = Yii::$app->request->get('ID');
$model = new $this->modelClass();
$info = $model->findOne($id);
if (!$info) {
throw new BadRequestHttpException('Requested resource does not exist !');
}
return $info;
}
/**
* @OA\PUT(
* path="/backend/web/v1/authority/authority-nodes/node-update",
* tags={"权限管理"},
* summary="更新权限节点(侯贺政)",
* description="更新权限节点",
* @OA\RequestBody(
* required=true,
* description="权限节点更新",
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* required={"ID"},
* @OA\Property(property="ID",type="int",description="节点ID"),
* @OA\Property(property="NAME" ,type="string", description="菜单地址"),
* @OA\Property(property="TITLE" ,type="string", description="菜单名称"),
* @OA\Property(property="LOGO" ,type="string",description="菜单前面的图标url"),
* @OA\Property(property="STATUS", type="int",description="菜单状态(1启用,0禁用)"),
* @OA\Property(property="IS_MENU", type="int",description="是否菜单(0否,1是)"),
* @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(0否,1是)"),
* @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(0否,1是)"),
* @OA\Property(property="REMARK", type="string",description="描述"),
* @OA\Property(property="SORT", type="int",description="菜单排序序号"),
* @OA\Property(property="PID", type="string",description="父级菜单ID(无:0)"),
* @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)")
* )
* )
* ),
* @OA\Response(response=200,description="更新成功!"),
* security={{"Authorization":{}}}
* )
*/
public function actionNodeUpdate()
{
$params = Yii::$app->request->bodyParams;
$model = new $this->modelClass();
$_model = $model::findOne($params['ID']);
if (!$_model) {
throw new BadRequestHttpException("不存在此节点!");
}
//过滤掉部分为空的参数
foreach ($params as $key => $value) {
if (in_array($key, ['TITLE', 'STATUS', 'IS_MENU', 'IS_TOP_MENU', 'IS_DEFAULT_SHOW', 'SORT', 'PID', 'LEVEL']) && empty(trim($value))) {
unset($params[$key]);
}
}
$_model->attributes = $params;
if (!$_model->save()) {
Yii::$app->response->statusCode = 422;
return $_model->errors;
}
throw new HttpException(200, '更新成功!');
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment