From 6053598a03953080df3cbd62c1ed81e082f340eb Mon Sep 17 00:00:00 2001 From: markwang Date: Fri, 15 Mar 2024 14:38:10 +0800 Subject: [PATCH 1/2] feat: optimized-error-handling&remove unused constant --- miniprogram/auth/auth.go | 6 ++-- miniprogram/business/phone_number.go | 7 +---- miniprogram/privacy/privacy.go | 20 +++---------- miniprogram/security/security.go | 34 ++-------------------- miniprogram/shortlink/shortlink.go | 6 +--- miniprogram/subscribe/subscribe.go | 6 +--- miniprogram/urllink/urllink.go | 13 +-------- miniprogram/urlscheme/query.go | 6 +--- miniprogram/urlscheme/urlscheme.go | 19 +----------- officialaccount/basic/short_url.go | 7 ++--- officialaccount/customerservice/manager.go | 19 ++---------- officialaccount/datacube/publisher.go | 28 ------------------ officialaccount/draft/draft.go | 20 ++----------- officialaccount/freepublish/freepublish.go | 31 ++------------------ officialaccount/message/subscribe.go | 31 ++++---------------- officialaccount/message/template.go | 12 ++------ officialaccount/user/migrate.go | 4 --- officialaccount/user/tag.go | 8 +---- openplatform/context/accessToken.go | 7 ++--- 19 files changed, 33 insertions(+), 251 deletions(-) diff --git a/miniprogram/auth/auth.go b/miniprogram/auth/auth.go index 32c1493..b0af59b 100644 --- a/miniprogram/auth/auth.go +++ b/miniprogram/auth/auth.go @@ -138,10 +138,8 @@ func (auth *Auth) GetPhoneNumberContext(ctx context2.Context, code string) (*Get } var result GetPhoneNumberResponse - if err = util.DecodeWithError(response, &result, "phonenumber.getPhoneNumber"); err != nil { - return nil, err - } - return &result, nil + err = util.DecodeWithError(response, &result, "phonenumber.getPhoneNumber") + return &result, err } // GetPhoneNumber 小程序通过code获取用户手机号 diff --git a/miniprogram/business/phone_number.go b/miniprogram/business/phone_number.go index bf99057..7292149 100644 --- a/miniprogram/business/phone_number.go +++ b/miniprogram/business/phone_number.go @@ -45,10 +45,5 @@ func (business *Business) GetPhoneNumber(in *GetPhoneNumberRequest) (info PhoneI PhoneInfo PhoneInfo `json:"phone_info"` } err = util.DecodeWithError(response, &resp, "business.GetPhoneNumber") - if nil != err { - return - } - - info = resp.PhoneInfo - return + return resp.PhoneInfo, err } diff --git a/miniprogram/privacy/privacy.go b/miniprogram/privacy/privacy.go index 024e379..9c3cc6c 100644 --- a/miniprogram/privacy/privacy.go +++ b/miniprogram/privacy/privacy.go @@ -55,8 +55,6 @@ const ( // PrivacyV1 用户隐私保护指引的版本,1表示现网版本。 PrivacyV1 = 1 - // PrivacyV2 2表示开发版。默认是2开发版。 - PrivacyV2 = 2 ) // GetPrivacySettingResponse 获取权限配置的响应结果 @@ -103,11 +101,8 @@ func (s *Privacy) GetPrivacySetting(privacyVer int) (GetPrivacySettingResponse, } // 返回错误信息 var result GetPrivacySettingResponse - if err = util.DecodeWithError(response, &result, "getprivacysetting"); err != nil { - return GetPrivacySettingResponse{}, err - } - - return result, nil + err = util.DecodeWithError(response, &result, "getprivacysetting") + return result, err } // SetPrivacySetting 更新小程序权限配置 @@ -130,11 +125,7 @@ func (s *Privacy) SetPrivacySetting(privacyVer int, ownerSetting OwnerSetting, s } // 返回错误信息 - if err = util.DecodeWithCommonError(response, "setprivacysetting"); err != nil { - return err - } - - return err + return util.DecodeWithCommonError(response, "setprivacysetting") } // UploadPrivacyExtFileResponse 上传权限定义模板响应参数 @@ -159,9 +150,6 @@ func (s *Privacy) UploadPrivacyExtFile(fileData []byte) (UploadPrivacyExtFileRes // 返回错误信息 var result UploadPrivacyExtFileResponse - if err = util.DecodeWithError(response, &result, "setprivacysetting"); err != nil { - return UploadPrivacyExtFileResponse{}, err - } - + err = util.DecodeWithError(response, &result, "setprivacysetting") return result, err } diff --git a/miniprogram/security/security.go b/miniprogram/security/security.go index 7e4d5dc..214185f 100644 --- a/miniprogram/security/security.go +++ b/miniprogram/security/security.go @@ -51,12 +51,7 @@ func (security *Security) MediaCheckAsyncV1(in *MediaCheckAsyncV1Request) (trace TraceID string `json:"trace_id"` } err = util.DecodeWithError(response, &res, "MediaCheckAsyncV1") - if err != nil { - return - } - - traceID = res.TraceID - return + return res.TraceID, err } // MediaCheckAsyncRequest 图片/音频异步校验请求参数 @@ -93,12 +88,7 @@ func (security *Security) MediaCheckAsync(in *MediaCheckAsyncRequest) (traceID s TraceID string `json:"trace_id"` } err = util.DecodeWithError(response, &res, "MediaCheckAsync") - if err != nil { - return - } - - traceID = res.TraceID - return + return res.TraceID, err } // ImageCheckV1 校验一张图片是否含有违法违规内容(同步) @@ -124,29 +114,9 @@ func (security *Security) ImageCheckV1(filename string) (err error) { // CheckSuggest 检查建议 type CheckSuggest string -const ( - // CheckSuggestRisky 违规风险建议 - CheckSuggestRisky CheckSuggest = "risky" - // CheckSuggestPass 安全 - CheckSuggestPass CheckSuggest = "pass" - // CheckSuggestReview 需要审查 - CheckSuggestReview CheckSuggest = "review" -) - // MsgScene 文本场景 type MsgScene uint8 -const ( - // MsgSceneMaterial 资料文件检查场景 - MsgSceneMaterial MsgScene = iota + 1 - // MsgSceneComment 评论 - MsgSceneComment - // MsgSceneForum 论坛 - MsgSceneForum - // MsgSceneSocialLog 社交日志 - MsgSceneSocialLog -) - // CheckLabel 检查命中标签 type CheckLabel int diff --git a/miniprogram/shortlink/shortlink.go b/miniprogram/shortlink/shortlink.go index c386c21..f55b89b 100644 --- a/miniprogram/shortlink/shortlink.go +++ b/miniprogram/shortlink/shortlink.go @@ -60,11 +60,7 @@ func (shortLink *ShortLink) generate(shortLinkParams ShortLinker) (string, error // 使用通用方法返回错误 var res resShortLinker err = util.DecodeWithError(response, &res, "GenerateShortLink") - if err != nil { - return "", err - } - - return res.Link, nil + return res.Link, err } // GenerateShortLinkPermanent 生成永久 shortLink diff --git a/miniprogram/subscribe/subscribe.go b/miniprogram/subscribe/subscribe.go index 0015a43..9099044 100644 --- a/miniprogram/subscribe/subscribe.go +++ b/miniprogram/subscribe/subscribe.go @@ -168,11 +168,7 @@ func (s *Subscribe) Add(ShortID string, kidList []int, sceneDesc string) (templa } var result resSubscribeAdd err = util.DecodeWithError(response, &result, "AddSubscribe") - if err != nil { - return - } - templateID = result.TemplateID - return + return result.TemplateID, err } // Delete 删除私有模板 diff --git a/miniprogram/urllink/urllink.go b/miniprogram/urllink/urllink.go index 378d58a..0892dac 100644 --- a/miniprogram/urllink/urllink.go +++ b/miniprogram/urllink/urllink.go @@ -22,14 +22,6 @@ const generateURL = "https://api.weixin.qq.com/wxa/generate_urllink" // TExpireType 失效类型 (指定时间戳/指定间隔) type TExpireType int -const ( - // ExpireTypeTime 指定时间戳后失效 - ExpireTypeTime TExpireType = 0 - - // ExpireTypeInterval 间隔指定天数后失效 - ExpireTypeInterval TExpireType = 1 -) - // ULParams 请求参数 // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-link/urllink.generate.html#请求参数 type ULParams struct { @@ -65,8 +57,5 @@ func (u *URLLink) Generate(params *ULParams) (string, error) { } var resp ULResult err = util.DecodeWithError(response, &resp, "URLLink.Generate") - if err != nil { - return "", err - } - return resp.URLLink, nil + return resp.URLLink, err } diff --git a/miniprogram/urlscheme/query.go b/miniprogram/urlscheme/query.go index 79b37fb..72506e8 100644 --- a/miniprogram/urlscheme/query.go +++ b/miniprogram/urlscheme/query.go @@ -62,9 +62,5 @@ func (u *URLScheme) QueryScheme(querySchemeParams QueryScheme) (schemeInfo Schem // 使用通用方法返回错误 var res resQueryScheme err = util.DecodeWithError(response, &res, "QueryScheme") - if err != nil { - return - } - - return res.SchemeInfo, res.VisitOpenid, nil + return res.SchemeInfo, res.VisitOpenid, err } diff --git a/miniprogram/urlscheme/urlscheme.go b/miniprogram/urlscheme/urlscheme.go index 37bcd75..27c37ee 100644 --- a/miniprogram/urlscheme/urlscheme.go +++ b/miniprogram/urlscheme/urlscheme.go @@ -25,20 +25,6 @@ type TExpireType int // EnvVersion 要打开的小程序版本 type EnvVersion string -const ( - // ExpireTypeTime 指定时间戳后失效 - ExpireTypeTime TExpireType = 0 - // ExpireTypeInterval 间隔指定天数后失效 - ExpireTypeInterval TExpireType = 1 - - // EnvVersionRelease 正式版为"release" - EnvVersionRelease EnvVersion = "release" - // EnvVersionTrial 体验版为"trial" - EnvVersionTrial EnvVersion = "trial" - // EnvVersionDevelop 开发版为"develop" - EnvVersionDevelop EnvVersion = "develop" -) - // JumpWxa 跳转到的目标小程序信息 type JumpWxa struct { Path string `json:"path"` @@ -78,8 +64,5 @@ func (u *URLScheme) Generate(params *USParams) (string, error) { } var resp USResult err = util.DecodeWithError(response, &resp, "URLScheme.Generate") - if err != nil { - return "", err - } - return resp.OpenLink, nil + return resp.OpenLink, err } diff --git a/officialaccount/basic/short_url.go b/officialaccount/basic/short_url.go index 94be9bb..a3a1440 100644 --- a/officialaccount/basic/short_url.go +++ b/officialaccount/basic/short_url.go @@ -44,9 +44,6 @@ func (basic *Basic) Long2ShortURL(longURL string) (shortURL string, err error) { if err != nil { return } - if err = util.DecodeWithError(responseBytes, resp, long2shortAction); err != nil { - return - } - shortURL = resp.ShortURL - return + err = util.DecodeWithError(responseBytes, resp, long2shortAction) + return resp.ShortURL, err } diff --git a/officialaccount/customerservice/manager.go b/officialaccount/customerservice/manager.go index 6422fb7..ada6d2c 100644 --- a/officialaccount/customerservice/manager.go +++ b/officialaccount/customerservice/manager.go @@ -21,13 +21,6 @@ const ( customerServiceTypingURL = "https://api.weixin.qq.com/cgi-bin/message/custom/typing" ) -const ( - // Typing 表示正在输入状态 - Typing TypingStatus = "Typing" - // CancelTyping 表示取消正在输入状态 - CancelTyping TypingStatus = "CancelTyping" -) - // Manager 客服管理者,可以管理客服 type Manager struct { *context.Context @@ -72,11 +65,7 @@ func (csm *Manager) List() (customerServiceList []*KeFuInfo, err error) { } var res resKeFuList err = util.DecodeWithError(response, &res, "ListCustomerService") - if err != nil { - return - } - customerServiceList = res.KfList - return + return res.KfList, err } // KeFuOnlineInfo 客服在线信息 @@ -107,11 +96,7 @@ func (csm *Manager) OnlineList() (customerServiceOnlineList []*KeFuOnlineInfo, e } var res resKeFuOnlineList err = util.DecodeWithError(response, &res, "ListOnlineCustomerService") - if err != nil { - return - } - customerServiceOnlineList = res.KfOnlineList - return + return res.KfOnlineList, err } // Add 添加客服账号 diff --git a/officialaccount/datacube/publisher.go b/officialaccount/datacube/publisher.go index bd640d0..cb5d03b 100644 --- a/officialaccount/datacube/publisher.go +++ b/officialaccount/datacube/publisher.go @@ -11,31 +11,6 @@ import ( // AdSlot 广告位类型 type AdSlot string -const ( - // SlotIDBizBottom 公众号底部广告 - SlotIDBizBottom AdSlot = "SLOT_ID_BIZ_BOTTOM" - // SlotIDBizMidContext 公众号文中广告 - SlotIDBizMidContext AdSlot = "SLOT_ID_BIZ_MID_CONTEXT" - // SlotIDBizVideoEnd 公众号视频后贴 - SlotIDBizVideoEnd AdSlot = "SLOT_ID_BIZ_VIDEO_END" - // SlotIDBizSponsor 公众号互选广告 - SlotIDBizSponsor AdSlot = "SLOT_ID_BIZ_SPONSOR" - // SlotIDBizCps 公众号返佣商品 - SlotIDBizCps AdSlot = "SLOT_ID_BIZ_CPS" - // SlotIDWeappBanner 小程序banner - SlotIDWeappBanner AdSlot = "SLOT_ID_WEAPP_BANNER" - // SlotIDWeappRewardVideo 小程序激励视频 - SlotIDWeappRewardVideo AdSlot = "SLOT_ID_WEAPP_REWARD_VIDEO" - // SlotIDWeappInterstitial 小程序插屏广告 - SlotIDWeappInterstitial AdSlot = "SLOT_ID_WEAPP_INTERSTITIAL" - // SlotIDWeappVideoFeeds 小程序视频广告 - SlotIDWeappVideoFeeds AdSlot = "SLOT_ID_WEAPP_VIDEO_FEEDS" - // SlotIDWeappVideoBegin 小程序视频前贴 - SlotIDWeappVideoBegin AdSlot = "SLOT_ID_WEAPP_VIDEO_BEGIN" - // SlotIDWeappBox 小程序格子广告 - SlotIDWeappBox AdSlot = "SLOT_ID_WEAPP_BOX" -) - const ( publisherURL = "https://api.weixin.qq.com/publisher/stat" ) @@ -183,9 +158,6 @@ func (cube *DataCube) fetchData(params ParamsPublisher) (response []byte, err er uri := fmt.Sprintf("%s?%s", publisherURL, v.Encode()) response, err = util.HTTPGet(uri) - if err != nil { - return - } return } diff --git a/officialaccount/draft/draft.go b/officialaccount/draft/draft.go index e7f15d3..76a3751 100644 --- a/officialaccount/draft/draft.go +++ b/officialaccount/draft/draft.go @@ -64,11 +64,7 @@ func (draft *Draft) AddDraft(articles []*Article) (mediaID string, err error) { MediaID string `json:"media_id"` } err = util.DecodeWithError(response, &res, "AddDraft") - if err != nil { - return - } - mediaID = res.MediaID - return + return res.MediaID, err } // GetDraft 获取草稿 @@ -94,12 +90,7 @@ func (draft *Draft) GetDraft(mediaID string) (articles []*Article, err error) { NewsItem []*Article `json:"news_item"` } err = util.DecodeWithError(response, &res, "GetDraft") - if err != nil { - return - } - - articles = res.NewsItem - return + return res.NewsItem, err } // DeleteDraft 删除草稿 @@ -172,12 +163,7 @@ func (draft *Draft) CountDraft() (total uint, err error) { Total uint `json:"total_count"` } err = util.DecodeWithError(response, &res, "CountDraft") - if nil != err { - return - } - - total = res.Total - return + return res.Total, err } // ArticleList 草稿列表 diff --git a/officialaccount/freepublish/freepublish.go b/officialaccount/freepublish/freepublish.go index 041bf66..24df3ad 100644 --- a/officialaccount/freepublish/freepublish.go +++ b/officialaccount/freepublish/freepublish.go @@ -18,23 +18,6 @@ const ( // PublishStatus 发布状态 type PublishStatus uint -const ( - // PublishStatusSuccess 0:成功 - PublishStatusSuccess PublishStatus = iota - // PublishStatusPublishing 1:发布中 - PublishStatusPublishing - // PublishStatusOriginalFail 2:原创失败 - PublishStatusOriginalFail - // PublishStatusFail 3:常规失败 - PublishStatusFail - // PublishStatusAuditRefused 4:平台审核不通过 - PublishStatusAuditRefused - // PublishStatusUserDeleted 5:成功后用户删除所有文章 - PublishStatusUserDeleted - // PublishStatusSystemBanned 6:成功后系统封禁所有文章 - PublishStatusSystemBanned -) - // FreePublish 发布能力 type FreePublish struct { *context.Context @@ -73,12 +56,7 @@ func (freePublish *FreePublish) Publish(mediaID string) (publishID int64, err er PublishID int64 `json:"publish_id"` } err = util.DecodeWithError(response, &res, "SubmitFreePublish") - if err != nil { - return - } - - publishID = res.PublishID - return + return res.PublishID, err } // PublishStatusList 发布任务状态列表 @@ -191,12 +169,7 @@ func (freePublish *FreePublish) First(articleID string) (list []Article, err err NewsItem []Article `json:"news_item"` } err = util.DecodeWithError(response, &res, "FirstFreePublish") - if err != nil { - return - } - - list = res.NewsItem - return + return res.NewsItem, err } // ArticleList 发布列表 diff --git a/officialaccount/message/subscribe.go b/officialaccount/message/subscribe.go index 9b6e18a..c0e9516 100644 --- a/officialaccount/message/subscribe.go +++ b/officialaccount/message/subscribe.go @@ -90,11 +90,7 @@ func (tpl *Subscribe) List() (templateList []*PrivateSubscribeItem, err error) { } var res resPrivateSubscribeList err = util.DecodeWithError(response, &res, "ListSubscribe") - if err != nil { - return - } - templateList = res.SubscriptionList - return + return res.SubscriptionList, err } type resSubscribeAdd struct { @@ -123,11 +119,7 @@ func (tpl *Subscribe) Add(ShortID string, kidList []int, sceneDesc string) (temp } var result resSubscribeAdd err = util.DecodeWithError(response, &result, "AddSubscribe") - if err != nil { - return - } - templateID = result.TemplateID - return + return result.TemplateID, err } // Delete 删除私有模板 @@ -175,11 +167,7 @@ func (tpl *Subscribe) GetCategory() (categoryList []*PublicTemplateCategory, err } var result resSubscribeCategoryList err = util.DecodeWithError(response, &result, "GetCategory") - if err != nil { - return - } - categoryList = result.CategoryList - return + return result.CategoryList, err } // PublicTemplateKeyWords 模板中的关键词 @@ -210,11 +198,7 @@ func (tpl *Subscribe) GetPubTplKeyWordsByID(titleID string) (keyWordsList []*Pub } var result resPublicTemplateKeyWordsList err = util.DecodeWithError(response, &result, "GetPublicTemplateKeyWords") - if err != nil { - return - } - keyWordsList = result.KeyWordsList - return + return result.KeyWordsList, err } // PublicTemplateTitle 类目下的公共模板 @@ -246,10 +230,5 @@ func (tpl *Subscribe) GetPublicTemplateTitleList(ids string, start int, limit in } var result resPublicTemplateTitleList err = util.DecodeWithError(response, &result, "GetPublicTemplateTitle") - if err != nil { - return - } - count = result.Count - templateTitleList = result.TemplateTitleList - return + return result.Count, result.TemplateTitleList, err } diff --git a/officialaccount/message/template.go b/officialaccount/message/template.go index 24a47ba..1c657ea 100644 --- a/officialaccount/message/template.go +++ b/officialaccount/message/template.go @@ -111,11 +111,7 @@ func (tpl *Template) List() (templateList []*TemplateItem, err error) { } var res resTemplateList err = util.DecodeWithError(response, &res, "ListTemplate") - if err != nil { - return - } - templateList = res.TemplateList - return + return res.TemplateList, err } type resTemplateAdd struct { @@ -143,11 +139,7 @@ func (tpl *Template) Add(shortID string) (templateID string, err error) { var result resTemplateAdd err = util.DecodeWithError(response, &result, "AddTemplate") - if err != nil { - return - } - templateID = result.TemplateID - return + return result.TemplateID, err } // Delete 删除私有模板. diff --git a/officialaccount/user/migrate.go b/officialaccount/user/migrate.go index 44afe05..cac6a1e 100644 --- a/officialaccount/user/migrate.go +++ b/officialaccount/user/migrate.go @@ -62,10 +62,6 @@ func (user *User) ListChangeOpenIDs(fromAppID string, openIDs ...string) (list * } err = util.DecodeWithError(resp, list, "ListChangeOpenIDs") - if err != nil { - return - } - return } diff --git a/officialaccount/user/tag.go b/officialaccount/user/tag.go index 3a61c5d..6353cfc 100644 --- a/officialaccount/user/tag.go +++ b/officialaccount/user/tag.go @@ -126,10 +126,7 @@ func (user *User) GetTag() (tags []*TagInfo, err error) { Tags []*TagInfo `json:"tags"` } err = json.Unmarshal(response, &result) - if err != nil { - return - } - return result.Tags, nil + return result.Tags, err } // OpenIDListByTag 获取标签下粉丝列表 @@ -154,9 +151,6 @@ func (user *User) OpenIDListByTag(tagID int32, nextOpenID ...string) (userList * } userList = new(TagOpenIDList) err = json.Unmarshal(response, &userList) - if err != nil { - return - } return } diff --git a/openplatform/context/accessToken.go b/openplatform/context/accessToken.go index 6886129..465eb17 100644 --- a/openplatform/context/accessToken.go +++ b/openplatform/context/accessToken.go @@ -100,11 +100,8 @@ func (ctx *Context) GetPreCodeContext(stdCtx context.Context) (string, error) { var ret struct { PreCode string `json:"pre_auth_code"` } - if err := json.Unmarshal(body, &ret); err != nil { - return "", err - } - - return ret.PreCode, nil + err = json.Unmarshal(body, &ret) + return ret.PreCode, err } // GetPreCode 获取预授权码 From ea684369a9f0005d27bbcaba120115bdead8802c Mon Sep 17 00:00:00 2001 From: markwang Date: Fri, 15 Mar 2024 16:23:48 +0800 Subject: [PATCH 2/2] feat: optimized-error-handling --- miniprogram/privacy/privacy.go | 2 ++ miniprogram/security/security.go | 20 +++++++++++++++++ miniprogram/urllink/urllink.go | 8 +++++++ miniprogram/urlscheme/urlscheme.go | 14 ++++++++++++ officialaccount/customerservice/manager.go | 7 ++++++ officialaccount/datacube/publisher.go | 25 ++++++++++++++++++++++ officialaccount/freepublish/freepublish.go | 17 +++++++++++++++ 7 files changed, 93 insertions(+) diff --git a/miniprogram/privacy/privacy.go b/miniprogram/privacy/privacy.go index 9c3cc6c..176dfc5 100644 --- a/miniprogram/privacy/privacy.go +++ b/miniprogram/privacy/privacy.go @@ -55,6 +55,8 @@ const ( // PrivacyV1 用户隐私保护指引的版本,1表示现网版本。 PrivacyV1 = 1 + // PrivacyV2 2表示开发版。默认是2开发版。 + PrivacyV2 = 2 ) // GetPrivacySettingResponse 获取权限配置的响应结果 diff --git a/miniprogram/security/security.go b/miniprogram/security/security.go index 214185f..3e979a5 100644 --- a/miniprogram/security/security.go +++ b/miniprogram/security/security.go @@ -114,9 +114,29 @@ func (security *Security) ImageCheckV1(filename string) (err error) { // CheckSuggest 检查建议 type CheckSuggest string +const ( + // CheckSuggestRisky 违规风险建议 + CheckSuggestRisky CheckSuggest = "risky" + // CheckSuggestPass 安全 + CheckSuggestPass CheckSuggest = "pass" + // CheckSuggestReview 需要审查 + CheckSuggestReview CheckSuggest = "review" +) + // MsgScene 文本场景 type MsgScene uint8 +const ( + // MsgSceneMaterial 资料文件检查场景 + MsgSceneMaterial MsgScene = iota + 1 + // MsgSceneComment 评论 + MsgSceneComment + // MsgSceneForum 论坛 + MsgSceneForum + // MsgSceneSocialLog 社交日志 + MsgSceneSocialLog +) + // CheckLabel 检查命中标签 type CheckLabel int diff --git a/miniprogram/urllink/urllink.go b/miniprogram/urllink/urllink.go index 0892dac..56975a6 100644 --- a/miniprogram/urllink/urllink.go +++ b/miniprogram/urllink/urllink.go @@ -22,6 +22,14 @@ const generateURL = "https://api.weixin.qq.com/wxa/generate_urllink" // TExpireType 失效类型 (指定时间戳/指定间隔) type TExpireType int +const ( + // ExpireTypeTime 指定时间戳后失效 + ExpireTypeTime TExpireType = 0 + + // ExpireTypeInterval 间隔指定天数后失效 + ExpireTypeInterval TExpireType = 1 +) + // ULParams 请求参数 // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-link/urllink.generate.html#请求参数 type ULParams struct { diff --git a/miniprogram/urlscheme/urlscheme.go b/miniprogram/urlscheme/urlscheme.go index 27c37ee..2659cfb 100644 --- a/miniprogram/urlscheme/urlscheme.go +++ b/miniprogram/urlscheme/urlscheme.go @@ -25,6 +25,20 @@ type TExpireType int // EnvVersion 要打开的小程序版本 type EnvVersion string +const ( + // ExpireTypeTime 指定时间戳后失效 + ExpireTypeTime TExpireType = 0 + // ExpireTypeInterval 间隔指定天数后失效 + ExpireTypeInterval TExpireType = 1 + + // EnvVersionRelease 正式版为"release" + EnvVersionRelease EnvVersion = "release" + // EnvVersionTrial 体验版为"trial" + EnvVersionTrial EnvVersion = "trial" + // EnvVersionDevelop 开发版为"develop" + EnvVersionDevelop EnvVersion = "develop" +) + // JumpWxa 跳转到的目标小程序信息 type JumpWxa struct { Path string `json:"path"` diff --git a/officialaccount/customerservice/manager.go b/officialaccount/customerservice/manager.go index ada6d2c..973a86c 100644 --- a/officialaccount/customerservice/manager.go +++ b/officialaccount/customerservice/manager.go @@ -21,6 +21,13 @@ const ( customerServiceTypingURL = "https://api.weixin.qq.com/cgi-bin/message/custom/typing" ) +const ( + // Typing 表示正在输入状态 + Typing TypingStatus = "Typing" + // CancelTyping 表示取消正在输入状态 + CancelTyping TypingStatus = "CancelTyping" +) + // Manager 客服管理者,可以管理客服 type Manager struct { *context.Context diff --git a/officialaccount/datacube/publisher.go b/officialaccount/datacube/publisher.go index cb5d03b..73997cf 100644 --- a/officialaccount/datacube/publisher.go +++ b/officialaccount/datacube/publisher.go @@ -11,6 +11,31 @@ import ( // AdSlot 广告位类型 type AdSlot string +const ( + // SlotIDBizBottom 公众号底部广告 + SlotIDBizBottom AdSlot = "SLOT_ID_BIZ_BOTTOM" + // SlotIDBizMidContext 公众号文中广告 + SlotIDBizMidContext AdSlot = "SLOT_ID_BIZ_MID_CONTEXT" + // SlotIDBizVideoEnd 公众号视频后贴 + SlotIDBizVideoEnd AdSlot = "SLOT_ID_BIZ_VIDEO_END" + // SlotIDBizSponsor 公众号互选广告 + SlotIDBizSponsor AdSlot = "SLOT_ID_BIZ_SPONSOR" + // SlotIDBizCps 公众号返佣商品 + SlotIDBizCps AdSlot = "SLOT_ID_BIZ_CPS" + // SlotIDWeappBanner 小程序banner + SlotIDWeappBanner AdSlot = "SLOT_ID_WEAPP_BANNER" + // SlotIDWeappRewardVideo 小程序激励视频 + SlotIDWeappRewardVideo AdSlot = "SLOT_ID_WEAPP_REWARD_VIDEO" + // SlotIDWeappInterstitial 小程序插屏广告 + SlotIDWeappInterstitial AdSlot = "SLOT_ID_WEAPP_INTERSTITIAL" + // SlotIDWeappVideoFeeds 小程序视频广告 + SlotIDWeappVideoFeeds AdSlot = "SLOT_ID_WEAPP_VIDEO_FEEDS" + // SlotIDWeappVideoBegin 小程序视频前贴 + SlotIDWeappVideoBegin AdSlot = "SLOT_ID_WEAPP_VIDEO_BEGIN" + // SlotIDWeappBox 小程序格子广告 + SlotIDWeappBox AdSlot = "SLOT_ID_WEAPP_BOX" +) + const ( publisherURL = "https://api.weixin.qq.com/publisher/stat" ) diff --git a/officialaccount/freepublish/freepublish.go b/officialaccount/freepublish/freepublish.go index 24df3ad..7c414a8 100644 --- a/officialaccount/freepublish/freepublish.go +++ b/officialaccount/freepublish/freepublish.go @@ -18,6 +18,23 @@ const ( // PublishStatus 发布状态 type PublishStatus uint +const ( + // PublishStatusSuccess 0:成功 + PublishStatusSuccess PublishStatus = iota + // PublishStatusPublishing 1:发布中 + PublishStatusPublishing + // PublishStatusOriginalFail 2:原创失败 + PublishStatusOriginalFail + // PublishStatusFail 3:常规失败 + PublishStatusFail + // PublishStatusAuditRefused 4:平台审核不通过 + PublishStatusAuditRefused + // PublishStatusUserDeleted 5:成功后用户删除所有文章 + PublishStatusUserDeleted + // PublishStatusSystemBanned 6:成功后系统封禁所有文章 + PublishStatusSystemBanned +) + // FreePublish 发布能力 type FreePublish struct { *context.Context