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:
@@ -11,7 +11,7 @@ namespace ywxapp\library;
|
||||
|
||||
use think\facade\Event;
|
||||
use ywxapp\library\Result;
|
||||
use ywxapp\model\Email as EmailModel;
|
||||
use ywxapp\model\CommonEmail as EmailModel;
|
||||
use ywxapp\model\MemberUser as UsersModel;
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,13 +134,18 @@ class Result
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回封装后的 API 数据到客户端.
|
||||
* 返回封装后的 API 数据到客户端(已弃用,字段契约与 success/error 不一致).
|
||||
*
|
||||
* 请改用 apiSuccess() / apiError():统一 JSON、统一字段(code/msg/data/timestamp),
|
||||
* 业务 code 与 HTTP 状态码解耦,不再受后台 HTML/401 跳转逻辑影响。
|
||||
*
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param int $code 返回的 code
|
||||
* @param mixed $msg 提示信息
|
||||
* @param string $type 返回数据格式
|
||||
* @param array $header 发送的 Header 信息
|
||||
*
|
||||
* @deprecated 使用 apiSuccess() / apiError() 替代
|
||||
*/
|
||||
protected function result($data, $code = 0, $msg = '', $type = '', array $header = [])
|
||||
{
|
||||
@@ -156,6 +161,82 @@ class Result
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* API 成功响应(强制 JSON,契约稳定).
|
||||
*
|
||||
* 专供 App / 小程序 / 第三方客户端调用,与后台 HTML 响应完全解耦:
|
||||
* - 无论请求是否 ajax,固定返回 JSON;
|
||||
* - 统一字段:code(0) / msg / data / timestamp;
|
||||
* - 若本实例持有 token,自动附加 access_token / refresh_token 等字段;
|
||||
* - 若设置了 count,自动附加 count(分页场景)。
|
||||
*
|
||||
* @param mixed $data 业务数据,可为数组 / 模型 / null
|
||||
* @param string $message 成功提示语
|
||||
* @param int $count 分页总数(可选,>0 时附加 count 字段)
|
||||
*
|
||||
* @return void 通过 Response 直接输出并终止
|
||||
*/
|
||||
public function apiSuccess($data = null, string $message = 'success', int $count = 0): void
|
||||
{
|
||||
$result = ['code' => 0, 'msg' => $message, 'timestamp' => time()];
|
||||
if ($data !== null) {
|
||||
$result['data'] = $data;
|
||||
}
|
||||
if ($count > 0) {
|
||||
$result['count'] = $count;
|
||||
}
|
||||
if ($this->AccessToken !== null) {
|
||||
$result['access_token'] = $this->AccessToken;
|
||||
$result['access_expired'] = $this->AccessExpired;
|
||||
}
|
||||
if ($this->RefreshToken !== null) {
|
||||
$result['refresh_token'] = $this->RefreshToken;
|
||||
$result['refresh_expired'] = $this->RefreshExpired;
|
||||
}
|
||||
$response = Response::create($result, 'json', $this->StatusCode)->header($this->Headers);
|
||||
$this->applyTokenCookies($response);
|
||||
$response->send();
|
||||
app()->http->end($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* API 失败响应(强制 JSON,业务 code 与 HTTP 状态解耦).
|
||||
*
|
||||
* 与 apiSuccess 配套,专供客户端调用:
|
||||
* - 固定返回 JSON;
|
||||
* - 统一字段:code / msg / data(可选) / timestamp;
|
||||
* - 业务 code 原样透传(如 401 失败返回 code=401,而非被覆盖);
|
||||
* - HTTP 状态码由 $httpStatus 控制(默认 200,鉴权失败传 401)。
|
||||
*
|
||||
* @param string $message 失败提示语
|
||||
* @param int $code 业务状态码(默认 1,鉴权失败建议 401)
|
||||
* @param mixed $data 附加数据(可选)
|
||||
* @param int $httpStatus HTTP 状态码(默认 200)
|
||||
*
|
||||
* @return void 通过 Response 直接输出并终止
|
||||
*/
|
||||
public function apiError(string $message = 'Error', int $code = 1, $data = null, int $httpStatus = 200): void
|
||||
{
|
||||
$result = ['code' => $code, 'msg' => $message, 'timestamp' => time()];
|
||||
if ($data !== null) {
|
||||
$result['data'] = $data;
|
||||
}
|
||||
if ($this->AccessToken !== null) {
|
||||
$result['access_token'] = $this->AccessToken;
|
||||
$result['access_expired'] = $this->AccessExpired;
|
||||
}
|
||||
if ($this->RefreshToken !== null) {
|
||||
$result['refresh_token'] = $this->RefreshToken;
|
||||
$result['refresh_expired'] = $this->RefreshExpired;
|
||||
}
|
||||
$response = Response::create($result, 'json', $httpStatus)->header($this->Headers);
|
||||
$this->applyTokenCookies($response);
|
||||
$response->send();
|
||||
app()->http->end($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 重定向.
|
||||
*
|
||||
|
||||
+14
-4
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-06 22:05:48
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-19 22:12:47
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\ywxapp\library\Sms.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
@@ -9,13 +18,13 @@
|
||||
namespace ywxapp\library;
|
||||
|
||||
use ywxapp\utils\Random;
|
||||
use think\facade\Event;
|
||||
use ywxapp\model\Sms as SmsModel;
|
||||
use think\facade\Event;
|
||||
use ywxapp\model\CommonSms as SmsModel;
|
||||
|
||||
/**
|
||||
* 短信验证码类
|
||||
*/
|
||||
class Sms
|
||||
class Sms
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -53,7 +62,8 @@ class Sms
|
||||
* @return boolean
|
||||
*/
|
||||
public static function send($mobile, $code = null, $event = 'default')
|
||||
{
|
||||
{
|
||||
|
||||
$code = is_null($code) ? Random::numeric(6) : $code;
|
||||
$time = time();
|
||||
$ip = request()->ip();
|
||||
|
||||
Reference in New Issue
Block a user