58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller\user;
|
|
|
|
use app\api\controller\BaseApiController;
|
|
use app\api\logic\UserLogic;
|
|
use app\common\validate\login\PasswordValidate;
|
|
use app\common\validate\user\UserValidate;
|
|
use think\response\Json;
|
|
|
|
class UserController extends BaseApiController
|
|
{
|
|
public array $notNeedLogin = ['resetPassword'];
|
|
|
|
//重置密码
|
|
public function resetPassword(): Json
|
|
{
|
|
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
|
|
$result = UserLogic::resetPassword($params);
|
|
if (true === $result) {
|
|
return $this->success('操作成功');
|
|
}
|
|
return $this->fail(UserLogic::getError());
|
|
}
|
|
|
|
//修改密码
|
|
public function changePassword(): Json
|
|
{
|
|
$params = (new PasswordValidate())->post()->goCheck('changePassword');
|
|
$result = UserLogic::changePassword($params, $this->userId);
|
|
if (true === $result) {
|
|
return $this->success('操作成功');
|
|
}
|
|
return $this->fail(UserLogic::getError());
|
|
}
|
|
|
|
//绑定/变更 手机号
|
|
public function changeMobile(): Json
|
|
{
|
|
$params = (new UserValidate())->post()->goCheck('changeMobile');
|
|
$result = UserLogic::changeMobile($params,$this->userId);
|
|
if($result) {
|
|
return $this->success('修改成功');
|
|
}
|
|
return $this->fail(UserLogic::getError());
|
|
}
|
|
|
|
// 更新用户信息
|
|
public function updateUser(): Json
|
|
{
|
|
$params = (new UserValidate())->post()->goCheck('edit');
|
|
$result = UserLogic::updateUser($params,$this->userId);
|
|
if($result) {
|
|
return $this->success('更新成功');
|
|
}
|
|
return $this->fail(UserLogic::getError());
|
|
}
|
|
} |