Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:When there is no matching user, the person to be operated is al… #2214

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sqle/model/project_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ AND (w.create_user_id = ? OR cur_ass_user.id = ? OR op_ass_user.id = ?)
return count > 0, nil
}

// GetCanAuditWorkflowUsers will return admin user if no qualified user is found, preventing the process from being stuck because no user can operate
// GetCanAuditWorkflowUsers will return supper admin and project admin user if no qualified user is found, preventing the process from being stuck because no user can operate
func (s *Storage) GetCanAuditWorkflowUsers(instance *Instance) (users []*User, err error) {
users, err = s.GetWithOperationUserFromInstance(instance, OP_WORKFLOW_AUDIT)
if err != nil {
Expand All @@ -333,10 +333,10 @@ func (s *Storage) GetCanAuditWorkflowUsers(instance *Instance) (users []*User, e
if len(users) != 0 {
return
}
return s.GetUsersByNames([]string{DefaultAdminUser})
return s.GetManageUsersByProjectID(instance.ProjectId)
}

// GetCanExecuteWorkflowUsers will return admin user if no qualified user is found, preventing the process from being stuck because no user can operate
// GetCanExecuteWorkflowUsers will return supper admin and project admin if no qualified user is found, preventing the process from being stuck because no user can operate
func (s *Storage) GetCanExecuteWorkflowUsers(instance *Instance) (users []*User, err error) {
users, err = s.GetWithOperationUserFromInstance(instance, OP_WORKFLOW_EXECUTE)
if err != nil {
Expand All @@ -345,7 +345,7 @@ func (s *Storage) GetCanExecuteWorkflowUsers(instance *Instance) (users []*User,
if len(users) != 0 {
return
}
return s.GetUsersByNames([]string{DefaultAdminUser})
return s.GetManageUsersByProjectID(instance.ProjectId)
}

/*
Expand Down
10 changes: 10 additions & 0 deletions sqle/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ func (s *Storage) GetMemberTips(projectName string) ([]*User, error) {
return users, errors.ConnectStorageErrWrapper(err)
}

func (s *Storage) GetManageUsersByProjectID(projectID uint) ([]*User, error) {
var users []*User
err := s.db.Model(&User{}).
Joins("LEFT JOIN project_manager pm ON pm.user_id = users.id").
Where("pm.project_id = ?", projectID).
Where("users.deleted_at IS NULL").
Find(&users).Error
return users, errors.ConnectStorageErrWrapper(err)
}

type UserRole struct {
UserName string `json:"user_name"`
RoleName string `json:"role_name"`
Expand Down
Loading