From be8eeced90cadc5a7a69096ece3fbcf54c60e433 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Sat, 14 Sep 2024 17:41:57 +0800 Subject: [PATCH 1/8] feat: sql version model define --- sqle/model/sql_version.go | 42 +++++++++++++++++++++++++++++++++++++++ sqle/model/utils.go | 4 ++++ 2 files changed, 46 insertions(+) create mode 100644 sqle/model/sql_version.go diff --git a/sqle/model/sql_version.go b/sqle/model/sql_version.go new file mode 100644 index 000000000..f80feb728 --- /dev/null +++ b/sqle/model/sql_version.go @@ -0,0 +1,42 @@ +package model + +import "time" + +type SqlVersion struct { + Model + VersionNumber string `json:"version_number" gorm:"type:varchar(255) not null"` + Desc string `json:"desc" gorm:"type:varchar(512)"` + Status string `json:"status" gorm:"type:varchar(255)"` + LockTime *time.Time `json:"lock_time" gorm:"type:datetime(3)"` + IsLocked bool `json:"is_locked" gorm:"type:bool" example:"false"` + ProjectId ProjectUID `gorm:"index; not null"` + + SqlVersionStage []*SqlVersionStage +} + +type SqlVersionStage struct { + Model + SqlVersionID uint `json:"sql_version_id" gorm:"not null"` + Name string `json:"name" gorm:"type:varchar(255) not null"` + StageSequence int `json:"stage_sequence" gorm:"type:int not null"` + + SqlVersionStagesDependency []*SqlVersionStagesDependency + WorkflowReleaseStage []*WorkflowReleaseStage +} + +type SqlVersionStagesDependency struct { + Model + SqlVersionStageID uint `json:"sql_version_stage_id" gorm:"not null"` + NextStageID uint `json:"next_stage_id"` + StageInstanceID uint `json:"stage_instance_id" gorm:"not null"` + NextStageInstanceID uint `json:"next_stage_instance_id"` +} + +type WorkflowReleaseStage struct { + Model + WorkflowID string `json:"workflow_id" gorm:"not null"` + SqlVersionStageID uint `json:"sql_version_stage_id"` + WorkflowSequence int `json:" workflow_sequence" gorm:"type:int"` + + Workflow *Workflow `gorm:"foreignkey:WorkflowID"` +} diff --git a/sqle/model/utils.go b/sqle/model/utils.go index 418a3e34c..48e160b1a 100644 --- a/sqle/model/utils.go +++ b/sqle/model/utils.go @@ -167,6 +167,10 @@ var autoMigrateList = []interface{}{ &SQLManageQueue{}, &ReportPushConfig{}, &ReportPushConfigRecord{}, + &SqlVersion{}, + &SqlVersionStage{}, + &SqlVersionStagesDependency{}, + &WorkflowReleaseStage{}, } func (s *Storage) AutoMigrate() error { From 1144da07810f45c45b95f9afc6856a17811a5292 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Sat, 14 Sep 2024 17:41:57 +0800 Subject: [PATCH 2/8] feat: sql version api define --- sqle/api/app.go | 13 + sqle/api/controller/v1/sql_version.go | 333 +++++++++++++++++++++++ sqle/api/controller/v1/sql_version_ce.go | 45 +++ 3 files changed, 391 insertions(+) create mode 100644 sqle/api/controller/v1/sql_version.go create mode 100644 sqle/api/controller/v1/sql_version_ce.go diff --git a/sqle/api/app.go b/sqle/api/app.go index c2b3ad245..89faae840 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -250,6 +250,19 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti v1ProjectRouter.POST("/:project_name/workflows/:workflow_id/tasks/:task_id/order_file", v1.UpdateSqlFileOrderByWorkflowV1) v1ProjectRouter.GET("/:project_name/workflows/:workflow_id/tasks/:task_id/attachment", v1.GetWorkflowTaskAuditFile) + // sql version + v1ProjectRouter.POST("/:project_name/sql_version", v1.CreateSqlVersion) + v1ProjectRouter.GET("/:project_name/sql_version", v1.GetSqlVersionList) + v1ProjectRouter.GET("/:project_name/sql_version/:sql_version_id/", v1.GetSqlVersionDetail) + v1ProjectRouter.PUT("/:project_name/sql_version/:sql_version_id/", v1.UpdateSqlVersion) + v1ProjectRouter.DELETE("/:project_name/sql_version/:sql_version_id/", v1.DeleteSqlVersion) + v1ProjectRouter.PATCH("/:project_name/sql_version/:sql_version_id/lock", v1.LockSqlVersion) + v1ProjectRouter.GET("/:project_name/sql_version/:sql_version_id/sql_version_stage/:sql_version_stage_id/dependencies", v1.GetDependenciesBetweenStageInstance) + v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/batch_release", v1.BatchReleaseWorkflows) + v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/batch_execute", v1.BatchExecuteTasksOnWorkflow) + v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/execute_retry", v1.RetryExecWorkflow) + v1ProjectRouter.POST("/:project_name/sql_version/workflow/:workflow_id/", v1.WorkflowSqlVersion) + // audit plan; 智能扫描任务 v1ProjectRouter.POST("/:project_name/audit_plans", v1.CreateAuditPlan) v1ProjectRouter.GET("/:project_name/audit_plans", v1.GetAuditPlans) diff --git a/sqle/api/controller/v1/sql_version.go b/sqle/api/controller/v1/sql_version.go new file mode 100644 index 000000000..8fa579fe0 --- /dev/null +++ b/sqle/api/controller/v1/sql_version.go @@ -0,0 +1,333 @@ +package v1 + +import ( + "time" + + "github.com/actiontech/sqle/sqle/api/controller" + "github.com/labstack/echo/v4" +) + +type SqlVersionReqV1 struct { + VersionNumber string `json:"version_number" form:"version_number" valid:"required" example:"2.23"` + Desc string `json:"desc" form:"desc"` + SqlVersionStage []SqlVersionStage `json:"sql_version_stage" valid:"dive,required"` +} + +type SqlVersionStage struct { + Name string `json:"name" form:"name" valid:"required" example:"生产"` + StageSequence int `json:"stage_sequence" form:"stage_sequence" valid:"required"` + StagesDependency []SqlVersionStagesDependency `json:"stages_dependency" valid:"dive,required"` +} + +type SqlVersionStagesDependency struct { + StageInstanceID uint `json:"source_instance_id"` + NextStageInstanceID uint `json:"target_instance_id"` +} + +// @Summary 创建sql版本记录 +// @Description create sql version +// @Id createSqlVersionV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Accept json +// @Param project_name path string true "project name" +// @Param sql_version body v1.SqlVersionReqV1 true "create sql version request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version [post] +func CreateSqlVersion(c echo.Context) error { + + /** + 1、save version + 2、save stage + 3、遍历stage,stage的id作为dependency的stage id + 4、实现方法getNextSatgeBySequence,获取next stage id(SqlVersionStage表StageSequence + 1的id作为NextStageID) + 5、save dependenc + **/ + + return createSqlVersion(c) +} + +type GetSqlVersionListReqV1 struct { + FilterByCreatedAtFrom *string `json:"filter_by_created_at_from,omitempty" query:"filter_by_created_at_from"` + FilterByCreatedAtTo *string `json:"filter_by_created_at_to,omitempty" query:"filter_by_created_at_to"` + FilterByLockTimeFrom *string `json:"filter_by_lock_time_from,omitempty" query:"filter_by_lock_time_from"` + FilterByLockTimeTo *string `json:"filter_by_lock_time_to,omitempty" query:"filter_by_lock_time_to"` + FuzzySearch *string `json:"fuzzy_search,omitempty" query:"fuzzy_search"` + + PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` + PageSize uint32 `json:"page_size" query:"page_size" valid:"required"` +} + +type GetSqlVersionListResV1 struct { + controller.BaseRes + Data []*SqlVersionResV1 `json:"data"` + TotalNums uint64 `json:"total_nums"` +} + +type SqlVersionResV1 struct { + VersionNumber string `json:"version_number"` + Desc string `json:"desc"` + Status string `json:"status"` + LockTime *time.Time `json:"lock_time"` + CreatedAt *time.Time `json:"created_at"` + HasAssociatedWorkflow bool `json:"has_associated_workflow"` +} + +// @Summary 获取sql版本列表 +// @Description sql version list +// @Id getSqlVersionListV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Accept json +// @Param project_name path string true "project name" +// @Param filter_by_created_at_from query string false "filter by created at from" +// @Param filter_by_created_at_to query string false "filter by created at to" +// @Param filter_by_lock_time_from query string false "filter by lock time from" +// @Param filter_by_lock_time_to query string false "filter by lock time to" +// @Param fuzzy_search query string false "fuzzy search" +// @Param page_index query uint32 true "page index" +// @Param page_size query uint32 true "size of per page" +// @Success 200 {object} v1.GetSqlVersionListResV1 +// @router /v1/projects/{project_name}/sql_version [get] +func GetSqlVersionList(c echo.Context) error { + + // 获取列表同时返回版本是否有关联工单 + return getSqlVersionList(c) +} + +type GetSqlVersionDetailResV1 struct { + controller.BaseRes + Data []*SqlVersionDetailResV1 `json:"data"` +} + +type SqlVersionDetailResV1 struct { + StageID uint `json:"stage_id"` + StageName string `json:"stage_name"` + StageSequence int `json:"stage_sequence"` + WorkflowDetails []*WorkflowDetailWithInstance `json:"workflow_details"` +} + +type WorkflowDetailWithInstance struct { + Name string `json:"workflow_name"` + WorkflowId string `json:"workflow_id"` + Desc string `json:"desc,omitempty"` + Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` + WorkflowInstances []*WorkflowInstance `json:"workflow_instances"` +} +type WorkflowInstance struct { + InstanceID string `json:"instances_id"` + InstanceName string `json:"instances_name"` + InstanceSchema string `json:"instance_schema"` +} + +// @Summary 获取sql版本详情 +// @Description get sql version detail +// @Id getSqlVersionDetailV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Success 200 {object} v1.GetSqlVersionDetailResV1 +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [get] +func GetSqlVersionDetail(c echo.Context) error { + + /** + 1、getStageBySqlVersionID + 2、获取工单信息dms.GetWorkflowDetailByWorkflowId(projectUid, workflowID, s.GetWorkflowDetailWithoutInstancesByWorkflowID) + 3、遍历workflow获取WorkflowDetail遍历workflow.record.instancerecords获取WorkflowInstance + **/ + return getSqlVersionDetail(c) +} + +// @Summary 更新sql版本信息 +// @Description update sql version +// @Id updateSqlVersionV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param sql_version body v1.SqlVersionReqV1 true "update sql version request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [put] +func UpdateSqlVersion(c echo.Context) error { + /** + 没有工单: + 1、getStageBySqlVersionID + 2、save sql version + 3、遍历db stage,嵌套遍历req satge,根据stage顺号对比更新、删除、添加stage + 有工单: + save sql version + **/ + return updateSqlVersion(c) +} + +type LockSqlVersionReqV1 struct { + IsLocked bool `json:"is_locked"` +} + +// @Summary 锁定sql版本 +// @Description lock sql version +// @Id lockSqlVersionV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param sql_version body v1.LockSqlVersionReqV1 true "lock sql version request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/lock [patch] +func LockSqlVersion(c echo.Context) error { + + return lockSqlVersion(c) +} + +// @Summary 删除sql版本 +// @Description delete sql version +// @Id deleteSqlVersionV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [delete] +func DeleteSqlVersion(c echo.Context) error { + // delete sql version + // delete stage + // delete dependency + // delete workflow release stage + return deleteSqlVersion(c) +} + +type GetDepBetweenStageInstanceResV1 struct { + controller.BaseRes + Data []*DepBetweenStageInstance `json:"data"` +} + +type DepBetweenStageInstance struct { + StageInstanceID string `json:"stage_instance_id"` + NextStageInstanceID string `json:"next_stage_instance_id"` +} + +// @Summary 获取当前阶段与下一阶段实例的依赖信息 +// @Description get dependencies between stage instance +// @Tags sql_version +// @Id getInstanceTipListV1 +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param sql_version_stage_id path string true "sql version stage id" +// @Success 200 {object} v1.GetInstanceTipsResV1 +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies [get] +func GetDependenciesBetweenStageInstance(c echo.Context) error { + /** + select * from SqlVersionStagesDependency where SqlVersionStageID = sql_version_stage_id + **/ + return getDependenciesBetweenStageInstance(c) +} + +type BatchReleaseWorkflowReqV1 struct { + ReleaseWorkflows []ReleaseWorkflows `json:"release_workflows" form:"release_workflows" valid:"dive,required"` +} + +type ReleaseWorkflows struct { + WorkFlowID string `json:"workflow_id" form:"workflow_id" valid:"required"` + TargetReleaseInstances []TargetReleaseInstance `json:"target_release_instances" valid:"dive,required"` +} + +type TargetReleaseInstance struct { + InstanceID string `json:"instance_id" form:"instance_id" valid:"required"` + InstanceSchema string `json:"instance_schema" form:"instance_schema"` + TargetInstanceID string `json:"target_instance_id" form:"target_instance_id" valid:"required"` + TargetInstanceSchema string `json:"target_instance_schema" form:"target_instance_schema"` +} + +// @Summary 批量发布工单 +// @Description batch release workflow +// @Id batchReleaseWorkflowV1 +// @Tags sql_version +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param data body v1.BatchReleaseWorkflowReqV1 true "batch release workflow request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release [post] +func BatchReleaseWorkflows(c echo.Context) error { + /** + 1、遍历获取工单信息,dms.GetWorkflowDetailByWorkflowId(projectUid, workflowID, s.GetWorkflowDetailWithoutInstancesByWorkflowID) + 2、遍历workflow.task[],获取task信息 + 3、找到task的instance id,对应到target instance id + 4、dms.GetInstancesById(c.Request().Context(), req.InstanceId) + 5、参考func CreateAndAuditTask(c echo.Context) error 创建审核,如果原task的sql source是sql_file, + 参考func GetWorkflowTaskAuditFile(c echo.Context) error获取原始文件 + 6、提交工单工单(忽略工单审批流程模板的审核等级限制)参考func CreateWorkflowV2(c echo.Context) error + **/ + return batchReleaseWorkflows(c) +} + +type BatchExecuteTasksOnWorkflowReqV1 struct { + WorkflowIDs []string `json:"workflow_ids" valid:"required"` +} + +// @Summary 工单批量上线 +// @Description batch execute tasks on workflow +// @Tags sql_version +// @Id batchExecuteTasksOnWorkflow +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param data body v1.BatchExecuteTasksOnWorkflowReqV1 true "batch execute tasks on workflow request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute [post] +func BatchExecuteTasksOnWorkflow(c echo.Context) error { + /** + 1、遍历workflow id,获取workflow信息 + 2、参考func ExecuteTasksOnWorkflowV2(c echo.Context) error 执行上线 + **/ + return batchExecuteTasksOnWorkflow(c) +} + +type RetryExecWorkflowReqV1 struct { + WorkflowID string `json:"workflow_ids" valid:"required"` + TaskIds []uint `json:"task_ids" form:"task_ids" valid:"required"` +} + +// @Summary 工单重试 +// @Description reject exec failed workflow +// @Tags sql_version +// @Id rejectExecFailedWorkflow +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param data body v1.RetryExecWorkflowReqV1 true "reject exec failed workflow request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry [post] +func RetryExecWorkflow(c echo.Context) error { + /** + 暂不考虑重复上线问题,用户在修改sql时自行回滚或删除上线成功的sql。 + 发起人有权限重试并提交修改的sql, + 1、参考驳回后修改sql重新审核提交工单逻辑 + 2、不过滤上线失败的工单 + 3、调整工单上线逻辑,上线失败current_workflow_step_id不要置为0(考虑影响) + 4、workflow record history调整,可以在工单详情中查看到上线失败的history + **/ + return retryExecWorkflow(c) +} + +type WorkflowSqlVersionReqV1 struct { + SqlVersionID *string `json:"sql_version_id"` +} + +// @Summary 工单与版本建立关联 +// @Description workflow sql version +// @Tags sql_version +// @Id workflowSqlVersion +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param workflow_id path string true "workflow id" +// @Param data body v1.WorkflowSqlVersionReqV1 true "workflow sql version request" +// @Success 200 {object} controller.BaseRes +// @router /v1/projects/{project_name}/sql_version/workflow/{workflow_id}/ [post] +func WorkflowSqlVersion(c echo.Context) error { + + // 与第一个阶段进行关联 + return workflowSqlVersion(c) +} diff --git a/sqle/api/controller/v1/sql_version_ce.go b/sqle/api/controller/v1/sql_version_ce.go new file mode 100644 index 000000000..7ade1a796 --- /dev/null +++ b/sqle/api/controller/v1/sql_version_ce.go @@ -0,0 +1,45 @@ +package v1 + +import "github.com/labstack/echo/v4" + +func createSqlVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func getSqlVersionList(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func getSqlVersionDetail(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func updateSqlVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func lockSqlVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func deleteSqlVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func getDependenciesBetweenStageInstance(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func batchReleaseWorkflows(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func batchExecuteTasksOnWorkflow(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} +func retryExecWorkflow(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} +func workflowSqlVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} From 21dfebbcc17fd6d246b3f70f0eb6f2cc77f4ad8d Mon Sep 17 00:00:00 2001 From: iwanghc Date: Sat, 14 Sep 2024 17:41:58 +0800 Subject: [PATCH 3/8] modify: workflow api add sql version param --- sqle/api/controller/v1/workflow.go | 1 + sqle/api/controller/v2/workflow.go | 37 ++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/sqle/api/controller/v1/workflow.go b/sqle/api/controller/v1/workflow.go index 7f849814e..9c82a43a1 100644 --- a/sqle/api/controller/v1/workflow.go +++ b/sqle/api/controller/v1/workflow.go @@ -520,6 +520,7 @@ type WorkflowDetailResV1 struct { Name string `json:"workflow_name"` WorkflowId string `json:"workflow_id" ` Desc string `json:"desc"` + SqlVersionName string `json:"sql_version_name"` CreateUser string `json:"create_user_name"` CreateTime *time.Time `json:"create_time"` CurrentStepType string `json:"current_step_type,omitempty" enums:"sql_review,sql_execute"` diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index 46720ba91..ac076d16e 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -305,6 +305,8 @@ type BatchCompleteWorkflowsReqV2 struct { WorkflowIDList []string `json:"workflow_id_list" form:"workflow_id_list"` } +// TODO 支持上线失败时完成工单,需要填写备注信息,备注信息拼接到工单备注中 + // BatchCompleteWorkflowsV2 complete workflows. // @Summary 批量完成工单 // @Description this api will directly change the work order status to finished without real online operation @@ -567,9 +569,10 @@ func convertWorkflowToTasksSummaryRes(taskDetails []*model.WorkflowTasksSummaryD } type CreateWorkflowReqV2 struct { - Subject string `json:"workflow_subject" form:"workflow_subject" valid:"required,name"` - Desc string `json:"desc" form:"desc"` - TaskIds []uint `json:"task_ids" form:"task_ids" valid:"required"` + Subject string `json:"workflow_subject" form:"workflow_subject" valid:"required,name"` + Desc string `json:"desc" form:"desc"` + SqlVersionID string `json:"sql_version_id" form:"sql_version_id"` + TaskIds []uint `json:"task_ids" form:"task_ids" valid:"required"` } type CreateWorkflowResV2 struct { @@ -1095,15 +1098,25 @@ 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"` - Record *WorkflowRecordResV2 `json:"record"` - RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,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"` + SqlVersionName string `json:"sql_version_name"` + Record *WorkflowRecordResV2 `json:"record"` + RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,omitempty"` + AssociatedWorkflow *AssociatedWorkflow `json:"associated_workflow,omitempty"` +} + +type AssociatedWorkflow struct { + WorkflowID string `json:"workflow_id"` + WorkflowName string `json:"workflow_name"` + Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` + SqlVersionStageID uint `json:"sql_version_stage_id"` + StageSequence int `json:"stage_sequence"` } // GetWorkflowV2 From d939ecb69e78c9725c7e49195c9a704b8fe678c4 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Sat, 14 Sep 2024 17:43:03 +0800 Subject: [PATCH 4/8] gen swagger: sql version api --- sqle/docs/docs.go | 945 ++++++++++++++++++++++++++++++++++++++++- sqle/docs/swagger.json | 945 ++++++++++++++++++++++++++++++++++++++++- sqle/docs/swagger.yaml | 603 +++++++++++++++++++++++++- 3 files changed, 2457 insertions(+), 36 deletions(-) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index c7e2c7074..05f568aaa 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -5216,6 +5216,535 @@ var doc = `{ } } }, + "/v1/projects/{project_name}/sql_version": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "sql version list", + "consumes": [ + "application/json" + ], + "tags": [ + "sql_version" + ], + "summary": "获取sql版本列表", + "operationId": "getSqlVersionListV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "filter by created at from", + "name": "filter_by_created_at_from", + "in": "query" + }, + { + "type": "string", + "description": "filter by created at to", + "name": "filter_by_created_at_to", + "in": "query" + }, + { + "type": "string", + "description": "filter by lock time from", + "name": "filter_by_lock_time_from", + "in": "query" + }, + { + "type": "string", + "description": "filter by lock time to", + "name": "filter_by_lock_time_to", + "in": "query" + }, + { + "type": "string", + "description": "fuzzy search", + "name": "fuzzy_search", + "in": "query" + }, + { + "type": "integer", + "description": "page index", + "name": "page_index", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "size of per page", + "name": "page_size", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlVersionListResV1" + } + } + } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "create sql version", + "consumes": [ + "application/json" + ], + "tags": [ + "sql_version" + ], + "summary": "创建sql版本记录", + "operationId": "createSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "description": "create sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.SqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/workflow/{workflow_id}/": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "workflow sql version", + "tags": [ + "sql_version" + ], + "summary": "工单与版本建立关联", + "operationId": "workflowSqlVersion", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "path", + "required": true + }, + { + "description": "workflow sql version request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.WorkflowSqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get sql version detail", + "tags": [ + "sql_version" + ], + "summary": "获取sql版本详情", + "operationId": "getSqlVersionDetailV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update sql version", + "tags": [ + "sql_version" + ], + "summary": "更新sql版本信息", + "operationId": "updateSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "update sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.SqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "delete sql version", + "tags": [ + "sql_version" + ], + "summary": "删除sql版本", + "operationId": "deleteSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/lock": { + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "lock sql version", + "tags": [ + "sql_version" + ], + "summary": "锁定sql版本", + "operationId": "lockSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "lock sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LockSqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get dependencies between stage instance", + "tags": [ + "sql_version" + ], + "summary": "获取当前阶段与下一阶段实例的依赖信息", + "operationId": "getInstanceTipListV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetInstanceTipsResV1" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "batch execute tasks on workflow", + "tags": [ + "sql_version" + ], + "summary": "工单批量上线", + "operationId": "batchExecuteTasksOnWorkflow", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "batch execute tasks on workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "batch release workflow", + "tags": [ + "sql_version" + ], + "summary": "批量发布工单", + "operationId": "batchReleaseWorkflowV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "batch release workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "reject exec failed workflow", + "tags": [ + "sql_version" + ], + "summary": "工单重试", + "operationId": "rejectExecFailedWorkflow", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "reject exec failed workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/statistic/audit_plans": { "get": { "security": [ @@ -9882,10 +10411,28 @@ var doc = `{ } } }, + "model.AuditResultInfo": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "model.I18nAuditResultInfo": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/model.AuditResultInfo" + } + }, "params.EnumsValue": { "type": "object", "properties": { "desc": { + "description": "Deprecated: use I18nDesc instead", + "type": "string" + }, + "i18n_desc": { "type": "string" }, "value": { @@ -9972,7 +10519,7 @@ var doc = `{ "high_priority_conditions": { "type": "array", "items": { - "$ref": "#/definitions/v1.HighPriorityCondition" + "$ref": "#/definitions/v1.HighPriorityConditionResV1" } }, "instance_type": { @@ -10000,7 +10547,7 @@ var doc = `{ "enums_value": { "type": "array", "items": { - "$ref": "#/definitions/params.EnumsValue" + "$ref": "#/definitions/v1.EnumsValueResV1" } }, "key": { @@ -10574,6 +11121,17 @@ var doc = `{ } } }, + "v1.BatchExecuteTasksOnWorkflowReqV1": { + "type": "object", + "properties": { + "workflow_ids": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "v1.BatchGetInstanceConnectionsResV1": { "type": "object", "properties": { @@ -10593,6 +11151,17 @@ var doc = `{ } } }, + "v1.BatchReleaseWorkflowReqV1": { + "type": "object", + "properties": { + "release_workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.ReleaseWorkflows" + } + } + } + }, "v1.BatchUpdateSqlManageReq": { "type": "object", "properties": { @@ -11274,6 +11843,17 @@ var doc = `{ } } }, + "v1.EnumsValueResV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "v1.ExplainClassicResult": { "type": "object", "properties": { @@ -12803,19 +13383,56 @@ var doc = `{ "message": { "type": "string", "example": "ok" - }, - "sql_manage_bad_num": { - "type": "integer" - }, - "sql_manage_optimized_num": { - "type": "integer" - }, - "sql_manage_total_num": { - "type": "integer" + }, + "sql_manage_bad_num": { + "type": "integer" + }, + "sql_manage_optimized_num": { + "type": "integer" + }, + "sql_manage_total_num": { + "type": "integer" + } + } + }, + "v1.GetSqlManageRuleTipsResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.RuleTips" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, + "v1.GetSqlManageSqlAnalysisResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "description": "V1版本不能引用V2版本的结构体,所以只能复制一份", + "type": "object", + "$ref": "#/definitions/v1.SqlAnalysis" + }, + "message": { + "type": "string", + "example": "ok" } } }, - "v1.GetSqlManageRuleTipsResp": { + "v1.GetSqlVersionDetailResV1": { "type": "object", "properties": { "code": { @@ -12825,7 +13442,7 @@ var doc = `{ "data": { "type": "array", "items": { - "$ref": "#/definitions/v1.RuleTips" + "$ref": "#/definitions/v1.SqlVersionDetailResV1" } }, "message": { @@ -12834,7 +13451,7 @@ var doc = `{ } } }, - "v1.GetSqlManageSqlAnalysisResp": { + "v1.GetSqlVersionListResV1": { "type": "object", "properties": { "code": { @@ -12842,13 +13459,17 @@ var doc = `{ "example": 0 }, "data": { - "description": "V1版本不能引用V2版本的结构体,所以只能复制一份", - "type": "object", - "$ref": "#/definitions/v1.SqlAnalysis" + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionResV1" + } }, "message": { "type": "string", "example": "ok" + }, + "total_nums": { + "type": "integer" } } }, @@ -13328,6 +13949,39 @@ var doc = `{ } } }, + "v1.HighPriorityConditionResV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "enums_value": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.EnumsValueResV1" + } + }, + "key": { + "type": "string" + }, + "operator": { + "type": "object", + "$ref": "#/definitions/v1.OperatorResV1" + }, + "type": { + "type": "string", + "enum": [ + "string", + "int", + "bool", + "password" + ] + }, + "value": { + "type": "string" + } + } + }, "v1.InstanceAdditionalParamResV1": { "type": "object", "properties": { @@ -13657,6 +14311,14 @@ var doc = `{ } } }, + "v1.LockSqlVersionReqV1": { + "type": "object", + "properties": { + "is_locked": { + "type": "boolean" + } + } + }, "v1.MaintenanceTimeResV1": { "type": "object", "properties": { @@ -13773,6 +14435,20 @@ var doc = `{ } } }, + "v1.OperatorResV1": { + "type": "object", + "properties": { + "operator_enums_value": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.EnumsValueResV1" + } + }, + "operator_value": { + "type": "string" + } + } + }, "v1.OptimizationDetail": { "type": "object", "properties": { @@ -14094,6 +14770,20 @@ var doc = `{ } } }, + "v1.ReleaseWorkflows": { + "type": "object", + "properties": { + "target_release_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.TargetReleaseInstance" + } + }, + "workflow_id": { + "type": "string" + } + } + }, "v1.ReportPushConfigList": { "type": "object", "properties": { @@ -14134,6 +14824,20 @@ var doc = `{ } } }, + "v1.RetryExecWorkflowReqV1": { + "type": "object", + "properties": { + "task_ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "workflow_ids": { + "type": "string" + } + } + }, "v1.RewriteRule": { "type": "object", "properties": { @@ -14766,6 +15470,96 @@ var doc = `{ } } }, + "v1.SqlVersionDetailResV1": { + "type": "object", + "properties": { + "stage_id": { + "type": "integer" + }, + "stage_name": { + "type": "string" + }, + "stage_sequence": { + "type": "integer" + }, + "workflow_details": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + } + } + } + }, + "v1.SqlVersionReqV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionStage" + } + }, + "version_number": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.SqlVersionResV1": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "has_associated_workflow": { + "type": "boolean" + }, + "lock_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "version_number": { + "type": "string" + } + } + }, + "v1.SqlVersionStage": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "生产" + }, + "stage_sequence": { + "type": "integer" + }, + "stages_dependency": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionStagesDependency" + } + } + } + }, + "v1.SqlVersionStagesDependency": { + "type": "object", + "properties": { + "source_instance_id": { + "type": "integer" + }, + "target_instance_id": { + "type": "integer" + } + } + }, "v1.StatisticAuditPlanResV1": { "type": "object", "properties": { @@ -14939,6 +15733,23 @@ var doc = `{ } } }, + "v1.TargetReleaseInstance": { + "type": "object", + "properties": { + "instance_id": { + "type": "string" + }, + "instance_schema": { + "type": "string" + }, + "target_instance_id": { + "type": "string" + }, + "target_instance_schema": { + "type": "string" + } + } + }, "v1.TestAuditPlanNotifyConfigResDataV1": { "type": "object", "properties": { @@ -15666,6 +16477,35 @@ var doc = `{ "project_name": { "type": "string" }, + "sql_version_name": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "wait_for_audit", + "wait_for_execution", + "rejected", + "canceled", + "exec_failed", + "executing", + "finished" + ] + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, + "v1.WorkflowDetailWithInstance": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -15681,11 +16521,31 @@ var doc = `{ "workflow_id": { "type": "string" }, + "workflow_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowInstance" + } + }, "workflow_name": { "type": "string" } } }, + "v1.WorkflowInstance": { + "type": "object", + "properties": { + "instance_schema": { + "type": "string" + }, + "instances_id": { + "type": "string" + }, + "instances_name": { + "type": "string" + } + } + }, "v1.WorkflowPassPercentV1": { "type": "object", "properties": { @@ -15819,6 +16679,14 @@ var doc = `{ } } }, + "v1.WorkflowSqlVersionReqV1": { + "type": "object", + "properties": { + "sql_version_id": { + "type": "string" + } + } + }, "v1.WorkflowStageDuration": { "type": "object", "properties": { @@ -16205,6 +17073,35 @@ var doc = `{ } } }, + "v2.AssociatedWorkflow": { + "type": "object", + "properties": { + "sql_version_stage_id": { + "type": "integer" + }, + "stage_sequence": { + "type": "integer" + }, + "status": { + "type": "string", + "enum": [ + "wait_for_audit", + "wait_for_execution", + "rejected", + "canceled", + "exec_failed", + "executing", + "finished" + ] + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, "v2.AuditFileExecStatistic": { "type": "object", "properties": { @@ -16384,6 +17281,10 @@ var doc = `{ "db_type": { "type": "string" }, + "i18n_audit_result_info": { + "type": "object", + "$ref": "#/definitions/model.I18nAuditResultInfo" + }, "level": { "type": "string", "example": "warn" @@ -16506,6 +17407,9 @@ var doc = `{ "desc": { "type": "string" }, + "sql_version_id": { + "type": "string" + }, "task_ids": { "type": "array", "items": { @@ -17257,6 +18161,10 @@ var doc = `{ "v2.WorkflowResV2": { "type": "object", "properties": { + "associated_workflow": { + "type": "object", + "$ref": "#/definitions/v2.AssociatedWorkflow" + }, "create_time": { "type": "string" }, @@ -17290,6 +18198,9 @@ var doc = `{ "$ref": "#/definitions/v2.WorkflowRecordResV2" } }, + "sql_version_name": { + "type": "string" + }, "workflow_id": { "type": "string" }, diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 3040254cf..ced144966 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -5200,6 +5200,535 @@ } } }, + "/v1/projects/{project_name}/sql_version": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "sql version list", + "consumes": [ + "application/json" + ], + "tags": [ + "sql_version" + ], + "summary": "获取sql版本列表", + "operationId": "getSqlVersionListV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "filter by created at from", + "name": "filter_by_created_at_from", + "in": "query" + }, + { + "type": "string", + "description": "filter by created at to", + "name": "filter_by_created_at_to", + "in": "query" + }, + { + "type": "string", + "description": "filter by lock time from", + "name": "filter_by_lock_time_from", + "in": "query" + }, + { + "type": "string", + "description": "filter by lock time to", + "name": "filter_by_lock_time_to", + "in": "query" + }, + { + "type": "string", + "description": "fuzzy search", + "name": "fuzzy_search", + "in": "query" + }, + { + "type": "integer", + "description": "page index", + "name": "page_index", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "size of per page", + "name": "page_size", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlVersionListResV1" + } + } + } + }, + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "create sql version", + "consumes": [ + "application/json" + ], + "tags": [ + "sql_version" + ], + "summary": "创建sql版本记录", + "operationId": "createSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "description": "create sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.SqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/workflow/{workflow_id}/": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "workflow sql version", + "tags": [ + "sql_version" + ], + "summary": "工单与版本建立关联", + "operationId": "workflowSqlVersion", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "path", + "required": true + }, + { + "description": "workflow sql version request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.WorkflowSqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get sql version detail", + "tags": [ + "sql_version" + ], + "summary": "获取sql版本详情", + "operationId": "getSqlVersionDetailV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update sql version", + "tags": [ + "sql_version" + ], + "summary": "更新sql版本信息", + "operationId": "updateSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "update sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.SqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "delete sql version", + "tags": [ + "sql_version" + ], + "summary": "删除sql版本", + "operationId": "deleteSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/lock": { + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "lock sql version", + "tags": [ + "sql_version" + ], + "summary": "锁定sql版本", + "operationId": "lockSqlVersionV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "lock sql version request", + "name": "sql_version", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LockSqlVersionReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get dependencies between stage instance", + "tags": [ + "sql_version" + ], + "summary": "获取当前阶段与下一阶段实例的依赖信息", + "operationId": "getInstanceTipListV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetInstanceTipsResV1" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "batch execute tasks on workflow", + "tags": [ + "sql_version" + ], + "summary": "工单批量上线", + "operationId": "batchExecuteTasksOnWorkflow", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "batch execute tasks on workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "batch release workflow", + "tags": [ + "sql_version" + ], + "summary": "批量发布工单", + "operationId": "batchReleaseWorkflowV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "batch release workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, + "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "reject exec failed workflow", + "tags": [ + "sql_version" + ], + "summary": "工单重试", + "operationId": "rejectExecFailedWorkflow", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "description": "reject exec failed workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/projects/{project_name}/statistic/audit_plans": { "get": { "security": [ @@ -9866,10 +10395,28 @@ } } }, + "model.AuditResultInfo": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "model.I18nAuditResultInfo": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/model.AuditResultInfo" + } + }, "params.EnumsValue": { "type": "object", "properties": { "desc": { + "description": "Deprecated: use I18nDesc instead", + "type": "string" + }, + "i18n_desc": { "type": "string" }, "value": { @@ -9956,7 +10503,7 @@ "high_priority_conditions": { "type": "array", "items": { - "$ref": "#/definitions/v1.HighPriorityCondition" + "$ref": "#/definitions/v1.HighPriorityConditionResV1" } }, "instance_type": { @@ -9984,7 +10531,7 @@ "enums_value": { "type": "array", "items": { - "$ref": "#/definitions/params.EnumsValue" + "$ref": "#/definitions/v1.EnumsValueResV1" } }, "key": { @@ -10558,6 +11105,17 @@ } } }, + "v1.BatchExecuteTasksOnWorkflowReqV1": { + "type": "object", + "properties": { + "workflow_ids": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "v1.BatchGetInstanceConnectionsResV1": { "type": "object", "properties": { @@ -10577,6 +11135,17 @@ } } }, + "v1.BatchReleaseWorkflowReqV1": { + "type": "object", + "properties": { + "release_workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.ReleaseWorkflows" + } + } + } + }, "v1.BatchUpdateSqlManageReq": { "type": "object", "properties": { @@ -11258,6 +11827,17 @@ } } }, + "v1.EnumsValueResV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "v1.ExplainClassicResult": { "type": "object", "properties": { @@ -12787,19 +13367,56 @@ "message": { "type": "string", "example": "ok" - }, - "sql_manage_bad_num": { - "type": "integer" - }, - "sql_manage_optimized_num": { - "type": "integer" - }, - "sql_manage_total_num": { - "type": "integer" + }, + "sql_manage_bad_num": { + "type": "integer" + }, + "sql_manage_optimized_num": { + "type": "integer" + }, + "sql_manage_total_num": { + "type": "integer" + } + } + }, + "v1.GetSqlManageRuleTipsResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.RuleTips" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, + "v1.GetSqlManageSqlAnalysisResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "description": "V1版本不能引用V2版本的结构体,所以只能复制一份", + "type": "object", + "$ref": "#/definitions/v1.SqlAnalysis" + }, + "message": { + "type": "string", + "example": "ok" } } }, - "v1.GetSqlManageRuleTipsResp": { + "v1.GetSqlVersionDetailResV1": { "type": "object", "properties": { "code": { @@ -12809,7 +13426,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/v1.RuleTips" + "$ref": "#/definitions/v1.SqlVersionDetailResV1" } }, "message": { @@ -12818,7 +13435,7 @@ } } }, - "v1.GetSqlManageSqlAnalysisResp": { + "v1.GetSqlVersionListResV1": { "type": "object", "properties": { "code": { @@ -12826,13 +13443,17 @@ "example": 0 }, "data": { - "description": "V1版本不能引用V2版本的结构体,所以只能复制一份", - "type": "object", - "$ref": "#/definitions/v1.SqlAnalysis" + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionResV1" + } }, "message": { "type": "string", "example": "ok" + }, + "total_nums": { + "type": "integer" } } }, @@ -13312,6 +13933,39 @@ } } }, + "v1.HighPriorityConditionResV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "enums_value": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.EnumsValueResV1" + } + }, + "key": { + "type": "string" + }, + "operator": { + "type": "object", + "$ref": "#/definitions/v1.OperatorResV1" + }, + "type": { + "type": "string", + "enum": [ + "string", + "int", + "bool", + "password" + ] + }, + "value": { + "type": "string" + } + } + }, "v1.InstanceAdditionalParamResV1": { "type": "object", "properties": { @@ -13641,6 +14295,14 @@ } } }, + "v1.LockSqlVersionReqV1": { + "type": "object", + "properties": { + "is_locked": { + "type": "boolean" + } + } + }, "v1.MaintenanceTimeResV1": { "type": "object", "properties": { @@ -13757,6 +14419,20 @@ } } }, + "v1.OperatorResV1": { + "type": "object", + "properties": { + "operator_enums_value": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.EnumsValueResV1" + } + }, + "operator_value": { + "type": "string" + } + } + }, "v1.OptimizationDetail": { "type": "object", "properties": { @@ -14078,6 +14754,20 @@ } } }, + "v1.ReleaseWorkflows": { + "type": "object", + "properties": { + "target_release_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.TargetReleaseInstance" + } + }, + "workflow_id": { + "type": "string" + } + } + }, "v1.ReportPushConfigList": { "type": "object", "properties": { @@ -14118,6 +14808,20 @@ } } }, + "v1.RetryExecWorkflowReqV1": { + "type": "object", + "properties": { + "task_ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "workflow_ids": { + "type": "string" + } + } + }, "v1.RewriteRule": { "type": "object", "properties": { @@ -14750,6 +15454,96 @@ } } }, + "v1.SqlVersionDetailResV1": { + "type": "object", + "properties": { + "stage_id": { + "type": "integer" + }, + "stage_name": { + "type": "string" + }, + "stage_sequence": { + "type": "integer" + }, + "workflow_details": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + } + } + } + }, + "v1.SqlVersionReqV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionStage" + } + }, + "version_number": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.SqlVersionResV1": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "has_associated_workflow": { + "type": "boolean" + }, + "lock_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "version_number": { + "type": "string" + } + } + }, + "v1.SqlVersionStage": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "生产" + }, + "stage_sequence": { + "type": "integer" + }, + "stages_dependency": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.SqlVersionStagesDependency" + } + } + } + }, + "v1.SqlVersionStagesDependency": { + "type": "object", + "properties": { + "source_instance_id": { + "type": "integer" + }, + "target_instance_id": { + "type": "integer" + } + } + }, "v1.StatisticAuditPlanResV1": { "type": "object", "properties": { @@ -14923,6 +15717,23 @@ } } }, + "v1.TargetReleaseInstance": { + "type": "object", + "properties": { + "instance_id": { + "type": "string" + }, + "instance_schema": { + "type": "string" + }, + "target_instance_id": { + "type": "string" + }, + "target_instance_schema": { + "type": "string" + } + } + }, "v1.TestAuditPlanNotifyConfigResDataV1": { "type": "object", "properties": { @@ -15650,6 +16461,35 @@ "project_name": { "type": "string" }, + "sql_version_name": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "wait_for_audit", + "wait_for_execution", + "rejected", + "canceled", + "exec_failed", + "executing", + "finished" + ] + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, + "v1.WorkflowDetailWithInstance": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -15665,11 +16505,31 @@ "workflow_id": { "type": "string" }, + "workflow_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowInstance" + } + }, "workflow_name": { "type": "string" } } }, + "v1.WorkflowInstance": { + "type": "object", + "properties": { + "instance_schema": { + "type": "string" + }, + "instances_id": { + "type": "string" + }, + "instances_name": { + "type": "string" + } + } + }, "v1.WorkflowPassPercentV1": { "type": "object", "properties": { @@ -15803,6 +16663,14 @@ } } }, + "v1.WorkflowSqlVersionReqV1": { + "type": "object", + "properties": { + "sql_version_id": { + "type": "string" + } + } + }, "v1.WorkflowStageDuration": { "type": "object", "properties": { @@ -16189,6 +17057,35 @@ } } }, + "v2.AssociatedWorkflow": { + "type": "object", + "properties": { + "sql_version_stage_id": { + "type": "integer" + }, + "stage_sequence": { + "type": "integer" + }, + "status": { + "type": "string", + "enum": [ + "wait_for_audit", + "wait_for_execution", + "rejected", + "canceled", + "exec_failed", + "executing", + "finished" + ] + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, "v2.AuditFileExecStatistic": { "type": "object", "properties": { @@ -16368,6 +17265,10 @@ "db_type": { "type": "string" }, + "i18n_audit_result_info": { + "type": "object", + "$ref": "#/definitions/model.I18nAuditResultInfo" + }, "level": { "type": "string", "example": "warn" @@ -16490,6 +17391,9 @@ "desc": { "type": "string" }, + "sql_version_id": { + "type": "string" + }, "task_ids": { "type": "array", "items": { @@ -17241,6 +18145,10 @@ "v2.WorkflowResV2": { "type": "object", "properties": { + "associated_workflow": { + "type": "object", + "$ref": "#/definitions/v2.AssociatedWorkflow" + }, "create_time": { "type": "string" }, @@ -17274,6 +18182,9 @@ "$ref": "#/definitions/v2.WorkflowRecordResV2" } }, + "sql_version_name": { + "type": "string" + }, "workflow_id": { "type": "string" }, diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 33fdd3dd0..dc38ac843 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -9,9 +9,21 @@ definitions: example: ok type: string type: object + model.AuditResultInfo: + properties: + message: + type: string + type: object + model.I18nAuditResultInfo: + additionalProperties: + $ref: '#/definitions/model.AuditResultInfo' + type: object params.EnumsValue: properties: desc: + description: 'Deprecated: use I18nDesc instead' + type: string + i18n_desc: type: string value: type: string @@ -68,7 +80,7 @@ definitions: type: string high_priority_conditions: items: - $ref: '#/definitions/v1.HighPriorityCondition' + $ref: '#/definitions/v1.HighPriorityConditionResV1' type: array instance_type: type: string @@ -86,7 +98,7 @@ definitions: type: string enums_value: items: - $ref: '#/definitions/params.EnumsValue' + $ref: '#/definitions/v1.EnumsValueResV1' type: array key: type: string @@ -480,6 +492,13 @@ definitions: type: string type: array type: object + v1.BatchExecuteTasksOnWorkflowReqV1: + properties: + workflow_ids: + items: + type: string + type: array + type: object v1.BatchGetInstanceConnectionsResV1: properties: code: @@ -493,6 +512,13 @@ definitions: example: ok type: string type: object + v1.BatchReleaseWorkflowReqV1: + properties: + release_workflows: + items: + $ref: '#/definitions/v1.ReleaseWorkflows' + type: array + type: object v1.BatchUpdateSqlManageReq: properties: assignees: @@ -968,6 +994,13 @@ definitions: type: string type: array type: object + v1.EnumsValueResV1: + properties: + desc: + type: string + value: + type: string + type: object v1.ExplainClassicResult: properties: head: @@ -2052,6 +2085,34 @@ definitions: example: ok type: string type: object + v1.GetSqlVersionDetailResV1: + properties: + code: + example: 0 + type: integer + data: + items: + $ref: '#/definitions/v1.SqlVersionDetailResV1' + type: array + message: + example: ok + type: string + type: object + v1.GetSqlVersionListResV1: + properties: + code: + example: 0 + type: integer + data: + items: + $ref: '#/definitions/v1.SqlVersionResV1' + type: array + message: + example: ok + type: string + total_nums: + type: integer + type: object v1.GetSystemVariablesResV1: properties: code: @@ -2384,6 +2445,29 @@ definitions: value: type: string type: object + v1.HighPriorityConditionResV1: + properties: + desc: + type: string + enums_value: + items: + $ref: '#/definitions/v1.EnumsValueResV1' + type: array + key: + type: string + operator: + $ref: '#/definitions/v1.OperatorResV1' + type: object + type: + enum: + - string + - int + - bool + - password + type: string + value: + type: string + type: object v1.InstanceAdditionalParamResV1: properties: description: @@ -2605,6 +2689,11 @@ definitions: example: ok type: string type: object + v1.LockSqlVersionReqV1: + properties: + is_locked: + type: boolean + type: object v1.MaintenanceTimeResV1: properties: maintenance_start_time: @@ -2681,6 +2770,15 @@ definitions: operator_value: type: string type: object + v1.OperatorResV1: + properties: + operator_enums_value: + items: + $ref: '#/definitions/v1.EnumsValueResV1' + type: array + operator_value: + type: string + type: object v1.OptimizationDetail: properties: basic_summary: @@ -2898,6 +2996,15 @@ definitions: reason: type: string type: object + v1.ReleaseWorkflows: + properties: + target_release_instances: + items: + $ref: '#/definitions/v1.TargetReleaseInstance' + type: array + workflow_id: + type: string + type: object v1.ReportPushConfigList: properties: enabled: @@ -2925,6 +3032,15 @@ definitions: type: type: string type: object + v1.RetryExecWorkflowReqV1: + properties: + task_ids: + items: + type: integer + type: array + workflow_ids: + type: string + type: object v1.RewriteRule: properties: message: @@ -3348,6 +3464,65 @@ definitions: - manual_audited type: string type: object + v1.SqlVersionDetailResV1: + properties: + stage_id: + type: integer + stage_name: + type: string + stage_sequence: + type: integer + workflow_details: + items: + $ref: '#/definitions/v1.WorkflowDetailWithInstance' + type: array + type: object + v1.SqlVersionReqV1: + properties: + desc: + type: string + sql_version_stage: + items: + $ref: '#/definitions/v1.SqlVersionStage' + type: array + version_number: + example: "2.23" + type: string + type: object + v1.SqlVersionResV1: + properties: + created_at: + type: string + desc: + type: string + has_associated_workflow: + type: boolean + lock_time: + type: string + status: + type: string + version_number: + type: string + type: object + v1.SqlVersionStage: + properties: + name: + example: 生产 + type: string + stage_sequence: + type: integer + stages_dependency: + items: + $ref: '#/definitions/v1.SqlVersionStagesDependency' + type: array + type: object + v1.SqlVersionStagesDependency: + properties: + source_instance_id: + type: integer + target_instance_id: + type: integer + type: object v1.StatisticAuditPlanResV1: properties: code: @@ -3463,6 +3638,17 @@ definitions: $ref: '#/definitions/v1.TableMeta' type: array type: object + v1.TargetReleaseInstance: + properties: + instance_id: + type: string + instance_schema: + type: string + target_instance_id: + type: string + target_instance_schema: + type: string + type: object v1.TestAuditPlanNotifyConfigResDataV1: properties: is_notify_send_normal: @@ -3956,6 +4142,27 @@ definitions: type: string project_name: type: string + sql_version_name: + type: string + status: + enum: + - wait_for_audit + - wait_for_execution + - rejected + - canceled + - exec_failed + - executing + - finished + type: string + workflow_id: + type: string + workflow_name: + type: string + type: object + v1.WorkflowDetailWithInstance: + properties: + desc: + type: string status: enum: - wait_for_audit @@ -3968,9 +4175,22 @@ definitions: type: string workflow_id: type: string + workflow_instances: + items: + $ref: '#/definitions/v1.WorkflowInstance' + type: array workflow_name: type: string type: object + v1.WorkflowInstance: + properties: + instance_schema: + type: string + instances_id: + type: string + instances_name: + type: string + type: object v1.WorkflowPassPercentV1: properties: audit_pass_percent: @@ -4060,6 +4280,11 @@ definitions: workflow_name: type: string type: object + v1.WorkflowSqlVersionReqV1: + properties: + sql_version_id: + type: string + type: object v1.WorkflowStageDuration: properties: minutes: @@ -4331,6 +4556,27 @@ definitions: err_message: type: string type: object + v2.AssociatedWorkflow: + properties: + sql_version_stage_id: + type: integer + stage_sequence: + type: integer + status: + enum: + - wait_for_audit + - wait_for_execution + - rejected + - canceled + - exec_failed + - executing + - finished + type: string + workflow_id: + type: string + workflow_name: + type: string + type: object v2.AuditFileExecStatistic: properties: exec_result_count: @@ -4457,6 +4703,9 @@ definitions: properties: db_type: type: string + i18n_audit_result_info: + $ref: '#/definitions/model.I18nAuditResultInfo' + type: object level: example: warn type: string @@ -4537,6 +4786,8 @@ definitions: properties: desc: type: string + sql_version_id: + type: string task_ids: items: type: integer @@ -5056,6 +5307,9 @@ definitions: type: object v2.WorkflowResV2: properties: + associated_workflow: + $ref: '#/definitions/v2.AssociatedWorkflow' + type: object create_time: type: string create_user_name: @@ -5079,6 +5333,8 @@ definitions: items: $ref: '#/definitions/v2.WorkflowRecordResV2' type: array + sql_version_name: + type: string workflow_id: type: string workflow_name: @@ -8507,6 +8763,349 @@ paths: summary: 获取SQL优化语句详情 tags: - sql_optimization + /v1/projects/{project_name}/sql_version: + get: + consumes: + - application/json + description: sql version list + operationId: getSqlVersionListV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: filter by created at from + in: query + name: filter_by_created_at_from + type: string + - description: filter by created at to + in: query + name: filter_by_created_at_to + type: string + - description: filter by lock time from + in: query + name: filter_by_lock_time_from + type: string + - description: filter by lock time to + in: query + name: filter_by_lock_time_to + type: string + - description: fuzzy search + in: query + name: fuzzy_search + type: string + - description: page index + in: query + name: page_index + required: true + type: integer + - description: size of per page + in: query + name: page_size + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetSqlVersionListResV1' + security: + - ApiKeyAuth: [] + summary: 获取sql版本列表 + tags: + - sql_version + post: + consumes: + - application/json + description: create sql version + operationId: createSqlVersionV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: create sql version request + in: body + name: sql_version + required: true + schema: + $ref: '#/definitions/v1.SqlVersionReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 创建sql版本记录 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/: + delete: + description: delete sql version + operationId: deleteSqlVersionV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 删除sql版本 + tags: + - sql_version + get: + description: get sql version detail + operationId: getSqlVersionDetailV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetSqlVersionDetailResV1' + security: + - ApiKeyAuth: [] + summary: 获取sql版本详情 + tags: + - sql_version + put: + description: update sql version + operationId: updateSqlVersionV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: update sql version request + in: body + name: sql_version + required: true + schema: + $ref: '#/definitions/v1.SqlVersionReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 更新sql版本信息 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/lock: + patch: + description: lock sql version + operationId: lockSqlVersionV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: lock sql version request + in: body + name: sql_version + required: true + schema: + $ref: '#/definitions/v1.LockSqlVersionReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 锁定sql版本 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies: + get: + description: get dependencies between stage instance + operationId: getInstanceTipListV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: sql version stage id + in: path + name: sql_version_stage_id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetInstanceTipsResV1' + security: + - ApiKeyAuth: [] + summary: 获取当前阶段与下一阶段实例的依赖信息 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute: + post: + description: batch execute tasks on workflow + operationId: batchExecuteTasksOnWorkflow + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: batch execute tasks on workflow request + in: body + name: data + required: true + schema: + $ref: '#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 工单批量上线 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release: + post: + description: batch release workflow + operationId: batchReleaseWorkflowV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: batch release workflow request + in: body + name: data + required: true + schema: + $ref: '#/definitions/v1.BatchReleaseWorkflowReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 批量发布工单 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry: + post: + description: reject exec failed workflow + operationId: rejectExecFailedWorkflow + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: reject exec failed workflow request + in: body + name: data + required: true + schema: + $ref: '#/definitions/v1.RetryExecWorkflowReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 工单重试 + tags: + - sql_version + /v1/projects/{project_name}/sql_version/workflow/{workflow_id}/: + post: + description: workflow sql version + operationId: workflowSqlVersion + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: workflow id + in: path + name: workflow_id + required: true + type: string + - description: workflow sql version request + in: body + name: data + required: true + schema: + $ref: '#/definitions/v1.WorkflowSqlVersionReqV1' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 工单与版本建立关联 + tags: + - sql_version /v1/projects/{project_name}/statistic/audit_plans: get: description: statistic audit plan From aa759a27ba778c2ad2207ef42275ea7287d94223 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Fri, 20 Sep 2024 14:50:28 +0800 Subject: [PATCH 5/8] modify: sql version and workflow api definition modify --- sqle/api/app.go | 23 ++-- sqle/api/controller/v1/sql_version.go | 159 +++++++++++++++-------- sqle/api/controller/v1/sql_version_ce.go | 6 +- sqle/api/controller/v1/workflow.go | 1 + sqle/api/controller/v2/workflow.go | 24 ++-- sqle/model/sql_version.go | 33 +++-- sqle/model/utils.go | 2 +- 7 files changed, 155 insertions(+), 93 deletions(-) diff --git a/sqle/api/app.go b/sqle/api/app.go index 89faae840..3cf34e9dd 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -251,17 +251,18 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti v1ProjectRouter.GET("/:project_name/workflows/:workflow_id/tasks/:task_id/attachment", v1.GetWorkflowTaskAuditFile) // sql version - v1ProjectRouter.POST("/:project_name/sql_version", v1.CreateSqlVersion) - v1ProjectRouter.GET("/:project_name/sql_version", v1.GetSqlVersionList) - v1ProjectRouter.GET("/:project_name/sql_version/:sql_version_id/", v1.GetSqlVersionDetail) - v1ProjectRouter.PUT("/:project_name/sql_version/:sql_version_id/", v1.UpdateSqlVersion) - v1ProjectRouter.DELETE("/:project_name/sql_version/:sql_version_id/", v1.DeleteSqlVersion) - v1ProjectRouter.PATCH("/:project_name/sql_version/:sql_version_id/lock", v1.LockSqlVersion) - v1ProjectRouter.GET("/:project_name/sql_version/:sql_version_id/sql_version_stage/:sql_version_stage_id/dependencies", v1.GetDependenciesBetweenStageInstance) - v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/batch_release", v1.BatchReleaseWorkflows) - v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/batch_execute", v1.BatchExecuteTasksOnWorkflow) - v1ProjectRouter.POST("/:project_name/sql_version/:sql_version_id/workflow/execute_retry", v1.RetryExecWorkflow) - v1ProjectRouter.POST("/:project_name/sql_version/workflow/:workflow_id/", v1.WorkflowSqlVersion) + v1ProjectRouter.POST("/:project_name/sql_versions", v1.CreateSqlVersion) + v1ProjectRouter.GET("/:project_name/sql_versions", v1.GetSqlVersionList) + v1ProjectRouter.GET("/:project_name/sql_versions/:sql_version_id/", v1.GetSqlVersionDetail) + v1ProjectRouter.PATCH("/:project_name/sql_versions/:sql_version_id/", v1.UpdateSqlVersion) + v1ProjectRouter.DELETE("/:project_name/sql_versions/:sql_version_id/", v1.DeleteSqlVersion) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/lock", v1.LockSqlVersion) + v1ProjectRouter.GET("/:project_name/sql_versions/:sql_version_id/sql_version_stages/:sql_version_stage_id/dependencies", v1.GetDependenciesBetweenStageInstance) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/batch_release_workflows", v1.BatchReleaseWorkflows) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/batch_execute_workflows", v1.BatchExecuteTasksOnWorkflow) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/retry_workflow ", v1.RetryExecWorkflow) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/associate_workflows", v1.BatchAssociateWorkflowsWithVersion) + v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/sql_version_stages/:sql_version_stage_id/associate_workflows", v1.GetWorkflowsThatCanBeAssociatedToVersion) // audit plan; 智能扫描任务 v1ProjectRouter.POST("/:project_name/audit_plans", v1.CreateAuditPlan) diff --git a/sqle/api/controller/v1/sql_version.go b/sqle/api/controller/v1/sql_version.go index 8fa579fe0..a7f06b6a0 100644 --- a/sqle/api/controller/v1/sql_version.go +++ b/sqle/api/controller/v1/sql_version.go @@ -7,33 +7,33 @@ import ( "github.com/labstack/echo/v4" ) -type SqlVersionReqV1 struct { - VersionNumber string `json:"version_number" form:"version_number" valid:"required" example:"2.23"` - Desc string `json:"desc" form:"desc"` - SqlVersionStage []SqlVersionStage `json:"sql_version_stage" valid:"dive,required"` +type CreateSqlVersionReqV1 struct { + Version string `json:"version" form:"version" valid:"required" example:"2.23"` + Desc string `json:"desc" form:"desc"` + SqlVersionStage []CreateSqlVersionStage `json:"create_sql_version_stage" valid:"dive,required"` } -type SqlVersionStage struct { - Name string `json:"name" form:"name" valid:"required" example:"生产"` - StageSequence int `json:"stage_sequence" form:"stage_sequence" valid:"required"` - StagesDependency []SqlVersionStagesDependency `json:"stages_dependency" valid:"dive,required"` +type CreateSqlVersionStage struct { + Name string `json:"name" form:"name" valid:"required" example:"生产"` + StageSequence int `json:"stage_sequence" form:"stage_sequence" valid:"required"` + CreateStagesInstanceDep []CreateStagesInstanceDep `json:"create_stages_instance_dep"` } -type SqlVersionStagesDependency struct { - StageInstanceID uint `json:"source_instance_id"` - NextStageInstanceID uint `json:"target_instance_id"` +type CreateStagesInstanceDep struct { + StageInstanceID string `json:"stage_instance_id"` + NextStageInstanceID string `json:"next_stage_instance_id"` } -// @Summary 创建sql版本记录 +// @Summary 创建SQL版本记录 // @Description create sql version // @Id createSqlVersionV1 // @Tags sql_version // @Security ApiKeyAuth // @Accept json // @Param project_name path string true "project name" -// @Param sql_version body v1.SqlVersionReqV1 true "create sql version request" +// @Param sql_version body v1.CreateSqlVersionReqV1 true "create sql version request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version [post] +// @router /v1/projects/{project_name}/sql_versions [post] func CreateSqlVersion(c echo.Context) error { /** @@ -52,6 +52,7 @@ type GetSqlVersionListReqV1 struct { FilterByCreatedAtTo *string `json:"filter_by_created_at_to,omitempty" query:"filter_by_created_at_to"` FilterByLockTimeFrom *string `json:"filter_by_lock_time_from,omitempty" query:"filter_by_lock_time_from"` FilterByLockTimeTo *string `json:"filter_by_lock_time_to,omitempty" query:"filter_by_lock_time_to"` + FilterByVersionStatus *string `json:"filter_by_version_status,omitempty" query:"filter_by_version_status"` FuzzySearch *string `json:"fuzzy_search,omitempty" query:"fuzzy_search"` PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` @@ -65,15 +66,16 @@ type GetSqlVersionListResV1 struct { } type SqlVersionResV1 struct { - VersionNumber string `json:"version_number"` + VersionID uint `json:"version_id"` + Version string `json:"version"` Desc string `json:"desc"` - Status string `json:"status"` + Status string `json:"status" enums:"is_being_released,locked"` LockTime *time.Time `json:"lock_time"` CreatedAt *time.Time `json:"created_at"` HasAssociatedWorkflow bool `json:"has_associated_workflow"` } -// @Summary 获取sql版本列表 +// @Summary 获取SQL版本列表 // @Description sql version list // @Id getSqlVersionListV1 // @Tags sql_version @@ -84,11 +86,12 @@ type SqlVersionResV1 struct { // @Param filter_by_created_at_to query string false "filter by created at to" // @Param filter_by_lock_time_from query string false "filter by lock time from" // @Param filter_by_lock_time_to query string false "filter by lock time to" +// @Param filter_by_version_status query string false "filter by version status" // @Param fuzzy_search query string false "fuzzy search" // @Param page_index query uint32 true "page index" // @Param page_size query uint32 true "size of per page" // @Success 200 {object} v1.GetSqlVersionListResV1 -// @router /v1/projects/{project_name}/sql_version [get] +// @router /v1/projects/{project_name}/sql_versions [get] func GetSqlVersionList(c echo.Context) error { // 获取列表同时返回版本是否有关联工单 @@ -120,7 +123,7 @@ type WorkflowInstance struct { InstanceSchema string `json:"instance_schema"` } -// @Summary 获取sql版本详情 +// @Summary 获取SQL版本详情 // @Description get sql version detail // @Id getSqlVersionDetailV1 // @Tags sql_version @@ -128,7 +131,7 @@ type WorkflowInstance struct { // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" // @Success 200 {object} v1.GetSqlVersionDetailResV1 -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [get] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/ [get] func GetSqlVersionDetail(c echo.Context) error { /** @@ -139,24 +142,39 @@ func GetSqlVersionDetail(c echo.Context) error { return getSqlVersionDetail(c) } -// @Summary 更新sql版本信息 +type UpdateSqlVersionReqV1 struct { + Version *string `json:"version" form:"version" example:"2.23"` + Desc *string `json:"desc" form:"desc"` + SqlVersionStage *[]UpdateSqlVersionStage `json:"update_sql_version_stage"` +} + +type UpdateSqlVersionStage struct { + StageID *uint `json:"stage_id" form:"stage_id"` + Name *string `json:"name" form:"name" valid:"required" example:"生产"` + StageSequence *int `json:"stage_sequence" form:"stage_sequence" valid:"required"` + CreateStagesInstanceDep *[]UpdateStagesInstanceDep `json:"update_stages_instance_dep"` +} + +type UpdateStagesInstanceDep struct { + StageInstanceID string `json:"stage_instance_id"` + NextStageInstanceID string `json:"next_stage_instance_id"` +} + +// @Summary 更新SQL版本信息 // @Description update sql version // @Id updateSqlVersionV1 // @Tags sql_version // @Security ApiKeyAuth // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" -// @Param sql_version body v1.SqlVersionReqV1 true "update sql version request" +// @Param sql_version body v1.UpdateSqlVersionReqV1 false "update sql version request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [put] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/ [patch] func UpdateSqlVersion(c echo.Context) error { /** - 没有工单: 1、getStageBySqlVersionID 2、save sql version - 3、遍历db stage,嵌套遍历req satge,根据stage顺号对比更新、删除、添加stage - 有工单: - save sql version + 3、如果要更新stage,传入完整的stage,覆盖式更新stage及dependency **/ return updateSqlVersion(c) } @@ -165,7 +183,7 @@ type LockSqlVersionReqV1 struct { IsLocked bool `json:"is_locked"` } -// @Summary 锁定sql版本 +// @Summary 锁定SQL版本 // @Description lock sql version // @Id lockSqlVersionV1 // @Tags sql_version @@ -174,13 +192,13 @@ type LockSqlVersionReqV1 struct { // @Param sql_version_id path string true "sql version id" // @Param sql_version body v1.LockSqlVersionReqV1 true "lock sql version request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/lock [patch] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/lock [post] func LockSqlVersion(c echo.Context) error { return lockSqlVersion(c) } -// @Summary 删除sql版本 +// @Summary 删除SQL版本 // @Description delete sql version // @Id deleteSqlVersionV1 // @Tags sql_version @@ -188,7 +206,7 @@ func LockSqlVersion(c echo.Context) error { // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/ [delete] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/ [delete] func DeleteSqlVersion(c echo.Context) error { // delete sql version // delete stage @@ -203,20 +221,22 @@ type GetDepBetweenStageInstanceResV1 struct { } type DepBetweenStageInstance struct { - StageInstanceID string `json:"stage_instance_id"` - NextStageInstanceID string `json:"next_stage_instance_id"` + StageInstanceID string `json:"stage_instance_id"` + StageInstanceName string `json:"stage_instance_name"` + NextStageInstanceID string `json:"next_stage_instance_id"` + NextStageInstanceName string `json:"next_stage_instance_name"` } // @Summary 获取当前阶段与下一阶段实例的依赖信息 // @Description get dependencies between stage instance // @Tags sql_version -// @Id getInstanceTipListV1 +// @Id getDependenciesBetweenStageInstanceV1 // @Security ApiKeyAuth // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" // @Param sql_version_stage_id path string true "sql version stage id" -// @Success 200 {object} v1.GetInstanceTipsResV1 -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies [get] +// @Success 200 {object} v1.GetDepBetweenStageInstanceResV1 +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/dependencies [get] func GetDependenciesBetweenStageInstance(c echo.Context) error { /** select * from SqlVersionStagesDependency where SqlVersionStageID = sql_version_stage_id @@ -240,16 +260,16 @@ type TargetReleaseInstance struct { TargetInstanceSchema string `json:"target_instance_schema" form:"target_instance_schema"` } -// @Summary 批量发布工单 +// @Summary 批量发布工单(在版本的下一阶段创建工单) // @Description batch release workflow -// @Id batchReleaseWorkflowV1 +// @Id batchReleaseWorkflowsV1 // @Tags sql_version // @Security ApiKeyAuth // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" // @Param data body v1.BatchReleaseWorkflowReqV1 true "batch release workflow request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release [post] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_release_workflows [post] func BatchReleaseWorkflows(c echo.Context) error { /** 1、遍历获取工单信息,dms.GetWorkflowDetailByWorkflowId(projectUid, workflowID, s.GetWorkflowDetailWithoutInstancesByWorkflowID) @@ -270,13 +290,13 @@ type BatchExecuteTasksOnWorkflowReqV1 struct { // @Summary 工单批量上线 // @Description batch execute tasks on workflow // @Tags sql_version -// @Id batchExecuteTasksOnWorkflow +// @Id batchExecuteTasksOnWorkflowV1 // @Security ApiKeyAuth // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" // @Param data body v1.BatchExecuteTasksOnWorkflowReqV1 true "batch execute tasks on workflow request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute [post] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_execute_workflows [post] func BatchExecuteTasksOnWorkflow(c echo.Context) error { /** 1、遍历workflow id,获取workflow信息 @@ -290,16 +310,16 @@ type RetryExecWorkflowReqV1 struct { TaskIds []uint `json:"task_ids" form:"task_ids" valid:"required"` } -// @Summary 工单重试 +// @Summary 工单重试(上线失败修改sql重试上线) // @Description reject exec failed workflow // @Tags sql_version -// @Id rejectExecFailedWorkflow +// @Id retryExecWorkflowV1 // @Security ApiKeyAuth // @Param project_name path string true "project name" // @Param sql_version_id path string true "sql version id" -// @Param data body v1.RetryExecWorkflowReqV1 true "reject exec failed workflow request" +// @Param data body v1.RetryExecWorkflowReqV1 true "retry execute workflow request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry [post] +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/retry_workflow [post] func RetryExecWorkflow(c echo.Context) error { /** 暂不考虑重复上线问题,用户在修改sql时自行回滚或删除上线成功的sql。 @@ -312,22 +332,51 @@ func RetryExecWorkflow(c echo.Context) error { return retryExecWorkflow(c) } -type WorkflowSqlVersionReqV1 struct { - SqlVersionID *string `json:"sql_version_id"` +type BatchAssociateWorkflowsWithVersionReqV1 struct { + StageAndWorkflows []StageAndWorkflows `json:"stage_Workflows" form:"stage_Workflows" valid:"dive,required"` +} +type StageAndWorkflows struct { + SqlVersionStageID *string `json:"sql_version_stage_id"` + WorkflowID *string `json:"workflow_id" valid:"required"` } -// @Summary 工单与版本建立关联 -// @Description workflow sql version +// @Summary 批量关联工单到版本 +// @Description batch associate workflows with version // @Tags sql_version -// @Id workflowSqlVersion +// @Id batchAssociateWorkflowsWithVersionV1 // @Security ApiKeyAuth // @Param project_name path string true "project name" -// @Param workflow_id path string true "workflow id" -// @Param data body v1.WorkflowSqlVersionReqV1 true "workflow sql version request" +// @Param sql_version_id path string true "sql version id" +// @Param data body v1.BatchAssociateWorkflowsWithVersionReqV1 true "batch associate workflows with version request" // @Success 200 {object} controller.BaseRes -// @router /v1/projects/{project_name}/sql_version/workflow/{workflow_id}/ [post] -func WorkflowSqlVersion(c echo.Context) error { +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/associate_workflows [post] +func BatchAssociateWorkflowsWithVersion(c echo.Context) error { // 与第一个阶段进行关联 - return workflowSqlVersion(c) + return batchAssociateWorkflowsWithVersion(c) +} + +type GetWorkflowsThatCanBeAssociatedToVersionResV1 struct { + controller.BaseRes + Data []*AssociateWorkflows `json:"data"` +} +type AssociateWorkflows struct { + WorkflowID string `json:"workflow_id"` + WorkflowName string `json:"workflow_name"` + WorkflowDesc string `json:"desc"` +} + +// @Summary 获取可与版本关联的工单 +// @Description get workflows that can be associated to version +// @Tags sql_version +// @Id GetWorkflowsThatCanBeAssociatedToVersionV1 +// @Security ApiKeyAuth +// @Param project_name path string true "project name" +// @Param sql_version_id path string true "sql version id" +// @Param sql_version_stage_id path string true "sql version stage id" +// @Success 200 {object} v1.GetWorkflowsThatCanBeAssociatedToVersionResV1 +// @router /v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/associate_workflows [get] +func GetWorkflowsThatCanBeAssociatedToVersion(c echo.Context) error { + + return getWorkflowsThatCanBeAssociatedToVersion(c) } diff --git a/sqle/api/controller/v1/sql_version_ce.go b/sqle/api/controller/v1/sql_version_ce.go index 7ade1a796..25f829380 100644 --- a/sqle/api/controller/v1/sql_version_ce.go +++ b/sqle/api/controller/v1/sql_version_ce.go @@ -40,6 +40,10 @@ func batchExecuteTasksOnWorkflow(c echo.Context) error { func retryExecWorkflow(c echo.Context) error { return ErrCommunityEditionNotSupportSqlManage } -func workflowSqlVersion(c echo.Context) error { +func batchAssociateWorkflowsWithVersion(c echo.Context) error { + return ErrCommunityEditionNotSupportSqlManage +} + +func getWorkflowsThatCanBeAssociatedToVersion(c echo.Context) error { return ErrCommunityEditionNotSupportSqlManage } diff --git a/sqle/api/controller/v1/workflow.go b/sqle/api/controller/v1/workflow.go index 9c82a43a1..192021766 100644 --- a/sqle/api/controller/v1/workflow.go +++ b/sqle/api/controller/v1/workflow.go @@ -504,6 +504,7 @@ type GetWorkflowsReqV1 struct { FilterTaskInstanceId string `json:"filter_task_instance_id" query:"filter_task_instance_id"` FilterTaskExecuteStartTimeFrom string `json:"filter_task_execute_start_time_from" query:"filter_task_execute_start_time_from"` FilterTaskExecuteStartTimeTo string `json:"filter_task_execute_start_time_to" query:"filter_task_execute_start_time_to"` + FilterSqlVersionID *uint `json:"filter_sql_version_id" query:"filter_sql_version_id"` PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` PageSize uint32 `json:"page_size" query:"page_size" valid:"required"` FuzzyKeyword string `json:"fuzzy_keyword" query:"fuzzy_keyword"` diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index ac076d16e..5780224d2 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -1098,20 +1098,20 @@ 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"` - SqlVersionName string `json:"sql_version_name"` - Record *WorkflowRecordResV2 `json:"record"` - RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,omitempty"` - AssociatedWorkflow *AssociatedWorkflow `json:"associated_workflow,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"` + SqlVersionName string `json:"sql_version_name"` + Record *WorkflowRecordResV2 `json:"record"` + RecordHistory []*WorkflowRecordResV2 `json:"record_history_list,omitempty"` + AssociatedVersionStageWorkflows *AssociatedVersionStageWorkflows `json:"associated_version_stage_workflows,omitempty"` } -type AssociatedWorkflow struct { +type AssociatedVersionStageWorkflows struct { WorkflowID string `json:"workflow_id"` WorkflowName string `json:"workflow_name"` Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` diff --git a/sqle/model/sql_version.go b/sqle/model/sql_version.go index f80feb728..cfea25ce4 100644 --- a/sqle/model/sql_version.go +++ b/sqle/model/sql_version.go @@ -1,19 +1,25 @@ package model -import "time" +import ( + "time" +) type SqlVersion struct { Model - VersionNumber string `json:"version_number" gorm:"type:varchar(255) not null"` - Desc string `json:"desc" gorm:"type:varchar(512)"` - Status string `json:"status" gorm:"type:varchar(255)"` - LockTime *time.Time `json:"lock_time" gorm:"type:datetime(3)"` - IsLocked bool `json:"is_locked" gorm:"type:bool" example:"false"` - ProjectId ProjectUID `gorm:"index; not null"` + Version string `json:"version" gorm:"type:varchar(255) not null"` + Desc string `json:"desc" gorm:"type:varchar(512)"` + Status string `json:"status" gorm:"type:varchar(255)"` + LockTime *time.Time `json:"lock_time" gorm:"type:datetime(3)"` + ProjectId ProjectUID `gorm:"index; not null"` SqlVersionStage []*SqlVersionStage } +const ( + SqlVersionStatusReleased = "is_being_released" + SqlVersionStatusLock = "locked" +) + type SqlVersionStage struct { Model SqlVersionID uint `json:"sql_version_id" gorm:"not null"` @@ -21,20 +27,21 @@ type SqlVersionStage struct { StageSequence int `json:"stage_sequence" gorm:"type:int not null"` SqlVersionStagesDependency []*SqlVersionStagesDependency - WorkflowReleaseStage []*WorkflowReleaseStage + WorkflowReleaseStage []*WorkflowVersionStage } type SqlVersionStagesDependency struct { Model - SqlVersionStageID uint `json:"sql_version_stage_id" gorm:"not null"` - NextStageID uint `json:"next_stage_id"` - StageInstanceID uint `json:"stage_instance_id" gorm:"not null"` - NextStageInstanceID uint `json:"next_stage_instance_id"` + SqlVersionStageID uint `json:"sql_version_stage_id" gorm:"not null"` + NextStageID uint `json:"next_stage_id"` + StageInstanceID uint64 `json:"stage_instance_id" gorm:"not null"` + NextStageInstanceID uint64 `json:"next_stage_instance_id"` } -type WorkflowReleaseStage struct { +type WorkflowVersionStage struct { Model WorkflowID string `json:"workflow_id" gorm:"not null"` + SqlVersionID uint `json:"sql_version_id"` SqlVersionStageID uint `json:"sql_version_stage_id"` WorkflowSequence int `json:" workflow_sequence" gorm:"type:int"` diff --git a/sqle/model/utils.go b/sqle/model/utils.go index 48e160b1a..e575a315e 100644 --- a/sqle/model/utils.go +++ b/sqle/model/utils.go @@ -170,7 +170,7 @@ var autoMigrateList = []interface{}{ &SqlVersion{}, &SqlVersionStage{}, &SqlVersionStagesDependency{}, - &WorkflowReleaseStage{}, + &WorkflowVersionStage{}, } func (s *Storage) AutoMigrate() error { From 69555813492165f9990dde423ac4cdc84638c7d8 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Fri, 20 Sep 2024 14:50:39 +0800 Subject: [PATCH 6/8] gen swagger: sql version and workflow api modify --- sqle/docs/docs.go | 457 +++++++++++++++++++++++++++++------------ sqle/docs/swagger.json | 457 +++++++++++++++++++++++++++++------------ sqle/docs/swagger.yaml | 318 +++++++++++++++++++--------- 3 files changed, 870 insertions(+), 362 deletions(-) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 05f568aaa..8b8960c21 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -5216,7 +5216,7 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version": { + "/v1/projects/{project_name}/sql_versions": { "get": { "security": [ { @@ -5230,7 +5230,7 @@ var doc = `{ "tags": [ "sql_version" ], - "summary": "获取sql版本列表", + "summary": "获取SQL版本列表", "operationId": "getSqlVersionListV1", "parameters": [ { @@ -5264,6 +5264,12 @@ var doc = `{ "name": "filter_by_lock_time_to", "in": "query" }, + { + "type": "string", + "description": "filter by version status", + "name": "filter_by_version_status", + "in": "query" + }, { "type": "string", "description": "fuzzy search", @@ -5307,7 +5313,7 @@ var doc = `{ "tags": [ "sql_version" ], - "summary": "创建sql版本记录", + "summary": "创建SQL版本记录", "operationId": "createSqlVersionV1", "parameters": [ { @@ -5323,7 +5329,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.SqlVersionReqV1" + "$ref": "#/definitions/v1.CreateSqlVersionReqV1" } } ], @@ -5337,19 +5343,19 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version/workflow/{workflow_id}/": { - "post": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/": { + "get": { "security": [ { "ApiKeyAuth": [] } ], - "description": "workflow sql version", + "description": "get sql version detail", "tags": [ "sql_version" ], - "summary": "工单与版本建立关联", - "operationId": "workflowSqlVersion", + "summary": "获取SQL版本详情", + "operationId": "getSqlVersionDetailV1", "parameters": [ { "type": "string", @@ -5360,44 +5366,33 @@ var doc = `{ }, { "type": "string", - "description": "workflow id", - "name": "workflow_id", + "description": "sql version id", + "name": "sql_version_id", "in": "path", "required": true - }, - { - "description": "workflow sql version request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1.WorkflowSqlVersionReqV1" - } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controller.BaseRes" + "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" } } } - } - }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/": { - "get": { + }, + "delete": { "security": [ { "ApiKeyAuth": [] } ], - "description": "get sql version detail", + "description": "delete sql version", "tags": [ "sql_version" ], - "summary": "获取sql版本详情", - "operationId": "getSqlVersionDetailV1", + "summary": "删除SQL版本", + "operationId": "deleteSqlVersionV1", "parameters": [ { "type": "string", @@ -5418,12 +5413,12 @@ var doc = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" + "$ref": "#/definitions/controller.BaseRes" } } } }, - "put": { + "patch": { "security": [ { "ApiKeyAuth": [] @@ -5433,7 +5428,7 @@ var doc = `{ "tags": [ "sql_version" ], - "summary": "更新sql版本信息", + "summary": "更新SQL版本信息", "operationId": "updateSqlVersionV1", "parameters": [ { @@ -5454,9 +5449,8 @@ var doc = `{ "description": "update sql version request", "name": "sql_version", "in": "body", - "required": true, "schema": { - "$ref": "#/definitions/v1.SqlVersionReqV1" + "$ref": "#/definitions/v1.UpdateSqlVersionReqV1" } } ], @@ -5468,19 +5462,21 @@ var doc = `{ } } } - }, - "delete": { + } + }, + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/associate_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "delete sql version", + "description": "batch associate workflows with version", "tags": [ "sql_version" ], - "summary": "删除sql版本", - "operationId": "deleteSqlVersionV1", + "summary": "批量关联工单到版本", + "operationId": "batchAssociateWorkflowsWithVersionV1", "parameters": [ { "type": "string", @@ -5495,6 +5491,15 @@ var doc = `{ "name": "sql_version_id", "in": "path", "required": true + }, + { + "description": "batch associate workflows with version request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchAssociateWorkflowsWithVersionReqV1" + } } ], "responses": { @@ -5507,19 +5512,19 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/lock": { - "patch": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_execute_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "lock sql version", + "description": "batch execute tasks on workflow", "tags": [ "sql_version" ], - "summary": "锁定sql版本", - "operationId": "lockSqlVersionV1", + "summary": "工单批量上线", + "operationId": "batchExecuteTasksOnWorkflowV1", "parameters": [ { "type": "string", @@ -5536,12 +5541,12 @@ var doc = `{ "required": true }, { - "description": "lock sql version request", - "name": "sql_version", + "description": "batch execute tasks on workflow request", + "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.LockSqlVersionReqV1" + "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" } } ], @@ -5555,19 +5560,19 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies": { - "get": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_release_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "get dependencies between stage instance", + "description": "batch release workflow", "tags": [ "sql_version" ], - "summary": "获取当前阶段与下一阶段实例的依赖信息", - "operationId": "getInstanceTipListV1", + "summary": "批量发布工单(在版本的下一阶段创建工单)", + "operationId": "batchReleaseWorkflowsV1", "parameters": [ { "type": "string", @@ -5584,36 +5589,38 @@ var doc = `{ "required": true }, { - "type": "string", - "description": "sql version stage id", - "name": "sql_version_stage_id", - "in": "path", - "required": true + "description": "batch release workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.GetInstanceTipsResV1" + "$ref": "#/definitions/controller.BaseRes" } } } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/lock": { "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "batch execute tasks on workflow", + "description": "lock sql version", "tags": [ "sql_version" ], - "summary": "工单批量上线", - "operationId": "batchExecuteTasksOnWorkflow", + "summary": "锁定SQL版本", + "operationId": "lockSqlVersionV1", "parameters": [ { "type": "string", @@ -5630,12 +5637,12 @@ var doc = `{ "required": true }, { - "description": "batch execute tasks on workflow request", - "name": "data", + "description": "lock sql version request", + "name": "sql_version", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" + "$ref": "#/definitions/v1.LockSqlVersionReqV1" } } ], @@ -5649,19 +5656,19 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/retry_workflow": { "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "batch release workflow", + "description": "reject exec failed workflow", "tags": [ "sql_version" ], - "summary": "批量发布工单", - "operationId": "batchReleaseWorkflowV1", + "summary": "工单重试(上线失败修改sql重试上线)", + "operationId": "retryExecWorkflowV1", "parameters": [ { "type": "string", @@ -5678,12 +5685,12 @@ var doc = `{ "required": true }, { - "description": "batch release workflow request", + "description": "retry execute workflow request", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" } } ], @@ -5697,19 +5704,19 @@ var doc = `{ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry": { - "post": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/associate_workflows": { + "get": { "security": [ { "ApiKeyAuth": [] } ], - "description": "reject exec failed workflow", + "description": "get workflows that can be associated to version", "tags": [ "sql_version" ], - "summary": "工单重试", - "operationId": "rejectExecFailedWorkflow", + "summary": "获取可与版本关联的工单", + "operationId": "GetWorkflowsThatCanBeAssociatedToVersionV1", "parameters": [ { "type": "string", @@ -5726,20 +5733,64 @@ var doc = `{ "required": true }, { - "description": "reject exec failed workflow request", - "name": "data", - "in": "body", - "required": true, + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" + "$ref": "#/definitions/v1.GetWorkflowsThatCanBeAssociatedToVersionResV1" } } + } + } + }, + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/dependencies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get dependencies between stage instance", + "tags": [ + "sql_version" + ], + "summary": "获取当前阶段与下一阶段实例的依赖信息", + "operationId": "getDependenciesBetweenStageInstanceV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controller.BaseRes" + "$ref": "#/definitions/v1.GetDepBetweenStageInstanceResV1" } } } @@ -10451,6 +10502,20 @@ var doc = `{ } } }, + "v1.AssociateWorkflows": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, "v1.AuditFileResp": { "type": "object", "properties": { @@ -11088,6 +11153,17 @@ var doc = `{ } } }, + "v1.BatchAssociateWorkflowsWithVersionReqV1": { + "type": "object", + "properties": { + "stage_Workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.StageAndWorkflows" + } + } + } + }, "v1.BatchCancelWorkflowsReqV1": { "type": "object", "properties": { @@ -11602,6 +11678,53 @@ var doc = `{ } } }, + "v1.CreateSqlVersionReqV1": { + "type": "object", + "properties": { + "create_sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.CreateSqlVersionStage" + } + }, + "desc": { + "type": "string" + }, + "version": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.CreateSqlVersionStage": { + "type": "object", + "properties": { + "create_stages_instance_dep": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.CreateStagesInstanceDep" + } + }, + "name": { + "type": "string", + "example": "生产" + }, + "stage_sequence": { + "type": "integer" + } + } + }, + "v1.CreateStagesInstanceDep": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + } + } + }, "v1.CreateWorkflowReqV1": { "type": "object", "properties": { @@ -11710,6 +11833,23 @@ var doc = `{ } } }, + "v1.DepBetweenStageInstance": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "next_stage_instance_name": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + }, + "stage_instance_name": { + "type": "string" + } + } + }, "v1.DingTalkConfigurationV1": { "type": "object", "properties": { @@ -12480,6 +12620,25 @@ var doc = `{ } } }, + "v1.GetDepBetweenStageInstanceResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.DepBetweenStageInstance" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetDingTalkConfigurationResV1": { "type": "object", "properties": { @@ -13896,6 +14055,25 @@ var doc = `{ } } }, + "v1.GetWorkflowsThatCanBeAssociatedToVersionResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.AssociateWorkflows" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.HighPriorityCondition": { "type": "object", "properties": { @@ -15490,24 +15668,6 @@ var doc = `{ } } }, - "v1.SqlVersionReqV1": { - "type": "object", - "properties": { - "desc": { - "type": "string" - }, - "sql_version_stage": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionStage" - } - }, - "version_number": { - "type": "string", - "example": "2.23" - } - } - }, "v1.SqlVersionResV1": { "type": "object", "properties": { @@ -15524,39 +15684,28 @@ var doc = `{ "type": "string" }, "status": { - "type": "string" + "type": "string", + "enum": [ + "is_being_released", + "locked" + ] }, - "version_number": { + "version": { "type": "string" - } - } - }, - "v1.SqlVersionStage": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "生产" }, - "stage_sequence": { + "version_id": { "type": "integer" - }, - "stages_dependency": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionStagesDependency" - } } } }, - "v1.SqlVersionStagesDependency": { + "v1.StageAndWorkflows": { "type": "object", "properties": { - "source_instance_id": { - "type": "integer" + "sql_version_stage_id": { + "type": "string" }, - "target_instance_id": { - "type": "integer" + "workflow_id": { + "type": "string" } } }, @@ -16252,6 +16401,56 @@ var doc = `{ } } }, + "v1.UpdateSqlVersionReqV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "update_sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.UpdateSqlVersionStage" + } + }, + "version": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.UpdateSqlVersionStage": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "生产" + }, + "stage_id": { + "type": "integer" + }, + "stage_sequence": { + "type": "integer" + }, + "update_stages_instance_dep": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.UpdateStagesInstanceDep" + } + } + } + }, + "v1.UpdateStagesInstanceDep": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + } + } + }, "v1.UpdateSystemVariablesReqV1": { "type": "object", "properties": { @@ -16679,14 +16878,6 @@ var doc = `{ } } }, - "v1.WorkflowSqlVersionReqV1": { - "type": "object", - "properties": { - "sql_version_id": { - "type": "string" - } - } - }, "v1.WorkflowStageDuration": { "type": "object", "properties": { @@ -17073,7 +17264,7 @@ var doc = `{ } } }, - "v2.AssociatedWorkflow": { + "v2.AssociatedVersionStageWorkflows": { "type": "object", "properties": { "sql_version_stage_id": { @@ -18161,9 +18352,9 @@ var doc = `{ "v2.WorkflowResV2": { "type": "object", "properties": { - "associated_workflow": { + "associated_version_stage_workflows": { "type": "object", - "$ref": "#/definitions/v2.AssociatedWorkflow" + "$ref": "#/definitions/v2.AssociatedVersionStageWorkflows" }, "create_time": { "type": "string" diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index ced144966..1bd9b9859 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -5200,7 +5200,7 @@ } } }, - "/v1/projects/{project_name}/sql_version": { + "/v1/projects/{project_name}/sql_versions": { "get": { "security": [ { @@ -5214,7 +5214,7 @@ "tags": [ "sql_version" ], - "summary": "获取sql版本列表", + "summary": "获取SQL版本列表", "operationId": "getSqlVersionListV1", "parameters": [ { @@ -5248,6 +5248,12 @@ "name": "filter_by_lock_time_to", "in": "query" }, + { + "type": "string", + "description": "filter by version status", + "name": "filter_by_version_status", + "in": "query" + }, { "type": "string", "description": "fuzzy search", @@ -5291,7 +5297,7 @@ "tags": [ "sql_version" ], - "summary": "创建sql版本记录", + "summary": "创建SQL版本记录", "operationId": "createSqlVersionV1", "parameters": [ { @@ -5307,7 +5313,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.SqlVersionReqV1" + "$ref": "#/definitions/v1.CreateSqlVersionReqV1" } } ], @@ -5321,19 +5327,19 @@ } } }, - "/v1/projects/{project_name}/sql_version/workflow/{workflow_id}/": { - "post": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/": { + "get": { "security": [ { "ApiKeyAuth": [] } ], - "description": "workflow sql version", + "description": "get sql version detail", "tags": [ "sql_version" ], - "summary": "工单与版本建立关联", - "operationId": "workflowSqlVersion", + "summary": "获取SQL版本详情", + "operationId": "getSqlVersionDetailV1", "parameters": [ { "type": "string", @@ -5344,44 +5350,33 @@ }, { "type": "string", - "description": "workflow id", - "name": "workflow_id", + "description": "sql version id", + "name": "sql_version_id", "in": "path", "required": true - }, - { - "description": "workflow sql version request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1.WorkflowSqlVersionReqV1" - } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controller.BaseRes" + "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" } } } - } - }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/": { - "get": { + }, + "delete": { "security": [ { "ApiKeyAuth": [] } ], - "description": "get sql version detail", + "description": "delete sql version", "tags": [ "sql_version" ], - "summary": "获取sql版本详情", - "operationId": "getSqlVersionDetailV1", + "summary": "删除SQL版本", + "operationId": "deleteSqlVersionV1", "parameters": [ { "type": "string", @@ -5402,12 +5397,12 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.GetSqlVersionDetailResV1" + "$ref": "#/definitions/controller.BaseRes" } } } }, - "put": { + "patch": { "security": [ { "ApiKeyAuth": [] @@ -5417,7 +5412,7 @@ "tags": [ "sql_version" ], - "summary": "更新sql版本信息", + "summary": "更新SQL版本信息", "operationId": "updateSqlVersionV1", "parameters": [ { @@ -5438,9 +5433,8 @@ "description": "update sql version request", "name": "sql_version", "in": "body", - "required": true, "schema": { - "$ref": "#/definitions/v1.SqlVersionReqV1" + "$ref": "#/definitions/v1.UpdateSqlVersionReqV1" } } ], @@ -5452,19 +5446,21 @@ } } } - }, - "delete": { + } + }, + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/associate_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "delete sql version", + "description": "batch associate workflows with version", "tags": [ "sql_version" ], - "summary": "删除sql版本", - "operationId": "deleteSqlVersionV1", + "summary": "批量关联工单到版本", + "operationId": "batchAssociateWorkflowsWithVersionV1", "parameters": [ { "type": "string", @@ -5479,6 +5475,15 @@ "name": "sql_version_id", "in": "path", "required": true + }, + { + "description": "batch associate workflows with version request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchAssociateWorkflowsWithVersionReqV1" + } } ], "responses": { @@ -5491,19 +5496,19 @@ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/lock": { - "patch": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_execute_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "lock sql version", + "description": "batch execute tasks on workflow", "tags": [ "sql_version" ], - "summary": "锁定sql版本", - "operationId": "lockSqlVersionV1", + "summary": "工单批量上线", + "operationId": "batchExecuteTasksOnWorkflowV1", "parameters": [ { "type": "string", @@ -5520,12 +5525,12 @@ "required": true }, { - "description": "lock sql version request", - "name": "sql_version", + "description": "batch execute tasks on workflow request", + "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.LockSqlVersionReqV1" + "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" } } ], @@ -5539,19 +5544,19 @@ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies": { - "get": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_release_workflows": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "get dependencies between stage instance", + "description": "batch release workflow", "tags": [ "sql_version" ], - "summary": "获取当前阶段与下一阶段实例的依赖信息", - "operationId": "getInstanceTipListV1", + "summary": "批量发布工单(在版本的下一阶段创建工单)", + "operationId": "batchReleaseWorkflowsV1", "parameters": [ { "type": "string", @@ -5568,36 +5573,38 @@ "required": true }, { - "type": "string", - "description": "sql version stage id", - "name": "sql_version_stage_id", - "in": "path", - "required": true + "description": "batch release workflow request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/v1.GetInstanceTipsResV1" + "$ref": "#/definitions/controller.BaseRes" } } } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/lock": { "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "batch execute tasks on workflow", + "description": "lock sql version", "tags": [ "sql_version" ], - "summary": "工单批量上线", - "operationId": "batchExecuteTasksOnWorkflow", + "summary": "锁定SQL版本", + "operationId": "lockSqlVersionV1", "parameters": [ { "type": "string", @@ -5614,12 +5621,12 @@ "required": true }, { - "description": "batch execute tasks on workflow request", - "name": "data", + "description": "lock sql version request", + "name": "sql_version", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1" + "$ref": "#/definitions/v1.LockSqlVersionReqV1" } } ], @@ -5633,19 +5640,19 @@ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/retry_workflow": { "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "batch release workflow", + "description": "reject exec failed workflow", "tags": [ "sql_version" ], - "summary": "批量发布工单", - "operationId": "batchReleaseWorkflowV1", + "summary": "工单重试(上线失败修改sql重试上线)", + "operationId": "retryExecWorkflowV1", "parameters": [ { "type": "string", @@ -5662,12 +5669,12 @@ "required": true }, { - "description": "batch release workflow request", + "description": "retry execute workflow request", "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.BatchReleaseWorkflowReqV1" + "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" } } ], @@ -5681,19 +5688,19 @@ } } }, - "/v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry": { - "post": { + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/associate_workflows": { + "get": { "security": [ { "ApiKeyAuth": [] } ], - "description": "reject exec failed workflow", + "description": "get workflows that can be associated to version", "tags": [ "sql_version" ], - "summary": "工单重试", - "operationId": "rejectExecFailedWorkflow", + "summary": "获取可与版本关联的工单", + "operationId": "GetWorkflowsThatCanBeAssociatedToVersionV1", "parameters": [ { "type": "string", @@ -5710,20 +5717,64 @@ "required": true }, { - "description": "reject exec failed workflow request", - "name": "data", - "in": "body", - "required": true, + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", "schema": { - "$ref": "#/definitions/v1.RetryExecWorkflowReqV1" + "$ref": "#/definitions/v1.GetWorkflowsThatCanBeAssociatedToVersionResV1" } } + } + } + }, + "/v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/dependencies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get dependencies between stage instance", + "tags": [ + "sql_version" + ], + "summary": "获取当前阶段与下一阶段实例的依赖信息", + "operationId": "getDependenciesBetweenStageInstanceV1", + "parameters": [ + { + "type": "string", + "description": "project name", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version id", + "name": "sql_version_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "sql version stage id", + "name": "sql_version_stage_id", + "in": "path", + "required": true + } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controller.BaseRes" + "$ref": "#/definitions/v1.GetDepBetweenStageInstanceResV1" } } } @@ -10435,6 +10486,20 @@ } } }, + "v1.AssociateWorkflows": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, "v1.AuditFileResp": { "type": "object", "properties": { @@ -11072,6 +11137,17 @@ } } }, + "v1.BatchAssociateWorkflowsWithVersionReqV1": { + "type": "object", + "properties": { + "stage_Workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.StageAndWorkflows" + } + } + } + }, "v1.BatchCancelWorkflowsReqV1": { "type": "object", "properties": { @@ -11586,6 +11662,53 @@ } } }, + "v1.CreateSqlVersionReqV1": { + "type": "object", + "properties": { + "create_sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.CreateSqlVersionStage" + } + }, + "desc": { + "type": "string" + }, + "version": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.CreateSqlVersionStage": { + "type": "object", + "properties": { + "create_stages_instance_dep": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.CreateStagesInstanceDep" + } + }, + "name": { + "type": "string", + "example": "生产" + }, + "stage_sequence": { + "type": "integer" + } + } + }, + "v1.CreateStagesInstanceDep": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + } + } + }, "v1.CreateWorkflowReqV1": { "type": "object", "properties": { @@ -11694,6 +11817,23 @@ } } }, + "v1.DepBetweenStageInstance": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "next_stage_instance_name": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + }, + "stage_instance_name": { + "type": "string" + } + } + }, "v1.DingTalkConfigurationV1": { "type": "object", "properties": { @@ -12464,6 +12604,25 @@ } } }, + "v1.GetDepBetweenStageInstanceResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.DepBetweenStageInstance" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetDingTalkConfigurationResV1": { "type": "object", "properties": { @@ -13880,6 +14039,25 @@ } } }, + "v1.GetWorkflowsThatCanBeAssociatedToVersionResV1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.AssociateWorkflows" + } + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.HighPriorityCondition": { "type": "object", "properties": { @@ -15474,24 +15652,6 @@ } } }, - "v1.SqlVersionReqV1": { - "type": "object", - "properties": { - "desc": { - "type": "string" - }, - "sql_version_stage": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionStage" - } - }, - "version_number": { - "type": "string", - "example": "2.23" - } - } - }, "v1.SqlVersionResV1": { "type": "object", "properties": { @@ -15508,39 +15668,28 @@ "type": "string" }, "status": { - "type": "string" + "type": "string", + "enum": [ + "is_being_released", + "locked" + ] }, - "version_number": { + "version": { "type": "string" - } - } - }, - "v1.SqlVersionStage": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "生产" }, - "stage_sequence": { + "version_id": { "type": "integer" - }, - "stages_dependency": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionStagesDependency" - } } } }, - "v1.SqlVersionStagesDependency": { + "v1.StageAndWorkflows": { "type": "object", "properties": { - "source_instance_id": { - "type": "integer" + "sql_version_stage_id": { + "type": "string" }, - "target_instance_id": { - "type": "integer" + "workflow_id": { + "type": "string" } } }, @@ -16236,6 +16385,56 @@ } } }, + "v1.UpdateSqlVersionReqV1": { + "type": "object", + "properties": { + "desc": { + "type": "string" + }, + "update_sql_version_stage": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.UpdateSqlVersionStage" + } + }, + "version": { + "type": "string", + "example": "2.23" + } + } + }, + "v1.UpdateSqlVersionStage": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "生产" + }, + "stage_id": { + "type": "integer" + }, + "stage_sequence": { + "type": "integer" + }, + "update_stages_instance_dep": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.UpdateStagesInstanceDep" + } + } + } + }, + "v1.UpdateStagesInstanceDep": { + "type": "object", + "properties": { + "next_stage_instance_id": { + "type": "string" + }, + "stage_instance_id": { + "type": "string" + } + } + }, "v1.UpdateSystemVariablesReqV1": { "type": "object", "properties": { @@ -16663,14 +16862,6 @@ } } }, - "v1.WorkflowSqlVersionReqV1": { - "type": "object", - "properties": { - "sql_version_id": { - "type": "string" - } - } - }, "v1.WorkflowStageDuration": { "type": "object", "properties": { @@ -17057,7 +17248,7 @@ } } }, - "v2.AssociatedWorkflow": { + "v2.AssociatedVersionStageWorkflows": { "type": "object", "properties": { "sql_version_stage_id": { @@ -18145,9 +18336,9 @@ "v2.WorkflowResV2": { "type": "object", "properties": { - "associated_workflow": { + "associated_version_stage_workflows": { "type": "object", - "$ref": "#/definitions/v2.AssociatedWorkflow" + "$ref": "#/definitions/v2.AssociatedVersionStageWorkflows" }, "create_time": { "type": "string" diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index dc38ac843..7870a46b2 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -35,6 +35,15 @@ definitions: err_message: type: string type: object + v1.AssociateWorkflows: + properties: + desc: + type: string + workflow_id: + type: string + workflow_name: + type: string + type: object v1.AuditFileResp: properties: file_name: @@ -471,6 +480,13 @@ definitions: total_sql_count: type: integer type: object + v1.BatchAssociateWorkflowsWithVersionReqV1: + properties: + stage_Workflows: + items: + $ref: '#/definitions/v1.StageAndWorkflows' + type: array + type: object v1.BatchCancelWorkflowsReqV1: properties: workflow_names: @@ -825,6 +841,37 @@ definitions: example: ok type: string type: object + v1.CreateSqlVersionReqV1: + properties: + create_sql_version_stage: + items: + $ref: '#/definitions/v1.CreateSqlVersionStage' + type: array + desc: + type: string + version: + example: "2.23" + type: string + type: object + v1.CreateSqlVersionStage: + properties: + create_stages_instance_dep: + items: + $ref: '#/definitions/v1.CreateStagesInstanceDep' + type: array + name: + example: 生产 + type: string + stage_sequence: + type: integer + type: object + v1.CreateStagesInstanceDep: + properties: + next_stage_instance_id: + type: string + stage_instance_id: + type: string + type: object v1.CreateWorkflowReqV1: properties: desc: @@ -898,6 +945,17 @@ definitions: $ref: '#/definitions/v1.WorkflowStatisticsResV1' type: object type: object + v1.DepBetweenStageInstance: + properties: + next_stage_instance_id: + type: string + next_stage_instance_name: + type: string + stage_instance_id: + type: string + stage_instance_name: + type: string + type: object v1.DingTalkConfigurationV1: properties: app_key: @@ -1427,6 +1485,19 @@ definitions: example: ok type: string type: object + v1.GetDepBetweenStageInstanceResV1: + properties: + code: + example: 0 + type: integer + data: + items: + $ref: '#/definitions/v1.DepBetweenStageInstance' + type: array + message: + example: ok + type: string + type: object v1.GetDingTalkConfigurationResV1: properties: code: @@ -2408,6 +2479,19 @@ definitions: total_nums: type: integer type: object + v1.GetWorkflowsThatCanBeAssociatedToVersionResV1: + properties: + code: + example: 0 + type: integer + data: + items: + $ref: '#/definitions/v1.AssociateWorkflows' + type: array + message: + example: ok + type: string + type: object v1.HighPriorityCondition: properties: desc: @@ -3477,18 +3561,6 @@ definitions: $ref: '#/definitions/v1.WorkflowDetailWithInstance' type: array type: object - v1.SqlVersionReqV1: - properties: - desc: - type: string - sql_version_stage: - items: - $ref: '#/definitions/v1.SqlVersionStage' - type: array - version_number: - example: "2.23" - type: string - type: object v1.SqlVersionResV1: properties: created_at: @@ -3500,28 +3572,21 @@ definitions: lock_time: type: string status: + enum: + - is_being_released + - locked type: string - version_number: - type: string - type: object - v1.SqlVersionStage: - properties: - name: - example: 生产 + version: type: string - stage_sequence: + version_id: type: integer - stages_dependency: - items: - $ref: '#/definitions/v1.SqlVersionStagesDependency' - type: array type: object - v1.SqlVersionStagesDependency: + v1.StageAndWorkflows: properties: - source_instance_id: - type: integer - target_instance_id: - type: integer + sql_version_stage_id: + type: string + workflow_id: + type: string type: object v1.StatisticAuditPlanResV1: properties: @@ -3993,6 +4058,39 @@ definitions: $ref: '#/definitions/v1.FileToSort' type: array type: object + v1.UpdateSqlVersionReqV1: + properties: + desc: + type: string + update_sql_version_stage: + items: + $ref: '#/definitions/v1.UpdateSqlVersionStage' + type: array + version: + example: "2.23" + type: string + type: object + v1.UpdateSqlVersionStage: + properties: + name: + example: 生产 + type: string + stage_id: + type: integer + stage_sequence: + type: integer + update_stages_instance_dep: + items: + $ref: '#/definitions/v1.UpdateStagesInstanceDep' + type: array + type: object + v1.UpdateStagesInstanceDep: + properties: + next_stage_instance_id: + type: string + stage_instance_id: + type: string + type: object v1.UpdateSystemVariablesReqV1: properties: cb_operation_logs_expired_hours: @@ -4280,11 +4378,6 @@ definitions: workflow_name: type: string type: object - v1.WorkflowSqlVersionReqV1: - properties: - sql_version_id: - type: string - type: object v1.WorkflowStageDuration: properties: minutes: @@ -4556,7 +4649,7 @@ definitions: err_message: type: string type: object - v2.AssociatedWorkflow: + v2.AssociatedVersionStageWorkflows: properties: sql_version_stage_id: type: integer @@ -5307,8 +5400,8 @@ definitions: type: object v2.WorkflowResV2: properties: - associated_workflow: - $ref: '#/definitions/v2.AssociatedWorkflow' + associated_version_stage_workflows: + $ref: '#/definitions/v2.AssociatedVersionStageWorkflows' type: object create_time: type: string @@ -8763,7 +8856,7 @@ paths: summary: 获取SQL优化语句详情 tags: - sql_optimization - /v1/projects/{project_name}/sql_version: + /v1/projects/{project_name}/sql_versions: get: consumes: - application/json @@ -8791,6 +8884,10 @@ paths: in: query name: filter_by_lock_time_to type: string + - description: filter by version status + in: query + name: filter_by_version_status + type: string - description: fuzzy search in: query name: fuzzy_search @@ -8812,7 +8909,7 @@ paths: $ref: '#/definitions/v1.GetSqlVersionListResV1' security: - ApiKeyAuth: [] - summary: 获取sql版本列表 + summary: 获取SQL版本列表 tags: - sql_version post: @@ -8831,7 +8928,7 @@ paths: name: sql_version required: true schema: - $ref: '#/definitions/v1.SqlVersionReqV1' + $ref: '#/definitions/v1.CreateSqlVersionReqV1' responses: "200": description: OK @@ -8839,10 +8936,10 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 创建sql版本记录 + summary: 创建SQL版本记录 tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/: + /v1/projects/{project_name}/sql_versions/{sql_version_id}/: delete: description: delete sql version operationId: deleteSqlVersionV1 @@ -8864,7 +8961,7 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 删除sql版本 + summary: 删除SQL版本 tags: - sql_version get: @@ -8888,10 +8985,10 @@ paths: $ref: '#/definitions/v1.GetSqlVersionDetailResV1' security: - ApiKeyAuth: [] - summary: 获取sql版本详情 + summary: 获取SQL版本详情 tags: - sql_version - put: + patch: description: update sql version operationId: updateSqlVersionV1 parameters: @@ -8908,9 +9005,8 @@ paths: - description: update sql version request in: body name: sql_version - required: true schema: - $ref: '#/definitions/v1.SqlVersionReqV1' + $ref: '#/definitions/v1.UpdateSqlVersionReqV1' responses: "200": description: OK @@ -8918,13 +9014,13 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 更新sql版本信息 + summary: 更新SQL版本信息 tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/lock: - patch: - description: lock sql version - operationId: lockSqlVersionV1 + /v1/projects/{project_name}/sql_versions/{sql_version_id}/associate_workflows: + post: + description: batch associate workflows with version + operationId: batchAssociateWorkflowsWithVersionV1 parameters: - description: project name in: path @@ -8936,12 +9032,12 @@ paths: name: sql_version_id required: true type: string - - description: lock sql version request + - description: batch associate workflows with version request in: body - name: sql_version + name: data required: true schema: - $ref: '#/definitions/v1.LockSqlVersionReqV1' + $ref: '#/definitions/v1.BatchAssociateWorkflowsWithVersionReqV1' responses: "200": description: OK @@ -8949,13 +9045,13 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 锁定sql版本 + summary: 批量关联工单到版本 tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/sql_version_stage/{sql_version_stage_id}/dependencies: - get: - description: get dependencies between stage instance - operationId: getInstanceTipListV1 + /v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_execute_workflows: + post: + description: batch execute tasks on workflow + operationId: batchExecuteTasksOnWorkflowV1 parameters: - description: project name in: path @@ -8967,25 +9063,26 @@ paths: name: sql_version_id required: true type: string - - description: sql version stage id - in: path - name: sql_version_stage_id + - description: batch execute tasks on workflow request + in: body + name: data required: true - type: string + schema: + $ref: '#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1' responses: "200": description: OK schema: - $ref: '#/definitions/v1.GetInstanceTipsResV1' + $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 获取当前阶段与下一阶段实例的依赖信息 + summary: 工单批量上线 tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_execute: + /v1/projects/{project_name}/sql_versions/{sql_version_id}/batch_release_workflows: post: - description: batch execute tasks on workflow - operationId: batchExecuteTasksOnWorkflow + description: batch release workflow + operationId: batchReleaseWorkflowsV1 parameters: - description: project name in: path @@ -8997,12 +9094,12 @@ paths: name: sql_version_id required: true type: string - - description: batch execute tasks on workflow request + - description: batch release workflow request in: body name: data required: true schema: - $ref: '#/definitions/v1.BatchExecuteTasksOnWorkflowReqV1' + $ref: '#/definitions/v1.BatchReleaseWorkflowReqV1' responses: "200": description: OK @@ -9010,13 +9107,13 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 工单批量上线 + summary: 批量发布工单(在版本的下一阶段创建工单) tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/batch_release: + /v1/projects/{project_name}/sql_versions/{sql_version_id}/lock: post: - description: batch release workflow - operationId: batchReleaseWorkflowV1 + description: lock sql version + operationId: lockSqlVersionV1 parameters: - description: project name in: path @@ -9028,12 +9125,12 @@ paths: name: sql_version_id required: true type: string - - description: batch release workflow request + - description: lock sql version request in: body - name: data + name: sql_version required: true schema: - $ref: '#/definitions/v1.BatchReleaseWorkflowReqV1' + $ref: '#/definitions/v1.LockSqlVersionReqV1' responses: "200": description: OK @@ -9041,13 +9138,13 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 批量发布工单 + summary: 锁定SQL版本 tags: - sql_version - /v1/projects/{project_name}/sql_version/{sql_version_id}/workflow/execute_retry: + /v1/projects/{project_name}/sql_versions/{sql_version_id}/retry_workflow: post: description: reject exec failed workflow - operationId: rejectExecFailedWorkflow + operationId: retryExecWorkflowV1 parameters: - description: project name in: path @@ -9059,7 +9156,7 @@ paths: name: sql_version_id required: true type: string - - description: reject exec failed workflow request + - description: retry execute workflow request in: body name: data required: true @@ -9072,38 +9169,67 @@ paths: $ref: '#/definitions/controller.BaseRes' security: - ApiKeyAuth: [] - summary: 工单重试 + summary: 工单重试(上线失败修改sql重试上线) tags: - sql_version - /v1/projects/{project_name}/sql_version/workflow/{workflow_id}/: - post: - description: workflow sql version - operationId: workflowSqlVersion + /v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/associate_workflows: + get: + description: get workflows that can be associated to version + operationId: GetWorkflowsThatCanBeAssociatedToVersionV1 parameters: - description: project name in: path name: project_name required: true type: string - - description: workflow id + - description: sql version id in: path - name: workflow_id + name: sql_version_id required: true type: string - - description: workflow sql version request - in: body - name: data + - description: sql version stage id + in: path + name: sql_version_stage_id required: true - schema: - $ref: '#/definitions/v1.WorkflowSqlVersionReqV1' + type: string responses: "200": description: OK schema: - $ref: '#/definitions/controller.BaseRes' + $ref: '#/definitions/v1.GetWorkflowsThatCanBeAssociatedToVersionResV1' + security: + - ApiKeyAuth: [] + summary: 获取可与版本关联的工单 + tags: + - sql_version + /v1/projects/{project_name}/sql_versions/{sql_version_id}/sql_version_stages/{sql_version_stage_id}/dependencies: + get: + description: get dependencies between stage instance + operationId: getDependenciesBetweenStageInstanceV1 + parameters: + - description: project name + in: path + name: project_name + required: true + type: string + - description: sql version id + in: path + name: sql_version_id + required: true + type: string + - description: sql version stage id + in: path + name: sql_version_stage_id + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetDepBetweenStageInstanceResV1' security: - ApiKeyAuth: [] - summary: 工单与版本建立关联 + summary: 获取当前阶段与下一阶段实例的依赖信息 tags: - sql_version /v1/projects/{project_name}/statistic/audit_plans: From 21d2176956d55f73986a3c935961c214727b8ce8 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Fri, 20 Sep 2024 15:52:38 +0800 Subject: [PATCH 7/8] modify: sql version api --- sqle/api/app.go | 2 +- sqle/api/controller/v1/sql_version.go | 42 +++++++++++++++------------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/sqle/api/app.go b/sqle/api/app.go index 3cf34e9dd..63053b5bf 100644 --- a/sqle/api/app.go +++ b/sqle/api/app.go @@ -262,7 +262,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/batch_execute_workflows", v1.BatchExecuteTasksOnWorkflow) v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/retry_workflow ", v1.RetryExecWorkflow) v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/associate_workflows", v1.BatchAssociateWorkflowsWithVersion) - v1ProjectRouter.POST("/:project_name/sql_versions/:sql_version_id/sql_version_stages/:sql_version_stage_id/associate_workflows", v1.GetWorkflowsThatCanBeAssociatedToVersion) + v1ProjectRouter.GET("/:project_name/sql_versions/:sql_version_id/sql_version_stages/:sql_version_stage_id/associate_workflows", v1.GetWorkflowsThatCanBeAssociatedToVersion) // audit plan; 智能扫描任务 v1ProjectRouter.POST("/:project_name/audit_plans", v1.CreateAuditPlan) diff --git a/sqle/api/controller/v1/sql_version.go b/sqle/api/controller/v1/sql_version.go index a7f06b6a0..84dca0250 100644 --- a/sqle/api/controller/v1/sql_version.go +++ b/sqle/api/controller/v1/sql_version.go @@ -66,13 +66,12 @@ type GetSqlVersionListResV1 struct { } type SqlVersionResV1 struct { - VersionID uint `json:"version_id"` - Version string `json:"version"` - Desc string `json:"desc"` - Status string `json:"status" enums:"is_being_released,locked"` - LockTime *time.Time `json:"lock_time"` - CreatedAt *time.Time `json:"created_at"` - HasAssociatedWorkflow bool `json:"has_associated_workflow"` + VersionID uint `json:"version_id"` + Version string `json:"version"` + Desc string `json:"desc"` + Status string `json:"status" enums:"is_being_released,locked"` + LockTime *time.Time `json:"lock_time"` + CreatedAt *time.Time `json:"created_at"` } // @Summary 获取SQL版本列表 @@ -100,27 +99,35 @@ func GetSqlVersionList(c echo.Context) error { type GetSqlVersionDetailResV1 struct { controller.BaseRes - Data []*SqlVersionDetailResV1 `json:"data"` + Data *SqlVersionDetailResV1 `json:"data"` } type SqlVersionDetailResV1 struct { + SqlVersionID uint `json:"sql_version_id"` + Version string `json:"version"` + Status string `json:"status" enums:"is_being_released,locked"` + SqlVersionDesc string `json:"desc,omitempty"` + SqlVersionStageDetail *[]SqlVersionStageDetail `json:"sql_version_stage_detail"` +} +type SqlVersionStageDetail struct { StageID uint `json:"stage_id"` StageName string `json:"stage_name"` StageSequence int `json:"stage_sequence"` - WorkflowDetails []*WorkflowDetailWithInstance `json:"workflow_details"` + StageInstances *[]VersionStageInstance `json:"stage_instances"` + WorkflowDetails *[]WorkflowDetailWithInstance `json:"workflow_details"` } type WorkflowDetailWithInstance struct { - Name string `json:"workflow_name"` - WorkflowId string `json:"workflow_id"` - Desc string `json:"desc,omitempty"` - Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` - WorkflowInstances []*WorkflowInstance `json:"workflow_instances"` + Name string `json:"workflow_name"` + WorkflowId string `json:"workflow_id"` + Desc string `json:"desc,omitempty"` + Status string `json:"status" enums:"wait_for_audit,wait_for_execution,rejected,canceled,exec_failed,executing,finished"` + WorkflowInstances *[]VersionStageInstance `json:"workflow_instances"` } -type WorkflowInstance struct { +type VersionStageInstance struct { InstanceID string `json:"instances_id"` InstanceName string `json:"instances_name"` - InstanceSchema string `json:"instance_schema"` + InstanceSchema string `json:"instance_schema,omitempty"` } // @Summary 获取SQL版本详情 @@ -149,10 +156,9 @@ type UpdateSqlVersionReqV1 struct { } type UpdateSqlVersionStage struct { - StageID *uint `json:"stage_id" form:"stage_id"` Name *string `json:"name" form:"name" valid:"required" example:"生产"` StageSequence *int `json:"stage_sequence" form:"stage_sequence" valid:"required"` - CreateStagesInstanceDep *[]UpdateStagesInstanceDep `json:"update_stages_instance_dep"` + UpdateStagesInstanceDep *[]UpdateStagesInstanceDep `json:"update_stages_instance_dep" valid:"required"` } type UpdateStagesInstanceDep struct { From 24fc05f4194d2d41e3cdc61da4abd0293717e961 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Fri, 20 Sep 2024 15:53:12 +0800 Subject: [PATCH 8/8] gen swagger: sql version api modify --- sqle/docs/docs.go | 89 +++++++++++++++++++++++++++--------------- sqle/docs/swagger.json | 89 +++++++++++++++++++++++++++--------------- sqle/docs/swagger.yaml | 63 +++++++++++++++++++----------- 3 files changed, 154 insertions(+), 87 deletions(-) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 8b8960c21..18c42963e 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -13599,10 +13599,8 @@ var doc = `{ "example": 0 }, "data": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionDetailResV1" - } + "type": "object", + "$ref": "#/definitions/v1.SqlVersionDetailResV1" }, "message": { "type": "string", @@ -15651,20 +15649,27 @@ var doc = `{ "v1.SqlVersionDetailResV1": { "type": "object", "properties": { - "stage_id": { - "type": "integer" - }, - "stage_name": { + "desc": { "type": "string" }, - "stage_sequence": { + "sql_version_id": { "type": "integer" }, - "workflow_details": { + "sql_version_stage_detail": { "type": "array", "items": { - "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + "$ref": "#/definitions/v1.SqlVersionStageDetail" } + }, + "status": { + "type": "string", + "enum": [ + "is_being_released", + "locked" + ] + }, + "version": { + "type": "string" } } }, @@ -15677,9 +15682,6 @@ var doc = `{ "desc": { "type": "string" }, - "has_associated_workflow": { - "type": "boolean" - }, "lock_time": { "type": "string" }, @@ -15698,6 +15700,32 @@ var doc = `{ } } }, + "v1.SqlVersionStageDetail": { + "type": "object", + "properties": { + "stage_id": { + "type": "integer" + }, + "stage_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.VersionStageInstance" + } + }, + "stage_name": { + "type": "string" + }, + "stage_sequence": { + "type": "integer" + }, + "workflow_details": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + } + } + } + }, "v1.StageAndWorkflows": { "type": "object", "properties": { @@ -16426,9 +16454,6 @@ var doc = `{ "type": "string", "example": "生产" }, - "stage_id": { - "type": "integer" - }, "stage_sequence": { "type": "integer" }, @@ -16542,6 +16567,20 @@ var doc = `{ } } }, + "v1.VersionStageInstance": { + "type": "object", + "properties": { + "instance_schema": { + "type": "string" + }, + "instances_id": { + "type": "string" + }, + "instances_name": { + "type": "string" + } + } + }, "v1.WechatConfigurationV1": { "type": "object", "properties": { @@ -16723,7 +16762,7 @@ var doc = `{ "workflow_instances": { "type": "array", "items": { - "$ref": "#/definitions/v1.WorkflowInstance" + "$ref": "#/definitions/v1.VersionStageInstance" } }, "workflow_name": { @@ -16731,20 +16770,6 @@ var doc = `{ } } }, - "v1.WorkflowInstance": { - "type": "object", - "properties": { - "instance_schema": { - "type": "string" - }, - "instances_id": { - "type": "string" - }, - "instances_name": { - "type": "string" - } - } - }, "v1.WorkflowPassPercentV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 1bd9b9859..75e55d626 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -13583,10 +13583,8 @@ "example": 0 }, "data": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.SqlVersionDetailResV1" - } + "type": "object", + "$ref": "#/definitions/v1.SqlVersionDetailResV1" }, "message": { "type": "string", @@ -15635,20 +15633,27 @@ "v1.SqlVersionDetailResV1": { "type": "object", "properties": { - "stage_id": { - "type": "integer" - }, - "stage_name": { + "desc": { "type": "string" }, - "stage_sequence": { + "sql_version_id": { "type": "integer" }, - "workflow_details": { + "sql_version_stage_detail": { "type": "array", "items": { - "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + "$ref": "#/definitions/v1.SqlVersionStageDetail" } + }, + "status": { + "type": "string", + "enum": [ + "is_being_released", + "locked" + ] + }, + "version": { + "type": "string" } } }, @@ -15661,9 +15666,6 @@ "desc": { "type": "string" }, - "has_associated_workflow": { - "type": "boolean" - }, "lock_time": { "type": "string" }, @@ -15682,6 +15684,32 @@ } } }, + "v1.SqlVersionStageDetail": { + "type": "object", + "properties": { + "stage_id": { + "type": "integer" + }, + "stage_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.VersionStageInstance" + } + }, + "stage_name": { + "type": "string" + }, + "stage_sequence": { + "type": "integer" + }, + "workflow_details": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowDetailWithInstance" + } + } + } + }, "v1.StageAndWorkflows": { "type": "object", "properties": { @@ -16410,9 +16438,6 @@ "type": "string", "example": "生产" }, - "stage_id": { - "type": "integer" - }, "stage_sequence": { "type": "integer" }, @@ -16526,6 +16551,20 @@ } } }, + "v1.VersionStageInstance": { + "type": "object", + "properties": { + "instance_schema": { + "type": "string" + }, + "instances_id": { + "type": "string" + }, + "instances_name": { + "type": "string" + } + } + }, "v1.WechatConfigurationV1": { "type": "object", "properties": { @@ -16707,7 +16746,7 @@ "workflow_instances": { "type": "array", "items": { - "$ref": "#/definitions/v1.WorkflowInstance" + "$ref": "#/definitions/v1.VersionStageInstance" } }, "workflow_name": { @@ -16715,20 +16754,6 @@ } } }, - "v1.WorkflowInstance": { - "type": "object", - "properties": { - "instance_schema": { - "type": "string" - }, - "instances_id": { - "type": "string" - }, - "instances_name": { - "type": "string" - } - } - }, "v1.WorkflowPassPercentV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 7870a46b2..f9cd6e168 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -2162,9 +2162,8 @@ definitions: example: 0 type: integer data: - items: - $ref: '#/definitions/v1.SqlVersionDetailResV1' - type: array + $ref: '#/definitions/v1.SqlVersionDetailResV1' + type: object message: example: ok type: string @@ -3550,16 +3549,21 @@ definitions: type: object v1.SqlVersionDetailResV1: properties: - stage_id: - type: integer - stage_name: + desc: type: string - stage_sequence: + sql_version_id: type: integer - workflow_details: + sql_version_stage_detail: items: - $ref: '#/definitions/v1.WorkflowDetailWithInstance' + $ref: '#/definitions/v1.SqlVersionStageDetail' type: array + status: + enum: + - is_being_released + - locked + type: string + version: + type: string type: object v1.SqlVersionResV1: properties: @@ -3567,8 +3571,6 @@ definitions: type: string desc: type: string - has_associated_workflow: - type: boolean lock_time: type: string status: @@ -3581,6 +3583,23 @@ definitions: version_id: type: integer type: object + v1.SqlVersionStageDetail: + properties: + stage_id: + type: integer + stage_instances: + items: + $ref: '#/definitions/v1.VersionStageInstance' + type: array + stage_name: + type: string + stage_sequence: + type: integer + workflow_details: + items: + $ref: '#/definitions/v1.WorkflowDetailWithInstance' + type: array + type: object v1.StageAndWorkflows: properties: sql_version_stage_id: @@ -4075,8 +4094,6 @@ definitions: name: example: 生产 type: string - stage_id: - type: integer stage_sequence: type: integer update_stages_instance_dep: @@ -4152,6 +4169,15 @@ definitions: user_name: type: string type: object + v1.VersionStageInstance: + properties: + instance_schema: + type: string + instances_id: + type: string + instances_name: + type: string + type: object v1.WechatConfigurationV1: properties: corp_id: @@ -4275,20 +4301,11 @@ definitions: type: string workflow_instances: items: - $ref: '#/definitions/v1.WorkflowInstance' + $ref: '#/definitions/v1.VersionStageInstance' type: array workflow_name: type: string type: object - v1.WorkflowInstance: - properties: - instance_schema: - type: string - instances_id: - type: string - instances_name: - type: string - type: object v1.WorkflowPassPercentV1: properties: audit_pass_percent: