Files
anmo/server/app/shopapi/controller/LoginController.php
2025-08-19 14:16:51 +08:00

118 lines
3.5 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\shopapi\controller;
use app\shopapi\validate\{LoginAccountValidate, PasswordValidate, RegisterValidate};
use app\shopapi\logic\LoginLogic;
/**
* 登录注册
* Class LoginController
* @package app\coachapi\controller
*/
class LoginController extends BaseShopController
{
public array $notNeedLogin = ['register', 'account', 'logout','resetPassword'];
/**
* @notes 注册账号
* @return \think\response\Json
* @author 段誉
* @date 2022/9/7 15:38
*/
public function register()
{
$params = (new RegisterValidate())->post()->goCheck('register');
$result = LoginLogic::register($params);
if (true === $result) {
return $this->success('注册成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
/**
* @notes 账号密码/手机号密码/手机号验证码登录
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 10:42
*/
public function account()
{
$params = (new LoginAccountValidate())->post()->goCheck();
$result = LoginLogic::login($params);
if (false === $result) {
return $this->fail(LoginLogic::getError(),[],LoginLogic::getReturnCode());
}
return $this->data($result);
}
/**
* @notes 退出登录
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/16 10:42
*/
public function logout()
{
LoginLogic::logout($this->shopInfo);
return $this->success();
}
/**
* @notes 重置密码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 18:06
*/
public function resetPassword()
{
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
$result = (new LoginLogic())->resetPassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
/**
* @notes 修改密码
* @return \think\response\Json
* @author cjhao
* @date 2024/11/27 09:46
*/
public function changePassword()
{
$params = (new PasswordValidate())->post()->goCheck('changePassword',['shop_info'=>$this->shopInfo]);
$params['shop_info'] = $this->shopInfo;
$result = (new LoginLogic())->changePassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
}