Skip to content

Commit

Permalink
apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
BugsGuru committed Jul 12, 2024
1 parent 971f7b3 commit 6328154
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
v1Router.GET("/workflows", v1.GetGlobalWorkflowsV1)
v1Router.GET("/rule_knowledge/db_types/:db_type/rules/:rule_name/", v1.GetRuleKnowledge)
v1Router.GET("/rule_knowledge/db_types/:db_type/custom_rules/:rule_name/", v1.GetCustomRuleKnowledge)
v1Router.GET("/unfinished_workflows_count", v1.GetUnfinishedWorkflowsCountOfInstances)
v1Router.GET("/workflows/statistic_of_instances", v1.GetWorkflowStatisticOfInstances)

//rule
v1Router.GET("/rules", v1.GetRules)
Expand Down
28 changes: 14 additions & 14 deletions sqle/api/controller/v1/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,26 +710,26 @@ func GetWorkflowsV1(c echo.Context) error {
})
}

type GetUnfinishedWorkflowsCountOfInstancesResV1 struct {
type GetWorkflowStatisticOfInstancesResV1 struct {
controller.BaseRes
Data []*UnfinishedWorkflowsCountV1 `json:"data"`
Data []*WorkflowStatisticOfInstance `json:"data"`
}

type UnfinishedWorkflowsCountV1 struct {
type WorkflowStatisticOfInstance struct {
InstanceId int64 `json:"instance_id"`
UnfinishedCount int64 `json:"unfinished_count"`
}

// GetUnfinishedWorkflowsCountOfInstances
// @Summary 获取实例上未完成的工单数量
// @Description Get Unfinished Workflows Count Of Instances
// GetWorkflowStatisticOfInstances
// @Summary 获取实例上工单的统计信息
// @Description Get Workflows Statistic Of Instances
// @Tags workflow
// @Id GetUnfinishedWorkflowsCountOfInstances
// @Id GetWorkflowStatisticOfInstances
// @Security ApiKeyAuth
// @Param instance_id query string true "instance id"
// @Success 200 {object} v1.GetUnfinishedWorkflowsCountOfInstancesResV1
// @router /v1/workflows_info_of_instances [get]
func GetUnfinishedWorkflowsCountOfInstances(c echo.Context) error {
// @Success 200 {object} v1.GetWorkflowStatisticOfInstancesResV1
// @router /v1/workflows/statistic_of_instances [get]
func GetWorkflowStatisticOfInstances(c echo.Context) error {
instanceIds := c.QueryParams()["instance_id"]
if len(instanceIds) == 0 {
return controller.JSONBaseErrorReq(c, fmt.Errorf("query param instance_id requied"))
Expand All @@ -741,7 +741,7 @@ func GetUnfinishedWorkflowsCountOfInstances(c echo.Context) error {
}

if user.Name != model.DefaultAdminUser && user.Name != model.DefaultSysUser {
// dms-todo: 判断是否是超级管理员/系统用户
// dms-todo: 后续需要通过dms来判断权限,没这么做的原因是:目前dms接口获取用户权限时必需projectUid参数
return controller.JSONBaseErrorReq(c, fmt.Errorf("permission denied"))
}

Expand All @@ -752,15 +752,15 @@ func GetUnfinishedWorkflowsCountOfInstances(c echo.Context) error {
return err
}

workflowsInfoV1 := make([]*UnfinishedWorkflowsCountV1, len(results))
workflowsInfoV1 := make([]*WorkflowStatisticOfInstance, len(results))
for k, v := range results {
workflowsInfoV1[k] = &UnfinishedWorkflowsCountV1{
workflowsInfoV1[k] = &WorkflowStatisticOfInstance{
InstanceId: v.InstanceId,
UnfinishedCount: v.Count,
}
}

return c.JSON(http.StatusOK, GetUnfinishedWorkflowsCountOfInstancesResV1{
return c.JSON(http.StatusOK, GetWorkflowStatisticOfInstancesResV1{
BaseRes: controller.NewBaseReq(nil),
Data: workflowsInfoV1,
})
Expand Down

0 comments on commit 6328154

Please sign in to comment.