From 48302e1cf7d90ff977e459cc5a6c0054953b9f9e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 10 Jul 2020 13:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81eg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxapi/constant/WxMaCodeConstant.java | 74 +++ .../epmet/wxapi/enums/WxMaErrorMsgEnum.java | 482 ++++++++++++++++++ .../epmet/wxapi/param/WxMaCodeCommitReq.java | 34 ++ .../wxapi/param/WxMaCodeExtConfigReq.java | 203 ++++++++ .../java/com/epmet/wxapi/result/WxResult.java | 43 ++ .../epmet/wxapi/service/WxMaCodeService.java | 22 + .../service/impl/WxMaCodeServiceImpl.java | 22 + 7 files changed, 880 insertions(+) create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeExtConfigReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java new file mode 100644 index 0000000000..2aae2d8234 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -0,0 +1,74 @@ +package com.epmet.wxapi.constant; + +/** + * 代码管理api url + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 12:57 + */ +public class WxMaCodeConstant { + /** + * 为授权的小程序帐号上传小程序代码. + */ + String COMMIT_URL = "https://api.weixin.qq.com/wxa/commit"; + + /** + * 获取体验版二维码 + */ + String GET_QRCODE_URL = "https://api.weixin.qq.com/wxa/get_qrcode"; + + /** + * + */ + String GET_CATEGORY_URL = "https://api.weixin.qq.com/wxa/get_category"; + + /** + * 获取已上传的代码的页面列表 + */ + String GET_PAGE_URL = "https://api.weixin.qq.com/wxa/get_page"; + + /** + * 提交审核 + */ + String SUBMIT_AUDIT_URL = "https://api.weixin.qq.com/wxa/submit_audit"; + + /** + * 查询指定发布审核单的审核状态 + */ + String GET_AUDIT_STATUS_URL = "https://api.weixin.qq.com/wxa/get_auditstatus"; + + /** + * 查询最新一次提交的审核状态 + */ + String GET_LATEST_AUDIT_STATUS_URL = "https://api.weixin.qq.com/wxa/get_latest_auditstatus"; + + /** + * 发布已通过审核的小程序 + */ + String RELEASE_URL = "https://api.weixin.qq.com/wxa/release"; + + /** + * 修改小程序线上代码的可见状态(仅供第三方代小程序调用) + */ + String CHANGE_VISIT_STATUS_URL = "https://api.weixin.qq.com/wxa/change_visitstatus"; + + /** + * 版本回退 调用本接口可以将小程序的线上版本进行回退 + */ + String REVERT_CODE_RELEASE_URL = "https://api.weixin.qq.com/wxa/revertcoderelease"; + + /** + * 查询当前设置的最低基础库版本及各版本用户占比 + */ + String GET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getweappsupportversion"; + + /** + * 设置最低基础库版本 + */ + String SET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/setweappsupportversion"; + + /** + * 小程序审核撤回 + */ + String UNDO_CODE_AUDIT_URL = "https://api.weixin.qq.com/wxa/undocodeaudit"; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java new file mode 100644 index 0000000000..7e21cdf51c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java @@ -0,0 +1,482 @@ +package com.epmet.wxapi.enums; + +import lombok.Getter; + +/** + * 微信小程序错误码 + * + * @author biggates + */ +@Getter +public enum WxMaErrorMsgEnum { + /** + * 请求成功. + */ + CODE_0(0, "请求成功"), + + /** + *
+ * 获取 access_token 时 AppSecret 错误,
+ * 或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的小程序调用接口
+ * 对应操作:sendCustomerMessage
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
+ *
+ */
+ CODE_40001(40001, "access_token 无效或 AppSecret 错误"),
+ /**
+ *
+ * 不合法的凭证类型
+ * 对应操作:sendCustomerMessage
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
+ *
+ */
+ CODE_40002(40002, "不合法的凭证类型"),
+ /**
+ * + * touser不是正确的openid. + * 对应操作:+ */ + CODE_40003(40003, "openid 不正确"), + /** + *sendCustomerMessage
,sendUniformMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html + *
+ * 无效媒体文件类型
+ * 对应操作:uploadTempMedia
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/uploadTempMedia.html
+ *
+ */
+ CODE_40004(40004, "无效媒体文件类型"),
+ /**
+ *
+ * 无效媒体文件 ID.
+ * 对应操作:getTempMedia
+ * 对应地址:
+ * GET https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/getTempMedia.html
+ *
+ */
+ CODE_40007(40007, "无效媒体文件 ID"),
+ /**
+ *
+ * appid不正确,或者不符合绑定关系要求.
+ * 对应操作:sendUniformMessage
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
+ *
+ */
+ CODE_40013(40013, "appid不正确,或者不符合绑定关系要求"),
+ /**
+ * + * template_id 不正确. + * 对应操作:+ */ + CODE_40037(40037, "template_id 不正确"), + /** + *sendUniformMessage
,sendTemplateMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html + *
+ * form_id不正确,或者过期. + * 对应操作:+ */ + CODE_41028(41028, "form_id 不正确,或者过期"), + /** + *sendUniformMessage
,sendTemplateMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html + *
+ * code 或 template_id 不正确. + * 对应操作:+ */ + CODE_41029(41029, "请求的参数不正确"), + /** + *code2Session
,sendUniformMessage
,sendTemplateMessage
+ * 对应地址: + * GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html + *
+ * form_id 已被使用,或者所传page页面不存在,或者小程序没有发布
+ * 对应操作:sendUniformMessage, getWXACodeUnlimit
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
+ * POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html
+ * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html
+ *
+ */
+ CODE_41030(41030, "请求的参数不正确"),
+ /**
+ * + * 调用分钟频率受限. + * 对应操作:+ */ + CODE_45009(45009, "调用分钟频率受限"), + /** + *getWXACodeUnlimit
,sendUniformMessage
,sendTemplateMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/uniform-message/sendUniformMessage.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACodeUnlimit.html + *
+ * 频率限制,每个用户每分钟100次.
+ * 对应操作:code2Session
+ * 对应地址:
+ * GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/code2Session.html
+ *
+ */
+ CODE_45011(45011, "频率限制,每个用户每分钟100次"),
+ /**
+ *
+ * 回复时间超过限制.
+ * 对应操作:sendCustomerMessage
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
+ *
+ */
+ CODE_45015(45015, "回复时间超过限制"),
+ /**
+ * + * 接口调用超过限额, 或生成码个数总和到达最大个数限制. + * 对应操作:+ */ + CODE_45029(45029, "接口调用超过限额"), + /** + *createWXAQRCode
,sendTemplateMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/qr-code/getWXACode.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/template-message/sendTemplateMessage.html + *
+ * 客服接口下行条数超过上限.
+ * 对应操作:sendCustomerMessage
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html
+ *
+ */
+ CODE_45047(45047, "客服接口下行条数超过上限"),
+ /**
+ *
+ * command字段取值不对
+ * 对应操作:customerTyping
+ * 对应地址:
+ * POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
+ * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html
+ *
+ */
+ CODE_45072(45072, "command字段取值不对"),
+ /**
+ * + * 下发输入状态,需要之前30秒内跟用户有过消息交互. + * 对应操作:customerTyping
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html + */ + CODE_45080(45080, "下发输入状态,需要之前30秒内跟用户有过消息交互"), + /** + *+ * 已经在输入状态,不可重复下发. + * 对应操作:+ */ + CODE_45081(45081, "已经在输入状态,不可重复下发"), + /** + *customerTyping
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/customerTyping.html + *+ * API 功能未授权,请确认小程序已获得该接口. + * 对应操作:+ */ + CODE_48001(48001, "API 功能未授权"), + /** + *sendCustomerMessage
+ * 对应地址: + * POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/customer-message/sendCustomerMessage.html + *+ * 内容含有违法违规内容. + * 对应操作:+ */ + CODE_87014(87014, "内容含有违法违规内容"), + /** + * 系统繁忙,此时请开发者稍候再试. + */ + CODE_MINUS_1(-1, "系统繁忙,此时请开发者稍候再试"), + /** + * code 无效. + */ + CODE_40029(40029, "code 无效"), + /** + * access_token 过期. + */ + CODE_42001(42001, "access_token 过期"), + /** + * post 数据为空. + */ + CODE_44002(44002, "post 数据为空"), + /** + * post 数据中参数缺失. + */ + CODE_47001(47001, "post 数据中参数缺失"), + /** + * 参数 activity_id 错误. + */ + CODE_47501(47501, "参数 activity_id 错误"), + /** + * 参数 target_state 错误. + */ + CODE_47502(47502, "参数 target_state 错误"), + /** + * 参数 version_type 错误. + */ + CODE_47503(47503, "参数 version_type 错误"), + /** + * activity_id 过期. + */ + CODE_47504(47504, "activity_id 过期"), + /** + * 没有绑定开放平台帐号. + */ + CODE_89002(89002, "没有绑定开放平台帐号"), + /** + * 订单无效. + */ + CODE_89300(89300, "订单无效"), + + /** + * 代小程序实现业务的错误码,部分和小程序业务一致 + * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/Intro.html + */ + CODE_85060(85060, "无效的taskid"), + + CODE_85027(85027, "身份证绑定管理员名额达到上限"), + + CODE_85061(85061, "手机号绑定管理员名额达到上限"), + + CODE_85026(85026, "微信号绑定管理员名额达到上限"), + + CODE_85063(85063, "身份证黑名单"), + + CODE_85062(85062, "手机号黑名单"), + + CODE_85016(85016, "域名数量超过限制"), + + CODE_85017(85017, "没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加"), + + CODE_85018(85018, "域名没有在第三方平台设置"), + + CODE_89019(89019, "业务域名无更改,无需重复设置"), + + CODE_89020(89020, "尚未设置小程序业务域名,请先在第三方平台中设置小程序业务域名后在调用本接口"), + + CODE_89021(89021, "请求保存的域名不是第三方平台中已设置的小程序业务域名或子域名"), + + CODE_89029(89029, "业务域名数量超过限制"), + + CODE_89231(89231, "个人小程序不支持调用 setwebviewdomain 接口"), + + CODE_91001(91001, "不是公众号快速创建的小程序"), + + CODE_91002(91002, "小程序发布后不可改名"), + + CODE_91003(91003, "改名状态不合法"), + + CODE_91004(91004, "昵称不合法"), + + CODE_91005(91005, "昵称 15 天主体保护"), + + CODE_91006(91006, "昵称命中微信号"), + + CODE_91007(91007, "昵称已被占用"), + + CODE_91008(91008, "昵称命中 7 天侵权保护期"), + + CODE_91009(91009, "需要提交材料"), + + CODE_91010(91010, "其他错误"), + + CODE_91011(91011, "查不到昵称修改审核单信息"), + + CODE_91012(91012, "其他错误"), + + CODE_91013(91013, "占用名字过多"), + + CODE_91014(91014, "+号规则 同一类型关联名主体不一致"), + + CODE_91015(91015, "原始名不同类型主体不一致"), + + CODE_91016(91016, "名称占用者 ≥2"), + + CODE_91017(91017, "+号规则 不同类型关联名主体不一致"), + + CODE_40097(40097, "参数错误"), + + CODE_41006(41006, "media_id 不能为空"), + + CODE_46001(46001, "media_id 不存在"), + + CODE_40009(40009, "图片尺寸太大"), + + CODE_53202(53202, "本月头像修改次数已用完"), + + CODE_53200(53200, "本月功能介绍修改次数已用完"), + + CODE_53201(53201, "功能介绍内容命中黑名单关键字"), + + CODE_85083(85083, "搜索标记位被封禁,无法修改"), + + CODE_85084(85084, "非法的 status 值,只能填 0 或者 1"), + + CODE_85013(85013, "无效的自定义配置"), + + CODE_85014(85014, "无效的模版编号"), + + CODE_85043(85043, "模版错误"), + + CODE_85044(85044, "代码包超过大小限制"), + + CODE_85045(85045, "ext_json 有不存在的路径"), + + CODE_85046(85046, "tabBar 中缺少 path"), + + CODE_85047(85047, "pages 字段为空"), + + CODE_85048(85048, "ext_json 解析失败"), + + CODE_80082(80082, "没有权限使用该插件"), + + CODE_80067(80067, "找不到使用的插件"), + + CODE_80066(80066, "非法的插件版本"), + + CODE_86000(86000, "不是由第三方代小程序进行调用"), + + CODE_86001(86001, "不存在第三方的已经提交的代码"), + + CODE_85006(85006, "标签格式错误"), + + CODE_85007(85007, "页面路径错误"), + + CODE_85008(85008, "类目填写错误"), + + CODE_85009(85009, "已经有正在审核的版本"), + + CODE_85010(85010, "item_list 有项目为空"), + + CODE_85011(85011, "标题填写错误"), + + CODE_85023(85023, "审核列表填写的项目数不在 1-5 以内"), + + CODE_85077(85077, "小程序类目信息失效(类目中含有官方下架的类目,请重新选择类目)"), + + CODE_86002(86002, "小程序还未设置昵称、头像、简介。请先设置完后再重新提交"), + + CODE_85085(85085, "近 7 天提交审核的小程序数量过多,请耐心等待审核完毕后再次提交"), + + CODE_85086(85086, "提交代码审核之前需提前上传代码"), + + CODE_85087(85087, "小程序已使用 api navigateToMiniProgram,请声明跳转 appid 列表后再次提交"), + + CODE_85012(85012, "无效的审核 id"), + + CODE_87013(87013, "撤回次数达到上限(每天一次,每个月 10 次)"), + + CODE_85019(85019, "没有审核版本"), + + CODE_85020(85020, "审核状态未满足发布"), + + CODE_87011(87011, "现网已经在灰度发布,不能进行版本回退"), + + CODE_87012(87012, "该版本不能回退,可能的原因:1:无上一个线上版用于回退 2:此版本为已回退版本,不能回退 3:此版本为回退功能上线之前的版本,不能回退"), + + CODE_85079(85079, "小程序没有线上版本,不能进行灰度"), + + CODE_85080(85080, "小程序提交的审核未审核通过"), + + CODE_85081(85081, "无效的发布比例"), + + CODE_85082(85082, "当前的发布比例需要比之前设置的高"), + + CODE_85021(85021, "状态不可变"), + + CODE_85022(85022, "action 非法"), + + CODE_89401(89401, "系统不稳定,请稍后再试,如多次失败请通过社区反馈"), + + CODE_89402(89402, "该审核单不在待审核队列,请检查是否已提交审核或已审完"), + + CODE_89403(89403, "本单属于平台不支持加急种类,请等待正常审核流程"), + + CODE_89404(89404, "本单已加速成功,请勿重复提交"), + + CODE_89405(89405, "本月加急额度不足,请提升提审质量以获取更多额度"), + + CODE_85064(85064, "找不到模版/草稿"), + + CODE_85065(85065, "模版库已满"), + + /** + * 小程序订阅消息错误码 + * https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html + */ + CODE_43101(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系"), + + CODE_47003(47003, "模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错"), + ; + + private int code; + private String msg; + + WxMaErrorMsgEnum(int code, String msg) { + this.code = code; + this.msg = msg; + } + + /** + * 通过错误代码查找其中文含义. + */ + public static String findMsgByCode(int code) { + for (WxMaErrorMsgEnum value : WxMaErrorMsgEnum.values()) { + if (value.code == code) { + return value.msg; + } + } + + return null; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java new file mode 100644 index 0000000000..3054446c7f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeCommitReq.java @@ -0,0 +1,34 @@ +package com.epmet.wxapi.param; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 11:14 + */ +@Data +public class WxMaCodeCommitReq implements Serializable { + private static final long serialVersionUID = 9084356213189926999L; + + /** + * 代码库中的代码模版ID + */ + private Long templateId; + /** + * 第三方自定义的配置 + */ + private WxMaCodeExtConfigReq extConfig; + /** + * 代码版本号,开发者可自定义 + */ + private String userVersion; + /** + * 代码描述,开发者可自定义 + */ + private String userDesc; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeExtConfigReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeExtConfigReq.java new file mode 100644 index 0000000000..5296862502 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeExtConfigReq.java @@ -0,0 +1,203 @@ +package com.epmet.wxapi.param; + +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 11:19 + */ +@Data +public class WxMaCodeExtConfigReq implements Serializable { + private static final long serialVersionUID = 130934305232989991L; + /** + * 配置 ext.json 是否生效. + * 必填:是 + */ + private boolean extEnable; + /** + * 配置 extAppid. + * 必填:是 + */ + private String extAppid; + /** + * 开发自定义的数据字段. + * 必填:否 + */ + private Object ext; + /** + * 单独设置每个页面的 json. + * 必填:否 + * key: page 名称,如 pages/logs/logs + * value: page 配置 + */ + private MapimgSecCheck
,msgSecCheck
+ * 对应地址: + * POST https://api.weixin.qq.com/wxa/img_sec_check?access_token=ACCESS_TOKEN + * POST https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN + * 参考文档地址: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/imgSecCheck.html + * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/msgSecCheck.html + *extPages; + /** + * 是否直接提交到待审核列表. + * 必填:否 + */ + private Boolean directCommit; + /** + * 设置页面路径(同 app.json 相同的字段,填写会覆盖 app.json). + * 必填:否 + */ + private List pages; + /** + * 设置默认页面的窗口表现(同 app.json 相同的字段,填写会覆盖 app.json) + * 必填:否 + */ + private PageConfig window; + /** + * 设置各种网络请求的超时时间(同 app.json 相同的字段,填写会覆盖 app.json) + * 必填:否 + */ + private NetworkTimeout networkTimeout; + /** + * 设置是否开启 debug 模式(同 app.json 相同的字段,填写会覆盖 app.json) + * 必填:否 + */ + private Boolean debug; + /** + * 底部 tab 栏的表现. + * 必填:否 + */ + private TabBar tabBar; + + /** + * page.json 配置,页面配置 + * 文档:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html + */ + @Data + @Builder + public static class PageConfig { + /** + * 导航栏背景颜色,如"#000000" HexColor. + * 默认:#000000 + */ + private String navigationBarBackgroundColor; + /** + * 导航栏标题颜色,仅支持 black/white. + * 默认:white + */ + private String navigationBarTextStyle; + /** + * 导航栏标题文字内容. + */ + private String navigationBarTitleText; + /** + * 窗口的背景色 HexColor. + * 默认:#ffffff + */ + private String backgroundColor; + /** + * 下拉背景字体、loading 图的样式,仅支持 dark/light. + * 默认:dark + */ + private String backgroundTextStyle; + /** + * 是否开启下拉刷新,详见页面相关事件处理函数. + * 默认:false + */ + private String enablePullDownRefresh; + /** + * 设置为 true 则页面整体不能上下滚动;只在 page.json 中有效,无法在 app.json 中设置该项. + * 默认:false + */ + private Boolean disableScroll; + /** + * 页面上拉触底事件触发时距页面底部距离,单位为px. + * 默认:50 + */ + private Integer onReachBottomDistance; + } + + /** + * tabBar 配置. + */ + @Data + @Builder + public static class TabBar { + /** + * HexColor, tab 上的文字默认颜色. + */ + private String color; + /** + * HexColor, tab 上的文字选中时的颜色. + */ + private String selectedColor; + /** + * HexColor, tab 的背景色. + */ + private String backgroundColor; + /** + * tabbar 上边框的颜色,仅支持 black/white. + */ + private String borderStyle; + /** + * tab 的列表,最少2个、最多5个 tab. + */ + private List - list; + /** + * 可选值 bottom、top. + */ + private String position; + + /** + * list item. + */ + @Data + @Builder + public static class Item { + /** + * 页面路径,必须在 pages 中先定义. + */ + private String pagePath; + /** + * tab 上按钮文字. + */ + private String text; + /** + * 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片. + */ + private String iconPath; + /** + * 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效. + */ + private String selectedIconPath; + } + } + + /** + * 各种网络请求的超时时间. + */ + @Data + @Builder + public static class NetworkTimeout { + /** + * wx.request的超时时间,单位毫秒,默认为:60000. + * 必填:否 + */ + private Integer request; + /** + * wx.connectSocket的超时时间,单位毫秒,默认为:60000. + * 必填:否 + */ + private Integer connectSocket; + /** + * wx.uploadFile的超时时间,单位毫秒,默认为:60000. + * 必填:否 + */ + private Integer uploadFile; + /** + * wx.downloadFile的超时时间,单位毫秒,默认为:60000. + * 必填:否 + */ + private Integer downloadFile; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxResult.java new file mode 100644 index 0000000000..5672f47a5e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxResult.java @@ -0,0 +1,43 @@ +package com.epmet.wxapi.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 微信统一返参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 13:22 + */ +@Data +public class WxResult
implements Serializable { + /** + * 微信错误代码. + */ + private int errorCode=0; + + /** + * 微信错误信息. + */ + private String errorMsg="success"; + + /** + * 微信接口返回的错误原始信息(英文). json串 + */ + private String errorMsgEn; + + /** + * 响应数据 + */ + private T data; + + public WxResult ok(T data) { + this.setData(data); + return this; + } + + public boolean success(){ + return errorCode == 0 ? true : false; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java new file mode 100644 index 0000000000..f34511cfec --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java @@ -0,0 +1,22 @@ +package com.epmet.wxapi.service; + +import com.epmet.wxapi.param.WxMaCodeCommitReq; +import com.epmet.wxapi.result.WxResult; +import me.chanjar.weixin.common.error.WxErrorException; + +/** + * 小程序代码管理相关 API(大部分只能是第三方平台调用) + * 文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=&lang=zh_CN + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 11:21 + */ +public interface WxMaCodeService { + /** + * 为授权的小程序帐号上传小程序代码(仅仅支持第三方开放平台). + * + * @param commitRequest 参数 + * @throws WxErrorException 上传失败时抛出,具体错误码请看类注释文档 + */ + WxResult commit(String access_token, WxMaCodeCommitReq commitRequest) throws WxErrorException; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java new file mode 100644 index 0000000000..99860706eb --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java @@ -0,0 +1,22 @@ +package com.epmet.wxapi.service.impl; + +import com.epmet.wxapi.param.WxMaCodeCommitReq; +import com.epmet.wxapi.result.WxResult; +import com.epmet.wxapi.service.WxMaCodeService; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.stereotype.Service; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/10 11:23 + */ +@Service +public class WxMaCodeServiceImpl implements WxMaCodeService { + @Override + public WxResult commit(String access_token, WxMaCodeCommitReq commitRequest) throws WxErrorException { + + return null; + } +}