v4.0.17企业微信API插件优化

This commit is contained in:
2026-09-06 09:36:49 +08:00
parent 0e711be6c6
commit 192a401227
36 changed files with 2416 additions and 103 deletions
@@ -0,0 +1,35 @@
/**
* 创建 wecom_api_plugin(若不存在)。
* 不依赖 Prisma Client 新 model,可在 generate 之前执行。
*/
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
await prisma.$executeRawUnsafe(`
CREATE TABLE IF NOT EXISTS wecom_api_plugin (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(64) NOT NULL,
api_key VARCHAR(128) NOT NULL,
permissions TEXT NOT NULL,
remark VARCHAR(256) NULL,
enabled TINYINT(1) NOT NULL DEFAULT 1,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
UNIQUE KEY wecom_api_plugin_api_key_key (api_key),
KEY wecom_api_plugin_enabled_sort (enabled, sort_order)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
console.log('migrate-wecom-api-plugin done');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
+17
View File
@@ -493,6 +493,23 @@ model WecomBot {
@@map("wecom_bot")
}
/// 企微智能机器人 API 插件实例(v3.5.17 · 多 Key + 工具权限)
model WecomApiPlugin {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
name String @db.VarChar(64)
apiKey String @unique @map("api_key") @db.VarChar(128)
/// JSON 字符串数组,工具权限
permissions String @db.Text
remark String? @db.VarChar(256)
enabled Boolean @default(true)
sortOrder Int @default(0) @map("sort_order")
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
@@index([enabled, sortOrder])
@@map("wecom_api_plugin")
}
/// 企微机器人操作审计
model LogWecomBot {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt