feat(server-go): AI 巡检闭环后端(inspection_records + /inspections 幂等接口)

This commit is contained in:
weijuesen
2026-08-12 16:24:55 +08:00
parent b89ad5e865
commit 210bd6cefb
10 changed files with 354 additions and 3 deletions
+23
View File
@@ -0,0 +1,23 @@
package model
import (
"encoding/json"
"time"
)
// InspectionRecord AI 巡检记录
type InspectionRecord struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
UserID *string `gorm:"column:user_id;type:uuid;index" json:"userId,omitempty"`
RoomID *string `gorm:"column:room_id;type:uuid;index" json:"roomId,omitempty"`
ImageURL *string `gorm:"column:image_url;size:512" json:"imageUrl,omitempty"`
Detections json.RawMessage `gorm:"column:detections;type:jsonb" json:"detections,omitempty"`
RiskScore *float64 `gorm:"column:risk_score;type:float" json:"riskScore,omitempty"`
RiskLevel *string `gorm:"column:risk_level;size:16" json:"riskLevel,omitempty"`
AIStatus string `gorm:"column:ai_status;size:16;default:done" json:"aiStatus"`
IdempotencyKey *string `gorm:"column:idempotency_key;size:128;uniqueIndex" json:"idempotencyKey,omitempty"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (InspectionRecord) TableName() string { return "inspection_records" }