This commit is contained in:
2025-02-07 22:58:01 +08:00
commit ba4aad0ae5
23 changed files with 1061 additions and 0 deletions

13
dto/common_response.go Normal file
View File

@ -0,0 +1,13 @@
package dto
type ApiResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
type TaskListResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data []Task `json:"data"`
}

8
dto/ffmpeg.go Normal file
View File

@ -0,0 +1,8 @@
package dto
type FfmpegTask struct {
Files []File
Length int
Offset int
OutputFile string
}

16
dto/file.go Normal file
View File

@ -0,0 +1,16 @@
package dto
import "time"
type File struct {
BasePath string `json:"basePath"`
Url string `json:"url"`
Path string `json:"path"`
Name string `json:"name"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
}
func (f *File) GetDiffMs() int64 {
return f.EndTime.Sub(f.StartTime).Milliseconds()
}

62
dto/task.go Normal file
View File

@ -0,0 +1,62 @@
package dto
import (
"encoding/json"
"time"
)
// 自定义时间格式
const customTimeFormat = "2006-01-02 15:04:05"
func (t *Task) UnmarshalJSON(data []byte) error {
type Alias Task
aux := &struct {
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
*Alias
}{
Alias: (*Alias)(t),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
var err error
t.StartTime, err = time.ParseInLocation(customTimeFormat, aux.StartTime, time.Local)
if err != nil {
return err
}
t.EndTime, err = time.ParseInLocation(customTimeFormat, aux.EndTime, time.Local)
if err != nil {
return err
}
return nil
}
type Task struct {
TaskID string `json:"taskId"`
ScenicID string `json:"scenicId"`
DeviceID string `json:"deviceId"`
DeviceNo string `json:"deviceNo"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
}
type FileObject struct {
URL string `json:"url"`
NeedDownload bool `json:"needDownload"`
CreateTime time.Time `json:"createTime"`
EndTime time.Time `json:"endTime"`
}
func (f *FileObject) MarshalJSON() ([]byte, error) {
type Alias FileObject
return json.Marshal(&struct {
CreateTime string `json:"createTime"`
EndTime string `json:"endTime"`
*Alias
}{
CreateTime: f.CreateTime.Format(customTimeFormat),
EndTime: f.EndTime.Format(customTimeFormat),
Alias: (*Alias)(f),
})
}