| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const db = require('../../plugin/DataBase/db')
- const BindAuditAction = Object.freeze({
- PLATFORM_BIND: 'platform_bind',
- PLATFORM_UNBIND: 'platform_unbind',
- BOT_BIND: 'bot_bind',
- BOT_UNBIND: 'bot_unbind'
- })
- const BindAuditSource = Object.freeze({
- USER_API: 'user_api',
- ADMIN_API: 'admin_api',
- SERVICE_API: 'service_api',
- MCP_QQ: 'mcp_qq',
- MCP_WORK_ORDER: 'mcp_work_order'
- })
- async function insertBindAudit({
- studentNum,
- ownerUuid = null,
- action,
- source,
- operatorUuid = null,
- detail = null,
- createdAt = Date.now()
- }) {
- if (!studentNum || !action || !source) return false
- const sql = `
- INSERT INTO lepao_bind_audit
- (student_num, owner_uuid, action, source, operator_uuid, detail_json, created_at)
- VALUES (?, ?, ?, ?, ?, ?, ?)
- `
- const rows = await db.query(sql, [
- String(studentNum),
- ownerUuid || null,
- action,
- source,
- operatorUuid || null,
- detail ? JSON.stringify(detail) : null,
- Number(createdAt) || Date.now()
- ])
- return !!rows && rows.affectedRows === 1
- }
- module.exports = {
- BindAuditAction,
- BindAuditSource,
- insertBindAudit
- }
|