Skip to content

Commit

Permalink
Merge pull request #2817 from actiontech/feat_coding_opt
Browse files Browse the repository at this point in the history
feat: coding opt
  • Loading branch information
LordofAvernus authored Dec 11, 2024
2 parents 28f30c7 + 8efe149 commit d6ed0e4
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 128 deletions.
2 changes: 1 addition & 1 deletion sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
v1ProjectViewRouter.GET("/:project_name/sql_manages/exports", v1.ExportSqlManagesV1)
v1ProjectViewRouter.GET("/:project_name/sql_manages/rule_tips", v1.GetSqlManageRuleTips)
v1ProjectViewRouter.GET("/:project_name/sql_manages/:sql_manage_id/sql_analysis", v1.GetSqlManageSqlAnalysisV1)
v1ProjectViewRouter.POST("/:project_name/sql_manages/coding", v1.PostSqlManageToCoding)
v1ProjectViewRouter.POST("/:project_name/sql_manages/send", v1.SendSqlManage)

// sql dev records
v1ProjectViewRouter.GET("/:project_name/sql_dev_records", v1.GetSqlDEVRecordList)
Expand Down
16 changes: 8 additions & 8 deletions sqle/api/controller/v1/sql_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type SqlManage struct {
LastAppearTime string `json:"last_appear_time"`
AppearNum uint64 `json:"appear_num"`
Assignees []string `json:"assignees"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited,sent"`
Remark string `json:"remark"`
Endpoint string `json:"endpoint"`
}
Expand Down Expand Up @@ -290,18 +290,18 @@ func GetSqlManageSqlAnalysisV1(c echo.Context) error {
return getSqlManageSqlAnalysisV1(c)
}

// PostSqlManageToCoding
// @Summary 推送SQL管控结果到Coding
// SendSqlManage
// @Summary 推送SQL管控结果到外部系统
// @Description get sql manage analysis
// @Id PostSqlManageToCoding
// @Id SendSqlManage
// @Tags SqlManage
// @Param project_name path string true "project name"
// @Param SqlManageCodingReq body SqlManageCodingReq true "batch update sql manage request"
// @Security ApiKeyAuth
// @Success 200 {object} PostSqlManageCodingResp
// @Router /v1/projects/{project_name}/sql_manages/coding [post]
func PostSqlManageToCoding(c echo.Context) error {
return postSqlManageToCoding(c)
// @Router /v1/projects/{project_name}/sql_manages/send [post]
func SendSqlManage(c echo.Context) error {
return sendSqlManage(c)
}

func convertSQLAnalysisResultToRes(ctx context.Context, res *AnalysisResult, rawSQL string) *SqlAnalysis {
Expand Down Expand Up @@ -439,7 +439,7 @@ type GlobalSqlManage struct {
ProjectUid string `json:"project_uid"`
InstanceName string `json:"instance_name"`
InstanceId string `json:"instance_id"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited,sent"`
ProjectPriority dmsV1.ProjectPriority `json:"project_priority" enums:"high,medium,low"`
FirstAppearTimeStamp string `json:"first_appear_timestamp"`
ProblemDescriptions []string `json:"problem_descriptions"` // 根据来源信息拼接
Expand Down
2 changes: 1 addition & 1 deletion sqle/api/controller/v1/sql_manager_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func batchUpdateSqlManage(c echo.Context) error {
return ErrCommunityEditionNotSupportSqlManage
}

func postSqlManageToCoding(c echo.Context) error {
func sendSqlManage(c echo.Context) error {
return ErrCommunityEditionNotSupportSqlManage
}

Expand Down
4 changes: 2 additions & 2 deletions sqle/api/controller/v2/sql_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type SqlManage struct {
LastReceiveTimeStamp string `json:"last_receive_timestamp"`
FpCount uint64 `json:"fp_count"`
Assignees []string `json:"assignees"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited"`
Status string `json:"status" enums:"unhandled,solved,ignored,manual_audited,sent"`
Remark string `json:"remark"`
Endpoints []string `json:"endpoints"`
Priority string `json:"priority"`
Expand All @@ -47,7 +47,7 @@ type SqlManage struct {
// @Param filter_audit_level query string false "audit level" Enums(normal,notice,warn,error)
// @Param filter_last_audit_start_time_from query string false "last audit start time from"
// @Param filter_last_audit_start_time_to query string false "last audit start time to"
// @Param filter_status query string false "status" Enums(unhandled,solved,ignored,manual_audited)
// @Param filter_status query string false "status" Enums(unhandled,solved,ignored,manual_audited,sent)
// @Param filter_rule_name query string false "rule name"
// @Param filter_db_type query string false "db type"
// @Param filter_business query string false "business"
Expand Down
94 changes: 49 additions & 45 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5163,47 +5163,6 @@ var doc = `{
}
}
},
"/v1/projects/{project_name}/sql_manages/coding": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "推送SQL管控结果到Coding",
"operationId": "PostSqlManageToCoding",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"description": "batch update sql manage request",
"name": "SqlManageCodingReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.SqlManageCodingReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.PostSqlManageCodingResp"
}
}
}
}
},
"/v1/projects/{project_name}/sql_manages/exports": {
"get": {
"security": [
Expand Down Expand Up @@ -5393,6 +5352,47 @@ var doc = `{
}
}
},
"/v1/projects/{project_name}/sql_manages/send": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "推送SQL管控结果到外部系统",
"operationId": "SendSqlManage",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"description": "batch update sql manage request",
"name": "SqlManageCodingReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.SqlManageCodingReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.PostSqlManageCodingResp"
}
}
}
}
},
"/v1/projects/{project_name}/sql_manages/{sql_manage_id}/sql_analysis": {
"get": {
"security": [
Expand Down Expand Up @@ -10322,7 +10322,8 @@ var doc = `{
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
],
"type": "string",
"description": "status",
Expand Down Expand Up @@ -15422,7 +15423,8 @@ var doc = `{
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down Expand Up @@ -17159,7 +17161,8 @@ var doc = `{
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down Expand Up @@ -19999,7 +20002,8 @@ var doc = `{
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down
94 changes: 49 additions & 45 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5147,47 +5147,6 @@
}
}
},
"/v1/projects/{project_name}/sql_manages/coding": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "推送SQL管控结果到Coding",
"operationId": "PostSqlManageToCoding",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"description": "batch update sql manage request",
"name": "SqlManageCodingReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.SqlManageCodingReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.PostSqlManageCodingResp"
}
}
}
}
},
"/v1/projects/{project_name}/sql_manages/exports": {
"get": {
"security": [
Expand Down Expand Up @@ -5377,6 +5336,47 @@
}
}
},
"/v1/projects/{project_name}/sql_manages/send": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "推送SQL管控结果到外部系统",
"operationId": "SendSqlManage",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"description": "batch update sql manage request",
"name": "SqlManageCodingReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.SqlManageCodingReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.PostSqlManageCodingResp"
}
}
}
}
},
"/v1/projects/{project_name}/sql_manages/{sql_manage_id}/sql_analysis": {
"get": {
"security": [
Expand Down Expand Up @@ -10306,7 +10306,8 @@
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
],
"type": "string",
"description": "status",
Expand Down Expand Up @@ -15406,7 +15407,8 @@
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down Expand Up @@ -17143,7 +17145,8 @@
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down Expand Up @@ -19983,7 +19986,8 @@
"unhandled",
"solved",
"ignored",
"manual_audited"
"manual_audited",
"sent"
]
}
}
Expand Down
Loading

0 comments on commit d6ed0e4

Please sign in to comment.