Browse Source
- 新增 CustomerResourcesAuth 控制器,实现学生登录、忘记密码、获取配置信息等功能- 更新路由配置,添加学生用户端相关路由 - 修改 CommonService 中的 forgetPassword 方法,支持学生用户重置密码master
3 changed files with 151 additions and 3 deletions
@ -0,0 +1,130 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\dict\member\MemberLoginTypeDict; |
|||
use app\model\member\Member; |
|||
use app\Request; |
|||
use app\service\api\apiService\CommonService; |
|||
use app\service\api\login\LoginService; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 学员登陆控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class customerResourcesAuth extends BaseApiService |
|||
{ |
|||
|
|||
//获取字典 |
|||
public function login(Request $request) |
|||
{ |
|||
$phone = $request->param('phone', ''); //手机号 |
|||
$password = $request->param('password', ''); //密码 |
|||
$openid = $request->param('openid', ''); //微信小程序openid |
|||
|
|||
if (empty($phone)) { |
|||
return fail('请输入手机号'); |
|||
} |
|||
if (empty($password)) { |
|||
return fail('请输入密码'); |
|||
} |
|||
|
|||
$member_info = Member::where('mobile', $phone)->find();//查账户表信息是否存在 |
|||
|
|||
|
|||
if (!$member_info) { |
|||
return fail('账户手机号有误'); |
|||
} |
|||
|
|||
$customerResources = \app\model\customer_resources\CustomerResources::where('member_id', $member_info['member_id'])->find();//查客户资源表信息是否存在 |
|||
if (!$customerResources) { |
|||
return fail('账户信息有误'); |
|||
} |
|||
|
|||
//创建密码 |
|||
//$a = create_password($password); |
|||
//验证密码 |
|||
if (!check_password($password, $member_info->password)) { |
|||
return fail('手机号或密码不正确'); |
|||
} |
|||
|
|||
|
|||
$res = (new LoginService())->login($member_info, MemberLoginTypeDict::MOBILE); |
|||
if (!$res) { |
|||
return fail('账户信息有误'); |
|||
} |
|||
$res['user_type'] = '3';//用户类型|3=学员 |
|||
return success($res); |
|||
} |
|||
|
|||
//忘记密码-通过短信验证码进行密码重置(学生/员工通用) |
|||
public function forgetPassword(Request $request) |
|||
{ |
|||
$phone = $request->param('phone', '');//手机号 |
|||
$code = $request->param('code', '');//短信验证码 |
|||
$code_type = $request->param('code_type', '');//短信验证码类型(发送/验证 短信验证码的类型)|修改密码=editPassword |
|||
$password = $request->param('password', '');//新密码 |
|||
$user_type = $request->param('user_type', '');//用户类型|customer=学生|personnel=员工(销售/教师) |
|||
|
|||
if (empty($phone) || empty($code) || empty($code_type) || empty($password) || empty($user_type)) { |
|||
return fail('缺少必填参数'); |
|||
} |
|||
|
|||
//@todo 验证短信验证码是否正确(等发送短信验证码接入后在写) |
|||
//... |
|||
|
|||
|
|||
//重置密码 |
|||
$res = (new CommonService())->forgetPassword($phone, $password, $user_type); |
|||
if (!$res['code']) { |
|||
return fail($res['msg']); |
|||
} |
|||
return success([]); |
|||
|
|||
} |
|||
|
|||
//获取配置信息 |
|||
public function getConfig(Request $request) |
|||
{ |
|||
$config_key = $request->param('config_key', '');//配置项关键字 |
|||
if (empty($config_key)) { |
|||
return fail('缺少必填参数'); |
|||
} |
|||
$where = [ |
|||
'config_key' => $config_key |
|||
]; |
|||
|
|||
$res = (new CommonService())->getConfig($where); |
|||
if (!$res) { |
|||
return fail('配置信息有误'); |
|||
} |
|||
return success($res); |
|||
} |
|||
|
|||
public function getMiniWxOpenId(Request $request) |
|||
{ |
|||
$code = $request->param('code', '');//微信code |
|||
if (empty($code)) { |
|||
return fail('缺少必填参数'); |
|||
} |
|||
|
|||
$res = (new CommonService())->getMiniWxOpenId($code); |
|||
if (!$res['code']) { |
|||
return fail($res['msg']); |
|||
} |
|||
return success($res['data']); |
|||
} |
|||
|
|||
|
|||
} |
|||
Loading…
Reference in new issue