修改密码

This commit is contained in:
2025-07-18 16:45:16 +08:00
parent cc98a78ad6
commit edb8c5e9e2
5 changed files with 70 additions and 2 deletions
+19
View File
@@ -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());
}
}
}
+11
View File
@@ -42,4 +42,15 @@ class UserLogic
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;
}
}
+19 -1
View File
@@ -4,7 +4,9 @@ namespace app\common\service;
use app\common\logic\UserLogic;
use app\common\model\Corp;
use app\common\model\User;
use app\crm\model\Country;
use support\exception\BusinessException;
class UserService
{
@@ -69,7 +71,7 @@ class UserService
}
/**
* 获取用户信息(包括菜单和权限)
* 编辑用户信息
*/
public function edit(int $uid, array $data)
{
@@ -81,4 +83,20 @@ class UserService
$user = $this->logic->edit($uid,$data);
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;
}
}
+20 -1
View File
@@ -21,7 +21,8 @@ class CustomerService
$page = $params['current'] ?? 1;
$keyword = $params['keyword'] ?? '';
$recycle = $params['recycle'] ?? '';
$grade = $params['grade'] ?? '';
$follow = $params['follow'] ?? '';
$follow_last = $params['follow_last'] ?? '';
$where = [];
$user_id =$params['user_id'];
if(empty($user_id) || $user_id == 0){
@@ -36,6 +37,24 @@ class CustomerService
$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);
if(!empty($tagId)){
+1
View File
@@ -114,5 +114,6 @@ Route::group('/crm', function () {
Route::any('/user/edit', [app\common\controller\UserController::class, 'edit']);
Route::any('/user/savePassword', [app\common\controller\UserController::class, 'savePassword']);
});