refactor: 去除返回提示信息感叹号
This commit is contained in:
@@ -24,7 +24,7 @@ class Captcha
|
|||||||
Cache::store('redis')->set('captcha:token.' . $token, $hash, Config::get('captcha.expire'));
|
Cache::store('redis')->set('captcha:token.' . $token, $hash, Config::get('captcha.expire'));
|
||||||
|
|
||||||
// 输出验证码
|
// 输出验证码
|
||||||
return success('获取验证码成功!', [
|
return success('获取验证码成功', [
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'captcha' => $captcha["img"],
|
'captcha' => $captcha["img"],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -37,36 +37,36 @@ class Login
|
|||||||
// 校验验证码
|
// 校验验证码
|
||||||
$code = Cache::get('captcha:token.' . $post['token']);
|
$code = Cache::get('captcha:token.' . $post['token']);
|
||||||
if (!$code) {
|
if (!$code) {
|
||||||
throw new InvalidLoginException('验证码不存在或已过期!');
|
throw new InvalidLoginException('验证码不存在或已过期');
|
||||||
}
|
}
|
||||||
Cache::delete('captcha:token.' . $post['token']);
|
Cache::delete('captcha:token.' . $post['token']);
|
||||||
|
|
||||||
// 校验
|
// 校验
|
||||||
if (!password_verify($post['captcha'], $code)) {
|
if (!password_verify($post['captcha'], $code)) {
|
||||||
throw new InvalidLoginException('验证码错误!');
|
throw new InvalidLoginException('验证码错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证用户
|
// 验证用户
|
||||||
$user = UserModel::usernameOrMobile($post['username'])->find();
|
$user = UserModel::usernameOrMobile($post['username'])->find();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new InvalidLoginException('用户不存在!');
|
throw new InvalidLoginException('用户不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证密码
|
// 验证密码
|
||||||
if ($user['password'] != password_with_salt($post['password'], $user['salt'])) {
|
if ($user['password'] != password_with_salt($post['password'], $user['salt'])) {
|
||||||
throw new InvalidLoginException('密码错误!');
|
throw new InvalidLoginException('密码错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证用户状态
|
// 验证用户状态
|
||||||
if ($user['status'] == -1) {
|
if ($user['status'] == -1) {
|
||||||
throw new InvalidLoginException('用户已禁用,请联系管理员!');
|
throw new InvalidLoginException('用户已禁用,请联系管理员');
|
||||||
}
|
}
|
||||||
} catch (InvalidLoginException $e) {
|
} catch (InvalidLoginException $e) {
|
||||||
$msg = $e->getMessage();
|
$msg = $e->getMessage();
|
||||||
return error($msg);
|
return error($msg);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$msg = $th->getMessage();
|
$msg = $th->getMessage();
|
||||||
return error('登录失败!');
|
return error('登录失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录登录日志
|
// 记录登录日志
|
||||||
@@ -79,7 +79,7 @@ class Login
|
|||||||
// 生成 jwt token
|
// 生成 jwt token
|
||||||
$token = JWTAuth::builder(['uid' => $user['id']]);
|
$token = JWTAuth::builder(['uid' => $user['id']]);
|
||||||
|
|
||||||
return success('登录成功!', [
|
return success('登录成功', [
|
||||||
'uid' => $user['id'],
|
'uid' => $user['id'],
|
||||||
'nickname' => $user['nickname'],
|
'nickname' => $user['nickname'],
|
||||||
'avatar' => $user['avatar'],
|
'avatar' => $user['avatar'],
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ class ProductCategory
|
|||||||
])
|
])
|
||||||
->select();
|
->select();
|
||||||
if ($ret->isEmpty()) {
|
if ($ret->isEmpty()) {
|
||||||
return success('获取成功!');
|
return success('获取成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
return success('获取成功!', array_to_tree($ret->toArray(), 0, 'pid', 1));
|
return success('获取成功', array_to_tree($ret->toArray(), 0, 'pid', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,10 +50,10 @@ class ProductCategory
|
|||||||
->bypk(request()->param('id'))
|
->bypk(request()->param('id'))
|
||||||
->find();
|
->find();
|
||||||
if (empty($category)) {
|
if (empty($category)) {
|
||||||
return error('分类不存在!');
|
return error('分类不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
return success('获取成功!', $category);
|
return success('获取成功', $category);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,9 +96,9 @@ class ProductCategory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$category->save($data)) {
|
if (!$category->save($data)) {
|
||||||
return error('操作失败!');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
return success('操作成功!');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,7 +133,7 @@ class ProductCategory
|
|||||||
|
|
||||||
$category = ProductCategoryModel::bypk($id)->find();
|
$category = ProductCategoryModel::bypk($id)->find();
|
||||||
if (empty($category)) {
|
if (empty($category)) {
|
||||||
return error('请确认操作对对象是否存在!');
|
return error('请确认操作对对象是否存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理层级
|
// 处理层级
|
||||||
@@ -147,7 +147,7 @@ class ProductCategory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$category->save($data)) {
|
if (!$category->save($data)) {
|
||||||
return error('操作失败!');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理子分类层级
|
// 处理子分类层级
|
||||||
@@ -155,7 +155,7 @@ class ProductCategory
|
|||||||
$this->handle_children($category->id, $data['level']);
|
$this->handle_children($category->id, $data['level']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success('操作成功!');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
private function handle_children($pid, $level)
|
private function handle_children($pid, $level)
|
||||||
{
|
{
|
||||||
@@ -181,15 +181,15 @@ class ProductCategory
|
|||||||
|
|
||||||
$category = ProductCategoryModel::bypk($id)->find();
|
$category = ProductCategoryModel::bypk($id)->find();
|
||||||
if (empty($category)) {
|
if (empty($category)) {
|
||||||
return error('请确认操作对对象是否存在!');
|
return error('请确认操作对对象是否存在');
|
||||||
}
|
}
|
||||||
if ($sort != $category->sort) {
|
if ($sort != $category->sort) {
|
||||||
$category->sort = $sort;
|
$category->sort = $sort;
|
||||||
if (!$category->save()) {
|
if (!$category->save()) {
|
||||||
return error('操作失败!');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success('操作成功!');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,14 +201,14 @@ class ProductCategory
|
|||||||
|
|
||||||
$category = ProductCategoryModel::bypk($id)->find();
|
$category = ProductCategoryModel::bypk($id)->find();
|
||||||
if (empty($category)) {
|
if (empty($category)) {
|
||||||
return error('请确认操作对对象是否存在!');
|
return error('请确认操作对对象是否存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
$category->is_show = (int)!$category->is_show;
|
$category->is_show = (int)!$category->is_show;
|
||||||
if (!$category->save()) {
|
if (!$category->save()) {
|
||||||
return error('操作失败!');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
return success('操作成功!');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,12 +219,12 @@ class ProductCategory
|
|||||||
$id = request()->param('id');
|
$id = request()->param('id');
|
||||||
$category = ProductCategoryModel::bypk($id)->find();
|
$category = ProductCategoryModel::bypk($id)->find();
|
||||||
if (empty($category)) {
|
if (empty($category)) {
|
||||||
return error('请确认操作对对象是否存在!');
|
return error('请确认操作对对象是否存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$category->delete()) {
|
if (!$category->delete()) {
|
||||||
return error('操作失败!');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
return success('操作成功!');
|
return success('操作成功');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user