admin/sql/migrate_customer_openapi_credential.sql
zzh 2688058cb3
All checks were successful
Build and Deploy / deploy (push) Successful in 58s
feat: 客户 OpenAPI 机机凭证与 whoami 探针
一主客户一对 AppKey/AppSecret,支持门户自助与后台代管启停重置,供应商回调路径不动。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 10:19:38 +08:00

42 lines
1.7 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.

-- 客户 OpenAPI 机机凭证(一客户一对 AppKey/AppSecret,独立于 itfx)
-- 可重复执行。
-- 目标表:t_customer_openapi_credential
SET @db := DATABASE();
SET @exists := (
SELECT COUNT(1)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_customer_openapi_credential'
);
SET @sql := IF(
@exists = 0,
'CREATE TABLE `t_customer_openapi_credential` (
`Id` INT NOT NULL AUTO_INCREMENT COMMENT ''主键'',
`CustomerId` INT NOT NULL COMMENT ''归属主客户 t_customer.Id'',
`AppKey` VARCHAR(64) NOT NULL COMMENT ''开放接口 AppKey'',
`AppSecret` VARCHAR(128) NOT NULL COMMENT ''开放接口 AppSecret(明文,创建/重置时返回)'',
`Enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''是否启用:0-否,1-是'',
`LastUsedAt` DATETIME NULL COMMENT ''最近鉴权成功时间'',
`LastUsedIp` VARCHAR(64) NULL COMMENT ''最近鉴权成功 IP'',
`Remark` VARCHAR(512) NULL COMMENT ''备注'',
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT ''软删除:0-否,1-是'',
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT ''并发戳'',
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT ''创建人'',
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''创建时间'',
`UpdateUserId` INT NULL COMMENT ''更新人'',
`UpdateTime` DATETIME NULL COMMENT ''更新时间'',
PRIMARY KEY (`Id`),
UNIQUE KEY `uk_coc_customer` (`CustomerId`),
UNIQUE KEY `uk_coc_app_key` (`AppKey`),
KEY `idx_coc_enabled` (`Enabled`, `IsDeleted`)
) COMMENT=''客户 OpenAPI 机机凭证''',
'SELECT ''t_customer_openapi_credential already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;