31 lines
678 B
Go
31 lines
678 B
Go
package system
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"git.echol.cn/loser/Go-Web-Template/server/global"
|
|
"git.echol.cn/loser/Go-Web-Template/server/model/system"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
const paramAppOnlineWindowMinutes = "app.online_active_window_minutes"
|
|
|
|
// GetAppOnlineWindowMinutes 在线判定窗口(分钟),默认 5
|
|
func GetAppOnlineWindowMinutes() int {
|
|
var rec system.SysParams
|
|
err := global.GVA_DB.Where("key = ?", paramAppOnlineWindowMinutes).First(&rec).Error
|
|
if err != nil {
|
|
if err == gorm.ErrRecordNotFound {
|
|
return 5
|
|
}
|
|
return 5
|
|
}
|
|
v := strings.TrimSpace(rec.Value)
|
|
n, e := strconv.Atoi(v)
|
|
if e != nil || n <= 0 || n > 1440 {
|
|
return 5
|
|
}
|
|
return n
|
|
}
|