|
1234567891011121314151617181920212223242526272829303132 |
- package monitoring
-
- import (
- "context"
-
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type AlertRulesLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertRulesLogic {
- return &AlertRulesLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *AlertRulesLogic) AlertRules(req *types.AlertRulesReq) (resp *types.AlertRulesResp, err error) {
- resp = &types.AlertRulesResp{}
- var alertRules []types.AlertRule
- l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.alert_type = ? AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType).Scan(&alertRules)
- resp.AlertRules = alertRules
- return resp, nil
- }
|