feat: 网关只读资产改为数据表,只读资产只允许查询类调用
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m36s

- 新增 tb_gateway_readonly_card(卡 ICCID / 设备 IMEI)与开关 JUNHONG_GATEWAY_READONLY_ENABLED,
  替换环境变量名单 JUNHONG_GATEWAY_READONLY_ICCIDS
- 只读资产只放行查卡状态、查实名、查流量、查设备信息、查设备槽位、同步设备状态;
  停机、复机、限速、实名认证链接与设备写操作在网关出口本地拦截;查表失败按拦截;不缓存
- 测试环境部署开启只读模式;新增技术方案与清理顺序文档

Change: add-gateway-readonly-prod-import

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
邹进
2026-10-29 17:55:52 +09:00
parent a7428c7924
commit 5cf67b98de
19 changed files with 536 additions and 41 deletions

View File

@@ -0,0 +1,2 @@
-- 回滚网关只读资产表。执行前必须先关闭 JUNHONG_GATEWAY_READONLY_ENABLED 并处理导入资产(见清理顺序文档)。
DROP TABLE IF EXISTS tb_gateway_readonly_card;

View File

@@ -0,0 +1,24 @@
-- 网关只读资产表(add-gateway-readonly-prod-import)。
-- 测试环境导入生产卡与设备做流量计量验证时使用:开关 JUNHONG_GATEWAY_READONLY_ENABLED=true 时,
-- 表中的卡(ICCID)与设备(IMEI)只允许查询类网关调用(查卡状态、查实名、查流量、查设备信息、查设备槽位、同步设备状态),
-- 停机、复机、限速、实名认证链接与设备写操作在网关出口本地拦截。生产不配置该开关,不查本表。
-- 本迁移不写入数据;数据由测试环境导入脚本写入。
-- 撤除顺序见 docs/测试环境生产卡只读模式清理顺序.md:先处理导入资产 → 关开关并部署 → 新迁移删表。
-- 开关开启时删表会使所有非查询类调用失败(查表失败按拦截处理)。
CREATE TABLE tb_gateway_readonly_card (
id BIGSERIAL PRIMARY KEY,
identifier VARCHAR(64) NOT NULL,
identifier_type VARCHAR(16) NOT NULL,
source VARCHAR(64) NOT NULL DEFAULT '',
remark VARCHAR(255) NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT ck_gateway_readonly_card_type CHECK (identifier_type IN ('iccid', 'imei'))
);
CREATE UNIQUE INDEX uk_gateway_readonly_card_identifier ON tb_gateway_readonly_card (identifier);
COMMENT ON TABLE tb_gateway_readonly_card IS '网关只读资产:表中的卡与设备只允许查询类网关调用(测试环境导入生产数据验证用)';
COMMENT ON COLUMN tb_gateway_readonly_card.identifier IS '网关请求卡号(大写):卡为 ICCID,设备为 IMEI';
COMMENT ON COLUMN tb_gateway_readonly_card.identifier_type IS '卡号类型:iccid / imei';
COMMENT ON COLUMN tb_gateway_readonly_card.source IS '来源,如 prod_import_20261029';
COMMENT ON COLUMN tb_gateway_readonly_card.remark IS '备注';