cc
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user