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
498bfc45
Commit
498bfc45
authored
Jul 20, 2023
by
李科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完善批量推送逻辑
parent
0de4349f
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
256 additions
and
96 deletions
+256
-96
src/bean/entity/alert.go
src/bean/entity/alert.go
+36
-28
src/bean/entity/push_record.go
src/bean/entity/push_record.go
+3
-1
src/bean/vo/request/alert.go
src/bean/vo/request/alert.go
+7
-5
src/bean/vo/response/alert.go
src/bean/vo/response/alert.go
+1
-3
src/bean/vo/response/push_record.go
src/bean/vo/response/push_record.go
+0
-1
src/controller/alert.go
src/controller/alert.go
+1
-7
src/service/alert.go
src/service/alert.go
+204
-48
src/service/push_record.go
src/service/push_record.go
+4
-3
No files found.
src/bean/entity/alert.go
View file @
498bfc45
...
...
@@ -19,17 +19,19 @@ type Alert struct {
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'"`
// 预警规则(预警阈值) 字典值
AlertCondition
AlertCondition
`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:已关闭
PushRecords
[]
PushRecord
`json:"push_records"`
DisposedList
[]
DisposedList
`json:"disposed_list"`
// 处置列表
IsDisposed
int
`json:"is_disposed"`
// 是否处置(工单管理),1:已处置,2:未处置 通过DisposedList逻辑处理回显
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'"`
// 更新人
...
...
@@ -43,6 +45,12 @@ type DisposedList struct {
DisposalTime
jsontime
.
Time
`json:"disposal_time"`
// 处置时间(工单管理,结果反馈)
}
type
OpenSearchIds
struct
{
Ids
struct
{
Values
[]
string
`json:"values"`
}
`json:"ids"`
}
func
(
a
*
Alert
)
TableName
()
string
{
return
"alert"
}
src/bean/entity/push_record.go
View file @
498bfc45
...
...
@@ -7,11 +7,13 @@ type PushRecord struct {
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
NotifyMethod
[]
string
`json:"notify_method" xorm:"notify_method"`
// 预警通知方式 dingtalk sms
SystemAccount
string
`json:"system_account" xorm:"system_account"`
// 预警推送用户
PushTime
jsontime
.
Time
`json:"push_time" xorm:"'push_time'"`
// 推送时间
PushType
int
`json:"push_type" xorm:"'push_type'"`
// 推送类型,1:自动推送,2:手动推送
Status
int
`json:"status" xorm:"'status'"`
// 推送状态,1:成功,2:失败
UserName
string
`json:"user_name" xorm:"user_name"`
// 推送用户名称
Phone
string
`json:"phone" xorm:"phone"`
// 推送手机号
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'"`
// 更新人
...
...
src/bean/vo/request/alert.go
View file @
498bfc45
...
...
@@ -16,6 +16,7 @@ type UpdateAlert struct {
RiskLevel
int
`json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
Status
int
`json:"status" form:"status" binding:"omitempty,oneof=1 2 3"`
// 状态,1:已恢复 2:未恢复 3:已关闭
DisposalContent
string
`json:"disposal_content" form:"disposal_content"`
// 处置内容(工单管理,结果反馈)
PushRecords
[]
entity
.
PushRecord
`json:"push_records" form:"push_records"`
}
type
BatchPushAlert
struct
{
...
...
@@ -34,6 +35,7 @@ type BatchCloseAlert struct {
type
ListAlert
struct
{
Id
int
`json:"id" form:"id"`
Ids
[]
int
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
RiskLevel
int
`json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
Status
int
`json:"status" form:"status" binding:"omitempty,oneof=1 2 3"`
// 状态,1:已恢复 2:未恢复 3:已关闭
Keyword
string
`json:"keyword" form:"keyword"`
// 预警点/分类/指标
...
...
src/bean/vo/response/alert.go
View file @
498bfc45
...
...
@@ -6,8 +6,6 @@ import (
type
AlertItem
struct
{
entity
.
Alert
`xorm:"extends"`
AlertCondition
entity
.
AlertCondition
`json:"alert_condition" xorm:"alert_condition"`
PushRecords
[]
PushRecordItem
`json:"push_records"`
}
type
AlertList
struct
{
...
...
src/bean/vo/response/push_record.go
View file @
498bfc45
...
...
@@ -4,7 +4,6 @@ import "gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/entity"
type
PushRecordItem
struct
{
entity
.
PushRecord
`xorm:"extends"`
NotifyMethod
[]
string
`json:"notify_method" xorm:"notify_method"`
// 预警通知方式 dingtalk sms
}
type
PushRecordList
struct
{
...
...
src/controller/alert.go
View file @
498bfc45
...
...
@@ -3,7 +3,6 @@ package controller
import
(
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
...
...
@@ -33,12 +32,7 @@ func BatchPushAlert(c *gin.Context) {
}
svc
:=
service
.
AlertSvc
{
User
:
header
.
GetUser
(
c
)}
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
DbConnectError
.
WithError
(
err
),
nil
)
return
}
err
=
svc
.
BatchPushAlert
(
db
.
NewSession
(),
req
)
err
:=
svc
.
BatchPushAlert
(
req
)
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
FAIL
.
WithError
(
err
),
nil
)
return
...
...
src/service/alert.go
View file @
498bfc45
This diff is collapsed.
Click to expand it.
src/service/push_record.go
View file @
498bfc45
...
...
@@ -49,8 +49,10 @@ func (m *PushRecordSvc) GetDataById(req request.DetailPushRecord) (resp response
data
:=
response
.
PushRecordItem
{
PushRecord
:
entity
.
PushRecord
{
Id
:
1
,
AlertId
:
1
,
AlertRulesId
:
"83343ef6-4a99-47bd-abb4-bcff52feb2ec"
,
RiskLevel
:
1
,
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
SystemAccount
:
"xiaowang"
,
PushTime
:
now
,
PushType
:
1
,
...
...
@@ -60,7 +62,6 @@ func (m *PushRecordSvc) GetDataById(req request.DetailPushRecord) (resp response
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
}
resp
=
data
return
...
...
@@ -81,8 +82,8 @@ func (m *PushRecordSvc) List(req request.ListPushRecord) (resp response.PushReco
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
}
data2
:=
response
.
PushRecordItem
{
PushRecord
:
entity
.
PushRecord
{
...
...
@@ -97,8 +98,8 @@ func (m *PushRecordSvc) List(req request.ListPushRecord) (resp response.PushReco
CreatedAt
:
now
,
UpdatedBy
:
"admin"
,
UpdatedAt
:
now
,
},
NotifyMethod
:
[]
string
{
"dingtalk"
,
"sms"
},
},
}
resp
.
List
=
append
(
resp
.
List
,
data1
,
data2
)
resp
.
TotalCount
=
int64
(
len
(
resp
.
List
))
...
...
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