Files
YwxAppThink/addon/blog/install.sql
T
yangwx 18101cf11a feat: 上线前安全加固与发布工程化;appmall 由插件迁移为独立应用
安全(P0)
- 发布包签名:新增 scripts/package_keygen.php、scripts/package_verify.php、
  ywxapp\service\PackageVerifier;FrameworkService::apply() 解压前强制验签
  (ywxapp.framework_package_verify,默认开启)
- JWT 收紧:config/jwt.php 移除公开默认密钥,JwtService::assertStrongSecret()
  校验非空 / 长度≥32 / 已知弱值;.env.production.example 键名由 JWT_SECRET_KEY 修正为 JWT_SECRET
- /api/v1/Article:免登录白名单收窄为只读接口,写操作字段白名单 + assertOwner() 越权校验
- 开发者令牌:查找接口不再回显明文、统一失败文案 + 限流
- TemplateInstaller:文件名白名单 + realpath 归一化 + 目录内断言,修复 Zip Slip;补 use ZipArchive
- 后台登录:接入验证码、失败锁定与登录限流(config/ratelimit.php)
- 缓存 / Session 驱动可由 .env 覆盖(CACHE_DRIVER / SESSION_TYPE),集群部署改 redis
- paycenter 支付日志开关改为 PAY_LOG,不再跟随 APP_DEBUG

工程化 / 交付
- 新增 CHANGELOG.md 与 .env.production.example;composer.lock 入库锁定依赖版本
- 插件离线安装 CLI 增加 --uid,后台上传安装透传 uid,付费插件授权校验可通过
- 授权拒绝文案区分「未携带 uid」与「未找到有效授权」,便于排障
- .gitignore 放行 .env.production.example / .env.addon.example / .gitattributes / public/.htaccess

结构
- appmall 由 addon/appmall 迁移为独立应用 app/appmall(市场 / 开发者中心 / 审核 / 分润)
2026-10-22 00:53:39 +08:00

122 lines
5.8 KiB
SQL
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.
-- ============================================================
-- addon/blog/install.sql —— blog 插件数据表
-- 由 docs/split_install_sql.py 从根 install.sql 抽取。
-- 框架约定:插件安装时由 ywxapp\service\AddonService 执行本文件
-- (仅允许 CREATE TABLE / INSERT,见 importsql 白名单)。
-- 表名须为 __PREFIX__<插件名>_*,与 __PREFIX__addon 等核心表命名一致。
-- ============================================================
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_article` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`content` longtext NOT NULL COMMENT '内容',
`summary` varchar(500) DEFAULT NULL COMMENT '摘要',
`cover_image` varchar(255) DEFAULT NULL COMMENT '封面图',
`uid` int NOT NULL COMMENT '作者ID',
`cid` int DEFAULT NULL COMMENT '分类ID',
`status` tinyint(1) DEFAULT '1' COMMENT '状态:1发布 0草稿',
`audit_status` tinyint(1) DEFAULT '2' COMMENT '审核状态:0草稿 1待审 2通过 3驳回',
`lat` decimal(10,7) DEFAULT '0.0000000' COMMENT '纬度(可选,用于附近)',
`lng` decimal(10,7) DEFAULT '0.0000000' COMMENT '经度(可选,用于附近)',
`is_top` tinyint(1) DEFAULT '0' COMMENT '是否置顶',
`view_count` int DEFAULT '0' COMMENT '浏览次数',
`comment_count` int DEFAULT '0' COMMENT '评论数',
`like_count` int DEFAULT '0' COMMENT '点赞数',
`favorite_count` int DEFAULT '0' COMMENT '收藏数',
`share_count` int DEFAULT '0' COMMENT '分享数',
`create_at` int DEFAULT NULL COMMENT '创建时间',
`update_at` int DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_uid` (`uid`),
KEY `idx_cid` (`cid`),
KEY `idx_create_at` (`create_at`),
-- 前台列表:status + audit_status 过滤后按 create_at 排序
KEY `idx_published` (`status`,`audit_status`,`create_at`),
KEY `idx_top` (`is_top`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='文章表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_article_tag` (
`aid` int NOT NULL COMMENT '文章ID',
`tid` int NOT NULL COMMENT '标签ID',
PRIMARY KEY (`aid`,`tid`) USING BTREE,
-- 按标签反查文章
KEY `idx_tid` (`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='文章标签关联表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_category` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`uid` int unsigned NOT NULL DEFAULT '0' COMMENT '所属会员UID,0表示全局共享分类',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '分类名称',
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
`sort` int DEFAULT '0' COMMENT '排序权重',
`create_at` int DEFAULT NULL COMMENT '创建时间',
`update_at` int DEFAULT NULL COMMENT '更新时间',
`status` tinyint(1) DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_uid_name` (`uid`, `name`),
KEY `idx_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分类表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_comment` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`uid` int NOT NULL COMMENT '用户ID',
`aid` int NOT NULL COMMENT '文章ID',
`pid` int NOT NULL DEFAULT '0' COMMENT '父评论ID',
`content` text NOT NULL COMMENT '评论内容',
`status` tinyint(1) DEFAULT '1' COMMENT '状态:1正常 0待审核',
`like_count` int DEFAULT '0' COMMENT '点赞数',
`ip` varchar(45) DEFAULT NULL COMMENT 'IP地址',
`user_agent` varchar(255) DEFAULT NULL COMMENT '用户代理',
`create_at` int DEFAULT NULL COMMENT '创建时间',
`update_at` int DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_create_at` (`create_at`),
KEY `idx_aid` (`aid`) USING BTREE,
KEY `idx_pid` (`pid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='评论表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_favorite` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`uid` int NOT NULL COMMENT '用户ID',
`aid` int NOT NULL COMMENT '文章ID',
`create_at` int DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `user_article` (`uid`,`aid`) USING BTREE,
KEY `idx_aid` (`aid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='收藏表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_like` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`uid` int NOT NULL COMMENT '用户ID',
`aid` int NOT NULL COMMENT '文章ID',
`create_at` int DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `user_article` (`uid`,`aid`) USING BTREE,
KEY `idx_aid` (`aid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='点赞表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_tag` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '标签名称',
`description` varchar(255) DEFAULT NULL COMMENT '标签描述',
`create_at` int DEFAULT NULL COMMENT '创建时间',
`update_at` int DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='标签表';
CREATE TABLE IF NOT EXISTS `__PREFIX__blog_visit` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`ip` varchar(45) DEFAULT NULL COMMENT 'IP地址',
`url` varchar(255) DEFAULT NULL COMMENT '访问URL',
`referer` varchar(255) DEFAULT '' COMMENT '来源URL',
`user_agent` varchar(255) DEFAULT '' COMMENT '用户代理',
`create_at` int DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `idx_url` (`url`),
KEY `idx_create_at` (`create_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='访客记录表';
SET FOREIGN_KEY_CHECKS = 1;