mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-11-02 11:11:47 +08:00
feat:首页信息提示
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user