Documentation
¶
Index ¶
- Constants
- func InitAPITable(token string, baseUrl string) (err error)
- func InitAPITableByConfig() error
- func NewCheckboxValue(checked bool) bool
- func NewEmailValue(email string) string
- func NewMultiSelectValue(options ...string) []string
- func NewNumValue(value float64) float64
- func NewOneWayLinkValue(recordIds ...string) []string
- func NewPhoneValue(phone string) string
- func NewRatingValue(rating float64) float64
- func NewSingleSelectValue(option string) string
- func NewTextValue(text string) string
- func NewTimeValue(t time.Time) float64
- func NewTwoWayLinkValue(recordIds ...string) []string
- func ParseAutoNumberValue(value any) (float64, error)
- func ParseCheckboxValue(value any) (bool, error)
- func ParseEmailValue(value any) (string, error)
- func ParseFormulaValue(value any) (any, error)
- func ParseMagicLookUpValue(value any) ([]interface{}, error)
- func ParseMultiSelectValue(value any) ([]string, error)
- func ParseNumValue(value any) (float64, error)
- func ParseOneWayLinkValue(value any) ([]string, error)
- func ParsePhoneValue(value any) (string, error)
- func ParseRatingValue(value any) (float64, error)
- func ParseSingleSelectValue(value any) (string, error)
- func ParseTextValue(value any) (string, error)
- func ParseTimeValue(value any) (time.Time, error)
- func ParseTwoWayLinkValue(value any) ([]string, error)
- type AddField
- type AddRecord
- type CellAttachmentValue
- type CellOption
- type CellUrlValue
- type CellUserValue
- type CellWorkDocValue
- type CommonRecord
- type Field
- type FieldType
- type GetRecordRequest
- type GetTeamListResponse
- type GetTeamMembersResponse
- type GetUserResponse
- type MultiTableDoc
- func (doc *MultiTableDoc) AddCol(fields []*AddField) (ret []*Field, err error)
- func (doc *MultiTableDoc) AddRow(rows []*AddRecord) (records []*CommonRecord, err error)
- func (doc *MultiTableDoc) DelAllRows() error
- func (doc *MultiTableDoc) DelCol(fieldIds []string) error
- func (doc *MultiTableDoc) DelRow(recordIds []string) error
- func (doc *MultiTableDoc) EditRow(rows []*UpdateRecord) error
- func (doc *MultiTableDoc) GetCols() ([]*Field, error)
- func (doc *MultiTableDoc) GetRow(req *GetRecordRequest) (*getRecordResponse, error)
- func (doc *MultiTableDoc) SetColList(myColList []*AddField, deleteExcept bool) (isEdited bool, err error)
- type SelectFieldOption
- type SelectFieldOptionColor
- type SortRule
- type Team
- type UpdateRecord
- type UpdateRecordRequest
- type UpdateRecordResponse
- type User
Constants ¶
const ( CELL_VALUE_KEY_TYPE_FIELD_TITLE = "name" // apitable 使用 name 作为字段键 CELL_VALUE_KEY_TYPE_FIELD_ID = "id" // apitable 使用 id 作为字段键 )
Variables ¶
This section is empty.
Functions ¶
func InitAPITable ¶
func InitAPITableByConfig ¶
func InitAPITableByConfig() error
--------------------------------------------------
func NewCheckboxValue ¶
--------------------------------------------------
func NewEmailValue ¶
--------------------------------------------------
func NewMultiSelectValue ¶
--------------------------------------------------
func NewNumValue ¶
func NewOneWayLinkValue ¶
--------------------------------------------------
func NewPhoneValue ¶
--------------------------------------------------
func NewRatingValue ¶
--------------------------------------------------
func NewSingleSelectValue ¶
--------------------------------------------------
func NewTextValue ¶
--------------------------------------------------
func NewTimeValue ¶
--------------------------------------------------
func NewTwoWayLinkValue ¶
-------------------------------------------------- 双向链接值
func ParseAutoNumberValue ¶
-------------------------------------------------- 解析自动编号值(只读字段)
func ParseCheckboxValue ¶
func ParseEmailValue ¶
func ParseMagicLookUpValue ¶
解析引用值(只读字段)
func ParseMultiSelectValue ¶
func ParseNumValue ¶
func ParseOneWayLinkValue ¶
func ParsePhoneValue ¶
func ParseRatingValue ¶
func ParseSingleSelectValue ¶
func ParseTextValue ¶
func ParseTwoWayLinkValue ¶
Types ¶
type AddField ¶
type AddField struct {
Type FieldType `json:"type"`
Name string `json:"name"`
Property map[string]any `json:"property"`
}
func NewSimpleNumCol ¶
--------------------------------------------------
func NewSimpleSingleSelectCol ¶
func NewSimpleSingleSelectCol(colName string, options []*SelectFieldOption) *AddField
func NewSimpleTimeCol ¶
--------------------------------------------------
func NewSimpleUserCol ¶
--------------------------------------------------
func NewTextCol ¶
type CellAttachmentValue ¶
type CellAttachmentValue struct {
MimeType string `json:"mimeType"` // 附件的媒体类型
Name string `json:"name"` // 附件的名称
Size int32 `json:"size"` // 附件的大小,单位为字节
Width int32 `json:"width,omitempty"` // 如果附件是图片格式,表示图片的宽度,单位为px
Height int32 `json:"height,omitempty"` // 如果附件是图片格式,表示图片的高度,单位为px
Token string `json:"token"` // 附件的访问路径
Preview string `json:"preview,omitempty"` // 如果附件是PDF格式,将会生成一个预览图,用户可以通过此网址访问
}
-------------------------------------------------- 附件类型单元格值
func NewAttachmentValue ¶
func NewAttachmentValue(attachments ...CellAttachmentValue) []CellAttachmentValue
func ParseAttachmentValue ¶
func ParseAttachmentValue(value any) ([]CellAttachmentValue, error)
type CellOption ¶
type CellOption string
--------------------------------------------------
func NewOptionValue ¶
func NewOptionValue(option *SelectFieldOption) *CellOption
func ParseSingleOptionValue ¶
func ParseSingleOptionValue(value any) (*CellOption, error)
func (*CellOption) GetKey ¶
func (opt *CellOption) GetKey() string
type CellUrlValue ¶
type CellUrlValue struct {
Title string `json:"title"` // 网页标题
Text string `json:"text"` // 网页地址
Favicon string `json:"favicon"` // 网页 ICON
}
-------------------------------------------------- 链接类型单元格值
func NewUrlValue ¶
func NewUrlValue(title, text, favicon string) CellUrlValue
func ParseUrlValue ¶
func ParseUrlValue(value any) (*CellUrlValue, error)
type CellUserValue ¶
type CellUserValue struct {
// Id string `json:"id"` // 组织单元的ID
UserId string `json:"id"` // 组织单元的ID
Type int32 `json:"type"` // 组织单元的类型,1是小组,3是成员
Name string `json:"name"` // 小组或成员的名称
Avatar string `json:"avatar,omitempty"` // 头像URL,只读,不可写入
}
-------------------------------------------------- 成员类型单元格值
func NewUserValue ¶
func NewUserValue(userIds ...string) []CellUserValue
func ParseUserValue ¶
func ParseUserValue(value any) ([]CellUserValue, error)
type CellWorkDocValue ¶
-------------------------------------------------- 工作文档类型单元格值
func NewWorkDocValue ¶
func NewWorkDocValue(workDocs ...CellWorkDocValue) []CellWorkDocValue
func ParseWorkDocValue ¶
func ParseWorkDocValue(value any) ([]CellWorkDocValue, error)
type CommonRecord ¶
type CommonRecord struct {
RecordId string `json:"recordId"`
Fields map[string]any `json:"fields"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
--------------------------------------------------
type FieldType ¶
type FieldType string
-------------------------------------------------- 字段类型 -------------------------------------------------- 字段类型常量
const ( // FIELD_TYPE_SINGLE_TEXT FieldType = "SingleText" //单行文本 // FIELD_TYPE_TEXT FieldType = "Text" //多行文本 FIELD_TYPE_TEXT FieldType = "SingleText" // 用一个就好了,文档有两个类型 FIELD_TYPE_SINGLE_SELECT FieldType = "SingleSelect" //单选 FIELD_TYPE_MULTI_SELECT FieldType = "MultiSelect" //多选 FIELD_TYPE_NUMBER FieldType = "Number" //数字 FIELD_TYPE_CURRENCY FieldType = "Currency" //货币 FIELD_TYPE_PERCENT FieldType = "Percent" //百分比 FIELD_TYPE_DATE_TIME FieldType = "DateTime" //日期 FIELD_TYPE_ATTACHMENT FieldType = "Attachment" //附件 FIELD_TYPE_MEMBER FieldType = "Member" //成员 FIELD_TYPE_CHECKBOX FieldType = "Checkbox" //勾选 FIELD_TYPE_RATING FieldType = "Rating" //评分 FIELD_TYPE_URL FieldType = "URL" //网址 FIELD_TYPE_PHONE FieldType = "Phone" //电话 FIELD_TYPE_EMAIL FieldType = "Email" //邮箱 FIELD_TYPE_WORK_DOC FieldType = "WorkDoc" //轻文档 FIELD_TYPE_ONE_WAY_LINK FieldType = "OneWayLink" //单向关联 FIELD_TYPE_TWO_WAY_LINK FieldType = "TwoWayLink" //双向关联 FIELD_TYPE_MAGIC_LOOKUP FieldType = "MagicLookUp" //神奇引用 FIELD_TYPE_FORMULA FieldType = "Formula" //智能公式 FIELD_TYPE_AUTO_NUMBER FieldType = "AutoNumber" //自增数字 FIELD_TYPE_CREATED_TIME FieldType = "CreatedTime" //创建时间 FIELD_TYPE_LAST_MODIFIED_TIME FieldType = "LastModifiedTime" //修改时间 FIELD_TYPE_CREATED_BY FieldType = "CreatedBy" //创建人 FIELD_TYPE_LAST_MODIFIED_BY FieldType = "LastModifiedBy" //更新人 FIELD_TYPE_BUTTON FieldType = "Button" //按钮 )
type GetRecordRequest ¶
type GetRecordRequest struct {
PageSize int `json:"pageSize,omitempty"`
MaxRecords int `json:"maxRecords,omitempty"`
PageNum int `json:"pageNum,omitempty"`
Sort []SortRule `json:"sort,omitempty"`
RecordIds []string `json:"recordIds,omitempty"`
ViewId string `json:"viewId,omitempty"`
Fields []string `json:"fields,omitempty"`
FilterByFrmula string `json:"filterByFrmula,omitempty"`
CellFormat string `json:"cellFormat,omitempty"`
FieldKey string `json:"fieldKey,omitempty"`
}
查询记录请求结构
type GetTeamListResponse ¶
type GetTeamListResponse struct {
Success bool `json:"success"`
Code int `json:"code"`
Message string `json:"message"`
Data struct {
PageNum int `json:"pageNum"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
Teams []*Team `json:"teams"`
} `json:"data"`
}
GetTeamListResponse 获取小组列表响应
type GetTeamMembersResponse ¶
type GetTeamMembersResponse struct {
Success bool `json:"success"`
Code int `json:"code"`
Message string `json:"message"`
Data struct {
PageNum int `json:"pageNum"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
Members []*User `json:"members"`
} `json:"data"`
}
GetTeamMembersResponse 获取小组成员响应
type GetUserResponse ¶
type GetUserResponse struct {
Success bool `json:"success"`
Code int `json:"code"`
Message string `json:"message"`
Data User `json:"data"`
}
GetUserResponse 获取单个用户响应
type MultiTableDoc ¶
type MultiTableDoc struct {
SpaceId string `json:"spaceId"` // 空间ID
DatasheetId string `json:"datasheetId"` // 数据表ID
}
func CreateMultiTable ¶
func CreateMultiTable(spaceId, tblName string, keyCol *AddField) (doc *MultiTableDoc, err error)
APITable 首列不能隐藏/删除/拖拽等等操作,所以需要指定业务的主键列名
func NewMultiTableDoc ¶
func NewMultiTableDoc(spaceId, datasheetId string) *MultiTableDoc
func (*MultiTableDoc) AddCol ¶
func (doc *MultiTableDoc) AddCol(fields []*AddField) (ret []*Field, err error)
-------------------------------------------------- 添加指定类型的字段
func (*MultiTableDoc) AddRow ¶
func (doc *MultiTableDoc) AddRow(rows []*AddRecord) (records []*CommonRecord, err error)
-------------------------------------------------- 增加记录
func (*MultiTableDoc) DelAllRows ¶
func (doc *MultiTableDoc) DelAllRows() error
-------------------------------------------------- 清空记录
func (*MultiTableDoc) DelRow ¶
func (doc *MultiTableDoc) DelRow(recordIds []string) error
-------------------------------------------------- 删除记录
func (*MultiTableDoc) EditRow ¶
func (doc *MultiTableDoc) EditRow(rows []*UpdateRecord) error
--------------------------------------------------
func (*MultiTableDoc) GetCols ¶
func (doc *MultiTableDoc) GetCols() ([]*Field, error)
-------------------------------------------------- 内部方法:查询字段
func (*MultiTableDoc) GetRow ¶
func (doc *MultiTableDoc) GetRow(req *GetRecordRequest) (*getRecordResponse, error)
-------------------------------------------------- 创建记录
func (*MultiTableDoc) SetColList ¶
func (doc *MultiTableDoc) SetColList(myColList []*AddField, deleteExcept bool) (isEdited bool, err error)
设置多维表格文档的列列表: 如果该列已存在,则不修改。如需修改列,为了确保程序不会误删数据,应该手动删除列,再通过该方法重建。 如果该列不存在,则添加列。 如果deleteExcept为true,则删除除myColList之外的所有列。
type SelectFieldOption ¶
type SelectFieldOption struct {
Id string `json:"id,omitempty"`
// Name string `json:"name"`
Text string `json:"name"`
// Color *SelectFieldOptionColor `json:"color,omitempty"` // 文档有问题,这里只需要string
Style SelectFieldOptionColor `json:"color,omitempty"`
}
--------------------------------------------------
type SelectFieldOptionColor ¶
type SelectFieldOptionColor string
var ( ColorRed SelectFieldOptionColor = "red_4" ColorOrange SelectFieldOptionColor = "tangerine_4" ColorYellow SelectFieldOptionColor = "yellow_4" ColorBlue SelectFieldOptionColor = "blue_4" ColorGreen SelectFieldOptionColor = "green_4" ColorPurple SelectFieldOptionColor = "deepPurple_4" ColorGray SelectFieldOptionColor = "blue_0" ColorPink SelectFieldOptionColor = "pink_4" )
预定义的颜色选项
type Team ¶
type Team struct {
UnitId string `json:"unitId"`
Name string `json:"name"`
Sequence int `json:"sequence"`
ParentUnitId string `json:"parentUnitId"`
Roles []struct {
UnitId string `json:"unitId"`
Name string `json:"name"`
Sequence int `json:"sequence"`
} `json:"roles"`
}
Team 表示小组信息
type UpdateRecord ¶
type UpdateRecord struct {
RecordId string `json:"recordId"`
Fields map[string]any `json:"fields"`
}
-------------------------------------------------- api req/resp结构 --------------------------------------------------
type UpdateRecordRequest ¶
type UpdateRecordRequest struct {
Records []*UpdateRecord `json:"records"`
FieldKey string `json:"fieldKey,omitempty"` // "name" or "id", default "name"
}
type UpdateRecordResponse ¶
type UpdateRecordResponse struct {
Success bool `json:"success"`
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Records []CommonRecord `json:"records"`
} `json:"data"`
}
type User ¶
type User struct {
UnitId string `json:"unitId"`
Name string `json:"name"`
Email string `json:"email"`
Mobile struct {
Number string `json:"number"`
AreaCode string `json:"areaCode"`
} `json:"mobile"`
Avatar string `json:"avatar"`
Status int `json:"status"` // 0:未加入空间站, 1:已加入空间站
Type string `json:"type"` // PrimaryAdmin, SubAdmin, Member
Teams []struct {
UnitId string `json:"unitId"`
Name string `json:"name"`
Sequence int `json:"sequence"`
ParentUnitId string `json:"parentUnitId"`
} `json:"teams"`
Roles []struct {
UnitId string `json:"unitId"`
Name string `json:"name"`
Sequence int `json:"sequence"`
} `json:"roles"`
}
User 表示成员信息