feat: add audit logging and lesson statistics for clazz

- Add clazz_audit_log table with diesel migration for CRUD audit trail
- Add audit log backend: model, queries, handler, route
- Add audit log viewer in clazz detail modal (操作记录)
- Add student_lesson_stats API (GET /api/v1/clazz/stats/my-lessons)
- Add teacher_detail_stats API (GET /api/v1/clazz/stats/teacher-detail)
- Register all new routes in lib.rs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 19:45:56 +08:00
parent 723787a8ea
commit 5bf43143ea
7 changed files with 348 additions and 5 deletions
@@ -0,0 +1 @@
DROP TABLE IF EXISTS clazz_audit_log;
@@ -0,0 +1,13 @@
CREATE TABLE clazz_audit_log (
id VARCHAR PRIMARY KEY,
clazz_id VARCHAR NOT NULL,
action VARCHAR NOT NULL,
operator_hty_id VARCHAR NOT NULL,
operator_name VARCHAR,
changes JSONB,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
org_id VARCHAR
);
CREATE INDEX idx_clazz_audit_log_clazz_id ON clazz_audit_log (clazz_id);
CREATE INDEX idx_clazz_audit_log_created_at ON clazz_audit_log (created_at);