From 763f153db93be48542eeb3ad2c60c156e15c5a79 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Fri, 10 May 2019 17:25:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=AE=A4=E8=AF=81=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=8C=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E5=9C=A8=E6=9C=AA=E8=AE=A4=E8=AF=81=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=97=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../emun/WechatInfoCertificationTypeEnum.java | 42 +++++++++++++++++++ .../cms/emun/WechatInfoEncodingTypeEnum.java | 5 ++- src/main/java/com/lq/cms/vo/WechatInfoVo.java | 32 +++++++++++++- .../cms/web/wechat/WechatInfoController.java | 3 ++ .../com/lq/wechat/web/WechatController.java | 8 +++- .../mybatis/mapping/WechatInfoDao.xml | 9 ++-- .../views/jsp/cms/wechat/info/edit.jsp | 11 +++++ .../views/jsp/cms/wechat/info/index.jsp | 2 + 8 files changed, 103 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/lq/cms/emun/WechatInfoCertificationTypeEnum.java b/src/main/java/com/lq/cms/emun/WechatInfoCertificationTypeEnum.java index 00b0feb..ee4f8a5 100644 --- a/src/main/java/com/lq/cms/emun/WechatInfoCertificationTypeEnum.java +++ b/src/main/java/com/lq/cms/emun/WechatInfoCertificationTypeEnum.java @@ -1,5 +1,8 @@ package com.lq.cms.emun; +import java.util.HashMap; +import java.util.Map; + /** * @Author: qi * @Description: @@ -19,5 +22,44 @@ public enum WechatInfoCertificationTypeEnum { private String desc; + private static Map enumMap = new HashMap(WechatInfoEncodingTypeEnum.values().length); + + static { + WechatInfoCertificationTypeEnum[] wechatInfoEncodingTypeEnumArray = WechatInfoCertificationTypeEnum.values(); + for (WechatInfoCertificationTypeEnum wechatInfoCertificationTypeEnum : wechatInfoEncodingTypeEnumArray) { + enumMap.put(wechatInfoCertificationTypeEnum.value, wechatInfoCertificationTypeEnum.desc); + } + } + + public Integer getValue() { + return value; + } + public void setValue(Integer value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + //判断是否存在值 + public static boolean hasValue(String value){ + + return enumMap.containsKey(value); + } + + public static Map getEnumMap(){ + + return enumMap; + } + + public static String getDesc(Integer value){ + + return enumMap.get(value); + } } diff --git a/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java b/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java index 5326e22..dad5e40 100755 --- a/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java +++ b/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java @@ -14,7 +14,6 @@ public enum WechatInfoEncodingTypeEnum { private static Map enumMap = new HashMap(WechatInfoEncodingTypeEnum.values().length); static { - WechatInfoEncodingTypeEnum[] wechatInfoEncodingTypeEnumArray = WechatInfoEncodingTypeEnum.values(); for (WechatInfoEncodingTypeEnum wechatInfoEncodingTypeEnum : wechatInfoEncodingTypeEnumArray) { enumMap.put(wechatInfoEncodingTypeEnum.value, wechatInfoEncodingTypeEnum.desc); @@ -59,6 +58,10 @@ public enum WechatInfoEncodingTypeEnum { this.desc = desc; } + public static String getDesc(int value){ + + return enumMap.get(value); + } } diff --git a/src/main/java/com/lq/cms/vo/WechatInfoVo.java b/src/main/java/com/lq/cms/vo/WechatInfoVo.java index 00969e4..323ff23 100755 --- a/src/main/java/com/lq/cms/vo/WechatInfoVo.java +++ b/src/main/java/com/lq/cms/vo/WechatInfoVo.java @@ -1,5 +1,6 @@ package com.lq.cms.vo; +import com.lq.cms.emun.WechatInfoCertificationTypeEnum; import com.lq.cms.emun.WechatInfoEncodingTypeEnum; import com.lq.cms.emun.WechatInfoTypeEnum; import com.lq.code.util.DateUtil; @@ -44,6 +45,10 @@ public class WechatInfoVo extends BasePageVo { private Integer wechatInfoType; //公众号类型(字符串) private String wechatInfoTypeStr; + //公众号认证状态 + private Integer certification; + //公众号认证状态(字符串) + private String certificationStr; public Long getId() { return id; @@ -132,7 +137,9 @@ public class WechatInfoVo extends BasePageVo { public void setCreateTime(Date createTime) { this.createTime = createTime; - this.createTimeStr = DateUtil.getDateToStr(createTime); + if (createTime!=null) { + this.createTimeStr = DateUtil.getDateToStr(createTime); + } } public String getCreateTimeStr() { @@ -165,7 +172,9 @@ public class WechatInfoVo extends BasePageVo { public void setWechatInfoType(Integer wechatInfoType) { this.wechatInfoType = wechatInfoType; - this.wechatInfoTypeStr = WechatInfoTypeEnum.getDesc(wechatInfoType); + if (wechatInfoType!=null) { + this.wechatInfoTypeStr = WechatInfoTypeEnum.getDesc(wechatInfoType); + } } public String getWechatInfoTypeStr() { @@ -175,4 +184,23 @@ public class WechatInfoVo extends BasePageVo { public void setWechatInfoTypeStr(String wechatInfoTypeStr) { this.wechatInfoTypeStr = wechatInfoTypeStr; } + + public Integer getCertification() { + return certification; + } + + public void setCertification(Integer certification) { + this.certification = certification; + if (certification!=null){ + this.certificationStr = WechatInfoCertificationTypeEnum.getDesc(certification); + } + } + + public String getCertificationStr() { + return certificationStr; + } + + public void setCertificationStr(String certificationStr) { + this.certificationStr = certificationStr; + } } diff --git a/src/main/java/com/lq/cms/web/wechat/WechatInfoController.java b/src/main/java/com/lq/cms/web/wechat/WechatInfoController.java index 40f0495..ad3e83d 100755 --- a/src/main/java/com/lq/cms/web/wechat/WechatInfoController.java +++ b/src/main/java/com/lq/cms/web/wechat/WechatInfoController.java @@ -1,6 +1,7 @@ package com.lq.cms.web.wechat; import com.lq.cms.emun.StatusTypeEnum; +import com.lq.cms.emun.WechatInfoCertificationTypeEnum; import com.lq.cms.emun.WechatInfoEncodingTypeEnum; import com.lq.cms.emun.WechatInfoTypeEnum; import com.lq.cms.service.WechatInfoService; @@ -49,6 +50,8 @@ public class WechatInfoController { modelAndView.addObject("encodingTypeMap",encodingTypeMap); Map wechatInfoTypeMap = WechatInfoTypeEnum.getEnumMap(); modelAndView.addObject("wechatInfoTypeMap",wechatInfoTypeMap); + Map wechatInfoCertificationTypeMap = WechatInfoCertificationTypeEnum.getEnumMap(); + modelAndView.addObject("wechatInfoCertificationTypeMap",wechatInfoCertificationTypeMap); modelAndView.setViewName("cms/wechat/info/edit"); return modelAndView; } diff --git a/src/main/java/com/lq/wechat/web/WechatController.java b/src/main/java/com/lq/wechat/web/WechatController.java index 49ebe12..9c972ea 100755 --- a/src/main/java/com/lq/wechat/web/WechatController.java +++ b/src/main/java/com/lq/wechat/web/WechatController.java @@ -1,5 +1,6 @@ package com.lq.wechat.web; +import com.lq.cms.emun.WechatInfoCertificationTypeEnum; import com.lq.cms.service.WechatInfoService; import com.lq.cms.service.WechatUserService; import com.lq.code.util.StringUtil; @@ -144,8 +145,11 @@ public class WechatController extends BaseController { switch (event) { case ConstantSet.EVENT_TYPE_SUBSCRIBE: LOGGER.info("微信公众号关注事件:"+wechatInfo.getWechatName()); - WechatUser wechatUser = wechatUserService.saveWechatUser(openId,wechatInfo); - ; + //公众号在认证的情况下才可以获取用户信息 + if (WechatInfoCertificationTypeEnum.CERTIFICATION_YES.getValue().equals(wechatInfo.getCertification())) { + WechatUser wechatUser = wechatUserService.saveWechatUser(openId, wechatInfo); + } + break; case ConstantSet.EVENT_TYPE_UNSUBSCRIBE: ; diff --git a/src/main/resources/mybatis/mapping/WechatInfoDao.xml b/src/main/resources/mybatis/mapping/WechatInfoDao.xml index 3ff3c68..dadb626 100644 --- a/src/main/resources/mybatis/mapping/WechatInfoDao.xml +++ b/src/main/resources/mybatis/mapping/WechatInfoDao.xml @@ -7,7 +7,7 @@ - id,wechat_open_id,app_secpet,create_time,app_id,encoding_type,wechat_name,url,token,encoding_aes_key,last_update_time,status,wechat_info_type + id,wechat_open_id,app_secpet,create_time,app_id,encoding_type,wechat_name,url,token,encoding_aes_key,last_update_time,status,wechat_info_type,certification + + 认证状态: + + + + + 消息加密key: diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp index 36b34f5..9d8bad4 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp @@ -42,6 +42,7 @@ {field:'encodingTypeStr',title:'消息模式',width:100}, {field:'encodingAesKey',title:'消息加密key',width:100}, {field:'createTimeStr',title:'创建时间',width:130}, + {field:'certificationStr',title:'认证状态',width:50}, {field:'url',title:'对接url',width:300}, ]], toolbar: [{ @@ -109,6 +110,7 @@ obj.encodingType = $("#encodingType").val(); obj.encodingAesKey = $("#encodingAesKey").val(); obj.wechatInfoType = $("#wechatInfoType").val(); + obj.certification = $("#certification").val(); return obj; }