2025-05-05 09:44:50 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\BaseApp\BaseController;
|
2025-05-05 14:20:17 +08:00
|
|
|
use App\Service\UserService;
|
|
|
|
|
use Exception;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
2025-05-05 09:44:50 +08:00
|
|
|
|
|
|
|
|
class UserController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
//
|
2025-05-05 14:20:17 +08:00
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->service = UserService::getInstance();
|
|
|
|
|
$this->insertField = [ 'account', 'nick_name', 'password', 'role_id' ];
|
|
|
|
|
$this->updateField = [ 'id', 'account', 'nick_name', 'role_id' ];
|
|
|
|
|
$this->notRequest = ['qr_code', 'avatar', 'email', 'status'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改密码
|
|
|
|
|
* @Method POST
|
|
|
|
|
* @return JsonResponse
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function changePassword(): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$this->insertField = ['password', 'new_password'];
|
|
|
|
|
$params = $this->checkRequiredFields(request()->post());
|
|
|
|
|
|
|
|
|
|
return jok(
|
|
|
|
|
$this->service->changePassword($params['password'], $params['new_password']),
|
|
|
|
|
'重置密码成功'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重置密码
|
|
|
|
|
* @Method POST
|
|
|
|
|
* @return JsonResponse
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function resetPassword(): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$this->insertField = ['id', 'password', 'new_password'];
|
|
|
|
|
$params = $this->checkRequiredFields(request()->post());
|
|
|
|
|
|
|
|
|
|
return jok(
|
|
|
|
|
$this->service->resetPassword($params['id'], $params['password'], $params['new_password']),
|
|
|
|
|
'重置密码成功'
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-05-05 09:44:50 +08:00
|
|
|
}
|