Skip to content

Commit

Permalink
add:获取花名册元数据 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyunxing92 authored Dec 25, 2021
1 parent eaee79a commit 3622c6d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api_hrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ func (ding dingTalk) GetHrmEmployeeField(agentId int, userIds []string, fields [
func (ding dingTalk) UpdateHrmEmployeeField(req *request.UpdateHrmEmpField) (res response.Response, err error) {
return res, ding.Request(http.MethodPost, constant.UpdateHrmEmployeeFieldKey, nil, req, &res)
}

// GetHrmMeta 获取花名册元数据
func (ding dingTalk) GetHrmMeta(agentId int) (res response.GetHrmMeta, err error) {
if !ding.isv() {
agentId = ding.Id
}
return res, ding.Request(http.MethodPost, constant.GetHrmMetaKey, nil,
request.NewGetHrmField(agentId), &res)
}
7 changes: 7 additions & 0 deletions api_hrm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ func TestDingTalk_UpdateHrmEmployeeField(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, res)
}

func TestDingTalk_GetHrmMeta(t *testing.T) {
res, err := client.GetHrmMeta(1244553273)

assert.Nil(t, err)
assert.NotNil(t, res)
}
1 change: 1 addition & 0 deletions constant/api_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,5 @@ const (
GetHrmFieldKey = "/topapi/smartwork/hrm/employee/field/grouplist" // 获取花名册字段组详情
GetHrmEmployeeFieldKey = "/topapi/smartwork/hrm/employee/v2/list" // 获取员工花名册字段信息
UpdateHrmEmployeeFieldKey = "/topapi/smartwork/hrm/employee/v2/update" // 更新员工花名册信息
GetHrmMetaKey = "/topapi/smartwork/hrm/roster/meta/get" // 获取花名册元数据
)
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ client:= NewClient(1244553273, "appkey", "AppSecret", WithLevel(zap.DebugLevel))
- [x] [获取花名册字段组详情](https://open.dingtalk.com/document/orgapp-server/get-roster-field-group-details) `client.GetHrmField`
- [x] [获取员工花名册字段信息](https://open.dingtalk.com/document/orgapp-server/intelligent-personnel-obtain-employee-roster-information) `client.GetHrmEmployeeField`
- [x] [更新员工花名册信息](https://open.dingtalk.com/document/orgapp-server/intelligent-personnel-update-employee-file-information) `client.UpdateHrmEmployeeField`
- [x] [获取花名册元数据](https://open.dingtalk.com/document/orgapp-server/intelligent-personnel-roster-metadata-query) `client.GetHrmMeta`

* 应用管理 (**3**/4)
- [x] [获取应用列表](https://ding-doc.dingtalk.com/document#/org-dev-guide/queries-applications)
Expand Down
48 changes: 48 additions & 0 deletions response/get_hrm_meta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 GetHrmMeta struct {
Response

GroupMeta []hrmGroupMeta `json:"result"`
}

type hrmGroupMeta struct {

// 分组名称。
GroupName string `json:"group_name"`

// 分组标识。
GroupId string `json:"group_id"`

// 分组是否支持明细。
Detail bool `json:"detail"`

FieldMeta []fieldMeta `json:"field_meta_info_list"`
}

type fieldMeta struct {
// 字段名称
FieldName string `json:"field_name"`

// 字段标识
FieldCode string `json:"field_code"`

// 是否衍生字段,例如司龄、年龄等系统计算的字段
Derived bool `json:"derived"`
}

0 comments on commit 3622c6d

Please sign in to comment.