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
64e49181
Commit
64e49181
authored
Jul 20, 2023
by
李科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完善批量关闭预警
parent
d3cc2651
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
34 deletions
+38
-34
src/bean/vo/request/alert.go
src/bean/vo/request/alert.go
+13
-13
src/controller/alert.go
src/controller/alert.go
+1
-6
src/service/alert.go
src/service/alert.go
+24
-15
No files found.
src/bean/vo/request/alert.go
View file @
64e49181
...
@@ -10,7 +10,7 @@ type DetailAlert struct {
...
@@ -10,7 +10,7 @@ type DetailAlert struct {
type
UpdateAlert
struct
{
type
UpdateAlert
struct
{
Id
int
`json:"id" form:"id" binding:"required"`
Id
int
`json:"id" form:"id" binding:"required"`
Ids
[]
string
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
//Ids []int
`json:"ids" form:"ids" binding:"required_without=Id"` // 预警ids
CloseRemark
string
`json:"close_remark" form:"close_remark"`
// 关闭备注
CloseRemark
string
`json:"close_remark" form:"close_remark"`
// 关闭备注
DeferPush
int
`json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"`
// 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
DeferPush
int
`json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"`
// 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
RiskLevel
int
`json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
RiskLevel
int
`json:"risk_level" form:"risk_level" binding:"omitempty,oneof=1 2 3 4"`
// 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
...
@@ -19,15 +19,15 @@ type UpdateAlert struct {
...
@@ -19,15 +19,15 @@ type UpdateAlert struct {
}
}
type
BatchPushAlert
struct
{
type
BatchPushAlert
struct
{
Id
string
`json:"id" form:"id"`
Id
int
`json:"id" form:"id"`
Ids
[]
string
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
Ids
[]
int
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
NotifyMethod
[]
string
`json:"notify_method" form:"notify_method" binding:"max=2,dive,oneof=dingtalk sms"`
// 预警通知方式 dingtalk sms
NotifyMethod
[]
string
`json:"notify_method" form:"notify_method" binding:"max=2,dive,oneof=dingtalk sms"`
// 预警通知方式 dingtalk sms
NotifyRecipients
[]
entity
.
NotifyRecipients
`json:"notify_recipients" form:"notify_recipients" binding:"dive"`
// 预警推送用户
NotifyRecipients
[]
entity
.
NotifyRecipients
`json:"notify_recipients" form:"notify_recipients" binding:"dive"`
// 预警推送用户
}
}
type
BatchCloseAlert
struct
{
type
BatchCloseAlert
struct
{
Id
string
`json:"id" form:"id"`
Id
int
`json:"id" form:"id"`
Ids
[]
string
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
Ids
[]
int
`json:"ids" form:"ids" binding:"required_without=Id"`
// 预警ids
CloseRemark
string
`json:"close_remark" form:"close_remark" binding:"required"`
// 关闭备注
CloseRemark
string
`json:"close_remark" form:"close_remark" binding:"required"`
// 关闭备注
DeferPush
int
`json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"`
// 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
DeferPush
int
`json:"defer_push" form:"defer_push" binding:"omitempty,oneof=0 1"`
// 延迟三天推送: 0:否 1:是 三天内将不再自动推送该告警信息给处置人员,可手动推送,但告警数据依然会出现
}
}
...
...
src/controller/alert.go
View file @
64e49181
...
@@ -54,12 +54,7 @@ func BatchCloseAlert(c *gin.Context) {
...
@@ -54,12 +54,7 @@ func BatchCloseAlert(c *gin.Context) {
}
}
svc
:=
service
.
AlertSvc
{
User
:
header
.
GetUser
(
c
)}
svc
:=
service
.
AlertSvc
{
User
:
header
.
GetUser
(
c
)}
db
,
err
:=
client
.
GetDbClient
()
err
:=
svc
.
BatchCloseAlert
(
req
)
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
DbConnectError
.
WithError
(
err
),
nil
)
return
}
err
=
svc
.
BatchCloseAlert
(
db
.
NewSession
(),
req
)
if
err
!=
nil
{
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
FAIL
.
WithError
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
FAIL
.
WithError
(
err
),
nil
)
return
return
...
...
src/service/alert.go
View file @
64e49181
...
@@ -336,6 +336,7 @@ func (a *AlertSvc) IndexUpdate(req request.UpdateAlert) (err error) {
...
@@ -336,6 +336,7 @@ func (a *AlertSvc) IndexUpdate(req request.UpdateAlert) (err error) {
if
req
.
Status
!=
0
{
if
req
.
Status
!=
0
{
doc
[
"status"
]
=
req
.
Status
doc
[
"status"
]
=
req
.
Status
}
}
doc
[
"updated_at"
]
=
now
if
req
.
DisposalContent
!=
""
{
if
req
.
DisposalContent
!=
""
{
var
detailAlert
response
.
AlertItem
var
detailAlert
response
.
AlertItem
...
@@ -409,23 +410,31 @@ func (a *AlertSvc) BatchPushAlert(session *xorm.Session, req request.BatchPushAl
...
@@ -409,23 +410,31 @@ func (a *AlertSvc) BatchPushAlert(session *xorm.Session, req request.BatchPushAl
return
nil
return
nil
}
}
func
(
a
*
AlertSvc
)
BatchCloseAlert
(
session
*
xorm
.
Session
,
req
request
.
BatchCloseAlert
)
(
err
error
)
{
func
(
a
*
AlertSvc
)
BatchCloseAlert
(
req
request
.
BatchCloseAlert
)
(
err
error
)
{
var
(
if
len
(
req
.
Ids
)
>
0
{
sources
response
.
OpenSearchSource
for
_
,
id
:=
range
req
.
Ids
{
)
err
=
a
.
IndexUpdate
(
request
.
UpdateAlert
{
Id
:
id
,
cli
,
err
:=
client
.
GetOpenSearch
()
CloseRemark
:
req
.
CloseRemark
,
Status
:
3
,
})
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
_
=
sources
}
_
=
cli
}
else
{
err
=
a
.
IndexUpdate
(
request
.
UpdateAlert
{
now
:=
jsontime
.
Now
()
Id
:
req
.
Id
,
_
=
now
CloseRemark
:
req
.
CloseRemark
,
// TODO 批量推送用户告警
DeferPush
:
req
.
DeferPush
,
Status
:
3
,
})
if
err
!=
nil
{
return
}
}
conf
.
Logger
.
Info
(
"batch close"
,
zap
.
Any
(
"payload"
,
req
))
conf
.
Logger
.
Info
(
"batch close"
,
zap
.
Any
(
"payload"
,
req
))
return
nil
return
}
}
func
(
a
*
AlertSvc
)
GetDataById
(
req
request
.
DetailAlert
)
(
resp
response
.
AlertItem
,
err
error
)
{
func
(
a
*
AlertSvc
)
GetDataById
(
req
request
.
DetailAlert
)
(
resp
response
.
AlertItem
,
err
error
)
{
...
...
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