feat : basic
This commit is contained in:
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Admin\User;
|
||||
|
||||
use App\Constants\Admin\UserCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\StringUtil;
|
||||
use App\Lib\Crypto\CryptoFactory;
|
||||
use App\Model\AdminRole;
|
||||
@@ -81,7 +81,7 @@ class EmployeeService extends BaseService
|
||||
$oldAccount = $this->adminUserModel->getAdminInfoByAccount($account);
|
||||
$oldName = $this->adminUserModel->getAdminInfoByName($name);
|
||||
|
||||
if (!empty($oldName) && !empty($oldAccount)) throw new AdminException('账号或者员工已存在');
|
||||
if (!empty($oldName) && !empty($oldAccount)) throw new ErrException('账号或者员工已存在');
|
||||
|
||||
$salt = StringUtil::randStr(6);
|
||||
$defaultPassword = config('system.admin_default_password');
|
||||
@@ -98,7 +98,7 @@ class EmployeeService extends BaseService
|
||||
$model->role_id = $this->request->input('role_id', 0);
|
||||
$model->section_id = $this->request->input('section_id', 0);
|
||||
|
||||
if (!$model->save()) throw new AdminException('账号添加失败');
|
||||
if (!$model->save()) throw new ErrException('账号添加失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -114,13 +114,13 @@ class EmployeeService extends BaseService
|
||||
$account = $this->request->input('account');
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$oldAccount = $this->adminUserModel->getAdminInfoByAccount($account);
|
||||
$oldName = $this->adminUserModel->getAdminInfoByName($name);
|
||||
|
||||
if (!empty($oldName) && $oldName->id != $info->id) throw new AdminException('员工已存在');
|
||||
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new AdminException('账号已存在');
|
||||
if (!empty($oldName) && $oldName->id != $info->id) throw new ErrException('员工已存在');
|
||||
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new ErrException('账号已存在');
|
||||
|
||||
$info->username = $account;
|
||||
$info->mobile = $account;
|
||||
@@ -130,7 +130,7 @@ class EmployeeService extends BaseService
|
||||
$info->role_id = $this->request->input('role_id', 0);
|
||||
$info->section_id = $this->request->input('section_id', 0);
|
||||
|
||||
if (!$info->save()) throw new AdminException('账号修改失败');
|
||||
if (!$info->save()) throw new ErrException('账号修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -143,15 +143,15 @@ class EmployeeService extends BaseService
|
||||
{
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
if ($this->adminId == $id) throw new AdminException('不可删除自己');
|
||||
if ($this->adminId == $id) throw new ErrException('不可删除自己');
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$info->is_del = UserCode::IS_DEL;
|
||||
|
||||
if (!$info->save()) throw new AdminException('账号删除失败');
|
||||
if (!$info->save()) throw new ErrException('账号删除失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class EmployeeService extends BaseService
|
||||
|
||||
$info = $this->adminUserModel->where('id', $id)->where('is_del',UserCode::ENABLE)->first($this->filed);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$roleName = $this->adminRoleModel->where('id', $info->role_id)->value('name');
|
||||
|
||||
@@ -187,7 +187,7 @@ class EmployeeService extends BaseService
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$salt = StringUtil::randStr(6);
|
||||
$defaultPassword = config('system.admin_default_password');
|
||||
@@ -195,7 +195,7 @@ class EmployeeService extends BaseService
|
||||
$info->salt = $salt;
|
||||
$info->password = $this->cryptoFactory->cryptoClass('admin-password',$defaultPassword,$salt)->encrypt();
|
||||
|
||||
if (!$info->save()) throw new AdminException('密码重置失败');
|
||||
if (!$info->save()) throw new ErrException('密码重置失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user