|
@@ -1,6 +1,7 @@
|
|
|
package eta
|
|
|
|
|
|
import (
|
|
|
+ logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
"eta/eta_mini_ht_api/models"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -25,25 +26,26 @@ func (ETAReport) TableName() string {
|
|
|
}
|
|
|
|
|
|
type ETAReport struct {
|
|
|
- ID int `gorm:"primary_key;auto_increment"`
|
|
|
- ClassifyID int `gorm:"_"`
|
|
|
- ClassifyIDFirst int `gorm:"column:classify_id_first;default:0"`
|
|
|
- ClassifyIDSecond int `gorm:"column:classify_id_second;default:0"`
|
|
|
- ClassifyIDThird int `gorm:"column:classify_id_third;default:0"`
|
|
|
- Title string `gorm:"column:title;size:125;"`
|
|
|
- Abstract string `gorm:"column:abstract;size:255;"`
|
|
|
- Author string `gorm:"column:author;size:50;"`
|
|
|
- PublishTime time.Time `gorm:"column:publish_time"`
|
|
|
- Content string `gorm:"column:content"`
|
|
|
- CollaborateType int `gorm:"column:collaborate_type"`
|
|
|
- ReportLayout int `gorm:"column:report_layout"`
|
|
|
- VideoUrl string `gorm:"column:video_url"`
|
|
|
- VideoName string `gorm:"column:video_name"`
|
|
|
- VideoPlaySeconds string `gorm:"column:video_play_seconds"`
|
|
|
- HeadResourceId int `gorm:"column:head_resource_id"`
|
|
|
- EndResourceId int `gorm:"column:end_resource_id"`
|
|
|
- HasChapter bool `gorm:"column:has_chapter"`
|
|
|
- NeedSplice bool `gorm:"column:need_splice"`
|
|
|
+ ID int `gorm:"primary_key;auto_increment"`
|
|
|
+ ClassifyID int `gorm:"_"`
|
|
|
+ ClassifyIDFirst int `gorm:"column:classify_id_first;default:0"`
|
|
|
+ ClassifyIDSecond int `gorm:"column:classify_id_second;default:0"`
|
|
|
+ ClassifyIDThird int `gorm:"column:classify_id_third;default:0"`
|
|
|
+ Title string `gorm:"column:title;size:125;"`
|
|
|
+ Abstract string `gorm:"column:abstract;size:255;"`
|
|
|
+ Author string `gorm:"column:author;size:50;"`
|
|
|
+ PublishTime string `gorm:"column:publish_time"`
|
|
|
+ PublishedTime time.Time
|
|
|
+ Content string `gorm:"column:content"`
|
|
|
+ CollaborateType int `gorm:"column:collaborate_type"`
|
|
|
+ ReportLayout int `gorm:"column:report_layout"`
|
|
|
+ VideoUrl string `gorm:"column:video_url"`
|
|
|
+ VideoName string `gorm:"column:video_name"`
|
|
|
+ VideoPlaySeconds string `gorm:"column:video_play_seconds"`
|
|
|
+ HeadResourceId int `gorm:"column:head_resource_id"`
|
|
|
+ EndResourceId int `gorm:"column:end_resource_id"`
|
|
|
+ HasChapter bool `gorm:"column:has_chapter"`
|
|
|
+ NeedSplice bool `gorm:"column:need_splice"`
|
|
|
}
|
|
|
|
|
|
//type ReportClassify struct {
|
|
@@ -67,7 +69,7 @@ func GetETAReports(id int) (reports []ETAReport, err error) {
|
|
|
}
|
|
|
|
|
|
func GetUpdateETAReports() (reports []ETAReport, err error) {
|
|
|
- duration := time.Now().Add(-15 * time.Second)
|
|
|
+ duration := time.Now().Add(-30 * time.Second)
|
|
|
modifyTime := duration.Format(time.DateTime)
|
|
|
err = models.ETA().Table("report").Select(colunms+strings.Join(classifyIds, ",")).Where("(state =? or state=?) and modify_time >=?", published, passed, modifyTime).Order("id asc").Find(&reports).Error
|
|
|
if reports != nil {
|
|
@@ -77,8 +79,18 @@ func GetUpdateETAReports() (reports []ETAReport, err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
func GetETAReportById(id int) (report ETAReport, err error) {
|
|
|
err = models.ETA().Table("report").Select(detailColumn).Where("id = ?", id).Where("state =? or state=?", published, passed).First(&report).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var date time.Time
|
|
|
+ date, err = time.Parse(time.DateTime, report.PublishTime)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("时间转换错误:%v", err)
|
|
|
+ }
|
|
|
+ report.PublishedTime = date
|
|
|
return
|
|
|
}
|
|
|
func DoSql(sql string, result interface{}, values ...interface{}) (err error) {
|