Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BugsGuru
Copy link
Collaborator

@BugsGuru BugsGuru commented Jan 28, 2026

User description

关联的 issue

#3206

描述你的变更

创建上线工单时,操作人过滤掉被禁用的用户

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 优化GetCanOpInstanceUsers批量获取用户信息

  • 新增filterDisabledUsers函数过滤禁用用户

  • 更新工单创建逻辑确保操作人不含禁用用户


Diagram Walkthrough

flowchart LR
  A["sqle/api/controller/v1/project_permission.go"] -- "更新用户权限获取" --> B["sqle/model/workflow.go"]
  B -- "新增过滤函数并更新工单逻辑" --> C["CreateWorkflowV2"]
Loading

File Walkthrough

Relevant files
Enhancement
project_permission.go
优化用户权限获取方法                                                                                             

sqle/api/controller/v1/project_permission.go

  • 重构GetCanOpInstanceUsers以收集用户UID
  • 使用批量接口获取完整用户信息
  • 移除了旧的map去重逻辑
+21/-8   
workflow.go
新增禁用用户过滤及工单创建优化                                                                                   

sqle/model/workflow.go

  • 添加filterDisabledUsers函数过滤禁用用户
  • 在CreateWorkflowV2中调用过滤函数
  • 保证审批人、执行人列表排除禁用用户
+18/-0   

…g for disabled users

- Refactored GetCanOpInstanceUsers to use a map for user management and batch retrieval of user information.
- Introduced filterDisabledUsers function to exclude users with disabled status from permission checks.
- Enhanced overall efficiency in handling user permissions within the workflow context.
@github-actions
Copy link

PR Reviewer Guide 🔍

🎫 Ticket compliance analysis 🔶

3206 - Partially compliant

Compliant requirements:

  • 操作人过滤禁用用户已实现
  • 工单创建逻辑更新以排除被禁用用户

Non-compliant requirements:

Requires further human verification:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

逻辑审查

请确认 filterDisabledUsers 函数中的过滤条件与系统中用户状态判定标准一致,确保不会错误过滤有效用户。

// filterDisabledUsers 过滤掉禁用状态的用户
func filterDisabledUsers(users []*User) []*User {
	if len(users) == 0 {
		return []*User{}
	}
	enabledUsers := make([]*User, 0)
	for _, user := range users {
		if user.Stat == 0 {
			enabledUsers = append(enabledUsers, user)
		}
	}
	return enabledUsers
}
代码可读性

建议明确变量命名,区分从 User.Uid 获取的字符串和转换后的数值 ID,以增强代码的可读性和维护性。

userUids := make([]string, 0)
userMap := make(map[string]*model.User)

// 收集所有有权限的用户ID
for _, memberWithPermission := range memberWithPermissions {
	for _, memberOpPermission := range memberWithPermission.MemberOpPermissionList {
		if CanOperationInstance([]dmsV1.OpPermissionItem{memberOpPermission}, opPermissions, instance) {
			userId, err := strconv.Atoi(memberWithPermission.User.Uid)
			if err != nil {
				return nil, err
			}
			userUid := memberWithPermission.User.Uid
			if _, ok := userMap[userUid]; !ok {
				userUids = append(userUids, userUid)
				opUser := &model.User{
					Model: model.Model{
						ID: uint(userId),
					},
					Name: memberWithPermission.User.Name,
				}
				userMap[userUid] = opUser
			}

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
校验用户状态过滤

建议确认判断条件 user.Stat == 0 是否正确反映用户的启用状态,以确保禁用用户被成功过滤。如果判断逻辑有误,请根据业务逻辑调整条件。

sqle/model/workflow.go [333-337]

     for _, user := range users {
+		// 假定 user.Stat == 0 表示启用,如不符合请修改判断条件
 		if user.Stat == 0 {
 			enabledUsers = append(enabledUsers, user)
 		}
 	}
Suggestion importance[1-10]: 3

__

Why: The suggestion merely adds a clarifying comment to verify that user.Stat == 0 correctly indicates an enabled user; it's low-impact and does not alter functionality.

Low

@iwanghc iwanghc merged commit 813cd3b into main Jan 29, 2026
4 checks passed
@BugsGuru BugsGuru deleted the feat-workflow-operator branch January 29, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants