用户相关api、jwt接入
This commit is contained in:
@@ -3,8 +3,54 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\UserService;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
//
|
||||
|
||||
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']),
|
||||
'重置密码成功'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user