1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-09 23:22:27 +08:00

[feature] Format the code and improve Mini Program authorization to o… (#473)

* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session)

* [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html)

* upgrade json error

* upgrade json error

Co-authored-by: houseme <houseme@outlook.com>
This commit is contained in:
houseme
2021-09-08 11:03:23 +08:00
committed by GitHub
parent 47adf42208
commit 96c1f98944
90 changed files with 787 additions and 760 deletions

View File

@@ -7,60 +7,60 @@ import (
)
const (
//获取文件上传链接
// 获取文件上传链接
uploadFilePathURL = "https://api.weixin.qq.com/tcb/uploadfile"
//获取文件下载链接
// 获取文件下载链接
batchDownloadFileURL = "https://api.weixin.qq.com/tcb/batchdownloadfile"
//删除文件链接
// 删除文件链接
batchDeleteFileURL = "https://api.weixin.qq.com/tcb/batchdeletefile"
)
//UploadFileReq 上传文件请求值
// UploadFileReq 上传文件请求值
type UploadFileReq struct {
Env string `json:"env,omitempty"`
Path string `json:"path,omitempty"`
}
//UploadFileRes 上传文件返回结果
// UploadFileRes 上传文件返回结果
type UploadFileRes struct {
util.CommonError
URL string `json:"url"` //上传url
Token string `json:"token"` //token
Authorization string `json:"authorization"` //authorization
FileID string `json:"file_id"` //文件ID
CosFileID string `json:"cos_file_id"` //cos文件ID
URL string `json:"url"` // 上传url
Token string `json:"token"` // token
Authorization string `json:"authorization"` // authorization
FileID string `json:"file_id"` // 文件ID
CosFileID string `json:"cos_file_id"` // cos文件ID
}
//BatchDownloadFileReq 上传文件请求值
// BatchDownloadFileReq 上传文件请求值
type BatchDownloadFileReq struct {
Env string `json:"env,omitempty"`
FileList []*DownloadFile `json:"file_list,omitempty"`
}
//DownloadFile 文件信息
// DownloadFile 文件信息
type DownloadFile struct {
FileID string `json:"fileid"` //文件ID
MaxAge int64 `json:"max_age"` //下载链接有效期
FileID string `json:"fileid"` // 文件ID
MaxAge int64 `json:"max_age"` // 下载链接有效期
}
//BatchDownloadFileRes 上传文件返回结果
// BatchDownloadFileRes 上传文件返回结果
type BatchDownloadFileRes struct {
util.CommonError
FileList []struct {
FileID string `json:"file_id"` //文件ID
DownloadURL string `json:"download_url"` //下载链接
Status int64 `json:"status"` //状态码
ErrMsg string `json:"errmsg"` //该文件错误信息
FileID string `json:"file_id"` // 文件ID
DownloadURL string `json:"download_url"` // 下载链接
Status int64 `json:"status"` // 状态码
ErrMsg string `json:"errmsg"` // 该文件错误信息
} `json:"file_list"`
}
//BatchDeleteFileReq 批量删除文件请求参数
// BatchDeleteFileReq 批量删除文件请求参数
type BatchDeleteFileReq struct {
Env string `json:"env,omitempty"`
FileIDList []string `json:"fileid_list,omitempty"`
}
//BatchDeleteFileRes 批量删除文件返回结果
// BatchDeleteFileRes 批量删除文件返回结果
type BatchDeleteFileRes struct {
util.CommonError
DeleteList []struct {
@@ -70,7 +70,7 @@ type BatchDeleteFileRes struct {
} `json:"delete_list"`
}
//UploadFile 上传文件
// UploadFile 上传文件
//reference:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/storage/uploadFile.html
func (tcb *Tcb) UploadFile(env, path string) (*UploadFileRes, error) {
accessToken, err := tcb.GetAccessToken()
@@ -91,7 +91,7 @@ func (tcb *Tcb) UploadFile(env, path string) (*UploadFileRes, error) {
return uploadFileRes, err
}
//BatchDownloadFile 获取文件下载链接
// BatchDownloadFile 获取文件下载链接
//reference:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/storage/batchDownloadFile.html
func (tcb *Tcb) BatchDownloadFile(env string, fileList []*DownloadFile) (*BatchDownloadFileRes, error) {
accessToken, err := tcb.GetAccessToken()
@@ -112,7 +112,7 @@ func (tcb *Tcb) BatchDownloadFile(env string, fileList []*DownloadFile) (*BatchD
return batchDownloadFileRes, err
}
//BatchDeleteFile 批量删除文件
// BatchDeleteFile 批量删除文件
//reference:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/storage/batchDeleteFile.html
func (tcb *Tcb) BatchDeleteFile(env string, fileIDList []string) (*BatchDeleteFileRes, error) {
accessToken, err := tcb.GetAccessToken()