|
|
@ -1,5 +1,6 @@ |
|
|
package com.ccsens.health.api; |
|
|
package com.ccsens.health.api; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.http.HttpUtil; |
|
|
import cn.hutool.http.HttpUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
@ -12,6 +13,7 @@ import com.ccsens.util.enterprisewx.AesException; |
|
|
import com.ccsens.util.enterprisewx.WXBizMsgCrypt; |
|
|
import com.ccsens.util.enterprisewx.WXBizMsgCrypt; |
|
|
import com.ccsens.util.enterprisewx.WeiXinConstant; |
|
|
import com.ccsens.util.enterprisewx.WeiXinConstant; |
|
|
import com.ccsens.util.enterprisewx.dto.MessageDto; |
|
|
import com.ccsens.util.enterprisewx.dto.MessageDto; |
|
|
|
|
|
import io.swagger.annotations.ApiModel; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
@ -26,6 +28,7 @@ import java.util.Map; |
|
|
/** |
|
|
/** |
|
|
* @author wu |
|
|
* @author wu |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@ApiModel("微信授权相关接口") |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@RestController |
|
|
@RestController |
|
|
public class WeixinController { |
|
|
public class WeixinController { |
|
|
@ -50,7 +53,7 @@ public class WeixinController { |
|
|
/** |
|
|
/** |
|
|
* 数据回调URL |
|
|
* 数据回调URL |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("userChangeNotice") |
|
|
@GetMapping("userChangeNotice") |
|
|
public String userChangeNotice(MessageDto dto) throws Exception{ |
|
|
public String userChangeNotice(MessageDto dto) throws Exception{ |
|
|
log.info("数据回调请求参数:{}", dto); |
|
|
log.info("数据回调请求参数:{}", dto); |
|
|
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID); |
|
|
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID); |
|
|
@ -61,13 +64,15 @@ public class WeixinController { |
|
|
/** |
|
|
/** |
|
|
* 指令回调URL |
|
|
* 指令回调URL |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("authorizationChangeNotice") |
|
|
@GetMapping("authorizationChangeNotice") |
|
|
public String authorizationChangeNotice(MessageDto dto) throws Exception{ |
|
|
public String authorizationChangeNotice(MessageDto dto) throws Exception{ |
|
|
log.info("请求参数:{}", dto); |
|
|
log.info("请求参数:{}", dto); |
|
|
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID); |
|
|
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID); |
|
|
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr()); |
|
|
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr()); |
|
|
log.info("解析结果:{}", verifyURL); |
|
|
log.info("解析结果:{}", verifyURL); |
|
|
|
|
|
if (StrUtil.isBlank(verifyURL) || !(verifyURL.startsWith("<xml") || verifyURL.startsWith("<XML"))){ |
|
|
|
|
|
return verifyURL; |
|
|
|
|
|
} |
|
|
String jsonStr = JacksonUtil.xmlToJson(verifyURL); |
|
|
String jsonStr = JacksonUtil.xmlToJson(verifyURL); |
|
|
JSONObject json = JSONObject.parseObject(jsonStr); |
|
|
JSONObject json = JSONObject.parseObject(jsonStr); |
|
|
switch (json.getString("InfoType")){ |
|
|
switch (json.getString("InfoType")){ |
|
|
@ -89,7 +94,7 @@ public class WeixinController { |
|
|
break; |
|
|
break; |
|
|
//TODO 成员变更和部门变更通知
|
|
|
//TODO 成员变更和部门变更通知
|
|
|
} |
|
|
} |
|
|
return "success"; |
|
|
return verifyURL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|