修改原有框架中英文映射
This commit is contained in:
@@ -85,7 +85,7 @@ class SystemUserLogic extends BaseLogic
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
@@ -105,11 +105,11 @@ class SystemUserLogic extends BaseLogic
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
$user = SystemUser::create($data);
|
||||
@@ -142,16 +142,16 @@ class SystemUserLogic extends BaseLogic
|
||||
}
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
$result = parent::edit($id, $data);
|
||||
@@ -179,12 +179,12 @@ class SystemUserLogic extends BaseLogic
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
if (count($ids) > 1) {
|
||||
throw new ApiException('禁止批量删除操作');
|
||||
throw new ApiException('Batch delete is not allowed');
|
||||
}
|
||||
$ids = $ids[0];
|
||||
}
|
||||
if ($ids == 1) {
|
||||
throw new ApiException('超级管理员禁止删除');
|
||||
throw new ApiException('Super admin cannot be deleted');
|
||||
}
|
||||
$query = $this->model->where('id', $ids);
|
||||
// 超级管理员可删除任意用户,普通管理员仅可删除当前部门和子部门的用户
|
||||
@@ -193,14 +193,14 @@ class SystemUserLogic extends BaseLogic
|
||||
}
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
$role_ids = $user->roles->toArray() ?: [];
|
||||
if (!empty($role_ids)) {
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], array_column($role_ids, 'id'))) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ class SystemUserLogic extends BaseLogic
|
||||
$model->password = password_hash($newPassword, PASSWORD_DEFAULT);
|
||||
return $model->save();
|
||||
} else {
|
||||
throw new ApiException('原密码错误');
|
||||
throw new ApiException('Old password is incorrect');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ class SystemUserLogic extends BaseLogic
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
}
|
||||
parent::edit($id, $data);
|
||||
|
||||
Reference in New Issue
Block a user