Skip to content

Commit

Permalink
Merge pull request #316 from actiontech/issue-2675-5
Browse files Browse the repository at this point in the history
modify: when get op permission without project id return permission from all projects
  • Loading branch information
LordofAvernus authored Oct 18, 2024
2 parents abc8253 + 033d7a6 commit a203de6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
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

0 comments on commit a203de6

Please sign in to comment.