49b709df9f
- Introduced a new API endpoint `POST /api/v1/video/remove_watermark/report_failure` for reporting download failures. - Added a new database table `video_download_failures` to store details about failed downloads, including domain, URL, error message, and reporting metadata. - Updated the video handler to process failure reports and save them to the database. - Enhanced documentation to include details about the new reporting feature and its usage.
75 lines
3.3 KiB
Go
75 lines
3.3 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type VideoParseLog struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"`
|
|
|
|
MiniProgramID uint `gorm:"index:idx_video_parse_user_date,priority:1;comment:小程序ID" json:"mini_program_id"`
|
|
UserID uint `gorm:"index:idx_video_parse_user_date,priority:2;comment:用户ID" json:"user_id"`
|
|
RequestContent string `gorm:"type:text;comment:用户提交原文" json:"request_content"`
|
|
ParsedURL string `gorm:"size:500;comment:解析得到的链接" json:"parsed_url"`
|
|
ThirdPartyStatus int `gorm:"comment:第三方HTTP状态或业务码" json:"third_party_status"`
|
|
ThirdPartyPayload []byte `gorm:"type:json;comment:第三方响应原文" json:"third_party_payload"`
|
|
FreeQuotaUsed bool `gorm:"default:1;comment:是否计入免费次数" json:"free_quota_used"`
|
|
DurationMs int `gorm:"comment:耗时毫秒" json:"duration_ms"`
|
|
ErrorMessage string `gorm:"size:500;comment:错误信息" json:"error_message"`
|
|
}
|
|
|
|
func (VideoParseLog) TableName() string {
|
|
return "video_parse_logs"
|
|
}
|
|
|
|
func (VideoParseLog) TableComment() string {
|
|
return "短视频去水印调用日志"
|
|
}
|
|
|
|
type VideoParseUnlock struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"`
|
|
|
|
MiniProgramID uint `gorm:"index:idx_video_unlock_user_date,priority:1;comment:小程序ID" json:"mini_program_id"`
|
|
UserID uint `gorm:"index:idx_video_unlock_user_date,priority:2;comment:用户ID" json:"user_id"`
|
|
UnlockDate time.Time `gorm:"type:date;index:idx_video_unlock_user_date,priority:3;comment:解锁日期" json:"unlock_date"`
|
|
AdWatchedAt time.Time `gorm:"comment:广告完成时间" json:"ad_watched_at"`
|
|
}
|
|
|
|
func (VideoParseUnlock) TableName() string {
|
|
return "video_parse_unlocks"
|
|
}
|
|
|
|
func (VideoParseUnlock) TableComment() string {
|
|
return "短视频去水印-每日广告解锁"
|
|
}
|
|
|
|
type VideoDownloadFailure struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"`
|
|
|
|
Domain string `gorm:"size:255;index;comment:来源域名" json:"domain"`
|
|
FailedURL string `gorm:"size:1000;comment:下载失败的URL" json:"failed_url"`
|
|
ErrorMessage string `gorm:"type:text;comment:失败原因" json:"error_message"`
|
|
ReportedAt time.Time `gorm:"index;comment:失败发生时间" json:"reported_at"`
|
|
UserAgent string `gorm:"size:255;comment:上报端UA" json:"user_agent"`
|
|
ClientIP string `gorm:"size:64;comment:上报IP" json:"client_ip"`
|
|
}
|
|
|
|
func (VideoDownloadFailure) TableName() string {
|
|
return "video_download_failures"
|
|
}
|
|
|
|
func (VideoDownloadFailure) TableComment() string {
|
|
return "短视频去水印-下载失败上报"
|
|
}
|