mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-16 22:36:50 +08:00
整理结构
This commit is contained in:
@@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import com.xboe.common.utils.StringUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -20,6 +19,8 @@ import com.xboe.account.service.IAccountService;
|
|||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.common.utils.IDGenerator;
|
import com.xboe.common.utils.IDGenerator;
|
||||||
|
import com.xboe.common.utils.StringUtil;
|
||||||
|
import com.xboe.core.event.IEventDataSender;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
import com.xboe.core.orm.IFieldFilter;
|
import com.xboe.core.orm.IFieldFilter;
|
||||||
import com.xboe.core.orm.LikeMatchMode;
|
import com.xboe.core.orm.LikeMatchMode;
|
||||||
@@ -48,7 +49,6 @@ import com.xboe.module.course.service.CourseToCourseFullText;
|
|||||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||||
import com.xboe.module.course.service.ICourseService;
|
import com.xboe.module.course.service.ICourseService;
|
||||||
import com.xboe.module.interaction.service.ICourseGradeService;
|
import com.xboe.module.interaction.service.ICourseGradeService;
|
||||||
import com.xboe.stat.IEventDataSender;
|
|
||||||
import com.xboe.system.authority.service.IResDataManagerService;
|
import com.xboe.system.authority.service.IResDataManagerService;
|
||||||
import com.xboe.system.logs.dao.SysLogAuditDao;
|
import com.xboe.system.logs.dao.SysLogAuditDao;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xboe.stat;
|
|
||||||
|
|
||||||
public interface IEventDataSender {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送事件消息
|
|
||||||
* @param title 事件标题
|
|
||||||
* @param eventKey 事件key
|
|
||||||
* @param content 事件内容
|
|
||||||
* @param objId 关联对象id
|
|
||||||
* @param objType 关联对象类型
|
|
||||||
* @param objInfo 关联对象信息
|
|
||||||
* @param aid 操作人
|
|
||||||
* @param aname 操作人姓名
|
|
||||||
*/
|
|
||||||
void send(String title,String eventKey,String content,String objId,String objType,String objInfo,String aid,String aname,String author);
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.xboe.stat.impl;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.xboe.core.SysConstant;
|
|
||||||
import com.xboe.core.api.TokenProxy;
|
|
||||||
import com.xboe.core.utils.OkHttpUtil;
|
|
||||||
import com.xboe.standard.BaseConstant;
|
|
||||||
import com.xboe.stat.IEventDataSender;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 事件数据发送者
|
|
||||||
* @author seastar
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class EventDataSender implements IEventDataSender{
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OkHttpUtil okHttpUtil;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HttpServletRequest request;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void send(String title, String eventKey, String content, String objId, String objType, String objInfo,
|
|
||||||
String aid, String aname,String author) {
|
|
||||||
|
|
||||||
String url = SysConstant.getConfigValue("xboe.stat.base.url") + "/xboe/m/stat/event/send";
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("title", title);
|
|
||||||
params.put("source", "all");
|
|
||||||
params.put("content", content);
|
|
||||||
params.put("objId", objId);
|
|
||||||
params.put("key", eventKey);
|
|
||||||
params.put("objType", objType);
|
|
||||||
params.put("objInfo", objInfo);
|
|
||||||
params.put("aid", aid);
|
|
||||||
params.put("aname", aname);
|
|
||||||
params.put("parameters","");
|
|
||||||
String token = TokenProxy.getToken(request);
|
|
||||||
//最后采用异常发送,不影响当前进程
|
|
||||||
|
|
||||||
new Thread(()->{
|
|
||||||
try {
|
|
||||||
ObjectMapper mapper=new ObjectMapper();
|
|
||||||
String json =mapper.writeValueAsString(params);
|
|
||||||
//String[] headers=new String[] {"token",token};
|
|
||||||
String[] headers=new String[] {BaseConstant.HTTP_ACCESS_TOKEN,token};
|
|
||||||
|
|
||||||
String responseStr = okHttpUtil.doPostJson(url, json,headers);
|
|
||||||
if(responseStr.indexOf("\"status\":200")==-1) {
|
|
||||||
log.error("发送事件失败:"+responseStr);
|
|
||||||
log.info("【发送的token】"+headers[0]+": "+headers[1]);
|
|
||||||
}
|
|
||||||
}catch(Exception e) {
|
|
||||||
log.error("发送事件错误",e);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user