feat: 公共表更名 common/member 前缀 + 插件命令自动加载 + 版本 1.1.1
- 18 张公共表更名(addon/attachment/configure/links/spider_log/spider_stat/sms/notice/ad/task/prop/medal/help/card -> common_*,member_wallets->member_wallet,score_rule/score_log -> member_*,addon_config->common_addonconf),模型全部对齐新表名,Db 直引用清零 - Attachment 模型补 表名绑定,修复富文本上传查 wxapp_attachment 1146 隐患 - install.sql + 迁移 SQL:backend_admin/backend_role delete_at 默认 0,修复软删除(NULL != 0)误过滤导致后台菜单为空 - AppService::boot() 支持插件 info.php 声明 commands 自动注册插件命令(psr-4 自动加载,坏类名自动跳过) - 各插件(haonav/mqttbroker/wxchat/articles/blog/forum 等)字段与配置同步调整 - 框架版本 1.1.0 -> 1.1.1
This commit is contained in:
@@ -10,30 +10,41 @@
|
||||
declare (strict_types = 1);
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use ywxapp\controller\ApiController;
|
||||
use ywxapp\controller\ApiBase;
|
||||
use think\facade\Event;
|
||||
use ywxapp\model\MemberUser as UserModel;
|
||||
use ywxapp\library\Result;
|
||||
use ywxapp\library\Email as EmailLib;
|
||||
|
||||
/**
|
||||
* 邮箱验证码接口.
|
||||
* 邮箱验证码接口(公开,无需登录)
|
||||
*
|
||||
* 路由前缀:/api/v1/ems/<action>
|
||||
* 业务事件(event)由调用方约定,如 register / resetpwd / changepwd / changeemail 等。
|
||||
*
|
||||
* @package app\api\controller\v1
|
||||
*/
|
||||
class Ems extends ApiController
|
||||
class Ems extends ApiBase
|
||||
{
|
||||
protected $noNeedLogin = '*';
|
||||
protected $needRight = '*';
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* 免登录(公开)接口白名单。
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $noNeedLogin = ['*'];
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
* 发送邮箱验证码(公开)。
|
||||
*
|
||||
* @param string $email 邮箱
|
||||
* @param string $event 事件名称
|
||||
* 触发 email_send 事件并调用 Email 服务下发验证码;
|
||||
* 按 event 校验账号是否已注册 / 占用 / 未注册。
|
||||
*
|
||||
* @param string $email 邮箱(必填)
|
||||
* @param string $event 事件名称(可选,默认 register)
|
||||
*
|
||||
* @return \think\Response JSON 响应,成功提示
|
||||
*
|
||||
* @route POST /api/v1/ems/send
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
@@ -43,24 +54,31 @@ class Ems extends ApiController
|
||||
Event::trigger('email_send', ['email'=>$email, 'event'=>'register'], true);
|
||||
$userinfo = UserModel::getByEmail($email);
|
||||
if ($event == 'register' && $userinfo)
|
||||
Result::instance()->error(('已被注册'));
|
||||
$this->apiError('已被注册');
|
||||
elseif (in_array($event, ['changeemail']) && $userinfo)
|
||||
Result::instance()->error(('已被占用'));
|
||||
$this->apiError('已被占用');
|
||||
elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo)
|
||||
Result::instance()->error(('未注册'));
|
||||
$this->apiError('未注册');
|
||||
$ret = \ywxapp\library\Email::instance()->sendEmail($email, null, $event);
|
||||
if (!$ret)
|
||||
Result::instance()->error(('发送失败'));
|
||||
$this->apiError('发送失败');
|
||||
|
||||
Result::instance()->success(('发送成功'));
|
||||
$this->apiSuccess([], '发送成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证码
|
||||
* 校验邮箱验证码(公开)。
|
||||
*
|
||||
* @param string $email 邮箱
|
||||
* @param string $event 事件名称
|
||||
* @param string $captcha 验证码
|
||||
* 校验邮箱格式、事件名称与验证码格式,并依 event 校验账号注册状态,
|
||||
* 最后调用 EmailLib::check 比对验证码。
|
||||
*
|
||||
* @param string $email 邮箱(必填)
|
||||
* @param string $event 事件名称(可选,默认 register)
|
||||
* @param string $captcha 验证码(必填)
|
||||
*
|
||||
* @return \think\Response JSON 响应,成功提示
|
||||
*
|
||||
* @route POST /api/v1/ems/check
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
@@ -74,20 +92,20 @@ class Ems extends ApiController
|
||||
'code' => 'Num',
|
||||
]);
|
||||
if (!$validate->check(['email' => $email, 'event' => $event, 'code' => $captcha]))
|
||||
Result::instance()->error($validate->getError());
|
||||
$this->apiError($validate->getError());
|
||||
|
||||
$userinfo = UserModel::where('email', $email)->find();
|
||||
if ($event == 'register' && $userinfo)
|
||||
$this->result->error(('已被注册'));
|
||||
$this->apiError('已被注册');
|
||||
elseif (in_array($event, ['changeemail']) && $userinfo)
|
||||
Result::instance()->error(('已被占用'));
|
||||
$this->apiError('已被占用');
|
||||
elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo)
|
||||
Result::instance()->error(('未注册'));
|
||||
$this->apiError('未注册');
|
||||
|
||||
$ret = EmailLib::instance()->check($email, $captcha, $event);
|
||||
if (!$ret)
|
||||
Result::instance()->error(('验证码不正确'));
|
||||
$this->apiError('验证码不正确');
|
||||
|
||||
Result::instance()->success(data: ('验证码正确'));
|
||||
$this->apiSuccess([], '验证码正确');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user