瀏覽代碼

临时提交

boweniac 3 月之前
父節點
當前提交
ae5057bc09
共有 1 個文件被更改,包括 18 次插入1 次删除
  1. 18 1
      internal/logic/dashboard/get_charts_logic.go

+ 18 - 1
internal/logic/dashboard/get_charts_logic.go

@@ -39,12 +39,15 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
 		"2006-01-02", // 对应 "2024-01-01"
 	}
 
+	var layoutsType int
+
 	var startTime time.Time
-	for _, layout := range layouts {
+	for i, layout := range layouts {
 		startTime, err = time.Parse(layout, *req.StartDate)
 		if err == nil {
 			break
 		}
+		layoutsType = i
 	}
 	if err != nil {
 		fmt.Println("解析开始时间失败:", err)
@@ -63,5 +66,19 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
 		return
 	}
 
+	// 判断截止日期是否包含当前日
+	var isCurrentDay bool
+	now := time.Now()
+
+	if layoutsType == 0 {
+		isCurrentDay = endTime.Year() == now.Year() && endTime.Month() == now.Month()
+	} else {
+		isCurrentDay = endTime.Year() == now.Year() && endTime.Month() == now.Month() && endTime.Day() == now.Day()
+	}
+
+	if isCurrentDay && layoutsType == 1 && req.StartDate == req.EndDate {
+		// 
+	}
+
 	return
 }