Documentation
¶
Overview ¶
Code generated by godddx, DO AVOID EDIT.
Package event 事件领域,负责管理 AI 检测事件的存储和查询。
事件由 AI 分析服务产生,每个检测到的目标对象(如 person、car)生成一条独立的事件记录。 事件关联到具体的设备 (DID) 和通道 (CID),并记录检测时间、置信度、边界框等信息。
主要功能:
- 事件的增删改查
- 按通道和时间范围查询事件
- 事件图片的存储路径管理
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Index ¶
- type AddEventInput
- type Core
- func (c Core) AddEvent(ctx context.Context, in *AddEventInput) (*Event, error)
- func (c Core) DelEvent(ctx context.Context, id int64) (*Event, error)
- func (c Core) EditEvent(ctx context.Context, in *EditEventInput, id int64) (*Event, error)
- func (c Core) FindEvents(ctx context.Context, in *FindEventInput) ([]*Event, int64, error)
- func (c Core) GetEvent(ctx context.Context, id int64) (*Event, error)
- func (c Core) StartCleanupWorker(days int)
- type EditEventInput
- type Event
- type EventStorer
- type FindEventInput
- type Storer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddEventInput ¶
type AddEventInput struct {
DID string `json:"-"` // 设备 ID (API 层填充)
CID string `json:"-"` // 通道 ID (API 层填充)
StartedAt orm.Time `json:"started_at"` // 事件开始时间 (毫秒时间戳)
EndedAt orm.Time `json:"ended_at"` // 事件结束时间 (毫秒时间戳)
Label string `json:"label"` // 检测标签
Score float32 `json:"score"` // 置信度
Zones string `json:"zones"` // 检测区域 JSON
ImagePath string `json:"image_path"` // 图片相对路径
Model string `json:"model"` // 分析模型名称
}
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core business domain
func (Core) FindEvents ¶
FindEvents 分页查询事件列表,支持按 CID 和时间范围筛选
func (Core) StartCleanupWorker ¶
StartCleanupWorker 启动定时清理协程,每天凌晨 3 点执行一次清理 days 参数指定保留的天数,超过该天数的事件将被删除
type EditEventInput ¶
type Event ¶
type Event struct {
ID int64 `gorm:"primaryKey" json:"id"` // 事件 ID
DID string `gorm:"column:did;notNull;default:'';comment:设备 ID (device 表的 id)" json:"did"` // 设备 ID (device 表的 id)
CID string `gorm:"column:cid;notNull;default:'';comment:通道 ID (channel 表的 id)" json:"cid"` // 通道 ID (channel 表的 id)
StartedAt orm.Time `gorm:"column:started_at;notNull;default:CURRENT_TIMESTAMP;comment:事件开始时间" json:"started_at"` // 事件开始时间
EndedAt orm.Time `gorm:"column:ended_at;notNull;default:CURRENT_TIMESTAMP;comment:事件结束时间" json:"ended_at"` // 事件结束时间
Label string `gorm:"column:label;notNull;default:'';comment:检测标签 (person, car 等)" json:"label"` // 检测标签 (person, car 等)
Score float32 `gorm:"column:score;notNull;default:0;comment:置信度 (0.0-1.0)" json:"score"` // 置信度 (0.0-1.0)
Zones string `gorm:"column:zones;notNull;default:'';comment:检测区域,JSON 格式存储边界框信息" json:"zones"` // 检测区域,JSON 格式存储边界框信息
ImagePath string `` // 图片相对路径 (cid/年月日时分秒_随机6位.jpg)
/* 128-byte string literal not displayed */
Model string `gorm:"column:model;notNull;default:'';comment:分析模型名称" json:"model"` // 分析模型名称
CreatedAt orm.Time `gorm:"column:created_at;notNull;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt orm.Time `gorm:"column:updated_at;notNull;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
}
Event domain model
type EventStorer ¶
type EventStorer interface {
Find(context.Context, *[]*Event, orm.Pager, ...orm.QueryOption) (int64, error)
Get(context.Context, *Event, ...orm.QueryOption) error
Add(context.Context, *Event) error
Edit(context.Context, *Event, func(*Event), ...orm.QueryOption) error
Del(context.Context, *Event, ...orm.QueryOption) error
Count(context.Context, ...orm.QueryOption) (int64, error)
Session(context.Context, ...func(*gorm.DB) error) error
EditWithSession(*gorm.DB, *Event, func(b *Event) error, ...orm.QueryOption) error
}
EventStorer Instantiation interface
type FindEventInput ¶
type FindEventInput struct {
web.PagerFilter
web.DateFilter
DID string `form:"did"` // 设备 ID
CID string `form:"cid"` // 通道 ID
Label string `form:"label"` // 检测标签
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
store
|
|
|
eventcache
Code generated by godddx, DO AVOID EDIT.
|
Code generated by godddx, DO AVOID EDIT. |
|
eventdb
Code generated by godddx, DO AVOID EDIT.
|
Code generated by godddx, DO AVOID EDIT. |
Click to show internal directories.
Click to hide internal directories.