1.新增认证状态,微信公众号在未认证的情况下会导致部分功能受限

master
星期八 6 years ago
parent c1c96d19c1
commit 763f153db9
  1. 42
      src/main/java/com/lq/cms/emun/WechatInfoCertificationTypeEnum.java
  2. 5
      src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java
  3. 32
      src/main/java/com/lq/cms/vo/WechatInfoVo.java
  4. 3
      src/main/java/com/lq/cms/web/wechat/WechatInfoController.java
  5. 8
      src/main/java/com/lq/wechat/web/WechatController.java
  6. 9
      src/main/resources/mybatis/mapping/WechatInfoDao.xml
  7. 11
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/edit.jsp
  8. 2
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp

@ -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<Integer,String> 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<Integer,String> getEnumMap(){
return enumMap;
}
public static String getDesc(Integer value){
return enumMap.get(value);
}
}

@ -14,7 +14,6 @@ public enum WechatInfoEncodingTypeEnum {
private static Map<String,String> 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);
}
}

@ -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;
}
}

@ -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<Integer,String> wechatInfoTypeMap = WechatInfoTypeEnum.getEnumMap();
modelAndView.addObject("wechatInfoTypeMap",wechatInfoTypeMap);
Map<Integer,String> wechatInfoCertificationTypeMap = WechatInfoCertificationTypeEnum.getEnumMap();
modelAndView.addObject("wechatInfoCertificationTypeMap",wechatInfoCertificationTypeMap);
modelAndView.setViewName("cms/wechat/info/edit");
return modelAndView;
}

@ -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:
;

@ -7,7 +7,7 @@
<!-- 注意:使用mapper代理方法开发 ,namespace有着特殊作用-->
<sql id="column_list">
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
</sql>
<select id="findOne" resultType="com.lq.entity.WechatInfo" parameterType="long">
SELECT <include refid="column_list"/> FROM wechat_info WHERE id=#{id} AND status = 1
@ -23,10 +23,10 @@
SELECT LAST_INSERT_ID()
</selectKey>
INSERT INTO
wechat_info(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)
wechat_info(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)
VALUES
(
#{wechatOpenId},#{appSecpet},#{createTime},#{appId},#{encodingType},#{wechatName},#{url},#{token},#{encodingAesKey},#{lastUpdateTime},#{status},#{wechatInfoType}
#{wechatOpenId},#{appSecpet},#{createTime},#{appId},#{encodingType},#{wechatName},#{url},#{token},#{encodingAesKey},#{lastUpdateTime},#{status},#{wechatInfoType},#{certification}
)
</insert>
@ -47,7 +47,8 @@
<if test="encodingAesKey!=null">encoding_aes_key=#{encodingAesKey},</if>
<if test="lastUpdateTime!=null">last_update_time=#{lastUpdateTime},</if>
<if test="status!=null">status=#{status},</if>
<if test="wechatInfoType!=null">wechat_info_type=#{wechatInfoType}</if>
<if test="wechatInfoType!=null">wechat_info_type=#{wechatInfoType},</if>
<if test="certification!=null">certification=#{certification},</if>
</trim>
WHERE
id=#{id}

@ -56,6 +56,17 @@
</select>
</td>
</tr>
<tr>
<td>认证状态:</td>
<td>
<select id="certification" >
<c:forEach items="${wechatInfoCertificationTypeMap}" var="certification">
<option <c:if test="${wechatInfo.certification == certification.key}">selected</c:if> value="${certification.key}">${certification.value}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td>消息加密key:</td>
<td><input class="easyui-textbox" type="text" id="encodingAesKey" data-options="required:true" value="${wechatInfo.encodingAesKey}" /></td>

@ -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;
}

Loading…
Cancel
Save