增加健康检查定时任务/健康检查可以发送消息

This commit is contained in:
GoEdgeLab
2020-10-20 16:45:03 +08:00
parent bf69a60913
commit 0992fcbee5
17 changed files with 555 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import (
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
)
type SysSettingDAO dbs.DAO
@@ -80,9 +81,9 @@ func (this *SysSettingDAO) UpdateSetting(codeFormat string, valueJSON []byte, co
}
// 读取配置
func (this *SysSettingDAO) ReadSetting(code string, args ...interface{}) (valueJSON []byte, err error) {
if len(args) > 0 {
code = fmt.Sprintf(code, args...)
func (this *SysSettingDAO) ReadSetting(code string, codeFormatArgs ...interface{}) (valueJSON []byte, err error) {
if len(codeFormatArgs) > 0 {
code = fmt.Sprintf(code, codeFormatArgs...)
}
col, err := this.Query().
Attr("code", code).
@@ -90,3 +91,19 @@ func (this *SysSettingDAO) ReadSetting(code string, args ...interface{}) (valueJ
FindStringCol("")
return []byte(col), err
}
// 对比配置中的数字大小
func (this *SysSettingDAO) CompareInt64Setting(code string, anotherValue int64) (int8, error) {
valueJSON, err := this.ReadSetting(code)
if err != nil {
return 0, err
}
value := types.Int64(string(valueJSON))
if value > anotherValue {
return 1, nil
}
if value < anotherValue {
return -1, nil
}
return 0, nil
}