wps

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

wps-sdk-go

WPS私有化部署方案的SDK

Documentation

Index

Constants

View Source
const (
	// 状态码
	// StatusOk 成功
	StatusOk string = "200"
)

Variables

This section is empty.

Functions

func NewResty

func NewResty() *resty.Request

NewResty Resty客户端

Types

type BaseRsp

type BaseRsp struct {
	// 状态码
	Code string `json:"code"`
	// 详细描述
	Msg string `json:"msg"`
	// 服务器时间
	ServerTime string `json:"servertime"`
}

BaseRsp 响应基类

func (*BaseRsp) ErrorCode added in v0.0.10

func (br *BaseRsp) ErrorCode() (code int)

type ConvertReq

type ConvertReq struct {
	// 上传后的文档Id
	Id string `json:"id"`
	// 目标文件格式,如果为空表示默认转换为默认的预览格式
	TargetFileFormat FormatType `json:"targetFileFormat"`
}

ConvertReq 文件转换请求

func (ConvertReq) String

func (cr ConvertReq) String() string

type ConvertRsp

type ConvertRsp struct {
	BaseRsp

	// 数据
	Data struct {
		// Download 下载Id,如果不存在此字段表示文档不可下载
		Download string `json:"download"`
		// Preview 预览Id,如果不存在此字段表示该文档不可被预览
		Preview string `json:"preview"`
		// OfficeUrl Office预览Uri,仅在后台管理开启配置且为WebOffice预览时才存在
		OfficeUrl string `json:"officeUrl"`
	} `json:"data"`
}

ConvertRsp 文档转换响应

func (ConvertRsp) String

func (fer ConvertRsp) String() string

type FileExistReq

type FileExistReq struct {
	// 文件Id
	Id string `json:"id"`
	// 文件类型
	Type FileType `json:"type"`
}

FileExistReq 文档是否存在的请求

func (FileExistReq) String

func (fer FileExistReq) String() string

type FileExistRsp

type FileExistRsp struct {
	BaseRsp

	// 数据
	Data struct {
		// 文件是否存在
		ExistsFile bool `json:"existsFile"`
	} `json:"data"`
}

func (FileExistRsp) String

func (fer FileExistRsp) String() string

type FileType

type FileType string

FileType 文件类型

const (
	// 上传文件
	FileTypeUpload FileType = "UPLOAD"
	// 下载文件
	FileTypeDownload FileType = "DOWNLOAD"
	// 预览文件
	FileTypePreview FileType = "PREVIEW"
)

type FormatType added in v0.0.4

type FormatType string

FormatType 扩展类型

const (
	FormatTypeNone FormatType = ""
	// 文字文件
	FormatTypeDoc  FormatType = "doc"
	FormatTypeDot  FormatType = "dot"
	FormatTypeWps  FormatType = "wps"
	FormatTypeWpt  FormatType = "wpt"
	FormatTypeDocx FormatType = "docx"
	FormatTypeDotx FormatType = "dotx"
	FormatTypeDocm FormatType = "docm"
	FormatTypeDotm FormatType = "dotm"

	// 表格文件
	FormatTypeXls  FormatType = "xls"
	FormatTypeXlt  FormatType = "xlt"
	FormatTypeEt   FormatType = "et"
	FormatTypeXlsx FormatType = "xlsx"
	FormatTypeXltx FormatType = "xltx"
	FormatTypeXlsm FormatType = "xlsm"
	FormatTypeXltm FormatType = "xltm"

	// 演示文件
	FormatTypePpt  FormatType = "ppt"
	FormatTypePptx FormatType = "pptx"
	FormatTypePptm FormatType = "pptm"
	FormatTypePpsx FormatType = "ppsx"
	FormatTypePpsm FormatType = "ppsm"
	FormatTypePps  FormatType = "pps"
	FormatTypePotx FormatType = "potx"
	FormatTypePotm FormatType = "potm"
	FormatTypeDpt  FormatType = "dpt"
	FormatTypeDps  FormatType = "dps"

	// Pdf文件
	FormatTypePdf FormatType = "pdf"
	FormatTypeOfd FormatType = "ofd"
)

type Reader

type Reader struct {
	// 文件预览Id
	File string `json:"file" url:"file" validate:"required"`
	// 水印文字
	MarkText string `json:"markText" url:"markText"`
	// 水印颜色,十六进制形式,比如#DB7093
	// 默认值是#A6A6A6
	MarkColor string `json:"markColor" url:"markColor"`
	// 水印透明度,可取值是0到1,0为完全透明
	// 默认值是0.6
	MarkTransparent float32 `json:"markTransparent" url:"markTransparent"`
	// 字体CSS样式,比如bold 20px Serif
	MarkFontCssStyle string `json:"markFontCssStyle" url:"markFontCssStyle"`
	// 水印旋转度,可取值是1到360
	MarkRotate int `json:"markRotate" url:"markRotate"`
	// 水印水平距离,可取值是1到100
	MarkHorizontal int8 `json:"markHorizontal" url:"markHorizontal"`
	// 水印垂直距离,可取值是1到100
	MarkVertical int8 `json:"markVertical" url:"markVertical"`
	// 是否可打印,默认false
	IsPrint bool `json:"isPrint" url:"isPrint"`
	// 是否可以被下载,默认为false
	IsDownload bool `json:"isDownload" url:"isDownload"`
	// 页面内容是否可以被复制,默认false
	IsCopy bool `json:"isCopy" url:"isCopy"`
	// 从低到高位,每位的取值是0或者1,依次代表如下
	// 第0位:默认1,0-最终状态,1- 原始状态
	// 第1位:默认1(显示),是否显示标记
	// 第2位和第3位组合使用:00是批注框显示修订者,10是嵌入方式显示,01及11为批注框方式
	// 第4位:默认1(显示),是否显示评论
	// 第5位:默认1(显示),是否显示插入和删除
	// 第6位:默认1(显示),是否显示格式修订
	WpsPreview string `json:"wpsPreview" url:"wpsPreview"`
}

Reader 文档预览

func (Reader) String

func (r Reader) String() string

type SupportType added in v0.0.2

type SupportType string

SupportType 文件预览支持格式

const (
	SupportTypeWriter       SupportType = "w"
	SupportTypeSpreadsheets SupportType = "s"
	SupportTypePresentation SupportType = "p"
	SupportTypePdf          SupportType = "f"
)

func CheckSupport added in v0.0.2

func CheckSupport(filename string) (ok bool, st SupportType)

type UploadFileRsp

type UploadFileRsp struct {
	BaseRsp

	// 数据
	Data struct {
		// WPS文件编号
		Id string `json:"id"`
	} `json:"data"`
}

UploadFileRsp 文件上传返回结果

func (UploadFileRsp) String

func (ur UploadFileRsp) String() string

type UploadLocalFileReq

type UploadLocalFileReq struct {
	// 文件
	File string `json:"file"`
}

UploadByLocalFileReq 本地文件上传

func (UploadLocalFileReq) String

func (ur UploadLocalFileReq) String() string

type UploadNetworkFileReq

type UploadNetworkFileReq struct {
	// 网络文件地址
	Url string `json:"url" url:"url"`
}

UploadNetworkFileReq HTTP/HTTPS网络文件上传

func (UploadNetworkFileReq) String

func (ur UploadNetworkFileReq) String() string

type Wps

type Wps struct {
	// ApiUrl 服务器地址
	ApiUrl string `json:"apiUrl"`
	// PreviewUrl 浏览地址
	ViewUrl string `json:"viewUrl"`
	// 文档预览前缀
	PreviewPrefix string `default:"web" json:"previewPrefix"`
	// 内部文档预览前缀
	OfficePrefix string `default:"office" json:"officePrefix"`
	// 文档转换前缀
	ConvertPrefix string `default:"web-preview" json:"convertPrefix"`
}

Wps 金山文档

func (*Wps) Convert

func (w *Wps) Convert(id string, formatType FormatType) (rsp ConvertRsp, err error)

Convert 文档转换

func (*Wps) ConvertByNetworkFile

func (w *Wps) ConvertByNetworkFile(
	url string,
	formatType FormatType,
) (previewId string, downloadId string, fileId string, err error)

ConvertByNetworkFile 转换网络文件

func (*Wps) DownloadUrl added in v0.0.4

func (w *Wps) DownloadUrl(id string) (downloadUrl string, err error)

DownloadUrl 获得下载地址

func (*Wps) Exist

func (w *Wps) Exist(id string, fileType FileType) (exist bool, err error)

Exist 判断文件是否存在

func (*Wps) OfficeUrl added in v0.0.8

func (w *Wps) OfficeUrl(filename string, reader Reader) (previewUrl string, err error)

OfficeUrl 获得预览地址,去掉外层iframe后的地址

func (*Wps) PreviewUrl

func (w *Wps) PreviewUrl(reader Reader) (previewUrl string, err error)

PreviewUrl 获得预览地址

func (Wps) String

func (w Wps) String() string

func (*Wps) UploadNetworkFile

func (w *Wps) UploadNetworkFile(fileUrl string) (rsp UploadFileRsp, err error)

UploadNetworkFile 上传网络文件 可以是Http和Https地址,且只支持这两种地址

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL