Skip to content

Commit

Permalink
add:获取权限列表 (#43)
Browse files Browse the repository at this point in the history
* add:获取权限列表

* 补充测试
  • Loading branch information
zhaoyunxing92 authored Dec 5, 2021
1 parent 28d10d9 commit 7f6f8fd
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api_drive_spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,14 @@ func (ding *dingTalk) GetDriveSpacesFilesUploadInfo(res *request.GetDriveSpacesF
return rsp, ding.Request(http.MethodPost, fmt.Sprintf(constant.GetDriveSpacesFilesUploadInfoKey, res.SpaceId, res.ParentId),
query, nil, &rsp)
}

//GetDriveSpacesFilesPermissions 获取权限列表
func (ding *dingTalk) GetDriveSpacesFilesPermissions(spaceId, fileId, unionId string) (rsp response.DriveSpacesFilesPermissions,
err error) {

query := url.Values{}
query.Set("unionId", unionId)

return rsp, ding.Request(http.MethodGet, fmt.Sprintf(constant.GetDriveSpacesFilesPermissionsKey, spaceId, fileId),
query, nil, &rsp)
}
8 changes: 8 additions & 0 deletions api_drive_spaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,11 @@ func TestDingTalk_GetDriveSpacesFilesDownloadInfo(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, res)
}

func TestDingTalk_GetDriveSpacesFilesPermissions(t *testing.T) {

res, err := client.GetDriveSpacesFilesPermissions("3452011774", "47494266429",
"ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
}
3 changes: 3 additions & 0 deletions constant/api_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ const (
GetDriveSpacesFilesDownloadInfoKey = "/v1.0/drive/spaces/%s/files/%s/downloadInfos" //获取文件下载信息
GetDriveSpacesFilesUploadInfoKey = "/v1.0/drive/spaces/%s/files/%s/uploadInfos" //获取文件上传信息

GetDriveSpacesFilesPermissionsKey = "/v1.0/drive/spaces/%s/files/%s/permissions" //获取权限列表
AddDriveSpacesFilesPermissionsKey = "/v1.0/drive/spaces/%s/files/%s/permissions" //添加权限

GetDingIndexKey = "/v1.0/contact/dingIndexs" //获取企业最新钉钉指数信息

CreateTodoKey = "/v1.0/todo/users/%s/tasks" //新增钉钉待办任务
Expand Down
33 changes: 33 additions & 0 deletions request/drive_spaces_files_upload_info_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2020 zhaoyunxing.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package request

import (
"testing"
)

import (
"github.com/stretchr/testify/assert"
)

func TestNewGetDriveSpacesFilesUploadInfo(t *testing.T) {

info := NewGetDriveSpacesFilesUploadInfo("spaceId", "parenId", "fileName", 10,
"m5d", "unionId")

assert.NotNil(t, info)
}
67 changes: 67 additions & 0 deletions response/get_drive_spaces_file_permissions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2020 zhaoyunxing.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package response

type DriveSpacesFilesPermissions struct {
Response
//企业内成员权限列表
Members []driveSpacesFilesPermissions `json:"members"`

//企业外成员权限列表
OutMembers []driveSpacesFilesPermissions `json:"outMembers"`
}

type driveSpacesFilesPermissions struct {
//权限角色。
//
//owner:所有者
//admin:管理员
//editor:可编辑
//viewer:可查看/下载
//only_viewer:只读
Role string `json:"role"`

//是否是继承的权限
Extend bool `json:"extend"`

permissionMember `json:"member"`
}

//成员信息
type permissionMember struct {
//企业的CorpId
CorpId string `json:"corpId"`

//成员ID。
//
//当memberType为org时,取值为corpId
//当memberType为department时,取值为deptId
//当memberType为conversation时,取值为chatId
//当memberType为user时,取值为staffId
MemberId string `json:"memberId"`

//成员类型。
//
//org:企业
//department:部门
//conversation:群
//user:用户
MemberType string `json:"memberType"`

//成员名称
MemberName string `json:"memberName"`
}

0 comments on commit 7f6f8fd

Please sign in to comment.