回复方式新增枚举

master
星期八 6 years ago
parent ae297ff272
commit afe2ba8ff2
  1. 66
      src/main/java/com/lq/cms/emun/WechatRuleReplyTypeEnum.java
  2. 3
      src/main/java/com/lq/cms/web/wechat/WechatRuleController.java
  3. 4
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp

@ -0,0 +1,66 @@
package com.lq.cms.emun;
import javax.persistence.criteria.CriteriaBuilder;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: qi
* @Description:
* @Date: Create in 3:14 PM 2019/5/16
*/
public enum WechatRuleReplyTypeEnum {
REPLY_ALL(1,"全回复"),
REPLY_RANDOM(2,"随机回复")
;
WechatRuleReplyTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
private Integer value;
private String 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;
}
private static Map<Integer,String> enumMap = new HashMap();
static {
WechatRuleReplyTypeEnum[] wechatRuleReplyTypeEnums = WechatRuleReplyTypeEnum.values();
for (WechatRuleReplyTypeEnum wechatRuleReplyTypeEnum:wechatRuleReplyTypeEnums) {
enumMap.put(wechatRuleReplyTypeEnum.value, wechatRuleReplyTypeEnum.desc);
}
}
//判断是否存在值
public static boolean hasValue(String value){
return enumMap.containsKey(value);
}
public static String getDesc(Integer value){
return enumMap.get(value);
}
public static Map<Integer,String> getEnumMap(){
return enumMap;
}
}

@ -2,6 +2,7 @@ package com.lq.cms.web.wechat;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.lq.cms.emun.WechatKeywordMatchinTypeEnum; import com.lq.cms.emun.WechatKeywordMatchinTypeEnum;
import com.lq.cms.emun.WechatRuleReplyTypeEnum;
import com.lq.cms.service.WechatInfoService; import com.lq.cms.service.WechatInfoService;
import com.lq.cms.vo.WechatRuleVo; import com.lq.cms.vo.WechatRuleVo;
import com.lq.code.entity.AjaxResult; import com.lq.code.entity.AjaxResult;
@ -37,6 +38,8 @@ public class WechatRuleController {
} }
Map<Integer,String> wechatKeywordMatchinTypeMap = WechatKeywordMatchinTypeEnum.getEnumMap(); Map<Integer,String> wechatKeywordMatchinTypeMap = WechatKeywordMatchinTypeEnum.getEnumMap();
modelAndView.addObject("wechatKeywordMatchinTypeMap",wechatKeywordMatchinTypeMap); modelAndView.addObject("wechatKeywordMatchinTypeMap",wechatKeywordMatchinTypeMap);
Map<Integer,String> wehcatRuleReplyTypeMap = WechatRuleReplyTypeEnum.getEnumMap();
modelAndView.addObject("wehcatRuleReplyTypeMap",wehcatRuleReplyTypeMap);
modelAndView.setViewName("cms/wechat/rule/index"); modelAndView.setViewName("cms/wechat/rule/index");
return modelAndView; return modelAndView;
} }

@ -138,7 +138,9 @@
<div class="row"> <div class="row">
<label class="lable_title">回复方式</label> <label class="lable_title">回复方式</label>
<input type="radio" name="replyType" value="WHOLE" />全回复 <input type="radio" name="replyType" value="RANDOM" checked="checked" /> 随机回复 <c:forEach items="${wehcatRuleReplyTypeMap}" var="wehcatRuleReplyType">
<input type="radio" name="replyType" value="${wehcatRuleReplyType.key}" />${wehcatRuleReplyType.value}
</c:forEach>
</div> </div>
<div class="row"> <div class="row">

Loading…
Cancel
Save