This commit is contained in:
2024-12-25 11:59:33 +08:00
parent a5fa833937
commit 36dd01056e
35 changed files with 2328 additions and 244 deletions

View File

@@ -81,10 +81,24 @@ func NotifyMiddleware() gin.HandlerFunc {
return
}
if utils.IsInTimeRange(startTime, endTime) {
response.FailNotify(c)
c.Abort()
return
currentTime := time.Now()
// 检查是否跨午夜
if endTime.Before(startTime) {
// 跨午夜,检查是否在开始时间到午夜,或者午夜到结束时间的范围内
if utils.IsInTimeRange(startTime, time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())) ||
utils.IsInTimeRange(time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location()), endTime) {
response.FailNotify(c)
c.Abort()
return
}
} else {
// 不跨午夜,按普通情况处理
if utils.IsInTimeRange(startTime, endTime) {
response.FailNotify(c)
c.Abort()
return
}
}
}
c.Next()