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
3ee9feb2
You need to sign in or sign up before continuing.
Commit
3ee9feb2
authored
Jul 27, 2023
by
李科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 数据来源字段
parent
ab73f082
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
48 additions
and
40 deletions
+48
-40
src/bean/entity/alert_class.go
src/bean/entity/alert_class.go
+9
-9
src/bean/entity/alert_webhook.go
src/bean/entity/alert_webhook.go
+0
-7
src/bean/entity/metric_config.go
src/bean/entity/metric_config.go
+1
-1
src/bean/vo/request/alert_class.go
src/bean/vo/request/alert_class.go
+4
-4
src/bean/vo/request/metric_config.go
src/bean/vo/request/metric_config.go
+2
-2
src/main.go
src/main.go
+3
-3
src/pkg/beagle/constant/constant.go
src/pkg/beagle/constant/constant.go
+6
-0
src/service/alert_class.go
src/service/alert_class.go
+8
-4
src/service/alert_overview.go
src/service/alert_overview.go
+1
-1
src/service/alert_rules.go
src/service/alert_rules.go
+10
-9
src/service/metric_config.go
src/service/metric_config.go
+4
-0
No files found.
src/bean/entity/alert_class.go
View file @
3ee9feb2
...
@@ -3,15 +3,15 @@ package entity
...
@@ -3,15 +3,15 @@ package entity
import
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
import
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
type
AlertClass
struct
{
type
AlertClass
struct
{
ClassId
int
`json:"class_id" xorm:"'class_id' pk autoincr"`
// 主键id
ClassId
int
`json:"class_id" xorm:"'class_id' pk autoincr"`
// 主键id
ClassName
string
`json:"class_name" xorm:"'class_name'"`
// 分类名称
ClassName
string
`json:"class_name" xorm:"'class_name'"`
// 分类名称
ParentId
int
`json:"parent_id" xorm:"'parent_id'"`
// 父级id
ParentId
int
`json:"parent_id" xorm:"'parent_id'"`
// 父级id
SortOrder
int
`json:"sort_order" xorm:"'sort_order'"`
// 排序
SortOrder
int
`json:"sort_order" xorm:"'sort_order'"`
// 排序
Source
From
int
`json:"source_from" xorm:"source_from"`
// 数据来源 1:默认 2:自定义
Source
int
`json:"source" xorm:"source"`
// 数据来源 1:默认 2:自定义
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
UpdatedAt
jsontime
.
Time
`json:"updated_at" xorm:"'updated_at'"`
// 更新时间
UpdatedAt
jsontime
.
Time
`json:"updated_at" xorm:"'updated_at'"`
// 更新时间
}
}
func
(
m
*
AlertClass
)
TableName
()
string
{
func
(
m
*
AlertClass
)
TableName
()
string
{
...
...
src/bean/entity/alert_webhook.go
deleted
100644 → 0
View file @
ab73f082
package
entity
import
(
"github.com/prometheus/alertmanager/notify/webhook"
)
type
Message
webhook
.
Message
src/bean/entity/metric_config.go
View file @
3ee9feb2
...
@@ -13,7 +13,7 @@ type MetricConfig struct {
...
@@ -13,7 +13,7 @@ type MetricConfig struct {
CheckPeriod
int
`json:"check_period" xorm:"'check_period'"`
// 检查周期 单位:分钟
CheckPeriod
int
`json:"check_period" xorm:"'check_period'"`
// 检查周期 单位:分钟
IsEnabled
int
`json:"is_enabled" xorm:"'is_enabled'"`
// 是否开启 1:是 2:否
IsEnabled
int
`json:"is_enabled" xorm:"'is_enabled'"`
// 是否开启 1:是 2:否
AlertRuleType
string
`json:"alert_rule_type" xorm:"'alert_rule_type'"`
// 预警规则类型 关联字典表
AlertRuleType
string
`json:"alert_rule_type" xorm:"'alert_rule_type'"`
// 预警规则类型 关联字典表
Source
From
int
`json:"source_from" xorm:"source_from"`
// 数据来源 1:默认 2:自定义
Source
int
`json:"source" xorm:"source"`
// 数据来源 1:默认 2:自定义
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedBy
string
`json:"created_by" xorm:"'created_by'"`
// 创建人
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
CreatedAt
jsontime
.
Time
`json:"created_at" xorm:"'created_at'"`
// 创建时间
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
UpdatedBy
string
`json:"updated_by" xorm:"'updated_by'"`
// 更新人
...
...
src/bean/vo/request/alert_class.go
View file @
3ee9feb2
package
request
package
request
type
AddAlertClass
struct
{
type
AddAlertClass
struct
{
ClassName
string
`json:"class_name" form:"class_name" binding:"required"`
ClassName
string
`json:"class_name" form:"class_name" binding:"required"`
ParentId
int
`json:"parent_id" form:"parent_id" binding:"omitempty,oneof=0 1"`
ParentId
int
`json:"parent_id" form:"parent_id" binding:"omitempty,oneof=0 1"`
SortOrder
int
`json:"sort_order" form:"sort_order"`
SortOrder
int
`json:"sort_order" form:"sort_order"`
Source
From
int
`json:"source_from" form:"source_from
" binding:"omitempty,oneof=1 2"`
// 数据来源 1:默认 2:自定义
Source
int
`json:"source" form:"source
" binding:"omitempty,oneof=1 2"`
// 数据来源 1:默认 2:自定义
}
}
type
UpdateAlertClass
struct
{
type
UpdateAlertClass
struct
{
...
...
src/bean/vo/request/metric_config.go
View file @
3ee9feb2
...
@@ -12,7 +12,7 @@ type AddMetricConfig struct {
...
@@ -12,7 +12,7 @@ type AddMetricConfig struct {
CheckPeriod
int
`json:"check_period" form:"check_period" binding:"oneof=1 3 5 10 20 30"`
// 检查周期 单位:分钟
CheckPeriod
int
`json:"check_period" form:"check_period" binding:"oneof=1 3 5 10 20 30"`
// 检查周期 单位:分钟
IsEnabled
int
`json:"is_enabled" form:"is_enabled" binding:"omitempty,oneof=1 2"`
// 是否开启 1:是 2:否
IsEnabled
int
`json:"is_enabled" form:"is_enabled" binding:"omitempty,oneof=1 2"`
// 是否开启 1:是 2:否
AlertRuleType
string
`json:"alert_rule_type" form:"alert_rule_type" binding:"required"`
// 预警规则类型 关联字典表
AlertRuleType
string
`json:"alert_rule_type" form:"alert_rule_type" binding:"required"`
// 预警规则类型 关联字典表
Source
From
int
`json:"source_from" form:"source_from" binding:"omitempty,oneof=1 2"`
// 数据来源
1:默认 2:自定义
Source
int
`json:"source" form:"source" binding:"omitempty,oneof=1 2"`
// 数据来源(自定义为非正常数据)
1:默认 2:自定义
}
}
type
UpdateMetricConfig
struct
{
type
UpdateMetricConfig
struct
{
...
@@ -26,7 +26,7 @@ type UpdateMetricConfig struct {
...
@@ -26,7 +26,7 @@ type UpdateMetricConfig struct {
CheckPeriod
int
`json:"check_period" form:"check_period" binding:"omitempty,oneof=1 3 5 10 20 30"`
// 检查周期 单位:分钟
CheckPeriod
int
`json:"check_period" form:"check_period" binding:"omitempty,oneof=1 3 5 10 20 30"`
// 检查周期 单位:分钟
IsEnabled
int
`json:"is_enabled" form:"is_enabled" binding:"omitempty,oneof=1 2"`
// 是否开启 1:是 2:否
IsEnabled
int
`json:"is_enabled" form:"is_enabled" binding:"omitempty,oneof=1 2"`
// 是否开启 1:是 2:否
AlertRuleType
string
`json:"alert_rule_type" form:"alert_rule_type"`
// 预警规则类型 关联字典表
AlertRuleType
string
`json:"alert_rule_type" form:"alert_rule_type"`
// 预警规则类型 关联字典表
Source
From
int
`json:"source_from" form:"source_from" binding:"omitempty,oneof=1 2"`
// 数据来源 1:默认 2:自定义
Source
int
`json:"source" form:"source" binding:"omitempty,oneof=1 2"`
// 数据来源 1:默认 2:自定义
}
}
type
DeleteMetricConfig
struct
{
type
DeleteMetricConfig
struct
{
...
...
src/main.go
View file @
3ee9feb2
...
@@ -90,9 +90,9 @@ func initConfig() {
...
@@ -90,9 +90,9 @@ func initConfig() {
SmsSignName
:
util
.
SetEnvStr
(
"SMS_SIGN_NAME"
,
"比格数据"
),
// 签名
SmsSignName
:
util
.
SetEnvStr
(
"SMS_SIGN_NAME"
,
"比格数据"
),
// 签名
AweRestURL
:
util
.
SetEnvStr
(
"AWE_REST_URL"
,
"http://awecloud-rest.beagle-system/awecloud/rest"
),
// awecloud-rest
AweRestURL
:
util
.
SetEnvStr
(
"AWE_REST_URL"
,
"http://awecloud-rest.beagle-system/awecloud/rest"
),
// awecloud-rest
KubernetesToken
:
util
.
SetEnvStr
(
"AWE_REST_K8S_TOKEN"
,
"eyJhbGciOiJSUzI1NiIsImtpZCI6InJ1alJzNEVGamN5UC0wRU1rS1BKQ0JZVUtNNWpzR0t2bmlrSlJhY2Q3R00ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJiZWFnbGUtc3lzdGVtIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InJvb3QiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoicm9vdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjRlMDM0OTI3LTc0ZTMtNDQ5Yy1hN2RlLWExMGE3MjU1NGYyMCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpiZWFnbGUtc3lzdGVtOnJvb3QifQ.YPLE_E2kIeo-YFQtKScBt5p4KhnniJF9n3iWN2i9UMYS06lIsq2-2wBrgON-YsJihWJupYyDQRiZ9h8bUWTrQzhnpsnuJ_aUclKyAw3QOT9rjvZhJp7qP--27dmdspSHncKtvIiprWE7UTUKzvF33WsMB0fSYFqYXOggNFMoT-fXmWwUXjgar3op0iOl3c3deJ_GeBzFyLSHEuGM7OVdjU8032aUmTen0Kji_P1yB4-O3Iqd0OdVs33BQy_tycjbxhQ8TDEpqrqhLnXjAwJCprLDEpFMx7ODZbjB9Wmuns8yJhaRDxTO47rTME7ZIAxjZ-zLR_QybtW97rlwnUTaNw"
),
KubernetesToken
:
util
.
SetEnvStr
(
"AWE_REST_K8S_TOKEN"
,
"eyJhbGciOiJSUzI1NiIsImtpZCI6InJ1alJzNEVGamN5UC0wRU1rS1BKQ0JZVUtNNWpzR0t2bmlrSlJhY2Q3R00ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJiZWFnbGUtc3lzdGVtIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InJvb3QiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoicm9vdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjRlMDM0OTI3LTc0ZTMtNDQ5Yy1hN2RlLWExMGE3MjU1NGYyMCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpiZWFnbGUtc3lzdGVtOnJvb3QifQ.YPLE_E2kIeo-YFQtKScBt5p4KhnniJF9n3iWN2i9UMYS06lIsq2-2wBrgON-YsJihWJupYyDQRiZ9h8bUWTrQzhnpsnuJ_aUclKyAw3QOT9rjvZhJp7qP--27dmdspSHncKtvIiprWE7UTUKzvF33WsMB0fSYFqYXOggNFMoT-fXmWwUXjgar3op0iOl3c3deJ_GeBzFyLSHEuGM7OVdjU8032aUmTen0Kji_P1yB4-O3Iqd0OdVs33BQy_tycjbxhQ8TDEpqrqhLnXjAwJCprLDEpFMx7ODZbjB9Wmuns8yJhaRDxTO47rTME7ZIAxjZ-zLR_QybtW97rlwnUTaNw"
),
OpenSearchAddresses
:
util
.
SetEnvStr
(
"Open_Search_Addresses"
,
"https://so-opensearch.wodcloud.com"
),
//
短信验证码模板
OpenSearchAddresses
:
util
.
SetEnvStr
(
"Open_Search_Addresses"
,
"https://so-opensearch.wodcloud.com"
),
//
OpenSearch连接地址
OpenSearchUserName
:
util
.
SetEnvStr
(
"Open_Search_User_Name"
,
""
),
//
短信验证码模板
OpenSearchUserName
:
util
.
SetEnvStr
(
"Open_Search_User_Name"
,
""
),
//
OpenSearch用户名
OpenSearchPassword
:
util
.
SetEnvStr
(
"Open_Search_Password"
,
""
),
//
短信验证码模板
OpenSearchPassword
:
util
.
SetEnvStr
(
"Open_Search_Password"
,
""
),
//
OpenSearch密码
}
}
}
}
...
...
src/pkg/beagle/constant/constant.go
View file @
3ee9feb2
...
@@ -123,6 +123,12 @@ var OpTypeIntMap = map[OpType]int{
...
@@ -123,6 +123,12 @@ var OpTypeIntMap = map[OpType]int{
Export
:
14
,
Export
:
14
,
}
}
// 数据来源(自定义为非正常数据) 1:默认 2:自定义
const
(
SourceDefault
=
1
SourceCustom
=
2
)
// RiskLevel 风险等级
// RiskLevel 风险等级
const
(
const
(
RiskLevelLow
=
iota
+
1
// 1:低风险
RiskLevelLow
=
iota
+
1
// 1:低风险
...
...
src/service/alert_class.go
View file @
3ee9feb2
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/constant"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"sort"
"sort"
...
@@ -26,6 +27,9 @@ func (a *AlertClassSvc) Add(session *xorm.Session, req request.AddAlertClass) (c
...
@@ -26,6 +27,9 @@ func (a *AlertClassSvc) Add(session *xorm.Session, req request.AddAlertClass) (c
UpdatedBy
:
a
.
User
.
SystemAccount
,
UpdatedBy
:
a
.
User
.
SystemAccount
,
UpdatedAt
:
now
,
UpdatedAt
:
now
,
}
}
if
req
.
Source
!=
constant
.
SourceCustom
{
req
.
Source
=
constant
.
SourceDefault
}
_
=
copier
.
Copy
(
&
data
,
&
req
)
_
=
copier
.
Copy
(
&
data
,
&
req
)
var
max
int
var
max
int
...
@@ -66,7 +70,7 @@ func (a *AlertClassSvc) Move(req request.MoveAlertClass) (err error) {
...
@@ -66,7 +70,7 @@ func (a *AlertClassSvc) Move(req request.MoveAlertClass) (err error) {
_
=
copier
.
Copy
(
&
data
,
&
req
)
_
=
copier
.
Copy
(
&
data
,
&
req
)
var
list
[]
entity
.
AlertClass
var
list
[]
entity
.
AlertClass
_
,
err
=
db
.
NewSession
()
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
.
Get
(
&
data
)
_
,
err
=
db
.
NewSession
()
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
.
Get
(
&
data
)
err
=
db
.
NewSession
()
.
Where
(
"parent_id = ?"
,
data
.
ParentId
)
.
Where
(
"source
_from
= 1"
)
.
OrderBy
(
"sort_order asc"
)
.
Find
(
&
list
)
err
=
db
.
NewSession
()
.
Where
(
"parent_id = ?"
,
data
.
ParentId
)
.
Where
(
"source = 1"
)
.
OrderBy
(
"sort_order asc"
)
.
Find
(
&
list
)
var
previousIndex
int
var
previousIndex
int
var
nextIndex
int
var
nextIndex
int
for
i
:=
0
;
i
<
len
(
list
);
i
++
{
for
i
:=
0
;
i
<
len
(
list
);
i
++
{
...
@@ -139,7 +143,7 @@ func (a *AlertClassSvc) List(req request.ListAlertClass) (resp response.AlertCla
...
@@ -139,7 +143,7 @@ func (a *AlertClassSvc) List(req request.ListAlertClass) (resp response.AlertCla
}
}
session
:=
db
.
NewSession
()
session
:=
db
.
NewSession
()
defer
session
.
Close
()
defer
session
.
Close
()
session
.
Where
(
"source
_from
= 1"
)
session
.
Where
(
"source = 1"
)
if
req
.
ClassId
!=
0
{
if
req
.
ClassId
!=
0
{
session
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
session
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
}
}
...
@@ -159,7 +163,7 @@ func (a *AlertClassSvc) Tree(req request.ListAlertClass) (resp []*response.Alert
...
@@ -159,7 +163,7 @@ func (a *AlertClassSvc) Tree(req request.ListAlertClass) (resp []*response.Alert
session
:=
db
.
NewSession
()
session
:=
db
.
NewSession
()
defer
session
.
Close
()
defer
session
.
Close
()
var
list
[]
entity
.
AlertClass
var
list
[]
entity
.
AlertClass
session
.
Where
(
"source
_from
= 1"
)
session
.
Where
(
"source = 1"
)
_
,
err
=
session
.
OrderBy
(
"sort_order"
)
.
FindAndCount
(
&
list
)
_
,
err
=
session
.
OrderBy
(
"sort_order"
)
.
FindAndCount
(
&
list
)
// TODO 对req进行过滤
// TODO 对req进行过滤
resp
,
err
=
AlertClassTree
(
list
)
resp
,
err
=
AlertClassTree
(
list
)
...
@@ -211,7 +215,7 @@ func (a *AlertClassSvc) SortOrderMax(parentId int) (max int, err error) {
...
@@ -211,7 +215,7 @@ func (a *AlertClassSvc) SortOrderMax(parentId int) (max int, err error) {
}
}
_
,
err
=
db
.
NewSession
()
.
Table
(
new
(
entity
.
AlertClass
))
.
_
,
err
=
db
.
NewSession
()
.
Table
(
new
(
entity
.
AlertClass
))
.
Select
(
"max(sort_order)"
)
.
Select
(
"max(sort_order)"
)
.
Where
(
"parent_id = ?"
,
parentId
)
.
Where
(
"source
_from
= 1"
)
.
Get
(
&
max
)
Where
(
"parent_id = ?"
,
parentId
)
.
Where
(
"source = 1"
)
.
Get
(
&
max
)
return
return
}
}
...
...
src/service/alert_overview.go
View file @
3ee9feb2
...
@@ -247,7 +247,7 @@ func (a *AlertOverviewSvc) List(req request.ListAlertOverview) (resp response.Al
...
@@ -247,7 +247,7 @@ func (a *AlertOverviewSvc) List(req request.ListAlertOverview) (resp response.Al
}
}
session
:=
db
.
NewSession
()
session
:=
db
.
NewSession
()
defer
session
.
Close
()
defer
session
.
Close
()
session
.
Where
(
"source
_from
= 1"
)
session
.
Where
(
"source = 1"
)
if
req
.
ClassId
!=
0
{
if
req
.
ClassId
!=
0
{
session
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
session
.
Where
(
"class_id = ?"
,
req
.
ClassId
)
}
}
...
...
src/service/alert_rules.go
View file @
3ee9feb2
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/constant"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
...
@@ -56,18 +57,18 @@ func (a *AlertRulesSvc) Add(req request.AddAlertRules) (err error) {
...
@@ -56,18 +57,18 @@ func (a *AlertRulesSvc) Add(req request.AddAlertRules) (err error) {
alertClassSvc
:=
AlertClassSvc
{
User
:
a
.
User
}
alertClassSvc
:=
AlertClassSvc
{
User
:
a
.
User
}
classParentId
,
err
=
alertClassSvc
.
Add
(
session
,
request
.
AddAlertClass
{
classParentId
,
err
=
alertClassSvc
.
Add
(
session
,
request
.
AddAlertClass
{
ClassName
:
req
.
ClassParentName
,
ClassName
:
req
.
ClassParentName
,
SortOrder
:
-
1
,
SortOrder
:
-
1
,
Source
From
:
2
,
Source
:
constant
.
SourceCustom
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
classId
,
err
=
alertClassSvc
.
Add
(
session
,
request
.
AddAlertClass
{
classId
,
err
=
alertClassSvc
.
Add
(
session
,
request
.
AddAlertClass
{
ClassName
:
req
.
ClassName
,
ClassName
:
req
.
ClassName
,
ParentId
:
classParentId
,
ParentId
:
classParentId
,
SortOrder
:
-
1
,
SortOrder
:
-
1
,
Source
From
:
2
,
Source
:
constant
.
SourceCustom
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -77,7 +78,7 @@ func (a *AlertRulesSvc) Add(req request.AddAlertRules) (err error) {
...
@@ -77,7 +78,7 @@ func (a *AlertRulesSvc) Add(req request.AddAlertRules) (err error) {
// 添加指标配置
// 添加指标配置
metricConfigSvc
:=
MetricConfigSvc
{
User
:
a
.
User
}
metricConfigSvc
:=
MetricConfigSvc
{
User
:
a
.
User
}
_
=
copier
.
Copy
(
&
addMetricConfig
,
&
req
)
_
=
copier
.
Copy
(
&
addMetricConfig
,
&
req
)
addMetricConfig
.
Source
From
=
2
addMetricConfig
.
Source
=
constant
.
SourceCustom
addMetricConfig
.
MetricName
=
req
.
MetricConfigName
addMetricConfig
.
MetricName
=
req
.
MetricConfigName
metricConfigId
,
err
=
metricConfigSvc
.
Add
(
session
,
addMetricConfig
)
metricConfigId
,
err
=
metricConfigSvc
.
Add
(
session
,
addMetricConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -159,7 +160,7 @@ func (a *AlertRulesSvc) Update(req request.UpdateAlertRules) (err error) {
...
@@ -159,7 +160,7 @@ func (a *AlertRulesSvc) Update(req request.UpdateAlertRules) (err error) {
// 更新指标配置
// 更新指标配置
metricConfigSvc
:=
MetricConfigSvc
{
User
:
a
.
User
}
metricConfigSvc
:=
MetricConfigSvc
{
User
:
a
.
User
}
_
=
copier
.
Copy
(
&
updateMetricConfig
,
&
req
)
_
=
copier
.
Copy
(
&
updateMetricConfig
,
&
req
)
updateMetricConfig
.
Source
From
=
2
updateMetricConfig
.
Source
=
constant
.
SourceCustom
updateMetricConfig
.
Id
=
dbAlertRules
.
MetricConfigId
updateMetricConfig
.
Id
=
dbAlertRules
.
MetricConfigId
err
=
metricConfigSvc
.
Update
(
session
,
updateMetricConfig
)
err
=
metricConfigSvc
.
Update
(
session
,
updateMetricConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
src/service/metric_config.go
View file @
3ee9feb2
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/constant"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"xorm.io/xorm"
"xorm.io/xorm"
...
@@ -25,6 +26,9 @@ func (m *MetricConfigSvc) Add(session *xorm.Session, req request.AddMetricConfig
...
@@ -25,6 +26,9 @@ func (m *MetricConfigSvc) Add(session *xorm.Session, req request.AddMetricConfig
UpdatedBy
:
m
.
User
.
SystemAccount
,
UpdatedBy
:
m
.
User
.
SystemAccount
,
UpdatedAt
:
now
,
UpdatedAt
:
now
,
}
}
if
req
.
Source
!=
constant
.
SourceCustom
{
req
.
Source
=
constant
.
SourceDefault
}
_
=
copier
.
Copy
(
&
data
,
&
req
)
_
=
copier
.
Copy
(
&
data
,
&
req
)
data
.
AlertRange
=
util
.
ConvertToString
(
req
.
AlertRange
)
data
.
AlertRange
=
util
.
ConvertToString
(
req
.
AlertRange
)
_
,
err
=
session
.
Insert
(
&
data
)
_
,
err
=
session
.
Insert
(
&
data
)
...
...
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