Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xen0n committed Jul 6, 2023
2 parents 567c67e + 4765bd0 commit 1d2c205
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: go build -v ./...

- name: Lint
uses: golangci/golangci-lint-action@v3.5.0
uses: golangci/golangci-lint-action@v3.6.0
with:
version: v1.53

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ CI 会在 `go1.17` 和 Go 的当前稳定版本、上一个稳定版本上跑测
- [ ] userid与openid互换
- [ ] 二次验证
- [ ] 邀请成员
- [ ] 获取加入企业二维码
- [x] 手机号获取userid
- [ ] 邮箱获取userid
- [ ] 获取成员ID列表
* [ ] 部门管理
- [ ] 创建部门
- [x] 创建部门
- [ ] 更新部门
- [ ] 删除部门
- [x] 获取部门列表
- [x] 获取子部门ID列表
* [ ] 标签管理
- [ ] 创建标签
- [ ] 更新标签名字
Expand Down
28 changes: 28 additions & 0 deletions apis.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions dept_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package workwx

// CreateDept 创建部门
func (c *WorkwxApp) CreateDept(deptInfo *DeptInfo) (deptID int64, err error) {
resp, err := c.execDeptCreate(reqDeptCreate{
DeptInfo: deptInfo,
})
if err != nil {
return 0, err
}
return resp.ID, nil
}

// ListAllDepts 获取全量组织架构。
func (c *WorkwxApp) ListAllDepts() ([]*DeptInfo, error) {
resp, err := c.execDeptList(reqDeptList{
Expand All @@ -25,3 +36,29 @@ func (c *WorkwxApp) ListDepts(id int64) ([]*DeptInfo, error) {

return resp.Department, nil
}

// SimpleListAllDepts 获取全量组织架构(简易)。
func (c *WorkwxApp) SimpleListAllDepts() ([]*DeptInfo, error) {
resp, err := c.execDeptSimpleList(reqDeptSimpleList{
HaveID: false,
ID: 0,
})
if err != nil {
return nil, err
}

return resp.DepartmentIDs, nil
}

// SimpleListDepts 获取指定部门及其下的子部门(简易)。
func (c *WorkwxApp) SimpleListDepts(id int64) ([]*DeptInfo, error) {
resp, err := c.execDeptSimpleList(reqDeptSimpleList{
HaveID: true,
ID: id,
})
if err != nil {
return nil, err
}

return resp.DepartmentIDs, nil
}
6 changes: 4 additions & 2 deletions dept_info.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ Name|Request Type|Response Type|Access Token|URL|Doc

Name|Request Type|Response Type|Access Token|URL|Doc
:---|------------|-------------|------------|:--|:--
`execDeptCreate`|TODO|TODO|+|`POST /cgi-bin/department/create`|[创建部门](https://work.weixin.qq.com/api/doc#90000/90135/90205)
`execDeptCreate`|`reqDeptCreate`|`respDeptCreate`|+|`POST /cgi-bin/department/create`|[创建部门](https://work.weixin.qq.com/api/doc#90000/90135/90205)
`execDeptUpdate`|TODO|TODO|+|`POST /cgi-bin/department/update`|[更新部门](https://work.weixin.qq.com/api/doc#90000/90135/90206)
`execDeptDelete`|TODO|TODO|+|`GET /cgi/bin/department/delete`|[删除部门](https://work.weixin.qq.com/api/doc#90000/90135/90207)
`execDeptList`|`reqDeptList`|`respDeptList`|+|`GET /cgi-bin/department/list`|[获取部门列表](https://work.weixin.qq.com/api/doc#90000/90135/90208)
`execDeptSimpleList`|`reqDeptSimpleList`| `respDeptSimpleList` |+|`GET /cgi-bin/department/simplelist`|[获取子部门ID列表](https://developer.work.weixin.qq.com/document/path/95350)

# 标签管理

Expand Down
9 changes: 5 additions & 4 deletions docs/dept_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

### `DeptInfo` 部门信息

Name|JSON|Type|Doc
:---|:---|:---|:--
`ID`|`id`|`int64`|部门 ID
`Name`|`name`|`string`|部门名称
Name| JSON |Type|Doc
:---|:-----------|:---|:--
`ID`|`id,omitempty`|`int64`|部门 ID
`Name`|`name,omitempty`|`string`|部门名称
`NameEn`|`name_en,omitempty`|`string`|部门英文名称
`ParentID`|`parentid`|`int64`|父亲部门id。根部门为1
`Order`|`order`|`uint32`|在父部门中的次序值。order值大的排序靠前。值范围是[0, 2^32)
58 changes: 54 additions & 4 deletions errcodes/mod.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0
github.com/smartystreets/goconvey v1.7.2
github.com/urfave/cli/v2 v2.24.4
golang.org/x/net v0.10.0
golang.org/x/net v0.11.0
)

require (
Expand All @@ -18,5 +18,5 @@ require (
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
)
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand All @@ -33,8 +34,9 @@ golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -46,17 +48,20 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
46 changes: 46 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ type respUserIDByMobile struct {
UserID string `json:"userid"`
}

// reqDeptCreate 创建部门
type reqDeptCreate struct {
DeptInfo *DeptInfo
}

var _ bodyer = reqDeptCreate{}

func (x reqDeptCreate) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.DeptInfo)
}

// respDeptCreate 创建部门响应
type respDeptCreate struct {
respCommon

ID int64 `json:"id"`
}

// reqDeptList 获取部门列表
// 从2022年8月15日10点开始,“企业管理后台 - 管理工具 - 通讯录同步”的新增IP将不能再调用此接口,企业可通过「获取部门ID列表」接口获取部门ID列表。查看调整详情。
// https://developer.work.weixin.qq.com/document/path/96079
type reqDeptList struct {
HaveID bool
ID int64
Expand All @@ -251,6 +272,31 @@ type respDeptList struct {
Department []*DeptInfo `json:"department"`
}

// reqDeptSimpleList 获取子部门ID列表
type reqDeptSimpleList struct {
HaveID bool
ID int64
}

var _ urlValuer = reqDeptSimpleList{}

func (x reqDeptSimpleList) intoURLValues() url.Values {
if !x.HaveID {
return url.Values{}
}

return url.Values{
"id": {strconv.FormatInt(x.ID, 10)},
}
}

// respDeptSimpleList 部门列表响应
type respDeptSimpleList struct {
respCommon

DepartmentIDs []*DeptInfo `json:"department_id"`
}

// reqAppchatGet 获取群聊会话请求
type reqAppchatGet struct {
ChatID string
Expand Down

0 comments on commit 1d2c205

Please sign in to comment.