查询使用 utc 时间

This commit is contained in:
2026-05-19 14:50:28 +08:00
parent dbc909c736
commit cf4bc4932a
13 changed files with 77 additions and 146 deletions

View File

@@ -42,12 +42,10 @@ func ListChannel(c *fiber.Ctx) error {
}
if req.ExpireAfter != nil {
start := u.DateHead(*req.ExpireAfter)
cond = cond.Where(q.Channel.ExpiredAt.Gte(start))
cond = cond.Where(q.Channel.ExpiredAt.Gte(req.ExpireAfter.UTC()))
}
if req.ExpireBefore != nil {
end := u.DateTail(*req.ExpireBefore)
cond = cond.Where(q.Channel.ExpiredAt.Lte(end))
cond = cond.Where(q.Channel.ExpiredAt.Lte(req.ExpireBefore.UTC()))
}
// 查询数据
@@ -226,18 +224,16 @@ func PageChannelByAdmin(c *fiber.Ctx) error {
do = do.Where(q.Channel.IP.Eq(ip))
}
if req.ExpiredAtStart != nil {
time := u.DateHead(*req.ExpiredAtStart)
do = do.Where(q.Channel.ExpiredAt.Gte(time))
do = do.Where(q.Channel.ExpiredAt.Gte(req.ExpiredAtStart.UTC()))
}
if req.ExpiredAtEnd != nil {
time := u.DateHead(*req.ExpiredAtEnd)
do = do.Where(q.Channel.ExpiredAt.Lte(time))
do = do.Where(q.Channel.ExpiredAt.Lte(req.ExpiredAtEnd.UTC()))
}
if req.Expired != nil {
if *req.Expired {
do = do.Where(q.Channel.ExpiredAt.Lte(time.Now()))
do = do.Where(q.Channel.ExpiredAt.Lte(time.Now().UTC()))
} else {
do = do.Where(q.Channel.ExpiredAt.Gt(time.Now()))
do = do.Where(q.Channel.ExpiredAt.Gt(time.Now().UTC()))
}
}
@@ -308,12 +304,10 @@ func PageChannelOfUserByAdmin(c *fiber.Ctx) error {
do = do.Where(q.Channel.Port.Eq(*req.ProxyPort))
}
if req.ExpiredAtStart != nil {
t := u.DateHead(*req.ExpiredAtStart)
do = do.Where(q.Channel.ExpiredAt.Gte(t))
do = do.Where(q.Channel.ExpiredAt.Gte(req.ExpiredAtStart.UTC()))
}
if req.ExpiredAtEnd != nil {
t := u.DateHead(*req.ExpiredAtEnd)
do = do.Where(q.Channel.ExpiredAt.Lte(t))
do = do.Where(q.Channel.ExpiredAt.Lte(req.ExpiredAtEnd.UTC()))
}
// 查询通道列表