feat : basic
This commit is contained in:
@@ -14,7 +14,7 @@ use App\Cache\Redis\Admin\MenuCache;
|
||||
use App\Cache\Redis\Admin\RoleCache;
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminRole;
|
||||
use App\Model\AdminRoleMenu;
|
||||
use App\Service\Admin\BaseService;
|
||||
@@ -80,7 +80,7 @@ class RoleService extends BaseService
|
||||
{
|
||||
$name = $this->request->input('role_name');
|
||||
|
||||
if ($this->adminRoleModel->getInfoByName($name)) throw new AdminException('角色已存在');
|
||||
if ($this->adminRoleModel->getInfoByName($name)) throw new ErrException('角色已存在');
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -112,7 +112,7 @@ class RoleService extends BaseService
|
||||
$this->roleCache->getRoleCache($model->id);
|
||||
} catch (Exception $e) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($e->getMessage());
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -128,11 +128,11 @@ class RoleService extends BaseService
|
||||
{
|
||||
$id = (int)$this->request->input('role_id');
|
||||
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new AdminException('角色不存在');
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new ErrException('角色不存在');
|
||||
|
||||
$name = $this->request->input('role_name');
|
||||
$oldInfo = $this->adminRoleModel->getInfoByName($name);
|
||||
if ($oldInfo->id != $id) throw new AdminException('角色已存在');
|
||||
if ($oldInfo->id != $id) throw new ErrException('角色已存在');
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -165,7 +165,7 @@ class RoleService extends BaseService
|
||||
$this->roleCache->getRoleCache($info->id);
|
||||
} catch (Exception $e) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($e->getMessage());
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -179,13 +179,13 @@ class RoleService extends BaseService
|
||||
public function changeStatus(): array
|
||||
{
|
||||
$id = (int)$this->request->input('role_id');
|
||||
if ($id == RoleCode::SUPER_ADMIN) throw new AdminException('超级管理员不可关闭');
|
||||
if ($id == RoleCode::SUPER_ADMIN) throw new ErrException('超级管理员不可关闭');
|
||||
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new AdminException('角色不存在');
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new ErrException('角色不存在');
|
||||
|
||||
$info->status = $this->request->input('role_status', 0);
|
||||
|
||||
if (!$info->save()) throw new AdminException('修改失败');
|
||||
if (!$info->save()) throw new ErrException('修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class RoleService extends BaseService
|
||||
{
|
||||
$roleId = $this->request->input('role_id');
|
||||
$res = $this->adminRoleModel->where('id',$roleId)->first($this->field);
|
||||
if (!$res) throw new AdminException('角色不存在');
|
||||
if (!$res) throw new ErrException('角色不存在');
|
||||
|
||||
$data = $this->roleCache->getRoleCache((int)$roleId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user