Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed Mar 22, 2024
1 parent 469f628 commit 61e276b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ https://godoc.org/github.com/chyroc/lark

## Support APIs

API Count: 1016, Event Count: 148
API Count: 1017, Event Count: 148

<details>
<summary>
Expand Down Expand Up @@ -496,6 +496,7 @@ API Count: 1016, Event Count: 148
- DeleteCoreHRDepartment
- UpdateCoreHRDepartment
- GetCoreHRDepartment
- BatchGetCoreHRDepartment
- GetCoreHRDepartmentList
- BatchGetCoreHRLocation
- CreateCoreHRLocation
Expand Down
3 changes: 2 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ https://godoc.org/github.com/chyroc/lark

## 支持的接口

API 总数: 1016, 事件总数: 148
API 总数: 1017, 事件总数: 148

<details>
<summary>
Expand Down Expand Up @@ -496,6 +496,7 @@ API 总数: 1016, 事件总数: 148
- DeleteCoreHRDepartment
- UpdateCoreHRDepartment
- GetCoreHRDepartment
- BatchGetCoreHRDepartment
- GetCoreHRDepartmentList
- BatchGetCoreHRLocation
- CreateCoreHRLocation
Expand Down
10 changes: 9 additions & 1 deletion larkext/docx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Docx struct {
typ string
}

// NewDoc new Docx client
// NewDocx new Docx client
func NewDocx(larkClient *lark.Lark, token string) *Docx {
return newDocx(larkClient, token, "")
}
Expand All @@ -54,3 +54,11 @@ func (r *Docx) Move(ctx context.Context, folderToken string) (*Task, error) {
func (r *Docx) Delete(ctx context.Context) (*Task, error) {
return deleteFile(ctx, r.larkClient, r.token, r.typ)
}

func (r *Docx) RawContent(ctx context.Context) (string, error) {
return r.rawContent(ctx)
}

func (r *Docx) Blocks(ctx context.Context) ([]*lark.DocxBlock, error) {
return r.blocks(ctx)
}
35 changes: 35 additions & 0 deletions larkext/docx_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,38 @@ func (r *Docx) copy(ctx context.Context, folderToken, name string) (*Docx, error
}
return newDocx(r.larkClient, res.Token, res.URL), nil
}

func (r *Docx) rawContent(ctx context.Context) (string, error) {
resp, _, err := r.larkClient.Drive.GetDocxDocumentRawContent(ctx, &lark.GetDocxDocumentRawContentReq{
DocumentID: r.token,
Lang: nil,
})
if err != nil {
return "", err
}
return resp.Content, nil
}

func (r *Docx) blocks(ctx context.Context) ([]*lark.DocxBlock, error) {
token := ""
size := int64(200)
blocks := []*lark.DocxBlock{}
for {
resp, _, err := r.larkClient.Drive.GetDocxBlockListOfDocument(ctx, &lark.GetDocxBlockListOfDocumentReq{
DocumentID: r.token,
PageSize: &size,
PageToken: &token,
DocumentRevisionID: nil,
UserIDType: nil,
})
if err != nil {
return nil, err
}
blocks = append(blocks, resp.Items...)
if !resp.HasMore {
break
}
token = resp.PageToken
}
return blocks, nil
}
1 change: 1 addition & 0 deletions mock.go

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

26 changes: 26 additions & 0 deletions test/CoreHR_sample_test.go

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

0 comments on commit 61e276b

Please sign in to comment.