修改原有框架中英文映射
This commit is contained in:
@@ -158,7 +158,7 @@ class DatabaseLogic extends BaseLogic
|
||||
$isDeleteTime = true;
|
||||
}
|
||||
if (!$isDeleteTime) {
|
||||
throw new ApiException('当前表不支持回收站功能');
|
||||
throw new ApiException('Current table does not support recycle bin');
|
||||
}
|
||||
// 查询软删除数据
|
||||
$request = request();
|
||||
|
||||
@@ -38,7 +38,7 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
{
|
||||
$category = SystemCategory::where('id', $category_id)->findOrEmpty();
|
||||
if ($category->isEmpty()) {
|
||||
throw new ApiException('目标分类不存在');
|
||||
throw new ApiException('Target category not found');
|
||||
}
|
||||
return $this->model->whereIn('id', $ids)->update(['category_id' => $category_id]);
|
||||
}
|
||||
@@ -54,11 +54,11 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
{
|
||||
$image_data = file_get_contents($url);
|
||||
if ($image_data === false) {
|
||||
throw new ApiException('获取文件资源失败');
|
||||
throw new ApiException('Failed to get file resource');
|
||||
}
|
||||
$image_resource = imagecreatefromstring($image_data);
|
||||
if (!$image_resource) {
|
||||
throw new ApiException('创建图片资源失败');
|
||||
throw new ApiException('Failed to create image resource');
|
||||
}
|
||||
$filename = basename($url);
|
||||
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
@@ -84,11 +84,11 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
break;
|
||||
default:
|
||||
imagedestroy($image_resource);
|
||||
throw new ApiException('文件格式错误');
|
||||
throw new ApiException('Invalid file format');
|
||||
}
|
||||
imagedestroy($image_resource);
|
||||
if (!$result) {
|
||||
throw new ApiException('文件保存失败');
|
||||
throw new ApiException('Failed to save file');
|
||||
}
|
||||
|
||||
$hash = md5_file($save_path);
|
||||
|
||||
@@ -41,14 +41,14 @@ class SystemCategoryLogic extends BaseLogic
|
||||
{
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('上级分类和当前分类不能相同');
|
||||
throw new ApiException('Parent category cannot be the same as current');
|
||||
}
|
||||
if (in_array($id, explode(',', $data['level']))) {
|
||||
throw new ApiException('不能将上级分类设置为当前分类的子分类');
|
||||
throw new ApiException('Cannot set parent category as child of current');
|
||||
}
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model->save($data);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class SystemCategoryLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该部门下存在子分类,请先删除子分类');
|
||||
throw new ApiException('This category has sub-categories, please delete them first');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ class SystemConfigGroupLogic extends BaseLogic
|
||||
$id = $ids[0];
|
||||
$model = $this->model->where('id', $id)->findOrEmpty();
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('配置数据未找到');
|
||||
throw new ApiException('Config data not found');
|
||||
}
|
||||
if (in_array(intval($id), [1, 2, 3])) {
|
||||
throw new ApiException('系统默认分组,无法删除');
|
||||
throw new ApiException('System default group cannot be deleted');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
@@ -51,7 +51,7 @@ class SystemConfigGroupLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('删除数据异常,请检查');
|
||||
throw new ApiException('Delete data error, please check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class SystemConfigLogic extends BaseLogic
|
||||
{
|
||||
$group = SystemConfigGroup::find($group_id);
|
||||
if (!$group) {
|
||||
throw new ApiException('配置组未找到');
|
||||
throw new ApiException('Config group not found');
|
||||
}
|
||||
$saveData = [];
|
||||
foreach ($config as $key => $value) {
|
||||
|
||||
@@ -44,10 +44,10 @@ class SystemDeptLogic extends BaseLogic
|
||||
$oldLevel = $data['level'] . $id . ',';
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('上级部门和当前部门不能相同');
|
||||
throw new ApiException('Parent department cannot be the same as current department');
|
||||
}
|
||||
if (in_array($id, explode(',', $data['level']))) {
|
||||
throw new ApiException('不能将上级部门设置为当前部门的子部门');
|
||||
throw new ApiException('Cannot set parent department to a child of current department');
|
||||
}
|
||||
$newLevel = $data['level'] . $id . ',';
|
||||
$deptIds = $this->model->where('level', 'like', $oldLevel . '%')->column('id');
|
||||
@@ -65,11 +65,11 @@ class SystemDeptLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该部门下存在子部门,请先删除子部门');
|
||||
throw new ApiException('This department has sub-departments, please delete them first');
|
||||
} else {
|
||||
$count = SystemUser::where('dept_id', 'in', $ids)->count();
|
||||
if ($count > 0) {
|
||||
throw new ApiException('该部门下存在用户,请先删除或者转移用户');
|
||||
throw new ApiException('This department has users, please delete or transfer them first');
|
||||
}
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class SystemDictDataLogic extends BaseLogic
|
||||
{
|
||||
$type = SystemDictType::where('id', $data['type_id'])->findOrEmpty();
|
||||
if ($type->isEmpty()) {
|
||||
throw new ApiException('字典类型不存在');
|
||||
throw new ApiException('Dict type not found');
|
||||
}
|
||||
$data['code'] = $type->code;
|
||||
$model = $this->model->create($data);
|
||||
|
||||
@@ -32,7 +32,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->where('code', $data['code'])->findOrEmpty();
|
||||
if (!$model->isEmpty()) {
|
||||
throw new ApiException('该字典标识已存在');
|
||||
throw new ApiException('This dict code already exists');
|
||||
}
|
||||
return $this->model->save($data);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('修改数据异常,请检查');
|
||||
throw new ApiException('Update data error, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('删除数据异常,请检查');
|
||||
throw new ApiException('Delete data error, please check');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SystemMenuLogic extends BaseLogic
|
||||
{
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('不能设置父级为自身');
|
||||
throw new ApiException('Cannot set parent to self');
|
||||
}
|
||||
return $this->model->update($data, ['id' => $id]);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class SystemMenuLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该菜单下存在子菜单,请先删除子菜单');
|
||||
throw new ApiException('This menu has sub-menus, please delete them first');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class SystemPostLogic extends BaseLogic
|
||||
}
|
||||
$this->saveAll($data);
|
||||
} catch (\Exception $e) {
|
||||
throw new ApiException('导入文件错误,请上传正确的文件格式xlsx');
|
||||
throw new ApiException('Import file error, please upload correct xlsx file');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
$data = $this->handleData($data);
|
||||
return $model->save($data);
|
||||
@@ -60,7 +60,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
|
||||
$num = SystemRole::where('level', '>=', $maxLevel)->whereIn('id', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('不能操作比当前账户职级高的角色');
|
||||
throw new ApiException('Cannot operate roles with higher level than current account');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
$levelArr = array_column($this->adminInfo['roleList'], 'level');
|
||||
$maxLevel = max($levelArr);
|
||||
if ($data['level'] >= $maxLevel) {
|
||||
throw new ApiException('不能操作比当前账户职级高的角色');
|
||||
throw new ApiException('Cannot operate roles with higher level than current account');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -50,7 +50,7 @@ class CrontabLogic extends BaseLogic
|
||||
6 => "0 {$minute} {$hour} * * {$week}",
|
||||
7 => "0 {$minute} {$hour} {$day} * *",
|
||||
8 => "0 {$minute} {$hour} {$day} {$month} *",
|
||||
default => throw new ApiException("任务类型异常"),
|
||||
default => throw new ApiException('Invalid task type'),
|
||||
};
|
||||
|
||||
// 定时任务模型新增
|
||||
@@ -95,13 +95,13 @@ class CrontabLogic extends BaseLogic
|
||||
6 => "0 {$minute} {$hour} * * {$week}",
|
||||
7 => "0 {$minute} {$hour} {$day} * *",
|
||||
8 => "0 {$minute} {$hour} {$day} {$month} *",
|
||||
default => throw new ApiException("任务类型异常"),
|
||||
default => throw new ApiException('Invalid task type'),
|
||||
};
|
||||
|
||||
// 查询任务数据
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
|
||||
$result = $model->save([
|
||||
@@ -134,7 +134,7 @@ class CrontabLogic extends BaseLogic
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
if (count($ids) > 1) {
|
||||
throw new ApiException('禁止批量删除操作');
|
||||
throw new ApiException('Batch delete is not allowed');
|
||||
}
|
||||
$ids = $ids[0];
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class CrontabLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
$result = $model->save(['status' => $status]);
|
||||
if ($result) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class GenerateTablesLogic extends BaseLogic
|
||||
$data = config('think-orm.connections');
|
||||
$config = $data[$source];
|
||||
if (!$config) {
|
||||
throw new ApiException('数据库配置读取失败');
|
||||
throw new ApiException('Failed to read database config');
|
||||
}
|
||||
|
||||
$prefix = $config['prefix'] ?? '';
|
||||
@@ -262,10 +262,10 @@ class GenerateTablesLogic extends BaseLogic
|
||||
{
|
||||
$table = $this->model->findOrEmpty($id);
|
||||
if (!in_array($table['template'], ["plugin", "app"])) {
|
||||
throw new ApiException('应用类型必须为plugin或者app');
|
||||
throw new ApiException('App type must be plugin or app');
|
||||
}
|
||||
if (empty($table['namespace'])) {
|
||||
throw new ApiException('请先设置应用名称');
|
||||
throw new ApiException('Please set app name first');
|
||||
}
|
||||
|
||||
$columns = $this->columnLogic->where('table_id', $id)
|
||||
@@ -320,11 +320,11 @@ class GenerateTablesLogic extends BaseLogic
|
||||
{
|
||||
$table = $this->model->where('id', $id)->findOrEmpty();
|
||||
if ($table->isEmpty()) {
|
||||
throw new ApiException('请选择要生成的表');
|
||||
throw new ApiException('Please select tables to generate');
|
||||
}
|
||||
$debug = config('app.debug', true);
|
||||
if (!$debug) {
|
||||
throw new ApiException('非调试模式下,不允许生成文件');
|
||||
throw new ApiException('File generation not allowed in non-debug mode');
|
||||
}
|
||||
$this->updateMenu($table);
|
||||
$this->genModule($id);
|
||||
|
||||
Reference in New Issue
Block a user