✨ 新增几大中心功能
This commit is contained in:
30
server/service/system/app_online_config.go
Normal file
30
server/service/system/app_online_config.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user