主要更新: - 更新 go.mod/go.sum 依赖 - 重新生成 Ent ORM 代码 - 更新 Wire 依赖注入配置 - 添加 docker-compose.override.yml 到 .gitignore - 更新 README 文档(Simple Mode 说明和已知问题) - 清理调试日志 - 其他代码优化和格式修复
36 lines
610 B
Go
36 lines
610 B
Go
package service
|
|
|
|
import "time"
|
|
|
|
// clampInt 将整数限制在指定范围内
|
|
func clampInt(value, min, max int) int {
|
|
if value < min {
|
|
return min
|
|
}
|
|
if value > max {
|
|
return max
|
|
}
|
|
return value
|
|
}
|
|
|
|
// clampFloat64 将浮点数限制在指定范围内
|
|
func clampFloat64(value, min, max float64) float64 {
|
|
if value < min {
|
|
return min
|
|
}
|
|
if value > max {
|
|
return max
|
|
}
|
|
return value
|
|
}
|
|
|
|
// remainingSecondsUntil 计算到指定时间的剩余秒数,保证非负
|
|
func remainingSecondsUntil(t time.Time) int {
|
|
seconds := int(time.Until(t).Seconds())
|
|
if seconds < 0 {
|
|
return 0
|
|
}
|
|
return seconds
|
|
}
|
|
|