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

modify: when get op permission without project id return permission from all projects #316

Merged
merged 2 commits into from
Oct 18, 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
14 changes: 14 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,20 @@
"description": "filter project by project id list, using in condition",
"name": "filter_by_project_uids",
"in": "query"
},
{
"enum": [
"high",
"medium",
"low",
"unknown"
],
"type": "string",
"x-go-enum-desc": "high ProjectPriorityHigh\nmedium ProjectPriorityMedium\nlow ProjectPriorityLow\nunknown ProjectPriorityUnknown",
"x-go-name": "FilterByProjectPriority",
"description": "filter project by project priority\nhigh ProjectPriorityHigh\nmedium ProjectPriorityMedium\nlow ProjectPriorityLow\nunknown ProjectPriorityUnknown",
"name": "filter_by_project_priority",
"in": "query"
}
],
"responses": {
Expand Down
20 changes: 20 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5572,6 +5572,26 @@ paths:
name: filter_by_project_uids
type: array
x-go-name: FilterByProjectUids
- description: |-
filter project by project priority
high ProjectPriorityHigh
medium ProjectPriorityMedium
low ProjectPriorityLow
unknown ProjectPriorityUnknown
enum:
- high
- medium
- low
- unknown
in: query
name: filter_by_project_priority
type: string
x-go-enum-desc: |-
high ProjectPriorityHigh
medium ProjectPriorityMedium
low ProjectPriorityLow
unknown ProjectPriorityUnknown
x-go-name: FilterByProjectPriority
responses:
"200":
description: ListProjectReply
Expand Down
17 changes: 13 additions & 4 deletions internal/dms/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,20 @@ func (d *DMSService) GetUserOpPermission(ctx context.Context, req *dmsCommonV1.G
}
permissions = append(permissions, globalPermissions...)

projectPermissions, err := d.OpPermissionVerifyUsecase.GetUserOpPermissionInProject(ctx, req.UserUid, projectUid)
if err != nil {
return nil, fmt.Errorf("get user op permission error: %v", err)
if projectUid != "" {
projectPermissions, err := d.OpPermissionVerifyUsecase.GetUserOpPermissionInProject(ctx, req.UserUid, projectUid)
if err != nil {
return nil, fmt.Errorf("get user op permission error: %v", err)
}
permissions = append(permissions, projectPermissions...)

} else {
projectPermissions, err := d.OpPermissionVerifyUsecase.GetUserOpPermission(ctx, req.UserUid)
if err != nil {
return nil, fmt.Errorf("get user op permission error: %v", err)
}
permissions = append(permissions, projectPermissions...)
}
permissions = append(permissions, projectPermissions...)

var replyOpPermission = make([]dmsCommonV1.OpPermissionItem, 0, len(permissions))
for _, p := range permissions {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dms-common/api/dms/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type GetUserOpPermissionReq struct {

type UserOpPermission struct {
// uesr project uid
ProjectUid string `json:"project_uid" validate:"required"`
ProjectUid string `json:"project_uid"`
}

// swagger:model GetUserOpPermissionReply
Expand Down