From e5da291b9c27d87bd832a50effae2bf031a8f687 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Fri, 11 Jan 2019 13:20:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86jsp?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lq/cms/dao/AdminBaseDao.java | 1 + .../cms/emun/WechatInfoEncodingTypeEnum.java | 16 ++++- .../lq/cms/emun/WechatMessageTypeEnum.java | 61 +++++++++++++++++++ .../com/lq/cms/service/AdminBaseService.java | 2 +- .../service/impl/AdminBaseServiceImpl.java | 6 +- .../impl/WechatMessageServiceImpl.java | 1 + .../java/com/lq/cms/vo/WechatMessageVo.java | 9 --- .../cms/web/wechat/WechatInfoController.java | 4 ++ .../web/wechat/WechatMessageController.java | 13 ++++ src/main/java/com/lq/code/util/BeanUtil.java | 1 + .../views/jsp/cms/wechat/info/edit.jsp | 6 +- .../views/jsp/cms/wechat/info/index.jsp | 16 +++-- .../views/jsp/cms/wechat/message/edit.jsp | 55 +++++++++++++++++ .../views/jsp/cms/wechat/message/index.jsp | 42 +++++++++++++ 14 files changed, 205 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/lq/cms/emun/WechatMessageTypeEnum.java create mode 100644 src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp diff --git a/src/main/java/com/lq/cms/dao/AdminBaseDao.java b/src/main/java/com/lq/cms/dao/AdminBaseDao.java index b471ed3..a370e55 100644 --- a/src/main/java/com/lq/cms/dao/AdminBaseDao.java +++ b/src/main/java/com/lq/cms/dao/AdminBaseDao.java @@ -10,4 +10,5 @@ public interface AdminBaseDao extends BaseDao { List findLisatPage(AdminBaseVo vo); int count(AdminBaseVo vo); + } diff --git a/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java b/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java index 40b96a8..5f15045 100644 --- a/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java +++ b/src/main/java/com/lq/cms/emun/WechatInfoEncodingTypeEnum.java @@ -11,13 +11,13 @@ public enum WechatInfoEncodingTypeEnum { BLEND("BLEND","混合"), ENCRYPT("ENCRYPT","加密") ; - private static Map map = new HashMap(); + private static Map enumMap = new HashMap(); static { WechatInfoEncodingTypeEnum[] wechatInfoEncodingTypeEnumArray = WechatInfoEncodingTypeEnum.values(); for (WechatInfoEncodingTypeEnum wechatInfoEncodingTypeEnum : wechatInfoEncodingTypeEnumArray) { - map.put(wechatInfoEncodingTypeEnum.getValue(), wechatInfoEncodingTypeEnum.getDesc()); + enumMap.put(wechatInfoEncodingTypeEnum.value, wechatInfoEncodingTypeEnum.desc); } } @@ -28,9 +28,19 @@ public enum WechatInfoEncodingTypeEnum { this.value = value; this.desc = desc; } + //判断是否存在值 + public static boolean hasValue(String value){ + + return enumMap.containsKey(value); + } + + public static Map getEnumMap(){ + + return enumMap; + } public static String getDesc(String value){ - return (String) map.get(value); + return (String) enumMap.get(value); } public String getValue() { diff --git a/src/main/java/com/lq/cms/emun/WechatMessageTypeEnum.java b/src/main/java/com/lq/cms/emun/WechatMessageTypeEnum.java new file mode 100644 index 0000000..cff10f5 --- /dev/null +++ b/src/main/java/com/lq/cms/emun/WechatMessageTypeEnum.java @@ -0,0 +1,61 @@ +package com.lq.cms.emun; + +import java.util.HashMap; +import java.util.Map; + +public enum WechatMessageTypeEnum { + IMAGE("IMAGE","图片"), + TEXT("TEXT","文本"), + IMAGE_TEXT("IMAGE_TEXT","图文混合") + ; + + WechatMessageTypeEnum(String value, String desc) { + this.value = value; + this.desc = desc; + } + + private String value; + + private String desc; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + private static Map enumMap = new HashMap(); + + static { + WechatMessageTypeEnum[] wechantMessageTypeEnums = WechatMessageTypeEnum.values(); + for (WechatMessageTypeEnum wechantMessageTypeEnum:wechantMessageTypeEnums) { + enumMap.put(wechantMessageTypeEnum.value, wechantMessageTypeEnum.desc); + } + } + + //判断是否存在值 + public static boolean hasValue(String value){ + + return enumMap.containsKey(value); + } + + public static String getDesc(String value){ + + return enumMap.get(value); + } + + public static Map getEnumMap(){ + + return enumMap; + } +} diff --git a/src/main/java/com/lq/cms/service/AdminBaseService.java b/src/main/java/com/lq/cms/service/AdminBaseService.java index c544e86..94a1d9d 100644 --- a/src/main/java/com/lq/cms/service/AdminBaseService.java +++ b/src/main/java/com/lq/cms/service/AdminBaseService.java @@ -5,7 +5,7 @@ import com.lq.code.service.BaseService; import java.util.List; -public interface AdminBaseService extends BaseService{ +public interface AdminBaseService extends BaseService{ List findListPage(AdminBaseVo vo); diff --git a/src/main/java/com/lq/cms/service/impl/AdminBaseServiceImpl.java b/src/main/java/com/lq/cms/service/impl/AdminBaseServiceImpl.java index 2d6b5cf..1dd116f 100644 --- a/src/main/java/com/lq/cms/service/impl/AdminBaseServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/AdminBaseServiceImpl.java @@ -13,9 +13,9 @@ import java.lang.reflect.ParameterizedType; import java.util.Date; import java.util.List; -public abstract class AdminBaseServiceImpl extends BaseServiceImpl implements AdminBaseService{ +public abstract class AdminBaseServiceImpl extends BaseServiceImpl implements AdminBaseService{ - abstract AdminBaseDao getAdminBaseDao(); + abstract AdminBaseDao getAdminBaseDao(); @Override public List findListPage(AdminBaseVo vo) { @@ -48,7 +48,7 @@ public abstract class AdminBaseServiceImpl extends BaseServiceImpl implements } @Override - public BaseDao getBaseDao() { + public BaseDao getBaseDao() { return getAdminBaseDao(); } diff --git a/src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java b/src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java index 10890ab..c9c594c 100644 --- a/src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java @@ -13,6 +13,7 @@ public class WechatMessageServiceImpl extends AdminBaseServiceImpl encodingTypeMap = WechatInfoEncodingTypeEnum.getEnumMap(); + + modelAndView.addObject("encodingTypeMap",encodingTypeMap); modelAndView.setViewName("cms/wechat/info/edit"); return modelAndView; } diff --git a/src/main/java/com/lq/cms/web/wechat/WechatMessageController.java b/src/main/java/com/lq/cms/web/wechat/WechatMessageController.java index dace36a..99384ad 100644 --- a/src/main/java/com/lq/cms/web/wechat/WechatMessageController.java +++ b/src/main/java/com/lq/cms/web/wechat/WechatMessageController.java @@ -1,5 +1,6 @@ package com.lq.cms.web.wechat; +import com.lq.cms.emun.WechatMessageTypeEnum; import com.lq.cms.service.AdminBaseService; import com.lq.cms.service.WechatMessageService; import com.lq.cms.vo.WechatMessageVo; @@ -7,6 +8,7 @@ import com.lq.cms.web.AdminBaseController; import com.lq.entity.WechatMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -30,6 +32,17 @@ public class WechatMessageController extends AdminBaseController return "cms/wechat/message/index"; } + @RequestMapping("/edit") + public String edit(Model model, Long id){ + if (id!=null){ + WechatMessage wechatMessage = wechatMessageService.findOne(id); + model.addAttribute("wechatMessage",wechatMessage); + } + Map emunMap = WechatMessageTypeEnum.getEnumMap(); + model.addAttribute("wechatMessageTypeMap",emunMap); + return "cms/wechat/message/edit"; + } + @Override public AdminBaseService getBaseService() { diff --git a/src/main/java/com/lq/code/util/BeanUtil.java b/src/main/java/com/lq/code/util/BeanUtil.java index 0e3d2b2..71743d7 100644 --- a/src/main/java/com/lq/code/util/BeanUtil.java +++ b/src/main/java/com/lq/code/util/BeanUtil.java @@ -198,6 +198,7 @@ public class BeanUtil { * @return */ public static Boolean isType(Object obj,Class clazzType){ + if (obj!=null) { Class clazz = obj.getClass(); return clazz.getTypeName().equals(clazzType.getTypeName()) ? true : false; diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/edit.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/edit.jsp index 8ff0fa8..ababbf1 100644 --- a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/edit.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/edit.jsp @@ -50,9 +50,9 @@ 消息加密类型: 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 bc2c06c..8c80f4e 100644 --- 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 @@ -83,14 +83,7 @@ var url = 'save'; var obj = new Object(); // obj.id = $("#id").val(); - obj.wechatOpenId = $("#wechatOpenId").val(); - obj.wechatName = $("#wechatName").val(); - obj.appId = $("#appId").val(); - obj.appSecpet = $("#appSecpet").val(); - obj.url = $("#url").val(); - obj.token = $("#token").val(); - obj.encodingType = $("#encodingType").val(); - obj.encodingAesKey = $("#encodingAesKey").val(); + obj = attrObj(obj); post(url,obj); } @@ -98,6 +91,11 @@ var url = 'update'; var obj = new Object(); obj.id = $("#id").val(); + obj = attrObj(obj); + post(url,obj); + } + + function attrObj(obj) { obj.wechatOpenId = $("#wechatOpenId").val(); obj.wechatName = $("#wechatName").val(); obj.appId = $("#appId").val(); @@ -106,7 +104,7 @@ obj.token = $("#token").val(); obj.encodingType = $("#encodingType").val(); obj.encodingAesKey = $("#encodingAesKey").val(); - post(url,obj); + return obj; } function del(id) { diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp new file mode 100644 index 0000000..e0df78c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp @@ -0,0 +1,55 @@ +<%-- + Created by IntelliJ IDEA. + User: qi_liang + Date: 2018/6/5 + Time: 下午11:40 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ include file="../../../common/import-tag.jsp"%> + + + 微信公众号消息编辑 + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
消息类型: + +
消息标题: + +
消息内容:
素材ID:
消息跳转链接:
+
+ + diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp index 80da4f6..b664ed5 100644 --- a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp @@ -46,5 +46,47 @@
+
+