feat(server-go): AI 巡检闭环后端(inspection_records + /inspections 幂等接口)
This commit is contained in:
@@ -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" }
|
||||
@@ -24,6 +24,8 @@ var AllPermissions = []PermissionDef{
|
||||
{"log:read", "日志查看", "查看控制日志"},
|
||||
{"knowledge:read", "知识库查看", "查看蚕病百科和知识文章"},
|
||||
{"knowledge:write", "知识库管理", "新增、编辑、删除知识库内容"},
|
||||
{"inspection:create", "巡检创建", "发起 AI 拍照巡检"},
|
||||
{"inspection:read", "巡检查看", "查看 AI 巡检记录"},
|
||||
{"user:manage", "用户管理", "管理用户、角色和权限"},
|
||||
{"audit:read", "审计查看", "查看审计日志"},
|
||||
}
|
||||
@@ -35,6 +37,7 @@ var RolePermissionMap = map[string][]string{
|
||||
"threshold:read", "threshold:write", "alarm:read", "alarm:ack",
|
||||
"video:read", "video:record", "energy:view", "log:read",
|
||||
"knowledge:read", "knowledge:write",
|
||||
"inspection:create", "inspection:read",
|
||||
"user:manage", "audit:read",
|
||||
},
|
||||
RoleOperator: {
|
||||
@@ -42,15 +45,18 @@ var RolePermissionMap = map[string][]string{
|
||||
"threshold:read", "threshold:write", "alarm:read", "alarm:ack",
|
||||
"video:read", "video:record", "energy:view", "log:read",
|
||||
"knowledge:read", "knowledge:write",
|
||||
"inspection:create", "inspection:read",
|
||||
},
|
||||
RoleViewer: {
|
||||
"dashboard:view", "room:read", "device:read",
|
||||
"threshold:read", "alarm:read", "video:read", "energy:view",
|
||||
"knowledge:read",
|
||||
"inspection:read",
|
||||
},
|
||||
RoleFarmer: {
|
||||
"dashboard:view", "room:read", "device:read", "device:control",
|
||||
"alarm:read", "alarm:ack", "video:read", "energy:view",
|
||||
"knowledge:read",
|
||||
"inspection:create", "inspection:read",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user