更新部分代码

master
星期八 5 years ago
parent f31520239d
commit 833e018b70
  1. 25
      src/main/java/com/lq/cms/service/SysRoleService.java
  2. 1
      src/main/java/com/lq/code/annotation/Length.java
  3. 31
      src/main/java/com/lq/code/entity/AjaxResult.java
  4. 2
      src/main/java/com/lq/jms/service/impl/ProductServiceImpl.java
  5. 170
      src/main/java/com/lq/wechat/web/WechatController.java

@ -12,14 +12,37 @@ import java.util.List;
* 角色事务类 * 角色事务类
*/ */
public interface SysRoleService extends BaseService<SysRole> { public interface SysRoleService extends BaseService<SysRole> {
/**
* 参数统计
* @param vo
* @return
*/
Integer count(SysRoleVo vo); Integer count(SysRoleVo vo);
/**
* 参数分页查询
* @param vo
* @return
*/
List<SysRoleVo> findListPage(SysRoleVo vo); List<SysRoleVo> findListPage(SysRoleVo vo);
/**
*
* @param userId
* @return
*/
List<SysUserRoleVo> findAllRoleVo(Long userId); List<SysUserRoleVo> findAllRoleVo(Long userId);
/**
* 通过用户ID查询角色
* @param userId
* @return
*/
List<SysRole> findByUserId(Long userId); List<SysRole> findByUserId(Long userId);
/**
* 通过角色ID删除角色
* @param roleId
*/
void deleteRole(Long roleId); void deleteRole(Long roleId);
} }

@ -4,6 +4,7 @@ import java.lang.annotation.*;
/** /**
* Created by qi_liang on 2018/4/26. * Created by qi_liang on 2018/4/26.
* @author qi
*/ */
@Documented @Documented
@Target(ElementType.FIELD) @Target(ElementType.FIELD)

@ -2,13 +2,20 @@ package com.lq.code.entity;
/** /**
* Created by qi on 2018-1-9. * Created by qi on 2018-1-9.
* @author qi
*/ */
public class AjaxResult { public class AjaxResult {
//操作结果 /**
private Boolean success; * 操作结果
//提示信息 */
private boolean success;
/**
* 提示信息
*/
private String msg; private String msg;
//返回数据 /**
* 返回数据
*/
private Object data; private Object data;
public AjaxResult() { public AjaxResult() {
@ -46,4 +53,20 @@ public class AjaxResult {
public void setData(Object data) { public void setData(Object data) {
this.data = data; this.data = data;
} }
public static AjaxResult getInstance(){
return new AjaxResult();
}
public static AjaxResult getSuccessInstance(){
return new AjaxResult();
}
public static AjaxResult getSuccessInstance(Object data){
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.setData(data);
return ajaxResult;
}
} }

@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ProductServiceImpl implements ProductService { public class ProductServiceImpl implements ProductService {
@Autowired @Autowired(required = false)
private JmsTemplate jmsTemplate; private JmsTemplate jmsTemplate;

@ -9,8 +9,6 @@ import com.lq.code.web.BaseController;
import com.lq.entity.WechatInfo; import com.lq.entity.WechatInfo;
import com.lq.entity.WechatUser; import com.lq.entity.WechatUser;
import com.lq.wechat.mode.message.BaseMessage; import com.lq.wechat.mode.message.BaseMessage;
import com.lq.wechat.mode.message.ItemMessage;
import com.lq.wechat.mode.message.NewsMessage;
import com.lq.wechat.mode.message.TextMessage; import com.lq.wechat.mode.message.TextMessage;
import com.lq.wechat.util.CheckUtil; import com.lq.wechat.util.CheckUtil;
import com.lq.wechat.util.ConstantSet; import com.lq.wechat.util.ConstantSet;
@ -26,8 +24,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -92,99 +88,79 @@ public class WechatController extends BaseController {
//微信公众号详情 //微信公众号详情
WechatInfo wechatInfo = wechatInfoService.getByOpenId(wechatOpenId); WechatInfo wechatInfo = wechatInfoService.getByOpenId(wechatOpenId);
TextMessage text = new TextMessage(); if (wechatInfo!=null) {
text.setFromUserName(wechatOpenId); TextMessage text = new TextMessage();
text.setToUserName(openId); text.setFromUserName(wechatOpenId);
text.setMsgType(ConstantSet.MESSAGE_TYPE_TEXT); text.setToUserName(openId);
text.setMsgType(ConstantSet.MESSAGE_TYPE_TEXT);
text.setCreateTime(System.currentTimeMillis());
text.setCreateTime(System.currentTimeMillis());
switch (msgType) {
case ConstantSet.MESSAGE_TYPE_TEXT: switch (msgType) {
String content = map.get(WECHAT_CONTENT_KEY); case ConstantSet.MESSAGE_TYPE_TEXT:
BaseMessage baseMessage = wechatRuleService.getByKeyworkdAndWechatInfoId(content,wechatInfo); String content = map.get(WECHAT_CONTENT_KEY);
baseMessage.setCreateTime(System.currentTimeMillis()); BaseMessage baseMessage = wechatRuleService.getByKeyworkdAndWechatInfoId(content, wechatInfo);
baseMessage.setFromUserName(wechatOpenId); baseMessage.setCreateTime(System.currentTimeMillis());
baseMessage.setToUserName(openId); baseMessage.setFromUserName(wechatOpenId);
message = MessageUtil.MessageToXml(baseMessage); baseMessage.setToUserName(openId);
// if("1".equals(content)){ message = MessageUtil.MessageToXml(baseMessage);
// NewsMessage newsMessage=new NewsMessage(); break;
// List<ItemMessage> items=new ArrayList<>(); case ConstantSet.MESSAGE_TYPE_IMAGE:
// ItemMessage item=new ItemMessage();
// item.setTitle("六弄咖啡馆"); text.setContent("您发送的消息是:" + "图片");
// item.setDescription("两个人在爱在距离面前是否禁受考验?"); message = MessageUtil.MessageToXml(text);
// String path = req.getContextPath(); break;
// String basePath = req.getScheme()+"://"+req.getServerName()+":"+req.getServerPort()+path+"/"; case ConstantSet.MESSAGE_TYPE_VIDEO:
// item.setPicUrl("https://img3.doubanio.com/view/photo/l/public/p2367455902.webp"); text.setContent("您发送的消息是:" + "视频");
// item.setUrl("http://www.iqiyi.com/v_19rr95j3vc.html?vfm=2008_aldbd"); message = MessageUtil.MessageToXml(text);
// items.add(item); break;
// newsMessage.setArticles(items); case ConstantSet.MESSAGE_TYPE_SHORTVIDEO:
// newsMessage.setArticleCount(1); text.setContent("您发送的消息是:" + "小视频");
// newsMessage.setCreateTime(System.currentTimeMillis()); message = MessageUtil.MessageToXml(text);
// newsMessage.setFromUserName(wechatOpenId); break;
// newsMessage.setMsgType(ConstantSet.MESSAGE_TYPE_NEW); case ConstantSet.MESSAGE_TYPE_VOICE:
// newsMessage.setToUserName(openId); text.setContent("您发送的消息是:" + "语音");
// message = MessageUtil.MessageToXml(newsMessage); message = MessageUtil.MessageToXml(text);
// } else{ break;
// text.setContent("您发送的消息是:" + content); case ConstantSet.MESSAGE_TYPE_LINK:
// message = MessageUtil.MessageToXml(text); text.setContent("您发送的消息是:" + "链接");
// } message = MessageUtil.MessageToXml(text);
break; break;
case ConstantSet.MESSAGE_TYPE_IMAGE: case ConstantSet.MESSAGE_TYPE_LOCATION:
text.setContent("您发送的消息是:" + "位置");
text.setContent("您发送的消息是:" + "图片"); message = MessageUtil.MessageToXml(text);
message = MessageUtil.MessageToXml(text); break;
break; case ConstantSet.MESSAGE_TYPE_EVENT:
case ConstantSet.MESSAGE_TYPE_VIDEO: String event = map.get("Event");
text.setContent("您发送的消息是:" + "视频"); switch (event) {
message = MessageUtil.MessageToXml(text); case ConstantSet.EVENT_TYPE_SUBSCRIBE:
break; LOGGER.info("微信公众号关注事件:" + wechatInfo.getWechatName());
case ConstantSet.MESSAGE_TYPE_SHORTVIDEO: //公众号在认证的情况下才可以获取用户信息
text.setContent("您发送的消息是:" + "小视频"); if (WechatInfoCertificationTypeEnum.CERTIFICATION_YES.getValue().equals(wechatInfo.getCertification())) {
message = MessageUtil.MessageToXml(text); WechatUser wechatUser = wechatUserService.saveWechatUser(openId, wechatInfo);
break; }
case ConstantSet.MESSAGE_TYPE_VOICE:
text.setContent("您发送的消息是:" + "语音"); break;
message = MessageUtil.MessageToXml(text); case ConstantSet.EVENT_TYPE_UNSUBSCRIBE:
break; ;
case ConstantSet.MESSAGE_TYPE_LINK: break;
text.setContent("您发送的消息是:" + "链接"); case ConstantSet.EVENT_TYPE_CLICK:
message = MessageUtil.MessageToXml(text); //自定义菜单点击事件KEY值
break; String eventKey = map.get(ConstantSet.EVENT_CLICK_KEY);
case ConstantSet.MESSAGE_TYPE_LOCATION:
text.setContent("您发送的消息是:" + "位置"); ;
message = MessageUtil.MessageToXml(text); break;
break; default:
case ConstantSet.MESSAGE_TYPE_EVENT: break;
String event = map.get("Event"); }
switch (event) {
case ConstantSet.EVENT_TYPE_SUBSCRIBE: break;
LOGGER.info("微信公众号关注事件:"+wechatInfo.getWechatName());
//公众号在认证的情况下才可以获取用户信息 default:
if (WechatInfoCertificationTypeEnum.CERTIFICATION_YES.getValue().equals(wechatInfo.getCertification())) { text.setContent("您发送的消息是:" + "无法理解");
WechatUser wechatUser = wechatUserService.saveWechatUser(openId, wechatInfo); message = MessageUtil.MessageToXml(text);
} break;
}
break;
case ConstantSet.EVENT_TYPE_UNSUBSCRIBE:
;
break;
case ConstantSet.EVENT_TYPE_CLICK:
//自定义菜单点击事件KEY值
String eventKey = map.get(ConstantSet.EVENT_CLICK_KEY);
;
break;
default:
break;
}
break;
default:
text.setContent("您发送的消息是:" + "无法理解");
message = MessageUtil.MessageToXml(text);
break;
} }
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save