|
|
|
@@ -64,18 +64,24 @@ public class WechatWeappCodeController { |
|
|
|
@ApiOperation(value = "为授权的小程序帐号上传小程序代码", notes = "extInfo参考https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html") |
|
|
|
@PostMapping("/codeCommit") |
|
|
|
public ResultData codeCommit(Long templateId, String userVersion, String userDesc, String extInfoStr) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
WxMaOpenCommitExtInfo extInfo = gson.fromJson(extInfoStr, new TypeToken<WxMaOpenCommitExtInfo>() {}.getType()); |
|
|
|
String appId = extInfo.getExtAppid(); |
|
|
|
|
|
|
|
// 检查appId是否已授权 |
|
|
|
WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); |
|
|
|
if(authorizerInfo == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "扩展设置中appId未设置"); |
|
|
|
} |
|
|
|
if(!authorizerInfo.getAuthorizationStatus().equals(EnumWxAuthorizationStatus.AUTHORIZED.getCode())) { |
|
|
|
return new ResultData(ErrorCode.APP_NOT_AUTH); |
|
|
|
} |
|
|
|
|
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
|
|
|
|
WxAppinfo appinfo = appinfoService.getByAppId(appId); |
|
|
|
|
|
|
|
try { |
|
|
|
Gson gson= new GsonBuilder().create(); |
|
|
|
WxMaOpenCommitExtInfo extInfo = gson.fromJson(extInfoStr, new TypeToken<WxMaOpenCommitExtInfo>() { }.getType()); |
|
|
|
String appId = extInfo.getExtAppid(); |
|
|
|
// 检查appId是否已授权 |
|
|
|
WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); |
|
|
|
if(authorizerInfo == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "扩展设置中appId未设置"); |
|
|
|
} |
|
|
|
if(!authorizerInfo.getAuthorizationStatus().equals(EnumWxAuthorizationStatus.AUTHORIZED.getCode())) { |
|
|
|
return new ResultData(ErrorCode.APP_NOT_AUTH); |
|
|
|
} |
|
|
|
// code提交 |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
logger.info(extInfo.toString()); |
|
|
|
@@ -85,9 +91,7 @@ public class WechatWeappCodeController { |
|
|
|
if (openRet.isSuccess()) { |
|
|
|
codeCommitStatus = true; |
|
|
|
} |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
if (codeStatus == null) { |
|
|
|
WxAppinfo appinfo = appinfoService.getByAppId(appId); |
|
|
|
codeStatus = new WxWeappCodeStatus(); |
|
|
|
codeStatus.setAppId(appId); |
|
|
|
if (appinfo != null) { |
|
|
|
@@ -99,8 +103,8 @@ public class WechatWeappCodeController { |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.SUCCESS.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.FAIL.getCode()); |
|
|
|
codeStatus.setCodeErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
codeStatus.setCodeErrCode(Integer.valueOf(openRet.getErrcode())); |
|
|
|
codeStatus.setCodeTime(new Date()); |
|
|
|
weappCodeStatusService.saveOrUpdate(codeStatus); |
|
|
|
} else { |
|
|
|
@@ -110,15 +114,35 @@ public class WechatWeappCodeController { |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.SUCCESS.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.FAIL.getCode()); |
|
|
|
codeStatus.setCodeErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
codeStatus.setCodeErrCode(Integer.valueOf(openRet.getErrcode())); |
|
|
|
codeStatus.setCodeTime(new Date()); |
|
|
|
weappCodeStatusService.updateCodeCommitStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getMessage()); |
|
|
|
if (codeStatus == null) { |
|
|
|
codeStatus = new WxWeappCodeStatus(); |
|
|
|
codeStatus.setAppId(appId); |
|
|
|
if (appinfo != null) { |
|
|
|
codeStatus.setType(appinfo.getType()); |
|
|
|
} |
|
|
|
codeStatus.setUserVersion(userVersion); |
|
|
|
codeStatus.setVersionDesc(userDesc); |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.FAIL.getCode()); |
|
|
|
codeStatus.setCodeErrCode(e.getMessage()); |
|
|
|
codeStatus.setCodeTime(new Date()); |
|
|
|
weappCodeStatusService.saveOrUpdate(codeStatus); |
|
|
|
} else { |
|
|
|
codeStatus.setUserVersion(userVersion); |
|
|
|
codeStatus.setVersionDesc(userDesc); |
|
|
|
codeStatus.setCodeStatus(EnumWeappCodeCommitStatus.FAIL.getCode()); |
|
|
|
codeStatus.setCodeErrCode(e.getMessage()); |
|
|
|
codeStatus.setCodeTime(new Date()); |
|
|
|
weappCodeStatusService.updateCodeCommitStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -167,8 +191,8 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("获取小程序的第三方提交代码的页面配置") |
|
|
|
@@ -181,37 +205,45 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("将第三方提交的代码包提交审核") |
|
|
|
@PostMapping("/submitAudit") |
|
|
|
public ResultData submitAudit(String appId, String subMesgStr) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
try { |
|
|
|
WxOpenMaSubmitAuditMessage subMessage = JSON.parseObject(subMesgStr, WxOpenMaSubmitAuditMessage.class); |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
WxOpenMaSubmitAuditResult openRet = openMaService.submitAudit(subMessage); |
|
|
|
logger.info(openRet.toString()); |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
if(codeStatus != null) { |
|
|
|
if(openRet.isSuccess()) { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.AUDITING.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.FAIL.getCode()); |
|
|
|
codeStatus.setAuditErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
weappCodeStatusService.updateAuditStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
if(codeStatus != null) { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.FAIL.getCode()); |
|
|
|
codeStatus.setAuditErrCode(e.getMessage()); |
|
|
|
weappCodeStatusService.updateAuditStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("查询某个指定版本的审核状态") |
|
|
|
@PostMapping("/getAuditstatus") |
|
|
|
public ResultData getAuditstatus(String appId, String auditidStr) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
WxOpenMaQueryAuditResult openRet = openMaService.getAuditStatus(Long.valueOf(auditidStr)); |
|
|
|
@@ -222,20 +254,21 @@ public class WechatWeappCodeController { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.SUCCESS.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.FAIL.getCode()); |
|
|
|
codeStatus.setAuditErrCode(Integer.valueOf(openRet.getErrcode())); |
|
|
|
codeStatus.setAuditErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
weappCodeStatusService.updateAuditStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("查询最新一次提交的审核状态") |
|
|
|
@GetMapping("/getLatestAuditstatus") |
|
|
|
public ResultData get_latest_auditstatus(String appId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
WxOpenMaQueryAuditResult openRet = openMaService.getLatestAuditStatus(); |
|
|
|
@@ -246,50 +279,56 @@ public class WechatWeappCodeController { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.SUCCESS.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setAuditStatus(EnumWeappAuditStatus.FAIL.getCode()); |
|
|
|
codeStatus.setAuditErrCode(Integer.valueOf(openRet.getErrcode())); |
|
|
|
codeStatus.setAuditErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
weappCodeStatusService.updateAuditStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("发布已通过审核的小程序") |
|
|
|
@PostMapping("/releaseAudited") |
|
|
|
public ResultData releaesAudited(String appId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
try { |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
WxOpenResult openRet = openMaService.releaesAudited(); |
|
|
|
logger.info(openRet.toString()); |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
if(codeStatus != null) { |
|
|
|
if(openRet.getErrcode().equals('0')) { |
|
|
|
codeStatus.setReleaseStatus(EnumWeappReleaseStatus.SUCCESS.getCode()); |
|
|
|
} else { |
|
|
|
codeStatus.setReleaseStatus(EnumWeappReleaseStatus.FAIL.getCode()); |
|
|
|
codeStatus.setReleaseErrCode(Integer.valueOf(openRet.getErrcode())); |
|
|
|
codeStatus.setReleaseErrCode(gson.toJson(openRet)); |
|
|
|
} |
|
|
|
weappCodeStatusService.updateReleaseStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
if(codeStatus != null) { |
|
|
|
codeStatus.setReleaseStatus(EnumWeappReleaseStatus.FAIL.getCode()); |
|
|
|
codeStatus.setReleaseErrCode(e.getMessage()); |
|
|
|
weappCodeStatusService.updateReleaseStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("小程序版本回退") |
|
|
|
@GetMapping("/revertCodeRelease") |
|
|
|
public ResultData revertCodeRelease(String appId) { |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
try { |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
WxOpenResult openRet = openMaService.revertCodeReleaes(); |
|
|
|
logger.info(openRet.toString()); |
|
|
|
if(openRet.isSuccess()) { |
|
|
|
WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); |
|
|
|
if(codeStatus != null) { |
|
|
|
codeStatus.setReleaseStatus(EnumWeappReleaseStatus.BACK.getCode()); |
|
|
|
weappCodeStatusService.updateReleaseStatus(codeStatus); |
|
|
|
@@ -299,7 +338,12 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getMessage()); |
|
|
|
if(codeStatus != null) { |
|
|
|
codeStatus.setReleaseStatus(EnumWeappReleaseStatus.FAIL.getCode()); |
|
|
|
codeStatus.setReleaseErrCode(e.getMessage()); |
|
|
|
weappCodeStatusService.updateReleaseStatus(codeStatus); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -313,8 +357,8 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("设置最低基础库版本") |
|
|
|
@@ -327,8 +371,8 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(openRet); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "小程序审核撤回", notes = "单个帐号每天审核撤回次数最多不超过1次,一个月不超过10次。") |
|
|
|
@@ -347,7 +391,7 @@ public class WechatWeappCodeController { |
|
|
|
return new ResultData(); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR); |
|
|
|
} |
|
|
|
} |