Parcourir la source

fix:图表详情兼容年月格式

Roc il y a 2 ans
Parent
commit
429273c9f4
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 12 1
      controllers/chart.go

+ 12 - 1
controllers/chart.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_chart_lib/services/data"
 	"hongze/hongze_chart_lib/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -104,7 +105,7 @@ func (this *ChartController) ChartInfoDetail() {
 		startDate = startDate + "-01"
 		endDate = endDate + "-01"
 	case 6:
-		startDate = startDate + "-01"
+		//startDate = startDate + "-01"
 		//endDate = time.Now().Format(utils.FormatDate)
 		endDate = ""
 	case 7:
@@ -124,6 +125,16 @@ func (this *ChartController) ChartInfoDetail() {
 		endDate = ""
 	}
 
+	// 兼容日期错误
+	{
+		if strings.Count(startDate, "-") == 1 {
+			startDate = startDate + "-01"
+		}
+		if strings.Count(endDate, "-") == 1 {
+			endDate = endDate + "-01"
+		}
+	}
+
 	if chartType == 2 {
 		if seasonStartDate != "" {
 			startDate = seasonStartDate + "-01-01"