feat:首页信息提示

This commit is contained in:
samwaf
2023-12-25 14:34:01 +08:00
parent 99c8535618
commit 951fd51fe6
10 changed files with 95 additions and 8 deletions
+17
View File
@@ -73,6 +73,23 @@ func (receiver *WafAccountService) GetInfoByLoginAccount(loginAccount string) mo
global.GWAF_LOCAL_DB.Where("login_account=? ", loginAccount).Find(&bean)
return bean
}
/*
*
*/
func (receiver *WafAccountService) IsExistDefaultAccount() bool {
var total int64 = 0
err := global.GWAF_LOCAL_DB.Model(&model.Account{}).Where("login_account=? and login_password =?", global.GWAF_DEFAULT_ACCOUNT, global.GWAF_DEFAULT_ACCOUNT_PWD).Count(&total).Error
if err == nil {
if total > 0 {
return true
} else {
return false
}
} else {
return false
}
}
func (receiver *WafAccountService) GetDetailByIdApi(id string) model.Account {
var bean model.Account
global.GWAF_LOCAL_DB.Where("id=?", id).Find(&bean)
+13
View File
@@ -142,3 +142,16 @@ func (receiver *WafHostService) CheckPortExistApi(port int) int64 {
global.GWAF_LOCAL_DB.Model(&model.Hosts{}).Where("port=?", port).Count(&total)
return total
}
func (receiver *WafHostService) IsEmptyHost() bool {
var total int64 = 0
err := global.GWAF_LOCAL_DB.Model(&model.Hosts{}).Where("global_host=?", 0).Count(&total).Error
if err == nil {
if total == 0 {
return true
} else {
return false
}
} else {
return false
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ func (receiver *WafRuleService) AddApi(wafRuleAddReq request.WafRuleAddReq, rule
IsManualRule: wafRuleAddReq.IsManualRule,
RuleStatus: 1,
}
global.GWAF_LOCAL_DB.Debug().Create(wafRule)
global.GWAF_LOCAL_DB.Create(wafRule)
return nil
}
+5
View File
@@ -120,3 +120,8 @@ func (receiver *WafStatService) StatAnalysisDayCountryRangeApi(req request.WafSt
req.StartDay, req.EndDay, req.AttackType).Select(" country as Name ,sum(count) as Value").Group("country").Order("sum(count) desc").Scan(&CountOfRange)
return CountOfRange
}
// 获取系统基本信息
func (receiver *WafStatService) StatHomeSysinfo() response2.WafHomeSysinfoStat {
return response2.WafHomeSysinfoStat{IsDefaultAccount: WafAccountServiceApp.IsExistDefaultAccount(), IsEmptyHost: WafHostServiceApp.IsEmptyHost()}
}