-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathapi_drive_sheet_find.go
98 lines (86 loc) · 5.25 KB
/
api_drive_sheet_find.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
* Copyright 2022 chyroc
*
* 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 lark
import (
"context"
)
// FindSheet 在指定范围内查找符合查找条件的单元格。
//
// 注意事项:
// - 当请求`range`范围大于实际数据区域时, 比如工作表只有 200 行, 但`range`填写的范围为 1 到 201 行, 接口将返回错误码`1310202`
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet-sheet/find
// new doc: https://open.feishu.cn/document/server-docs/docs/sheets-v3/data-operation/find
func (r *DriveService) FindSheet(ctx context.Context, request *FindSheetReq, options ...MethodOptionFunc) (*FindSheetResp, *Response, error) {
if r.cli.mock.mockDriveFindSheet != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#FindSheet mock enable")
return r.cli.mock.mockDriveFindSheet(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "Drive",
API: "FindSheet",
Method: "POST",
URL: r.cli.openBaseURL + "/open-apis/sheets/v3/spreadsheets/:spreadsheet_token/sheets/:sheet_id/find",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
NeedUserAccessToken: true,
}
resp := new(findSheetResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockDriveFindSheet mock DriveFindSheet method
func (r *Mock) MockDriveFindSheet(f func(ctx context.Context, request *FindSheetReq, options ...MethodOptionFunc) (*FindSheetResp, *Response, error)) {
r.mockDriveFindSheet = f
}
// UnMockDriveFindSheet un-mock DriveFindSheet method
func (r *Mock) UnMockDriveFindSheet() {
r.mockDriveFindSheet = nil
}
// FindSheetReq ...
type FindSheetReq struct {
SpreadSheetToken string `path:"spreadsheet_token" json:"-"` // 表格的token, 获取方式见[如何获取云文档资源相关 token](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN), 示例值: "shtcnmBA*yGehy8"
SheetID string `path:"sheet_id" json:"-"` // 工作表的id, 获取方式见[获取工作表](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet-sheet/query), 示例值: "0b**12"
FindCondition *FindSheetReqFindCondition `json:"find_condition,omitempty"` // 查找条件
Find string `json:"find,omitempty"` // 查找的字符串, 当`search_by_regex`字段为 true 时, 该字段为正则表达式, 示例值: "如下, 普通查找示例: "hello", 正则查找示例: "[A-Z]\w+""
}
// FindSheetReqFindCondition ...
type FindSheetReqFindCondition struct {
Range string `json:"range,omitempty"` // 查找范围, 参考 [名词解释 Range](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview), 示例值: "PNIfrm!A1:C5"
MatchCase *bool `json:"match_case,omitempty"` // 是否忽略大小写, 默认为 false, `true`: 表示忽略字符串中字母大小写差异, `false`: 表示区分字符串中字母大小写, 示例值: true
MatchEntireCell *bool `json:"match_entire_cell,omitempty"` // 是否完全匹配整个单元格, 默认值为 false, `true`: 表示完全匹配单元格, 比如 find 取值为 "hello", 则单元格中的内容必须为 "hello", `false`: 表示允许部分匹配单元格, 比如 find 取值为 "hello", 则单元格中的内容包含 "hello" 即可, 示例值: false
SearchByRegex *bool `json:"search_by_regex,omitempty"` // 是否为正则匹配, 默认值为 false, `true`: 表示使用正则匹配, `false`: 表示不使用正则匹配, 示例值: false
IncludeFormulas *bool `json:"include_formulas,omitempty"` // 是否仅搜索单元格公式, 默认值为 false, `true`: 表示仅搜索单元格公式, `false`: 表示仅搜索单元格内容, 示例值: false
}
// FindSheetResp ...
type FindSheetResp struct {
FindResult *FindSheetRespFindResult `json:"find_result,omitempty"` // 符合条件的信息
}
// FindSheetRespFindResult ...
type FindSheetRespFindResult struct {
MatchedCells []string `json:"matched_cells,omitempty"` // 符合查找条件的单元格数组, 不包含公式
MatchedFormulaCells []string `json:"matched_formula_cells,omitempty"` // 符合查找条件的含有公式的单元格数组
RowsCount int64 `json:"rows_count,omitempty"` // 符合查找条件的总行数
}
// findSheetResp ...
type findSheetResp struct {
Code int64 `json:"code,omitempty"` // 错误码, 非 0 表示失败
Msg string `json:"msg,omitempty"` // 错误描述
Data *FindSheetResp `json:"data,omitempty"`
Error *ErrorDetail `json:"error,omitempty"`
}