Skip to content

Commit c83ced7

Browse files
authored
Merge pull request #3182 from actiontech/feat-3171
Feat 3171
2 parents 253ac00 + 3681ac5 commit c83ced7

File tree

5 files changed

+127
-31
lines changed

5 files changed

+127
-31
lines changed

sqle/api/controller/v1/sql_manage.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,10 @@ func GetGlobalSqlManageList(c echo.Context) error {
517517
}
518518

519519
type GetGlobalSqlManageStatisticsReq struct {
520-
FilterProjectUid *string `query:"filter_project_uid" json:"filter_project_uid,omitempty"`
521-
FilterInstanceId *string `query:"filter_instance_id" json:"filter_instance_id,omitempty"`
522-
FilterProjectPriority *dmsV1.ProjectPriority `query:"filter_project_priority" json:"filter_project_priority,omitempty" enums:"high,medium,low"`
520+
FilterProjectUid *string `query:"filter_project_uid" json:"filter_project_uid,omitempty"`
521+
FilterInstanceId *string `query:"filter_instance_id" json:"filter_instance_id,omitempty"`
522+
FilterProjectPriority *dmsV1.ProjectPriority `query:"filter_project_priority" json:"filter_project_priority,omitempty" enums:"high,medium,low"`
523+
FilterCurrentStepAssigneeUserId *string `query:"filter_current_step_assignee_user_id" json:"filter_current_step_assignee_user_id,omitempty"`
523524
}
524525

525526
type GetGlobalSqlManageStatisticsResp struct {
@@ -536,6 +537,7 @@ type GetGlobalSqlManageStatisticsResp struct {
536537
// @Param filter_project_uid query string false "project uid"
537538
// @Param filter_instance_id query string false "instance id"
538539
// @Param filter_project_priority query string false "project priority" Enums(high,medium,low)
540+
// @Param filter_current_step_assignee_user_id query string false "filter current step assignee user id"
539541
// @Success 200 {object} v1.GetGlobalSqlManageStatisticsResp
540542
// @Router /v1/dashboard/sql_manages/statistics [get]
541543
func GetGlobalSqlManageStatistics(c echo.Context) error {

sqle/api/controller/v1/workflow.go

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ type BatchCompleteWorkflowsReqV1 struct {
236236
// @router /v1/projects/{project_name}/workflows/complete [post]
237237
func BatchCompleteWorkflows(c echo.Context) error {
238238
return nil
239-
240239
}
241240

242241
func FormatStringToInt(s string) (ret int, err error) {
@@ -720,6 +719,7 @@ type InstanceInfo struct {
720719
// @Param filter_project_uid query string false "filter by project uid"
721720
// @Param filter_instance_id query string false "filter by instance id in project"
722721
// @Param filter_project_priority query string false "filter by project priority" Enums(high,medium,low)
722+
// @Param filter_current_step_assignee_user_id query string false "filter current step assignee user id"
723723
// @Param page_index query uint32 true "page index"
724724
// @Param page_size query uint32 true "size of per page"
725725
// @Success 200 {object} v1.GetWorkflowsResV1
@@ -744,11 +744,12 @@ func GetGlobalWorkflowsV1(c echo.Context) error {
744744
// 3. 将用户可视范围、接口请求以及用户的权限范围,构造为全局工单的基础的过滤器,满足全局工单统一的过滤逻辑
745745
filter, err := constructGlobalWorkflowBasicFilter(c.Request().Context(), user, userVisibility,
746746
&globalWorkflowBasicFilter{
747-
FilterCreateUserId: req.FilterCreateUserId,
748-
FilterStatusList: req.FilterStatusList,
749-
FilterProjectUid: req.FilterProjectUid,
750-
FilterInstanceId: req.FilterInstanceId,
751-
FilterProjectPriority: req.FilterProjectPriority,
747+
FilterCreateUserId: req.FilterCreateUserId,
748+
FilterStatusList: req.FilterStatusList,
749+
FilterProjectUid: req.FilterProjectUid,
750+
FilterInstanceId: req.FilterInstanceId,
751+
FilterProjectPriority: req.FilterProjectPriority,
752+
FilterCurrentStepAssigneeUserId: req.FilterCurrentStepAssigneeUserId,
752753
})
753754
if err != nil {
754755
return controller.JSONBaseErrorReq(c, err)
@@ -771,7 +772,7 @@ func GetGlobalWorkflowsV1(c echo.Context) error {
771772
})
772773
}
773774
// 6. 从dms获取工单对应的项目信息
774-
var projectMap = make(ProjectMap)
775+
projectMap := make(ProjectMap)
775776
if req.FilterProjectPriority != "" {
776777
_, projectMap, err = loadProjectsByPriority(c.Request().Context(), req.FilterProjectPriority)
777778
} else {
@@ -864,11 +865,12 @@ func toGlobalWorkflowRes(workflows []*model.WorkflowListDetail, projectMap Proje
864865
}
865866

866867
type GetGlobalWorkflowStatisticsReqV1 struct {
867-
FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"`
868-
FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"`
869-
FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"`
870-
FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"`
871-
FilterProjectPriority dmsV1.ProjectPriority `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"`
868+
FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"`
869+
FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"`
870+
FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"`
871+
FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"`
872+
FilterProjectPriority dmsV1.ProjectPriority `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"`
873+
FilterCurrentStepAssigneeUserId string `json:"filter_current_step_assignee_user_id" query:"filter_current_step_assignee_user_id"`
872874
}
873875

874876
type GlobalWorkflowStatisticsResV1 struct {
@@ -887,6 +889,7 @@ type GlobalWorkflowStatisticsResV1 struct {
887889
// @Param filter_project_uid query string false "filter by project uid"
888890
// @Param filter_instance_id query string false "filter by instance id in project"
889891
// @Param filter_project_priority query string false "filter by project priority" Enums(high,medium,low)
892+
// @Param filter_current_step_assignee_user_id query string false "filter current step assignee user id"
890893
// @Success 200 {object} v1.GlobalWorkflowStatisticsResV1
891894
// @router /v1/dashboard/workflows/statistics [get]
892895
func GetGlobalWorkflowStatistics(c echo.Context) error {
@@ -909,11 +912,12 @@ func GetGlobalWorkflowStatistics(c echo.Context) error {
909912
// 3. 将用户可视范围、接口请求以及用户的权限范围,构造为全局工单的基础的过滤器,满足全局工单统一的过滤逻辑
910913
filter, err := constructGlobalWorkflowBasicFilter(c.Request().Context(), user, userVisibility,
911914
&globalWorkflowBasicFilter{
912-
FilterCreateUserId: req.FilterCreateUserId,
913-
FilterStatusList: req.FilterStatusList,
914-
FilterProjectUid: req.FilterProjectUid,
915-
FilterInstanceId: req.FilterInstanceId,
916-
FilterProjectPriority: req.FilterProjectPriority,
915+
FilterCreateUserId: req.FilterCreateUserId,
916+
FilterStatusList: req.FilterStatusList,
917+
FilterProjectUid: req.FilterProjectUid,
918+
FilterInstanceId: req.FilterInstanceId,
919+
FilterProjectPriority: req.FilterProjectPriority,
920+
FilterCurrentStepAssigneeUserId: req.FilterCurrentStepAssigneeUserId,
917921
})
918922
if err != nil {
919923
return controller.JSONBaseErrorReq(c, err)
@@ -942,6 +946,7 @@ func GetGlobalWorkflowStatistics(c echo.Context) error {
942946
// @Param filter_project_uid query string false "filter by project uid"
943947
// @Param filter_instance_id query string false "filter by instance id in project"
944948
// @Param filter_project_priority query string false "filter by project priority" Enums(high,medium,low)
949+
// @Param filter_current_step_assignee_user_id query string false "filter current step assignee user id"
945950
// @Param page_index query uint32 true "page index"
946951
// @Param page_size query uint32 true "size of per page"
947952
// @Success 200 {object} v1.GetWorkflowsResV1
@@ -961,18 +966,20 @@ func GetGlobalDataExportWorkflowsV1(c echo.Context) error {
961966
// @Param filter_project_uid query string false "filter by project uid"
962967
// @Param filter_instance_id query string false "filter by instance id in project"
963968
// @Param filter_project_priority query string false "filter by project priority" Enums(high,medium,low)
969+
// @Param filter_current_step_assignee_user_id query string false "filter current step assignee user id"
964970
// @Success 200 {object} v1.GlobalWorkflowStatisticsResV1
965971
// @router /v1/dashboard/data_export_workflows/statistics [get]
966972
func GetGlobalDataExportWorkflowStatisticsV1(c echo.Context) error {
967973
return getGlobalDataExportWorkflowStatisticsV1(c)
968974
}
969975

970976
type globalWorkflowBasicFilter struct {
971-
FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"`
972-
FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"`
973-
FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"`
974-
FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"`
975-
FilterProjectPriority dmsV1.ProjectPriority `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"`
977+
FilterCreateUserId string `json:"filter_create_user_id" query:"filter_create_user_id"`
978+
FilterStatusList []string `json:"filter_status_list" query:"filter_status_list" validate:"dive,oneof=wait_for_audit wait_for_execution rejected canceled executing exec_failed finished"`
979+
FilterProjectUid string `json:"filter_project_uid" query:"filter_project_uid"`
980+
FilterInstanceId string `json:"filter_instance_id" query:"filter_instance_id"`
981+
FilterProjectPriority dmsV1.ProjectPriority `json:"filter_project_priority" query:"filter_project_priority" valid:"omitempty,oneof=high medium low"`
982+
FilterCurrentStepAssigneeUserId string `json:"filter_current_step_assignee_user_id" query:"filter_current_step_assignee_user_id"`
976983
}
977984

978985
// 将用户可视范围、接口请求以及用户的权限范围,构造为全局工单的基础的过滤器,满足全局工单统一的过滤逻辑
@@ -984,6 +991,10 @@ func constructGlobalWorkflowBasicFilter(ctx context.Context, user *model.User, u
984991
"filter_project_id": req.FilterProjectUid, // 根据项目id筛选某些一个项目下的多个工单
985992
"filter_instance_id": req.FilterInstanceId, // 根据工单记录的数据源id,筛选包含该数据源的工单,多数据源情况下,一旦包含该数据源,则被选中
986993
}
994+
// 1.0 如果指定了待操作人筛选,则使用指定的待操作人ID
995+
if req.FilterCurrentStepAssigneeUserId != "" {
996+
data["filter_current_step_assignee_user_id"] = req.FilterCurrentStepAssigneeUserId
997+
}
987998
// 1.1 页面筛选项:如果根据项目优先级筛选,则先筛选出对应优先级下的项目
988999
var projectIdsByPriority []string
9891000
var err error
@@ -1011,16 +1022,21 @@ func constructGlobalWorkflowBasicFilter(ctx context.Context, user *model.User, u
10111022
}
10121023
case GlobalDashBoardVisibilityAssignee:
10131024
// 3.2 若用户可视范围为受让人,则查看分配给他的工单
1014-
data["filter_current_step_assignee_user_id"] = user.GetIDStr()
1025+
// 如果请求中已经指定了待操作人筛选,则使用请求中的值,否则使用当前用户ID
1026+
if req.FilterCurrentStepAssigneeUserId == "" {
1027+
data["filter_current_step_assignee_user_id"] = user.GetIDStr()
1028+
}
10151029
}
10161030
return data, nil
10171031
}
10181032

10191033
type VisibilityType string
10201034

1021-
const GlobalDashBoardVisibilityGlobal VisibilityType = "global" // 全局可见
1022-
const GlobalDashBoardVisibilityProjects VisibilityType = "projects" // 多项目可见
1023-
const GlobalDashBoardVisibilityAssignee VisibilityType = "assignee" // 仅可见授予自己的
1035+
const (
1036+
GlobalDashBoardVisibilityGlobal VisibilityType = "global" // 全局可见
1037+
GlobalDashBoardVisibilityProjects VisibilityType = "projects" // 多项目可见
1038+
GlobalDashBoardVisibilityAssignee VisibilityType = "assignee" // 仅可见授予自己的
1039+
)
10241040

10251041
type GlobalDashBoardVisibility struct {
10261042
VisibilityType VisibilityType
@@ -1589,7 +1605,6 @@ func ExportWorkflowV1(c echo.Context) error {
15891605
// @Success 200 {object} controller.BaseRes
15901606
// @Router /v1/projects/{project_name}/workflows/{workflow_id}/tasks/terminate [post]
15911607
func TerminateMultipleTaskByWorkflowV1(c echo.Context) error {
1592-
15931608
projectUid, err := dms.GetProjectUIDByName(context.TODO(), c.Param("project_name"), true)
15941609
if err != nil {
15951610
return controller.JSONBaseErrorReq(c, err)
@@ -1743,7 +1758,6 @@ func isTaskCanBeTerminate(s *model.Storage, taskID string) (bool, error) {
17431758
}
17441759

17451760
func getTerminatingTaskIDs(workflow *model.Workflow) (taskIDs []uint) {
1746-
17471761
taskIDs = make([]uint, 0)
17481762
for i := range workflow.Record.InstanceRecords {
17491763
instRecord := workflow.Record.InstanceRecords[i]

sqle/docs/docs.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,12 @@ var doc = `{
10871087
"name": "filter_project_priority",
10881088
"in": "query"
10891089
},
1090+
{
1091+
"type": "string",
1092+
"description": "filter current step assignee user id",
1093+
"name": "filter_current_step_assignee_user_id",
1094+
"in": "query"
1095+
},
10901096
{
10911097
"type": "integer",
10921098
"description": "page index",
@@ -1172,6 +1178,12 @@ var doc = `{
11721178
"description": "filter by project priority",
11731179
"name": "filter_project_priority",
11741180
"in": "query"
1181+
},
1182+
{
1183+
"type": "string",
1184+
"description": "filter current step assignee user id",
1185+
"name": "filter_current_step_assignee_user_id",
1186+
"in": "query"
11751187
}
11761188
],
11771189
"responses": {
@@ -1282,6 +1294,12 @@ var doc = `{
12821294
"description": "project priority",
12831295
"name": "filter_project_priority",
12841296
"in": "query"
1297+
},
1298+
{
1299+
"type": "string",
1300+
"description": "filter current step assignee user id",
1301+
"name": "filter_current_step_assignee_user_id",
1302+
"in": "query"
12851303
}
12861304
],
12871305
"responses": {
@@ -1355,6 +1373,12 @@ var doc = `{
13551373
"name": "filter_project_priority",
13561374
"in": "query"
13571375
},
1376+
{
1377+
"type": "string",
1378+
"description": "filter current step assignee user id",
1379+
"name": "filter_current_step_assignee_user_id",
1380+
"in": "query"
1381+
},
13581382
{
13591383
"type": "integer",
13601384
"description": "page index",
@@ -1440,6 +1464,12 @@ var doc = `{
14401464
"description": "filter by project priority",
14411465
"name": "filter_project_priority",
14421466
"in": "query"
1467+
},
1468+
{
1469+
"type": "string",
1470+
"description": "filter current step assignee user id",
1471+
"name": "filter_current_step_assignee_user_id",
1472+
"in": "query"
14431473
}
14441474
],
14451475
"responses": {

sqle/docs/swagger.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,12 @@
10711071
"name": "filter_project_priority",
10721072
"in": "query"
10731073
},
1074+
{
1075+
"type": "string",
1076+
"description": "filter current step assignee user id",
1077+
"name": "filter_current_step_assignee_user_id",
1078+
"in": "query"
1079+
},
10741080
{
10751081
"type": "integer",
10761082
"description": "page index",
@@ -1156,6 +1162,12 @@
11561162
"description": "filter by project priority",
11571163
"name": "filter_project_priority",
11581164
"in": "query"
1165+
},
1166+
{
1167+
"type": "string",
1168+
"description": "filter current step assignee user id",
1169+
"name": "filter_current_step_assignee_user_id",
1170+
"in": "query"
11591171
}
11601172
],
11611173
"responses": {
@@ -1266,6 +1278,12 @@
12661278
"description": "project priority",
12671279
"name": "filter_project_priority",
12681280
"in": "query"
1281+
},
1282+
{
1283+
"type": "string",
1284+
"description": "filter current step assignee user id",
1285+
"name": "filter_current_step_assignee_user_id",
1286+
"in": "query"
12691287
}
12701288
],
12711289
"responses": {
@@ -1339,6 +1357,12 @@
13391357
"name": "filter_project_priority",
13401358
"in": "query"
13411359
},
1360+
{
1361+
"type": "string",
1362+
"description": "filter current step assignee user id",
1363+
"name": "filter_current_step_assignee_user_id",
1364+
"in": "query"
1365+
},
13421366
{
13431367
"type": "integer",
13441368
"description": "page index",
@@ -1424,6 +1448,12 @@
14241448
"description": "filter by project priority",
14251449
"name": "filter_project_priority",
14261450
"in": "query"
1451+
},
1452+
{
1453+
"type": "string",
1454+
"description": "filter current step assignee user id",
1455+
"name": "filter_current_step_assignee_user_id",
1456+
"in": "query"
14271457
}
14281458
],
14291459
"responses": {

sqle/docs/swagger.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8089,6 +8089,10 @@ paths:
80898089
in: query
80908090
name: filter_project_priority
80918091
type: string
8092+
- description: filter current step assignee user id
8093+
in: query
8094+
name: filter_current_step_assignee_user_id
8095+
type: string
80928096
- description: page index
80938097
in: query
80948098
name: page_index
@@ -8148,6 +8152,10 @@ paths:
81488152
in: query
81498153
name: filter_project_priority
81508154
type: string
8155+
- description: filter current step assignee user id
8156+
in: query
8157+
name: filter_current_step_assignee_user_id
8158+
type: string
81518159
responses:
81528160
"200":
81538161
description: OK
@@ -8220,6 +8228,10 @@ paths:
82208228
in: query
82218229
name: filter_project_priority
82228230
type: string
8231+
- description: filter current step assignee user id
8232+
in: query
8233+
name: filter_current_step_assignee_user_id
8234+
type: string
82238235
responses:
82248236
"200":
82258237
description: OK
@@ -8269,6 +8281,10 @@ paths:
82698281
in: query
82708282
name: filter_project_priority
82718283
type: string
8284+
- description: filter current step assignee user id
8285+
in: query
8286+
name: filter_current_step_assignee_user_id
8287+
type: string
82728288
- description: page index
82738289
in: query
82748290
name: page_index
@@ -8328,6 +8344,10 @@ paths:
83288344
in: query
83298345
name: filter_project_priority
83308346
type: string
8347+
- description: filter current step assignee user id
8348+
in: query
8349+
name: filter_current_step_assignee_user_id
8350+
type: string
83318351
responses:
83328352
"200":
83338353
description: OK

0 commit comments

Comments
 (0)