Browse Source

时间格式处理

xingzai 3 years ago
parent
commit
26797f37ad
2 changed files with 23 additions and 1 deletions
  1. 4 1
      controllers/report.go
  2. 19 0
      utils/common.go

+ 4 - 1
controllers/report.go

@@ -1284,7 +1284,7 @@ func (this *ReportController) Detail() {
 	existMap := make(map[int]int)
 	var items []*models.ReportSelectionChartPermission
 	listLog, err := models.GetReportSelectionlogListAll(articleId)
-
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
@@ -1383,6 +1383,7 @@ func (this *ReportController) ResearchDetail() {
 		return
 	}
 	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	listFirst, err := models.GetResearchSummarylogListFirst(articleId)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -1495,6 +1496,7 @@ func (this *ReportController) MinutesDetail() {
 		return
 	}
 	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	listLog, err := models.GetMinutesSummarylogListAll(articleId)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -1582,6 +1584,7 @@ func (this *ReportController) RoadshowDetail() {
 		detail.Body = html.UnescapeString(detail.Body)
 		detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
 		detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+		detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 		if companyPermission == "" {
 			if applyCount > 0 {
 				hasPermission = 5

+ 19 - 0
utils/common.go

@@ -601,3 +601,22 @@ func WeekByDate(t time.Time) string {
 	resultSAtr = "(" + strconv.Itoa(t.Year()) + "年第" + strconv.Itoa(week) + "周" + ")"
 	return resultSAtr
 }
+
+func Mp3Time(videoPlaySeconds string) string {
+	var d int
+	var timeStr string
+	a, _ := strconv.ParseFloat(videoPlaySeconds, 32)
+	b := int(a)
+	c := b % 60
+	d = b / 60
+	if b <= 60 {
+		timeStr = "00:" + strconv.Itoa(b)
+	} else {
+		if d < 10 {
+			timeStr = "0" + strconv.Itoa(d) + ":" + strconv.Itoa(c)
+		} else {
+			timeStr = strconv.Itoa(d) + ":" + strconv.Itoa(c)
+		}
+	}
+	return timeStr
+}