| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace pt\controllers;
- use bizHd\auth\services\AuthService;
- use common\components\util;
- use Yii;
- class AuthController extends BaseController
- {
-
- //获取权限树 ssh 2019.11.24
- public function actionTree()
- {
- $get = Yii::$app->request->get();
- $endId = isset($get['endId']) ? $get['endId'] : 1;
- $tree = AuthService::getTree($endId);
- util::success($tree);
- }
-
- //添加权限 ssh 2019.11.24
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $endId = isset($post['endId']) ? $post['endId'] : 1;
- $authName = isset($post['authName']) ? $post['authName'] : '';
- $list = AuthService::getNameList($endId);
- if (in_array($authName, $list)) {
- util::fail('名称已经存在');
- }
- AuthService::add($_POST);
- util::complete();
- }
-
- //修改 ssh 2019.11.24
- public function actionUpdate()
- {
- $post = Yii::$app->request->post();
- $id = isset($post['id']) ? $post['id'] : 0;
- $auth = AuthService::getById($id);
- if (empty($auth)) {
- util::fail('没有找到权限');
- }
- $endId = $auth['endId'];
- $nameList = AuthService::getNameList($endId);
- $authName = isset($post['authName']) ? $post['authName'] : '';
- if ($authName != $auth['authName'] && in_array($authName, $nameList)) {
- util::fail('名称已经存在');
- }
- AuthService::updateById($id, $_POST);
- util::complete();
- }
- //删除权限 ssh 2020.1.7
- public function actionDelete()
- {
- $id = Yii::$app->request->get('id');
- util::complete('删除成功');
- }
- }
|