修改密码
This commit is contained in:
@@ -56,4 +56,23 @@ class UserController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
* @throws \Random\RandomException
|
||||||
|
*/
|
||||||
|
public function savePassword(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$uid = $request->user->uid;
|
||||||
|
$data = $request->all();
|
||||||
|
$result = (new UserService())->savePassword($uid,$data);;
|
||||||
|
return $this->success($result, '编辑成功');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,4 +42,15 @@ class UserLogic
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
*/
|
||||||
|
public function savePassword(int $uid, array $data)
|
||||||
|
{
|
||||||
|
$password = password_hash($data['password_new'], PASSWORD_DEFAULT);
|
||||||
|
$res = User::where('id',$uid)->update(['password' => $password]);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,9 @@ namespace app\common\service;
|
|||||||
|
|
||||||
use app\common\logic\UserLogic;
|
use app\common\logic\UserLogic;
|
||||||
use app\common\model\Corp;
|
use app\common\model\Corp;
|
||||||
|
use app\common\model\User;
|
||||||
use app\crm\model\Country;
|
use app\crm\model\Country;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
class UserService
|
class UserService
|
||||||
{
|
{
|
||||||
@@ -69,7 +71,7 @@ class UserService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息(包括菜单和权限)
|
* 编辑用户信息
|
||||||
*/
|
*/
|
||||||
public function edit(int $uid, array $data)
|
public function edit(int $uid, array $data)
|
||||||
{
|
{
|
||||||
@@ -81,4 +83,20 @@ class UserService
|
|||||||
$user = $this->logic->edit($uid,$data);
|
$user = $this->logic->edit($uid,$data);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
*/
|
||||||
|
public function savePassword(int $uid, array $data)
|
||||||
|
{
|
||||||
|
// 对密码进行哈希处理
|
||||||
|
$password = $data['password'];
|
||||||
|
$user = User::find($uid);
|
||||||
|
if (!password_verify($password, $user->password)) {
|
||||||
|
throw new BusinessException('密码错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->logic->savePassword($uid,$data);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,8 @@ class CustomerService
|
|||||||
$page = $params['current'] ?? 1;
|
$page = $params['current'] ?? 1;
|
||||||
$keyword = $params['keyword'] ?? '';
|
$keyword = $params['keyword'] ?? '';
|
||||||
$recycle = $params['recycle'] ?? '';
|
$recycle = $params['recycle'] ?? '';
|
||||||
$grade = $params['grade'] ?? '';
|
$follow = $params['follow'] ?? '';
|
||||||
|
$follow_last = $params['follow_last'] ?? '';
|
||||||
$where = [];
|
$where = [];
|
||||||
$user_id =$params['user_id'];
|
$user_id =$params['user_id'];
|
||||||
if(empty($user_id) || $user_id == 0){
|
if(empty($user_id) || $user_id == 0){
|
||||||
@@ -36,6 +37,24 @@ class CustomerService
|
|||||||
$where[] = ['user_id', $user_id];
|
$where[] = ['user_id', $user_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$grade = [];
|
||||||
|
if (!Util::isEmpty($follow) && $follow == 0) {
|
||||||
|
$where[] = ['grade', '<=', 2];
|
||||||
|
} elseif (!Util::isEmpty($follow) && $follow == 1) {
|
||||||
|
$grade = [3, 4];
|
||||||
|
} elseif (!Util::isEmpty($follow) && $follow == 2) {
|
||||||
|
$where[] = ['grade', '=', 5];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Util::isEmpty($follow_last) && $follow_last == 0) {
|
||||||
|
$where[] = ['follow_last', '>', strtotime('-1 day')];
|
||||||
|
} elseif (!Util::isEmpty($follow_last) && $follow_last == 1) {
|
||||||
|
$where[] = ['follow_last', '>', strtotime('-3 day')];
|
||||||
|
} elseif (!Util::isEmpty($follow_last) && $follow_last == 2) {
|
||||||
|
$where[] = ['follow_last', '>', strtotime('-7 day')];
|
||||||
|
}
|
||||||
|
|
||||||
$query = Customer::where($where);
|
$query = Customer::where($where);
|
||||||
|
|
||||||
if(!empty($tagId)){
|
if(!empty($tagId)){
|
||||||
|
|||||||
@@ -114,5 +114,6 @@ Route::group('/crm', function () {
|
|||||||
|
|
||||||
|
|
||||||
Route::any('/user/edit', [app\common\controller\UserController::class, 'edit']);
|
Route::any('/user/edit', [app\common\controller\UserController::class, 'edit']);
|
||||||
|
Route::any('/user/savePassword', [app\common\controller\UserController::class, 'savePassword']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user