重构监听事件对象
This commit is contained in:
parent
7e8209502e
commit
33390e4e83
|
@ -2,6 +2,8 @@ package com.snow.web.controller.system;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.dingtalk.api.response.OapiCallBackGetCallBackFailedResultResponse;
|
||||
import com.snow.dingtalk.service.impl.CallBackServiceImpl;
|
||||
import com.snow.framework.util.ShiroUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -35,6 +37,8 @@ public class DingtalkCallBackController extends BaseController
|
|||
|
||||
@Autowired
|
||||
private IDingtalkCallBackService dingtalkCallBackService;
|
||||
@Autowired
|
||||
private CallBackServiceImpl callBackServiceImpl;
|
||||
|
||||
@RequiresPermissions("system:back:view")
|
||||
@GetMapping()
|
||||
|
@ -132,7 +136,8 @@ public class DingtalkCallBackController extends BaseController
|
|||
@GetMapping("/detail/{id}")
|
||||
public String detail(@PathVariable("id") Long operId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("operLog", "");
|
||||
List<OapiCallBackGetCallBackFailedResultResponse.Failed> callBackFailedResult = callBackServiceImpl.getCallBackFailedResult();
|
||||
mmap.put("operLog", callBackFailedResult);
|
||||
return prefix + "/detail";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('system:back:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:back:remove')}]];
|
||||
var detailFlag = [[${@permission.hasPermi('system:back:detail')}]];
|
||||
var prefix = ctx + "system/back";
|
||||
|
||||
$(function() {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('操作日志详细')" />
|
||||
<th:block th:include="include :: jsonview-css" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m-t" id="signupForm">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">操作模块:</label>
|
||||
<div class="form-control-static" th:text="${operLog.title} + ' / ' + ${@dict.getLabel('sys_oper_type',operLog.businessType)}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">登录信息:</label>
|
||||
<div class="form-control-static" th:text="${operLog.operName} + ' / ' + ${operLog.deptName} + ' / ' + ${operLog.operIp}+ ' / ' + ${operLog.operLocation}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">请求地址:</label>
|
||||
<div class="form-control-static" th:text="${operLog.operUrl}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">请求方式:</label>
|
||||
<div class="form-control-static" th:text="${operLog.requestMethod}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">操作方法:</label>
|
||||
<div class="form-control-static" th:text="${operLog.method}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">请求参数:</label>
|
||||
<div class="form-control-static"><pre id="operParam"></pre></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">返回参数:</label>
|
||||
<div class="form-control-static"><pre id="jsonResult"></pre></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">状态:</label>
|
||||
<div class="form-control-static" th:class="${operLog.status == 0 ? 'label label-primary' : 'label label-danger'}" th:text="${operLog.status == 0 ? '正常' : '异常'}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" th:style="'display:' + ${operLog.status == 0 ? 'none' : 'block'}">
|
||||
<label class="col-sm-2 control-label">异常信息:</label>
|
||||
<div class="form-control-static" th:text="${operLog.errorMsg}">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<th:block th:include="include :: jsonview-js" />
|
||||
<script th:inline="javascript">
|
||||
$(function() {
|
||||
var operParam = [[${operLog.operParam}]];
|
||||
if ($.common.isNotEmpty(operParam) && operParam.length < 2000) {
|
||||
$("#operParam").JSONView(operParam);
|
||||
} else {
|
||||
$("#operParam").text(operParam);
|
||||
}
|
||||
var jsonResult = [[${operLog.jsonResult}]];
|
||||
if ($.common.isNotEmpty(jsonResult) && jsonResult.length < 2000) {
|
||||
$("#jsonResult").JSONView(jsonResult);
|
||||
} else {
|
||||
$("#jsonResult").text(jsonResult);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -20,6 +20,8 @@ public enum DingTalkListenerType {
|
|||
CALL_BACK_UPDATE(21,10, "回调更新"),
|
||||
|
||||
CALL_BACK_DELETE(22,10, "回调删除"),
|
||||
|
||||
CALL_BACK_FAILED_RESULT(23,10, "获取回调失败结果"),
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -24,13 +24,18 @@ public class CallBackService implements ISyncDingTalkInfo {
|
|||
@Override
|
||||
public void syncDingTalkInfoEvent(SyncEvent syncEvent) {
|
||||
log.info("调用创建钉钉注册回调传入的原始参数:{}"+JSON.toJSONString(syncEvent));
|
||||
Enum eventType =(Enum) syncEvent.getT();
|
||||
if(eventType.equals(DingTalkListenerType.CALL_BACK_REGISTER.getCode())){
|
||||
callBackServiceImpl.registerCallBack((DingtalkCallBack) syncEvent.getT());
|
||||
DingTalkListenerType eventType =(DingTalkListenerType) syncEvent.getT();
|
||||
Integer code = eventType.getCode();
|
||||
if(code.equals(DingTalkListenerType.CALL_BACK_REGISTER.getCode())){
|
||||
callBackServiceImpl.registerCallBack((DingtalkCallBack) syncEvent.getSource());
|
||||
}
|
||||
else if( eventType.equals(DingTalkListenerType.CALL_BACK_UPDATE.getCode())){
|
||||
callBackServiceImpl.updateCallBack((DingtalkCallBack) syncEvent.getT());
|
||||
else if( code.equals(DingTalkListenerType.CALL_BACK_UPDATE.getCode())){
|
||||
callBackServiceImpl.updateCallBack((DingtalkCallBack) syncEvent.getSource());
|
||||
}
|
||||
else if(code.equals(DingTalkListenerType.CALL_BACK_DELETE.getCode())){
|
||||
callBackServiceImpl.deleteCallBack((DingtalkCallBack) syncEvent.getSource());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,15 +17,15 @@ public class SyncDingTalkInfoFactory {
|
|||
|
||||
public ISyncDingTalkInfo getSyncDingTalkService(SyncEvent syncEvent){
|
||||
|
||||
Enum dingTalkEnum = (Enum) syncEvent.getT();
|
||||
|
||||
if(dingTalkEnum.equals(DingTalkListenerType.DEPARTMENT_CREATE.getType())){
|
||||
DingTalkListenerType dingTalkEnum = (DingTalkListenerType) syncEvent.getT();
|
||||
Integer type = dingTalkEnum.getType();
|
||||
if(type.equals(DingTalkListenerType.DEPARTMENT_CREATE.getType())){
|
||||
return new DepartmentCreateEventService();
|
||||
}
|
||||
else if(dingTalkEnum.equals(DingTalkListenerType.USER_CREATED.getType())){
|
||||
else if(type.equals(DingTalkListenerType.USER_CREATED.getType())){
|
||||
return new UserCreateEventService();
|
||||
}
|
||||
else if(dingTalkEnum.equals(DingTalkListenerType.CALL_BACK_REGISTER.getType())){
|
||||
else if(type.equals(DingTalkListenerType.CALL_BACK_REGISTER.getType())){
|
||||
return new CallBackService();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.snow.dingtalk.service;
|
||||
|
||||
import com.dingtalk.api.response.OapiCallBackGetCallBackFailedResultResponse;
|
||||
import com.snow.system.domain.DingtalkCallBack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
|
@ -29,5 +32,5 @@ public interface CallBackService {
|
|||
/**
|
||||
* 获取回调失败结果
|
||||
*/
|
||||
void getCallBackFailedResult();
|
||||
List<OapiCallBackGetCallBackFailedResultResponse.Failed> getCallBackFailedResult();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ import com.snow.system.domain.DingtalkCallBack;
|
|||
import com.taobao.api.ApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
|
@ -38,7 +39,7 @@ public class CallBackServiceImpl extends BaseService implements CallBackService
|
|||
request.setToken(dingtalkCallBack.getToken());
|
||||
request.setCallBackTag(dingtalkCallBack.getEventNameList());
|
||||
try {
|
||||
OapiCallBackRegisterCallBackResponse response = client.execute(request,getCallBackDingTalkToken(dingtalkCallBack));
|
||||
OapiCallBackRegisterCallBackResponse response = client.execute(request,getDingTalkToken());
|
||||
if(response.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.REGISTER_CALL_BACK,response.getMessage(),"registerCallBack()", JSON.toJSONString(request));
|
||||
}else {
|
||||
|
@ -60,7 +61,7 @@ public class CallBackServiceImpl extends BaseService implements CallBackService
|
|||
request.setToken(dingtalkCallBack.getToken());
|
||||
request.setCallBackTag(dingtalkCallBack.getEventNameList());
|
||||
try {
|
||||
OapiCallBackUpdateCallBackResponse response = client.execute(request,getCallBackDingTalkToken(dingtalkCallBack));
|
||||
OapiCallBackUpdateCallBackResponse response = client.execute(request,getDingTalkToken());
|
||||
if(response.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.UPDATE_CALL_BACK,response.getMessage(),"updateCallBack()", JSON.toJSONString(request));
|
||||
}else {
|
||||
|
@ -93,27 +94,31 @@ public class CallBackServiceImpl extends BaseService implements CallBackService
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getCallBackFailedResult() {
|
||||
public List<OapiCallBackGetCallBackFailedResultResponse.Failed> getCallBackFailedResult() {
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.CALL_BACK_FAILED_RESULT);
|
||||
OapiCallBackGetCallBackFailedResultRequest request = new OapiCallBackGetCallBackFailedResultRequest();
|
||||
request.setHttpMethod("GET");
|
||||
try {
|
||||
OapiCallBackGetCallBackFailedResultResponse response = client.execute(request, getDingTalkToken());
|
||||
if(response.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.DELETE_CALL_BACK,response.getMessage(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
List<OapiCallBackGetCallBackFailedResultResponse.Failed> failedList = response.getFailedList();
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.CALL_BACK_FAILED_RESULT,response.getMessage(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
return failedList;
|
||||
}else {
|
||||
//记录获取token失败日志
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.DELETE_CALL_BACK,response.getErrmsg(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.CALL_BACK_FAILED_RESULT,response.getErrmsg(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.DELETE_CALL_BACK,e.getMessage(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.CALL_BACK_FAILED_RESULT,e.getMessage(),"getCallBackFailedResult()", JSON.toJSONString(request));
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 获取token
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCallBackDingTalkToken(DingtalkCallBack dingtalkCallBack){
|
||||
//创建缓存,缓存默认是7100S
|
||||
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(7100);
|
||||
|
|
Loading…
Reference in New Issue