Skip to content

Commit

Permalink
api definition: modify audit task resp and workflow resp
Browse files Browse the repository at this point in the history
1. rollback sql to rollback sqls
2. associated workflow add name in it
3. add associated workflow in returns of workflow resp
  • Loading branch information
winfredLIN committed Nov 19, 2024
1 parent d4ec1e4 commit 6664931
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 40 deletions.
39 changes: 22 additions & 17 deletions sqle/api/controller/v2/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,27 @@ type GetAuditTaskSQLsResV2 struct {
}

type AuditTaskSQLResV2 struct {
ExecSqlID uint `json:"exec_sql_id"`
Number uint `json:"number"`
ExecSQL string `json:"exec_sql"`
SQLSourceFile string `json:"sql_source_file"`
SQLStartLine uint64 `json:"sql_start_line"`
AuditResult []*AuditResult `json:"audit_result"`
AuditLevel string `json:"audit_level"`
AuditStatus string `json:"audit_status"`
ExecResult string `json:"exec_result"`
ExecStatus string `json:"exec_status"`
RollbackSQL string `json:"rollback_sql,omitempty"`
Description string `json:"description"`
SQLType string `json:"sql_type"`
BackupStrategy string `json:"backup_strategy" enums:"none,manual,reverse_sql,origin_row"`
BackupStrategyTip string `json:"backup_strategy_tip"`
AssociatedWorkflowIds []string `json:"associate_workflow_ids"`
ExecSqlID uint `json:"exec_sql_id"`
Number uint `json:"number"`
ExecSQL string `json:"exec_sql"`
SQLSourceFile string `json:"sql_source_file"`
SQLStartLine uint64 `json:"sql_start_line"`
AuditResult []*AuditResult `json:"audit_result"`
AuditLevel string `json:"audit_level"`
AuditStatus string `json:"audit_status"`
ExecResult string `json:"exec_result"`
ExecStatus string `json:"exec_status"`
RollbackSQLs []string `json:"rollback_sqls,omitempty"`
Description string `json:"description"`
SQLType string `json:"sql_type"`
BackupStrategy string `json:"backup_strategy" enums:"none,manual,reverse_sql,origin_row"`
BackupStrategyTip string `json:"backup_strategy_tip"`
AssociatedRollbackWorkflows []AssociatedRollbackWorkflow `json:"associated_rollback_workflows"`
}

type AssociatedRollbackWorkflow struct {
WorkflowID string `json:"workflow_id"`
WorkflowName string `json:"workflow_name"`
}

type AuditResult struct {
Expand Down Expand Up @@ -115,7 +120,7 @@ func GetTaskSQLs(c echo.Context) error {
AuditStatus: taskSQL.AuditStatus,
ExecResult: taskSQL.ExecResult,
ExecStatus: taskSQL.ExecStatus,
RollbackSQL: taskSQL.RollbackSQL.String,
RollbackSQLs: []string{taskSQL.RollbackSQL.String},
SQLType: taskSQL.SQLType.String,
}
for i := range taskSQL.AuditResults {
Expand Down
23 changes: 12 additions & 11 deletions sqle/api/controller/v2/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,17 +1134,18 @@ type WorkflowRecordResV2 struct {
}

type WorkflowResV2 struct {
Name string `json:"workflow_name"`
WorkflowID string `json:"workflow_id"`
Desc string `json:"desc,omitempty"`
Mode string `json:"mode" enums:"same_sqls,different_sqls"`
ExecMode string `json:"exec_mode" enums:"sql_file,sqls"`
CreateUser string `json:"create_user_name"`
CreateTime *time.Time `json:"create_time"`
SqlVersion *SqlVersion `json:"sql_version,omitempty"`
Record *WorkflowRecordResV2 `json:"record"`
RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,omitempty"`
AssociatedStageWorkflows []*AssociatedStageWorkflows `json:"associated_stage_workflows,omitempty"`
Name string `json:"workflow_name"`
WorkflowID string `json:"workflow_id"`
Desc string `json:"desc,omitempty"`
Mode string `json:"mode" enums:"same_sqls,different_sqls"`
ExecMode string `json:"exec_mode" enums:"sql_file,sqls"`
CreateUser string `json:"create_user_name"`
CreateTime *time.Time `json:"create_time"`
SqlVersion *SqlVersion `json:"sql_version,omitempty"`
Record *WorkflowRecordResV2 `json:"record"`
RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,omitempty"`
AssociatedStageWorkflows []*AssociatedStageWorkflows `json:"associated_stage_workflows,omitempty"`
AssociatedRollbackWorkflows []*AssociatedRollbackWorkflow `json:"associated_rollback_workflows"`
}

type AssociatedStageWorkflows struct {
Expand Down
28 changes: 24 additions & 4 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18510,6 +18510,17 @@ var doc = `{
}
}
},
"v2.AssociatedRollbackWorkflow": {
"type": "object",
"properties": {
"workflow_id": {
"type": "string"
},
"workflow_name": {
"type": "string"
}
}
},
"v2.AssociatedStageWorkflows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -18775,10 +18786,10 @@ var doc = `{
"v2.AuditTaskSQLResV2": {
"type": "object",
"properties": {
"associate_workflow_ids": {
"associated_rollback_workflows": {
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/v2.AssociatedRollbackWorkflow"
}
},
"audit_level": {
Expand Down Expand Up @@ -18823,8 +18834,11 @@ var doc = `{
"number": {
"type": "integer"
},
"rollback_sql": {
"type": "string"
"rollback_sqls": {
"type": "array",
"items": {
"type": "string"
}
},
"sql_source_file": {
"type": "string"
Expand Down Expand Up @@ -19639,6 +19653,12 @@ var doc = `{
"v2.WorkflowResV2": {
"type": "object",
"properties": {
"associated_rollback_workflows": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.AssociatedRollbackWorkflow"
}
},
"associated_stage_workflows": {
"type": "array",
"items": {
Expand Down
28 changes: 24 additions & 4 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -18494,6 +18494,17 @@
}
}
},
"v2.AssociatedRollbackWorkflow": {
"type": "object",
"properties": {
"workflow_id": {
"type": "string"
},
"workflow_name": {
"type": "string"
}
}
},
"v2.AssociatedStageWorkflows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -18759,10 +18770,10 @@
"v2.AuditTaskSQLResV2": {
"type": "object",
"properties": {
"associate_workflow_ids": {
"associated_rollback_workflows": {
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/v2.AssociatedRollbackWorkflow"
}
},
"audit_level": {
Expand Down Expand Up @@ -18807,8 +18818,11 @@
"number": {
"type": "integer"
},
"rollback_sql": {
"type": "string"
"rollback_sqls": {
"type": "array",
"items": {
"type": "string"
}
},
"sql_source_file": {
"type": "string"
Expand Down Expand Up @@ -19623,6 +19637,12 @@
"v2.WorkflowResV2": {
"type": "object",
"properties": {
"associated_rollback_workflows": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.AssociatedRollbackWorkflow"
}
},
"associated_stage_workflows": {
"type": "array",
"items": {
Expand Down
21 changes: 17 additions & 4 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5078,6 +5078,13 @@ definitions:
err_message:
type: string
type: object
v2.AssociatedRollbackWorkflow:
properties:
workflow_id:
type: string
workflow_name:
type: string
type: object
v2.AssociatedStageWorkflows:
properties:
sql_version_stage_id:
Expand Down Expand Up @@ -5263,9 +5270,9 @@ definitions:
type: object
v2.AuditTaskSQLResV2:
properties:
associate_workflow_ids:
associated_rollback_workflows:
items:
type: string
$ref: '#/definitions/v2.AssociatedRollbackWorkflow'
type: array
audit_level:
type: string
Expand Down Expand Up @@ -5296,8 +5303,10 @@ definitions:
type: string
number:
type: integer
rollback_sql:
type: string
rollback_sqls:
items:
type: string
type: array
sql_source_file:
type: string
sql_start_line:
Expand Down Expand Up @@ -5857,6 +5866,10 @@ definitions:
type: object
v2.WorkflowResV2:
properties:
associated_rollback_workflows:
items:
$ref: '#/definitions/v2.AssociatedRollbackWorkflow'
type: array
associated_stage_workflows:
items:
$ref: '#/definitions/v2.AssociatedStageWorkflows'
Expand Down

0 comments on commit 6664931

Please sign in to comment.