feat: M4 seed — upload & publish 20 rule sets, fix config/schema column names

- Fix _export_settings for pydantic v2 compatibility (model_fields)
- Fix delete_time→deleted_at, update_time→updated_at in RuleServiceImpl
- Add OssClient.EnsureBucket method
- Replace contract_lease/sale/tech rules.yaml from new-rules
- Seed script: batch upload 20 rule YAMLs to OSS + write DB + publish
- Config: fix OSS import chain
This commit is contained in:
wren
2026-04-28 12:13:46 +08:00
parent 246c0e5ded
commit 2d108c8381
11 changed files with 9208 additions and 2819 deletions
@@ -46,7 +46,7 @@ class RuleServiceImpl(IRuleService):
current_version_id,
status
FROM leaudit_rule_sets
WHERE delete_time IS NULL
WHERE deleted_at IS NULL
ORDER BY id DESC
"""
)
@@ -80,7 +80,7 @@ class RuleServiceImpl(IRuleService):
FROM leaudit_rule_versions rv
JOIN leaudit_rule_sets rs ON rs.id = rv.rule_set_id
WHERE rs.rule_type = :rule_type
AND rs.delete_time IS NULL
AND rs.deleted_at IS NULL
ORDER BY rv.version_seq DESC, rv.id DESC
"""
),
@@ -208,7 +208,7 @@ class RuleServiceImpl(IRuleService):
rule_name = :rule_name,
domain_type = :domain_type,
description = :description,
update_time = now()
updated_at = now()
WHERE id = :rule_set_id
"""
),
@@ -361,7 +361,7 @@ class RuleServiceImpl(IRuleService):
FROM leaudit_rule_type_bindings b
JOIN leaudit_rule_sets rs ON rs.id = b.rule_set_id
WHERE rs.rule_type = :rule_type
AND rs.delete_time IS NULL
AND rs.deleted_at IS NULL
ORDER BY b.priority DESC, b.id DESC
"""
),
@@ -384,7 +384,7 @@ class RuleServiceImpl(IRuleService):
rs.rule_name
FROM leaudit_rule_type_bindings b
JOIN leaudit_rule_sets rs ON rs.id = b.rule_set_id
WHERE rs.delete_time IS NULL
WHERE rs.deleted_at IS NULL
ORDER BY rs.rule_type, b.priority DESC, b.id DESC
"""
),
@@ -417,7 +417,7 @@ class RuleServiceImpl(IRuleService):
"""创建规则类型绑定。"""
async with GetAsyncSession() as Session:
RuleSet = await Session.execute(
text("SELECT id, rule_type, rule_name FROM leaudit_rule_sets WHERE id = :rid AND delete_time IS NULL LIMIT 1"),
text("SELECT id, rule_type, rule_name FROM leaudit_rule_sets WHERE id = :rid AND deleted_at IS NULL LIMIT 1"),
{"rid": RuleSetId},
)
RsRow = RuleSet.mappings().first()
@@ -531,7 +531,7 @@ class RuleServiceImpl(IRuleService):
Params["note"] = Note
if SetClauses:
SetClauses.append("update_time = now()")
SetClauses.append("updated_at = now()")
await Session.execute(
text(f"UPDATE leaudit_rule_type_bindings SET {', '.join(SetClauses)} WHERE id = :bid"),
Params,
@@ -615,7 +615,7 @@ class RuleServiceImpl(IRuleService):
WHEN id = :version_id THEN now()
ELSE published_at
END,
update_time = now()
updated_at = now()
WHERE rule_set_id = :rule_set_id
"""
),
@@ -634,7 +634,7 @@ class RuleServiceImpl(IRuleService):
SET
current_version_id = :version_id,
status = 'active',
update_time = now()
updated_at = now()
WHERE id = :rule_set_id
"""
),
@@ -656,7 +656,7 @@ class RuleServiceImpl(IRuleService):
SELECT id, rule_type, rule_name, domain_type, current_version_id, status
FROM leaudit_rule_sets
WHERE rule_type = :rule_type
AND delete_time IS NULL
AND deleted_at IS NULL
LIMIT 1
"""
),