mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-10-31 02:01:44 +08:00
feat:首页信息提示
This commit is contained in:
@@ -9,6 +9,11 @@ import (
|
||||
type WafStatApi struct {
|
||||
}
|
||||
|
||||
// 获取系统基本信息
|
||||
func (w *WafStatApi) StatSysinfoApi(c *gin.Context) {
|
||||
|
||||
response.OkWithDetailed(wafStatService.StatHomeSysinfo(), "获取成功", c)
|
||||
}
|
||||
func (w *WafStatApi) StatHomeSumDayApi(c *gin.Context) {
|
||||
|
||||
wafStat, _ := wafStatService.StatHomeSumDayApi()
|
||||
|
||||
@@ -23,8 +23,14 @@ export function wafstatsumdaytopiprangeapi(params) {
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//首页获取基本信息
|
||||
export function wafStatSysinfoapi(params) {
|
||||
return request({
|
||||
url: 'statsysinfo',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
//【数据分析】查询周期区间国家级别攻击和正常信息
|
||||
export function wafanalysisdaycountryrange(params) {
|
||||
return request({
|
||||
|
||||
@@ -88,7 +88,6 @@ export default {
|
||||
|
||||
window.addEventListener('resize', this.updateContainer, false);
|
||||
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div>
|
||||
<t-alert theme="info" :message="infoMessage" >
|
||||
<t-alert theme="error" :message="defaultAccountMessage" v-if="defaultAccountVisable" >
|
||||
<template #operation>
|
||||
<span @click="handleModifyDefaultPassWebOperation">马上修改</span>
|
||||
</template>
|
||||
</t-alert>
|
||||
<t-alert theme="success" :message="emptyHostMessage" v-if="emptyHostVisable">
|
||||
<template #operation>
|
||||
<span @click="handleCreateWebOperation">马上创建</span>
|
||||
</template>
|
||||
@@ -13,12 +18,14 @@
|
||||
<!-- <rank-list class="row-container" /> -->
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import TopPanel from './components/TopPanel.vue';
|
||||
import MiddleChart from './components/MiddleChart.vue';
|
||||
import RankList from './components/RankList.vue';
|
||||
import OutputOverview from './components/OutputOverview.vue';
|
||||
|
||||
import {
|
||||
wafStatSysinfoapi
|
||||
} from '@/apis/stats';
|
||||
export default {
|
||||
name: 'DashboardBase',
|
||||
components: {
|
||||
@@ -31,9 +38,15 @@ export default {
|
||||
return {
|
||||
center: {lng: 0, lat: 0},
|
||||
zoom: 3,
|
||||
infoMessage:"您当前未创建需要防护的网站,点击进行创建"
|
||||
emptyHostMessage:"您当前未创建需要防护的网站,点击进行创建",
|
||||
emptyHostVisable: false,
|
||||
defaultAccountMessage:"您当前还是使用默认帐号和密码请尽快修改",
|
||||
defaultAccountVisable:false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadSysInfo()
|
||||
},
|
||||
methods: {
|
||||
handler ({BMap, map}) {
|
||||
console.log(BMap, map)
|
||||
@@ -51,6 +64,25 @@ export default {
|
||||
},
|
||||
},
|
||||
);
|
||||
},//引导修改默认密码
|
||||
handleModifyDefaultPassWebOperation(){
|
||||
this.$router.push(
|
||||
{
|
||||
path: '/account/Account',
|
||||
query: {
|
||||
sourcePage: "HomeFrist",
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
loadSysInfo(){
|
||||
wafStatSysinfoapi({}).then((res)=>{
|
||||
console.log("home res",res.data)
|
||||
this.defaultAccountVisable = res.data.is_default_account
|
||||
this.emptyHostVisable = res.data.is_empty_host
|
||||
} ).catch((e: Error) => {
|
||||
console.log(e);
|
||||
}).finally(() => {})
|
||||
},
|
||||
//end method
|
||||
},
|
||||
|
||||
@@ -39,3 +39,12 @@ type WafAnalysisDayStats struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
Value int64 `json:"value" form:"value"`
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
首页 获取系统基本信息
|
||||
*/
|
||||
type WafHomeSysinfoStat struct {
|
||||
IsDefaultAccount bool `json:"is_default_account" form:"is_default_account"`
|
||||
IsEmptyHost bool `json:"is_empty_host" form:"is_empty_host"`
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ func (receiver *StatRouter) InitStatRouter(group *gin.RouterGroup) {
|
||||
router.GET("/samwaf/wafstatsumday", statApi.StatHomeSumDayApi)
|
||||
router.GET("/samwaf/wafstatsumdayrange", statApi.StatHomeSumDayRangeApi)
|
||||
router.GET("/samwaf/wafstatsumdaytopiprange", statApi.StatHomeSumDayTopIPRangeApi)
|
||||
router.GET("/samwaf/statsysinfo", statApi.StatSysinfoApi)
|
||||
|
||||
//数据分析
|
||||
router.GET("/samwaf/wafanalysisdaycountryrange", statApi.StatAnalysisDayCountryRangeApi)
|
||||
|
||||
@@ -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