优化部分代码

master
星期八 6 years ago
parent 72461c18f1
commit 6152c03ed0
  1. 2
      src/main/java/com/lq/cms/service/WechatMessageService.java
  2. 11
      src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java
  3. 9
      src/main/java/com/lq/cms/web/AdminBaseController.java
  4. 4
      src/main/java/com/lq/cms/web/wechat/WechatMessageController.java
  5. 3
      src/main/java/com/lq/dao/WechatMessageDao.java
  6. 11
      src/main/resources/mybatis/mapping/WechatMessageDao.xml
  7. 6
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp
  8. 2
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp
  9. 3
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp
  10. 6
      src/main/webapp/resources/cms/wechat/wechat.js

@ -8,5 +8,5 @@ import java.util.List;
public interface WechatMessageService extends AdminBaseService<WechatMessage,WechatMessageVo> { public interface WechatMessageService extends AdminBaseService<WechatMessage,WechatMessageVo> {
List<WechatMessageVo> findAllWechatMessageVo(); List<WechatMessageVo> findAllWechatMessageVo(WechatMessageVo wechatMessageVo);
} }

@ -26,13 +26,14 @@ public class WechatMessageServiceImpl extends AdminBaseServiceImpl<WechatMessage
} }
@Override @Override
public List<WechatMessageVo> findAllWechatMessageVo() { public List<WechatMessageVo> findAllWechatMessageVo(WechatMessageVo wechatMessageVo) {
List<WechatMessageVo> wechatMessageVoList = new ArrayList<>(); List<WechatMessageVo> wechatMessageVoList = new ArrayList<>();
List<WechatMessage> wechatMessageList = wechatMessageDao.findAll(); List<WechatMessage> wechatMessageList = wechatMessageDao.findAllByWechatMessageVo(wechatMessageVo);
wechatMessageList.forEach(wechatMessage -> { wechatMessageList.forEach(wechatMessage -> {
WechatMessageVo wechatMessageVo = new WechatMessageVo(); WechatMessageVo wechatMessageVo1 = new WechatMessageVo();
BeanUtil.copyNotNull(wechatMessageVo,wechatMessage); BeanUtil.copyNotNull(wechatMessageVo1,wechatMessage);
wechatMessageVoList.add(wechatMessageVo); wechatMessageVoList.add(wechatMessageVo1);
}); });
return wechatMessageVoList; return wechatMessageVoList;

@ -5,6 +5,7 @@ import com.lq.cms.mode.AdminDataGridParam;
import com.lq.cms.service.AdminBaseService; import com.lq.cms.service.AdminBaseService;
import com.lq.cms.vo.AdminBaseVo; import com.lq.cms.vo.AdminBaseVo;
import com.lq.code.entity.AjaxResult; import com.lq.code.entity.AjaxResult;
import com.lq.code.util.Constant;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -46,7 +47,7 @@ public abstract class AdminBaseController<T,V extends AdminBaseVo> {
@ResponseBody @ResponseBody
public AdminDataGridParam<V> list(V vo){ public AdminDataGridParam<V> list(V vo){
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.SELECT.getConstant()); subject.checkPermission(getIndexUrl()+ Constant.PERSSION_MARK+ PermissionTyepEnum.SELECT.getConstant());
AdminDataGridParam<V> adminDataGridParam = setPageDate(vo); AdminDataGridParam<V> adminDataGridParam = setPageDate(vo);
return adminDataGridParam; return adminDataGridParam;
} }
@ -55,7 +56,7 @@ public abstract class AdminBaseController<T,V extends AdminBaseVo> {
@ResponseBody @ResponseBody
public AjaxResult save(V vo) throws InstantiationException, IllegalAccessException { public AjaxResult save(V vo) throws InstantiationException, IllegalAccessException {
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.INSERT.getConstant()); subject.checkPermission(getIndexUrl()+Constant.PERSSION_MARK+ PermissionTyepEnum.INSERT.getConstant());
AjaxResult ajaxResult = new AjaxResult(); AjaxResult ajaxResult = new AjaxResult();
T t = getBaseService().save(vo); T t = getBaseService().save(vo);
ajaxResult.setData(t); ajaxResult.setData(t);
@ -66,7 +67,7 @@ public abstract class AdminBaseController<T,V extends AdminBaseVo> {
@ResponseBody @ResponseBody
public AjaxResult update(V vo){ public AjaxResult update(V vo){
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.UPDATE.getConstant()); subject.checkPermission(getIndexUrl()+Constant.PERSSION_MARK+ PermissionTyepEnum.UPDATE.getConstant());
AjaxResult ajaxResult= new AjaxResult(); AjaxResult ajaxResult= new AjaxResult();
getBaseService().update(vo); getBaseService().update(vo);
return ajaxResult; return ajaxResult;
@ -76,7 +77,7 @@ public abstract class AdminBaseController<T,V extends AdminBaseVo> {
@ResponseBody @ResponseBody
public AjaxResult delete(Long id){ public AjaxResult delete(Long id){
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.DELETE.getConstant()); subject.checkPermission(getIndexUrl()+Constant.PERSSION_MARK+ PermissionTyepEnum.DELETE.getConstant());
AjaxResult ajaxResult = new AjaxResult(); AjaxResult ajaxResult = new AjaxResult();
getBaseService().delete(id); getBaseService().delete(id);
return ajaxResult; return ajaxResult;

@ -46,8 +46,8 @@ public class WechatMessageController extends AdminBaseController<WechatMessage,W
@RequestMapping("/findMessageDataList") @RequestMapping("/findMessageDataList")
@ResponseBody @ResponseBody
public Object findAll(){ public Object findAll(WechatMessageVo wechatMessageVo){
List<WechatMessageVo> wechatMessageVoList = wechatMessageService.findAllWechatMessageVo(); List<WechatMessageVo> wechatMessageVoList = wechatMessageService.findAllWechatMessageVo(wechatMessageVo);
WechatMessageBo wechatMessageBo = new WechatMessageBo(); WechatMessageBo wechatMessageBo = new WechatMessageBo();
wechatMessageBo.setWechatMessageVoList(wechatMessageVoList); wechatMessageBo.setWechatMessageVoList(wechatMessageVoList);
wechatMessageBo.setWechatMessageCount(wechatMessageVoList.size()); wechatMessageBo.setWechatMessageCount(wechatMessageVoList.size());

@ -4,6 +4,9 @@ import com.lq.cms.dao.AdminBaseDao;
import com.lq.cms.vo.WechatMessageVo; import com.lq.cms.vo.WechatMessageVo;
import com.lq.entity.WechatMessage; import com.lq.entity.WechatMessage;
import java.util.List;
public interface WechatMessageDao extends AdminBaseDao<WechatMessage,WechatMessageVo> { public interface WechatMessageDao extends AdminBaseDao<WechatMessage,WechatMessageVo> {
List<WechatMessage> findAllByWechatMessageVo(WechatMessageVo wechatMessageVo);
} }

@ -78,5 +78,16 @@
status = 1 status = 1
</select> </select>
<select id="findAllByWechatMessageVo" resultType="com.lq.entity.WechatMessage" parameterType="WechatMessageVo">
SELECT <include refid="column_list"/>
FROM wechat_message
WHERE
status = 1
<if test="messageType!=null">
AND message_type=#{messageType}
</if>
</select>
</mapper> </mapper>

@ -21,7 +21,7 @@
<td> <td>
<select id="messageType" > <select id="messageType" >
<c:forEach items="${wechatMessageTypeMap}" var="wechatMessageType"> <c:forEach items="${wechatMessageTypeMap}" var="wechatMessageType">
<option <c:if test="${wechatMessage.messageType == wechatMessageType.key}">selected</c:if> value="${wechatMessageType.key}">${wechatMessageType.value}</option> <option <c:if test="${wechatMessage.messageType == wechatMessageType.key}">selected</c:if> value=${wechatMessageType.key} >${wechatMessageType.value}</option>
</c:forEach> </c:forEach>
</select> </select>
</td> </td>
@ -69,6 +69,7 @@
</table> </table>
</div> </div>
</body> </body>
<script type="text/javascript" href="${ctx}/resources/cms/wechat/wechat.js"/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#imageUrl').on('change', function() {//当chooseImage的值改变时,执行此函数 $('#imageUrl').on('change', function() {//当chooseImage的值改变时,执行此函数
@ -93,9 +94,7 @@
showMessageTypeInput(messageType); showMessageTypeInput(messageType);
$("#messageType").on("change",function () { $("#messageType").on("change",function () {
console.log("================");
var messageType = $(this).val(); var messageType = $(this).val();
console.log(messageType);
showMessageTypeInput(messageType); showMessageTypeInput(messageType);
}) })
@ -103,7 +102,6 @@
}); });
function showMessageTypeInput(messageType) { function showMessageTypeInput(messageType) {
console.log(messageType);
switch (messageType){ switch (messageType){
case '2': case '2':
$("#tr_imageUrl").show(); $("#tr_imageUrl").show();

@ -15,6 +15,8 @@
<script type="text/javascript" src="${ctx}/resources/code/js/jquery-2.2.4.min.js"></script> <script type="text/javascript" src="${ctx}/resources/code/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/code/easyui/jquery.easyui.min.1.2.2.js"></script> <script type="text/javascript" src="${ctx}/resources/code/easyui/jquery.easyui.min.1.2.2.js"></script>
<script type="text/javascript" src="${ctx}/resources/plugins/layer/layer.js"></script> <script type="text/javascript" src="${ctx}/resources/plugins/layer/layer.js"></script>
<script type="text/javascript" href="${ctx}/resources/cms/wechat/wechat.js"></script>
</head> </head>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {

@ -154,6 +154,7 @@
</body> </body>
<script type="text/javascript" src="${ctx}/resources/code/js/jquery-2.2.4.min.js"></script> <script type="text/javascript" src="${ctx}/resources/code/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/plugins/layer/layer.js"></script> <script type="text/javascript" src="${ctx}/resources/plugins/layer/layer.js"></script>
<script type="text/javascript" href="${ctx}/resources/cms/wechat/wechat.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var isCheck = ${wechatInfo.openReply==1}; var isCheck = ${wechatInfo.openReply==1};
var addkeywordRowHtml = $("#keyword").html(); var addkeywordRowHtml = $("#keyword").html();
@ -388,7 +389,7 @@
$("#addIcon").click(function(){ $("#addIcon").click(function(){
var data = new Object(); var data = new Object();
data.messageType = 'text-image'; data.messageType = 3;
$.ajax({ $.ajax({
type:"post", type:"post",
url:"${ctx}/cms/wechat/message/findMessageDataList", url:"${ctx}/cms/wechat/message/findMessageDataList",

@ -0,0 +1,6 @@
//微信公众号消息类型-图片
var WECHAT_MESSAGE_MESSAGE_TYPE_IMAGE ='2';
//微信公众号消息类型-文字
var WECHAT_MESSAGE_MESSAGE_TYPE_TEXT = '1';
//微信公众号消息类型-图文混合
var WECHAT_MESSAGE_MESSAGE_TYPE_IMAGE_TEXT = '3';
Loading…
Cancel
Save