| @@ -59,6 +59,10 @@ public class WxAuthorizerInfo implements Serializable { | |||||
| private String currentDesc; | private String currentDesc; | ||||
| @io.swagger.annotations.ApiModelProperty(value="当前版本发布时间",name="releaseTime") | @io.swagger.annotations.ApiModelProperty(value="当前版本发布时间",name="releaseTime") | ||||
| private Date releaseTime; | private Date releaseTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信开放平台appId",name="openAppid") | |||||
| private String openAppid; | |||||
| @io.swagger.annotations.ApiModelProperty(value="绑定开发平台时间",name="bindOpenTime") | |||||
| private Date bindOpenTime; | |||||
| @@ -84,6 +88,8 @@ public class WxAuthorizerInfo implements Serializable { | |||||
| ,CurrentVersion_ASC("`current_version` ASC"),CurrentVersion_DESC("`current_version` DESC") | ,CurrentVersion_ASC("`current_version` ASC"),CurrentVersion_DESC("`current_version` DESC") | ||||
| ,CurrentDesc_ASC("`current_desc` ASC"),CurrentDesc_DESC("`current_desc` DESC") | ,CurrentDesc_ASC("`current_desc` ASC"),CurrentDesc_DESC("`current_desc` DESC") | ||||
| ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC") | ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC") | ||||
| ,OpenAppId_ASC("`open_appid` ASC"),OpenAppId_DESC("`open_appid` DESC") | |||||
| ,BindOpenTime_ASC("`bind_open_time` ASC"),BindOpen_DESC("`bind_open_time` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -41,6 +41,8 @@ public class WxWeappInfo extends WxAuthorizerInfo { | |||||
| ,CurrentVersion_ASC("ai.`current_version` ASC"),CurrentVersion_DESC("ai.`current_version` DESC") | ,CurrentVersion_ASC("ai.`current_version` ASC"),CurrentVersion_DESC("ai.`current_version` DESC") | ||||
| ,CurrentDesc_ASC("ai.`current_desc` ASC"),CurrentDesc_DESC("ai.`current_desc` DESC") | ,CurrentDesc_ASC("ai.`current_desc` ASC"),CurrentDesc_DESC("ai.`current_desc` DESC") | ||||
| ,ReleaseTime_ASC("ai.`release_time` ASC"),ReleaseTime_DESC("ai.`release_time` DESC") | ,ReleaseTime_ASC("ai.`release_time` ASC"),ReleaseTime_DESC("ai.`release_time` DESC") | ||||
| ,OpenAppid_ASC("ai.`open_appid` ASC"),OpenAppid_DESC("ai.`open_appid` DESC") | |||||
| ,BindOpenTime_ASC("ai.`bind_open_time` ASC"),BindOpenTime_DESC("ai.`bind_open_time` DESC") | |||||
| ,Name_ASC("a.`name` ASC"),Name_DESC("a.`name` DESC") | ,Name_ASC("a.`name` ASC"),Name_DESC("a.`name` DESC") | ||||
| ,Type_ASC("a.`type` ASC"),Type_DESC("a.`type` DESC") | ,Type_ASC("a.`type` ASC"),Type_DESC("a.`type` DESC") | ||||
| ; | ; | ||||
| @@ -75,5 +75,7 @@ public interface WxAuthorizerInfoService { | |||||
| void updateWebDomainUrl(WxAuthorizerInfo record); | void updateWebDomainUrl(WxAuthorizerInfo record); | ||||
| void updateTemplate(WxAuthorizerInfo record); | void updateTemplate(WxAuthorizerInfo record); | ||||
| void updateOpenAppid(WxAuthorizerInfo record); | |||||
| } | } | ||||
| @@ -165,6 +165,16 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||||
| info.setUpdateTime(curDate); | info.setUpdateTime(curDate); | ||||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | authorizerInfoMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| @Override | |||||
| public void updateOpenAppid(WxAuthorizerInfo record) { | |||||
| Date curDate = new Date(); | |||||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||||
| info.setId(record.getId()); | |||||
| info.setOpenAppid(record.getOpenAppid()); | |||||
| info.setBindOpenTime(curDate); | |||||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| @@ -22,12 +22,15 @@ | |||||
| <result column="current_version" jdbcType="VARCHAR" property="currentVersion" /> | <result column="current_version" jdbcType="VARCHAR" property="currentVersion" /> | ||||
| <result column="current_desc" jdbcType="VARCHAR" property="currentDesc" /> | <result column="current_desc" jdbcType="VARCHAR" property="currentDesc" /> | ||||
| <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" /> | <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" /> | ||||
| <result column="open_appid" jdbcType="VARCHAR" property="openAppid" /> | |||||
| <result column="bind_open_time" jdbcType="TIMESTAMP" property="bindOpenTime" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, | `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, | ||||
| `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, | `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, | ||||
| `current_version`,`current_desc`,`release_time` | |||||
| `current_version`,`current_desc`,`release_time`, | |||||
| `open_appid`,`bind_open_time` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -91,6 +94,12 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != releaseTime "> | <if test=" null != releaseTime "> | ||||
| and `release_time` = #{releaseTime} | and `release_time` = #{releaseTime} | ||||
| </if> | |||||
| <if test=" null != openAppid "> | |||||
| and `open_appid` = #{openAppid} | |||||
| </if> | |||||
| <if test=" null != bindOpenTime "> | |||||
| and `bind_open_time` = #{bindOpenTime} | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| @@ -112,7 +121,6 @@ | |||||
| where `authorizer_appid` = #{authorizerAppid} | where `authorizer_appid` = #{authorizerAppid} | ||||
| </update> | </update> | ||||
| <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.WxWeappInfo"> | <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.WxWeappInfo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||
| <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid" /> | <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid" /> | ||||
| @@ -134,6 +142,8 @@ | |||||
| <result column="current_version" jdbcType="VARCHAR" property="currentVersion" /> | <result column="current_version" jdbcType="VARCHAR" property="currentVersion" /> | ||||
| <result column="current_desc" jdbcType="VARCHAR" property="currentDesc" /> | <result column="current_desc" jdbcType="VARCHAR" property="currentDesc" /> | ||||
| <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" /> | <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" /> | ||||
| <result column="open_appid" jdbcType="VARCHAR" property="openAppid" /> | |||||
| <result column="bind_open_time" jdbcType="TIMESTAMP" property="bindOpenTime" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | <result column="type" jdbcType="INTEGER" property="type" /> | ||||
| <result column="name" jdbcType="TIMESTAMP" property="name" /> | <result column="name" jdbcType="TIMESTAMP" property="name" /> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -146,6 +156,7 @@ | |||||
| ai.`webdomain_status`,ai.`webdomain_time`, | ai.`webdomain_status`,ai.`webdomain_time`, | ||||
| ai.`template_status`,ai.`template_time`, | ai.`template_status`,ai.`template_time`, | ||||
| ai.`current_version`,ai.`current_desc`,ai.`release_time`, | ai.`current_version`,ai.`current_desc`,ai.`release_time`, | ||||
| ai.`open_appid`,ai.`bind_open_time`, | |||||
| a.`type`,a.`name` | a.`type`,a.`name` | ||||
| </sql> | </sql> | ||||
| @@ -196,6 +207,9 @@ | |||||
| <if test=" null != currentVersion "> | <if test=" null != currentVersion "> | ||||
| and ai.`current_version` = #{currentVersion} | and ai.`current_version` = #{currentVersion} | ||||
| </if> | </if> | ||||
| <if test=" null != openAppid "> | |||||
| and ai.`open_appid` = #{openAppid} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and ai.id in | and ai.id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -1,5 +1,9 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.google.gson.Gson; | |||||
| import com.google.gson.GsonBuilder; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumWeappAuditStatus; | import com.iformall.enums.EnumWeappAuditStatus; | ||||
| import com.iformall.enums.EnumWxAuthorizationInfoType; | import com.iformall.enums.EnumWxAuthorizationInfoType; | ||||
| @@ -14,7 +18,9 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | |||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||||
| import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; | import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; | ||||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | ||||
| import me.chanjar.weixin.open.bean.result.WxOpenPlatformResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | ||||
| import me.chanjar.weixin.open.bean.result.WxOpenResult; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -312,53 +318,78 @@ public class WechatCalllbackController extends BaseController { | |||||
| @GetMapping(value = "/createOpenPlatform") | @GetMapping(value = "/createOpenPlatform") | ||||
| @ApiOperation("创建微信开放平台") | @ApiOperation("创建微信开放平台") | ||||
| public String createOpenPlatform(@RequestParam(value="appId") String appId) { | |||||
| public ResultData createOpenPlatform(@RequestParam(value="appId") String appId) { | |||||
| Gson gson = new GsonBuilder().create(); | |||||
| try { | try { | ||||
| String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); | |||||
| logger.info(llstr); | |||||
| return llstr; | |||||
| String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); | |||||
| logger.info(responseStr); | |||||
| WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); | |||||
| if(openPlatformResult.isSuccess()) { | |||||
| WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); | |||||
| if(authorizerInfo != null) { | |||||
| authorizerInfo.setId(authorizerInfo.getId()); | |||||
| authorizerInfo.setOpenAppid(openPlatformResult.getOpenAppid()); | |||||
| authorizerInfoService.updateOpenAppid(authorizerInfo); | |||||
| } | |||||
| } | |||||
| return new ResultData(responseStr); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | } | ||||
| return null; | |||||
| } | } | ||||
| @GetMapping(value = "/bindOpenPlatform") | @GetMapping(value = "/bindOpenPlatform") | ||||
| @ApiOperation("绑定微信开放平台") | @ApiOperation("绑定微信开放平台") | ||||
| public String bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { | |||||
| public ResultData bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { | |||||
| Gson gson = new GsonBuilder().create(); | |||||
| try { | try { | ||||
| String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); | |||||
| logger.info(llstr); | |||||
| return llstr; | |||||
| String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); | |||||
| logger.info(responseStr); | |||||
| WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); | |||||
| if(openResult.isSuccess()) { | |||||
| return new ResultData(); | |||||
| } | |||||
| return new ResultData(Result.ERROR, responseStr); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | } | ||||
| return null; | |||||
| } | } | ||||
| @GetMapping(value = "/unbindOpenPlatform") | @GetMapping(value = "/unbindOpenPlatform") | ||||
| @ApiOperation("解绑微信开放平台") | @ApiOperation("解绑微信开放平台") | ||||
| public String unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { | |||||
| public ResultData unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { | |||||
| Gson gson = new GsonBuilder().create(); | |||||
| try { | try { | ||||
| String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); | |||||
| logger.info(llstr); | |||||
| return llstr; | |||||
| String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); | |||||
| logger.info(responseStr); | |||||
| WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); | |||||
| if(openResult.isSuccess()) { | |||||
| return new ResultData(); | |||||
| } | |||||
| return new ResultData(Result.ERROR, responseStr); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | } | ||||
| return null; | |||||
| } | } | ||||
| @GetMapping(value = "/getOpenPlatform") | @GetMapping(value = "/getOpenPlatform") | ||||
| @ApiOperation("获取微信开放平台") | |||||
| public String getOpenPlatform(@RequestParam(value = "appId") String appId) { | |||||
| @ApiOperation("获取微信开放平台appId") | |||||
| public ResultData getOpenPlatform(@RequestParam(value = "appId") String appId) { | |||||
| Gson gson = new GsonBuilder().create(); | |||||
| try { | try { | ||||
| String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); | |||||
| logger.info(llstr); | |||||
| return llstr; | |||||
| String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); | |||||
| logger.info(responseStr); | |||||
| WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); | |||||
| if(openPlatformResult.isSuccess()) { | |||||
| return new ResultData(openPlatformResult.getOpenAppid()); | |||||
| } | |||||
| return new ResultData(Result.ERROR, responseStr); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | } | ||||
| return null; | |||||
| } | } | ||||
| } | } | ||||