Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
478ef3ef
Commit
478ef3ef
authored
Jul 07, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://cloud.wodcloud.com/git/smart-operation/so-operation-api
into dev
parents
332200c1
916c21a7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
196 additions
and
42 deletions
+196
-42
src/bean/entity/alert_list.go
src/bean/entity/alert_list.go
+34
-25
src/bean/entity/push_record.go
src/bean/entity/push_record.go
+1
-0
src/bean/entity/system_menu.go
src/bean/entity/system_menu.go
+1
-0
src/bean/vo/request/system_menu.go
src/bean/vo/request/system_menu.go
+1
-0
src/bean/vo/response/alert_list.go
src/bean/vo/response/alert_list.go
+1
-0
src/bean/vo/response/system_menu.go
src/bean/vo/response/system_menu.go
+2
-0
src/service/alert_list.go
src/service/alert_list.go
+153
-16
src/service/system_menu.go
src/service/system_menu.go
+3
-1
No files found.
src/bean/entity/alert_list.go
View file @
478ef3ef
...
...
@@ -5,31 +5,40 @@ import (
)
type
AlertList
struct
{
Id
int
`json:"id"`
// 预警列表ID,主键,自增长
AlertPoint
string
`json:"alert_point"`
// 预警点
AlertRulesId
string
`json:"alert_rules_id"`
// 告警规则id
RiskLevel
int
`json:"risk_level"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
AlertTime
jsontime
.
Time
`json:"alert_time"`
// 预警时间
ClassId
int
`json:"class_id" xorm:"'class_id'"`
// 预警对象id(级联:预警分类/预警对象)
ClassParentName
string
`json:"class_parent_name" xorm:"class_parent_name"`
// 预警分类名称 TODO 该字段做关联存储或查询
ClassName
string
`json:"class_name" xorm:"class_name"`
// 预警对象名称 TODO 该字段做关联存储或查询
MetricConfigId
string
`json:"metric_config_id"`
// 预警指标id // 预警指标
MetricConfigName
string
`json:"metric_config_name" xorm:"metric_config_name"`
// 预警指标名称
AlertRuleType
string
`json:"alert_rule_type" xorm:"alert_rule_type"`
// 预警规则类型id TODO 该字段做关联存储或查询
AlertRuleTypeName
string
`json:"alert_rule_type_name" xorm:"alert_rule_type_name"`
// 预警规则类型名称 TODO 该字段做关联存储或查询
CurrentValue
float64
`json:"current_value"`
// 当前报警值
AlertCondition
string
`json:"alert_condition" xorm:"'alert_condition'"`
// 预警规则(预警阈值) 字典值
NotificationCount
int
`json:"notification_count"`
// 通知人数
PushCount
int
`json:"push_count"`
// 推送次数
LastPushTime
jsontime
.
Time
`json:"last_push_time"`
// 最近推送时间
Status
int
`json:"status"`
// 状态,1:已恢复 2:未恢复 3:已关闭
IsDisposed
int
`json:"is_disposed"`
// 是否处置(工单管理),1:已处置,2:未处置
DisposalContent
string
`json:"disposal_content"`
// 处置内容(工单管理,结果反馈)
CloseRemark
string
`json:"close_remark"`
// 关闭备注,预警关闭提醒
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
UpdatedAt
jsontime
.
Time
`json:"updated_at" xorm:"'updated_at'"`
// 更新时间
Id
int
`json:"id"`
// 预警列表ID,主键,自增长
AlertPoint
string
`json:"alert_point"`
// 预警点
AlertRulesId
string
`json:"alert_rules_id"`
// 告警规则id
RiskLevel
int
`json:"risk_level"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
AlertTime
jsontime
.
Time
`json:"alert_time"`
// 预警时间
ClassId
int
`json:"class_id"`
// 预警对象id(级联:预警分类/预警对象)
ClassParentName
string
`json:"class_parent_name"`
// 预警分类名称 TODO 该字段做关联存储或查询
ClassName
string
`json:"class_name"`
// 预警对象名称 TODO 该字段做关联存储或查询
MetricConfigId
string
`json:"metric_config_id"`
// 预警指标id // 预警指标
MetricConfigName
string
`json:"metric_config_name"`
// 预警指标名称
AlertRuleType
string
`json:"alert_rule_type"`
// 预警规则类型id TODO 该字段做关联存储或查询
AlertRuleTypeName
string
`json:"alert_rule_type_name"`
// 预警规则类型名称 TODO 该字段做关联存储或查询
CurrentValue
float64
`json:"current_value"`
// 当前报警值
AlertCondition
string
`json:"alert_condition" xorm:"'alert_condition'"`
// 预警规则(预警阈值) 字典值
NotificationCount
int
`json:"notification_count"`
// 通知人数
PushCount
int
`json:"push_count"`
// 推送次数
LastPushTime
jsontime
.
Time
`json:"last_push_time"`
// 最近推送时间
Status
int
`json:"status"`
// 状态,1:已恢复 2:未恢复 3:已关闭
DisposedList
[]
DisposedList
`json:"disposed_list"`
// 处置列表
CloseRemark
string
`json:"close_remark"`
// 关闭备注(预警关闭提醒)
CloseUser
string
`json:"close_user"`
// 关闭用户,预警关闭提醒
CloseTime
jsontime
.
Time
`json:"close_time"`
// 关闭关闭时间,预警关闭提醒
DeferPush
int
`json:"defer_push" xorm:"defer_push"`
// 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
UpdatedAt
jsontime
.
Time
`json:"updated_at" xorm:"'updated_at'"`
// 更新时间
}
type
DisposedList
struct
{
IsDisposed
int
`json:"is_disposed"`
// 是否处置(工单管理),1:已处置,2:未处置
DisposalContent
string
`json:"disposal_content"`
// 处置内容(工单管理,结果反馈)
DisposalUser
string
`json:"disposal_user"`
// 处置人(工单管理,结果反馈)
DisposalTime
jsontime
.
Time
`json:"disposal_time"`
// 处置时间(工单管理,结果反馈)
}
func
(
a
*
AlertList
)
TableName
()
string
{
...
...
src/bean/entity/push_record.go
View file @
478ef3ef
...
...
@@ -4,6 +4,7 @@ import "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/json
type
PushRecord
struct
{
Id
int
`json:"id" xorm:"'id' pk autoincr"`
// 主键id
AlertId
int
`json:"alert_id" xorm:"alert_id"`
// 告警id
AlertRulesId
string
`json:"alert_rules_id" xorm:"'alert_rules_id'"`
// 告警规则id
RiskLevel
int
`json:"risk_level" xorm:"'risk_level'"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
NotifyMethod
string
`json:"notify_method" xorm:"'notify_method'"`
// 预警通知方式 dingtalk sms
...
...
src/bean/entity/system_menu.go
View file @
478ef3ef
...
...
@@ -22,4 +22,5 @@ type SystemMenu struct {
Source
string
`json:"source"`
NewWindow
int
`json:"new_window"`
Remark
string
`json:"remark"`
SystemType
string
`json:"system_type"`
//系统类型
}
src/bean/vo/request/system_menu.go
View file @
478ef3ef
...
...
@@ -13,6 +13,7 @@ type SystemMenuReq struct {
Source
string
`json:"source"`
NewWindow
int
`json:"new_window"`
Remark
string
`json:"remark"`
SystemType
string
`json:"system_type"`
//系统类型
}
// 组织排序参数
...
...
src/bean/vo/response/alert_list.go
View file @
478ef3ef
...
...
@@ -7,6 +7,7 @@ import (
type
AlertListItem
struct
{
entity
.
AlertList
`xorm:"extends"`
AlertCondition
entity
.
AlertCondition
`json:"alert_condition" xorm:"alert_condition"`
PushRecords
[]
PushRecordItem
`json:"push_records"`
}
type
AlertListList
struct
{
...
...
src/bean/vo/response/system_menu.go
View file @
478ef3ef
...
...
@@ -22,6 +22,7 @@ type SystemMenuTree struct {
MenuId
string
`json:"menu_id" xorm:"menu_id"`
//菜单id
PMenuId
string
`json:"p_menu_id" xorm:"p_menu_id"`
//上级菜单id
Source
string
`json:"source" xorm:"source"`
//源
SystemType
string
`json:"system_type"`
//系统类型
Child
[]
SystemMenuTree
`xorm:"-"`
}
...
...
@@ -38,5 +39,6 @@ type SystemMenuTreePer struct {
Icon
string
`json:"icon" xorm:"menu_logo"`
//菜单图标
MenuId
string
`json:"menu_id" xorm:"menu_id"`
//菜单id
PMenuId
string
`json:"p_menu_id" xorm:"p_menu_id"`
//上级菜单id
SystemType
string
`json:"system_type"`
//系统类型
Children
[]
SystemMenuTreePer
`json:"children" xorm:"-"`
}
src/service/alert_list.go
View file @
478ef3ef
...
...
@@ -62,22 +62,68 @@ func (a *AlertListSvc) GetDataById(req request.DetailAlertList) (resp response.A
AlertRuleType
:
"51a2cc1e-eb24-4b16-b106-3dc9db963a49"
,
AlertRuleTypeName
:
"%"
,
CurrentValue
:
85
,
AlertCondition
:
""
,
NotificationCount
:
3
,
PushCount
:
3
,
LastPushTime
:
now
,
Status
:
2
,
IsDisposed
:
1
,
DisposalContent
:
"已处置完毕,已做恢复操作"
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
DisposedList
:
[]
entity
.
DisposedList
{
{
IsDisposed
:
1
,
DisposalContent
:
"处置记录"
,
DisposalUser
:
"xiaowang"
,
DisposalTime
:
now
,
},
},
CloseRemark
:
""
,
CloseUser
:
""
,
DeferPush
:
0
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
AlertCondition
:
entity
.
AlertCondition
{
ThresholdsMax
:
100
,
ThresholdsMin
:
80
,
RiskLevel
:
4
,
},
PushRecords
:
[]
response
.
PushRecordItem
{
{
PushRecord
:
entity
.
PushRecord
{
Id
:
1
,
AlertId
:
1
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
1
,
SystemAccount
:
"xiaowang"
,
PushTime
:
now
,
PushType
:
1
,
Status
:
1
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
{
PushRecord
:
entity
.
PushRecord
{
Id
:
2
,
AlertId
:
3
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
2
,
SystemAccount
:
"xiaowang"
,
PushTime
:
now
,
PushType
:
2
,
Status
:
2
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
},
}
resp
=
data
return
...
...
@@ -100,22 +146,74 @@ func (a *AlertListSvc) List(req request.ListAlertList) (resp response.AlertListL
AlertRuleType
:
"51a2cc1e-eb24-4b16-b106-3dc9db963a49"
,
AlertRuleTypeName
:
"%"
,
CurrentValue
:
85
,
AlertCondition
:
""
,
NotificationCount
:
3
,
PushCount
:
3
,
LastPushTime
:
now
,
Status
:
2
,
IsDisposed
:
1
,
DisposalContent
:
"处置为未恢复"
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
Status
:
1
,
DisposedList
:
[]
entity
.
DisposedList
{
{
IsDisposed
:
2
,
DisposalContent
:
"未恢复处置"
,
DisposalUser
:
"xiaozhang"
,
DisposalTime
:
now
,
},
{
IsDisposed
:
1
,
DisposalContent
:
"已恢复处置"
,
DisposalUser
:
"lisi"
,
DisposalTime
:
now
,
},
},
CloseRemark
:
""
,
CloseUser
:
""
,
DeferPush
:
0
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
AlertCondition
:
entity
.
AlertCondition
{
ThresholdsMax
:
100
,
ThresholdsMin
:
80
,
RiskLevel
:
4
,
},
PushRecords
:
[]
response
.
PushRecordItem
{
{
PushRecord
:
entity
.
PushRecord
{
Id
:
1
,
AlertId
:
1
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
1
,
SystemAccount
:
"xiaozhang"
,
PushTime
:
now
,
PushType
:
1
,
Status
:
1
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
{
PushRecord
:
entity
.
PushRecord
{
Id
:
2
,
AlertId
:
3
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
2
,
SystemAccount
:
"xiaowang"
,
PushTime
:
now
,
PushType
:
2
,
Status
:
2
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
},
}
data2
:=
response
.
AlertListItem
{
AlertList
:
entity
.
AlertList
{
...
...
@@ -132,12 +230,15 @@ func (a *AlertListSvc) List(req request.ListAlertList) (resp response.AlertListL
AlertRuleType
:
"51a2cc1e-eb24-4b16-b106-3dc9db963a49"
,
AlertRuleTypeName
:
"%"
,
CurrentValue
:
85
,
AlertCondition
:
""
,
NotificationCount
:
1
,
PushCount
:
1
,
LastPushTime
:
now
,
Status
:
1
,
IsDisposed
:
1
,
DisposalContent
:
"处置内容为已恢复"
,
Status
:
3
,
CloseRemark
:
"关闭备注"
,
CloseUser
:
"xiaowang"
,
CloseTime
:
now
,
DeferPush
:
1
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
...
...
@@ -148,6 +249,42 @@ func (a *AlertListSvc) List(req request.ListAlertList) (resp response.AlertListL
ThresholdsMin
:
50
,
RiskLevel
:
3
,
},
PushRecords
:
[]
response
.
PushRecordItem
{
{
PushRecord
:
entity
.
PushRecord
{
Id
:
1
,
AlertId
:
1
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
1
,
SystemAccount
:
"xiaozhang"
,
PushTime
:
now
,
PushType
:
1
,
Status
:
1
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
{
PushRecord
:
entity
.
PushRecord
{
Id
:
2
,
AlertId
:
3
,
AlertRulesId
:
"47f7a57f-7a67-4876-8c89-ea074d040858"
,
RiskLevel
:
2
,
SystemAccount
:
"xiaowang"
,
PushTime
:
now
,
PushType
:
2
,
Status
:
2
,
CreatedBy
:
"admin"
,
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
},
}
resp
.
List
=
append
(
resp
.
List
,
data1
,
data2
)
resp
.
TotalCount
=
int64
(
len
(
resp
.
List
))
...
...
src/service/system_menu.go
View file @
478ef3ef
...
...
@@ -235,7 +235,7 @@ func (s *SystemMenu) UpdateMenu(id int64, input request.SystemMenuReq) error {
if
!
has
{
return
resp
.
DbSelectError
.
ErrorDetail
(
errors
.
New
(
"该菜单不存在"
))
}
if
_
,
err
:=
db
.
Table
(
"system_menu"
)
.
Cols
(
"menu_name, dict_group_id, state, menu_url, menu_logo, updated_by, updated_time"
,
"source"
,
"new_window"
,
"remark"
)
.
if
_
,
err
:=
db
.
Table
(
"system_menu"
)
.
Cols
(
"menu_name, dict_group_id, state, menu_url, menu_logo, updated_by, updated_time"
,
"source"
,
"new_window"
,
"remark"
,
"system_type"
)
.
Where
(
"id = ?"
,
id
)
.
Update
(
&
entity
.
SystemMenu
{
MenuName
:
input
.
MenuName
,
DictGroupId
:
input
.
DictGroupId
,
...
...
@@ -247,6 +247,7 @@ func (s *SystemMenu) UpdateMenu(id int64, input request.SystemMenuReq) error {
Source
:
input
.
Source
,
NewWindow
:
input
.
NewWindow
,
Remark
:
input
.
Remark
,
SystemType
:
input
.
SystemType
,
});
err
!=
nil
{
conf
.
Logger
.
Error
(
"更新菜单失败"
,
zap
.
Error
(
err
))
return
resp
.
DbUpdateError
.
ErrorDetail
(
err
)
...
...
@@ -348,6 +349,7 @@ func (s *SystemMenu) GetInputToEntityMenu(input request.SystemMenuReq) (res enti
Source
:
input
.
Source
,
NewWindow
:
input
.
NewWindow
,
Remark
:
input
.
Remark
,
SystemType
:
input
.
SystemType
,
}
return
res
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment