Search in sources :

Example 1 with VisitLog

use of com.dimple.project.log.domain.VisitLog in project DimpleBlog by martin-chips.

the class DashboardServiceImpl method getVisitLogStringList.

@Override
public List<String> getVisitLogStringList() {
    List<VisitLog> visitLogList = dashBoardMapper.getVisitLog();
    List<String> result = new ArrayList<>();
    for (VisitLog visitLog : visitLogList) {
        String name = "";
        if (visitLog.getPageId() != null) {
            if (visitLog.getPageId() == -1000) {
                name = "留言页";
            } else {
                Long pageId = visitLog.getPageId();
                if (pageId != null) {
                    name = dashBoardMapper.getBlogNameByPageId(pageId);
                }
            }
        }
        // XXX 分钟前 : @47.112.14.207 浏览了 <strong>title</strong> <a href='url'>XXXXX</a>
        result.add(StringUtils.format("{} : @{} 浏览了 <strong> {} </strong> <a href='{}'> {} </a>", DateUtils.showTime(visitLog.getCreateTime()), visitLog.getIp(), visitLog.getTitle(), visitLog.getUrl(), StringUtils.isEmpty(name) ? visitLog.getUrl() : name));
    }
    return result;
}
Also used : VisitLog(com.dimple.project.log.domain.VisitLog) ArrayList(java.util.ArrayList)

Example 2 with VisitLog

use of com.dimple.project.log.domain.VisitLog in project DimpleBlog by martin-chips.

the class AddressUpdateTask method updateVisitLogAddress.

private String updateVisitLogAddress() {
    List<VisitLog> visitLogList = visitLogMapper.selectVisitLogList(new VisitLog());
    Integer count = 0;
    for (VisitLog visitLog : visitLogList) {
        String ip = visitLog.getIp();
        if (StringUtils.isNotEmpty(ip)) {
            count++;
            String cityInfoByIp = AddressUtils.getCityInfoByIp(ip);
            visitLog.setLocation(cityInfoByIp);
            visitLogMapper.updateVisitLog(visitLog);
        }
    }
    return "VisitLog总数:" + visitLogList.size() + ";更新总数:" + count;
}
Also used : VisitLog(com.dimple.project.log.domain.VisitLog)

Example 3 with VisitLog

use of com.dimple.project.log.domain.VisitLog in project DimpleBlog by martin-chips.

the class VisitLogAspect method handleLog.

protected void handleLog(final JoinPoint joinPoint, final Exception e) {
    try {
        // 获得注解
        VLog vLog = getAnnotationLog(joinPoint);
        if (vLog == null) {
            return;
        }
        VisitLog visitLog = new VisitLog();
        visitLog.setPageId(getPageId(vLog, joinPoint));
        visitLog.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
        visitLog.setUrl(ServletUtils.getRequest().getRequestURI());
        if (e != null) {
            visitLog.setStatus(false);
            visitLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
        } else {
            visitLog.setStatus(true);
        }
        // 设置入口地址
        visitLog.setEntryUrl(ServletUtils.getRequest().getHeader("referer"));
        // 处理设置注解上的参数
        getControllerMethodDescription(vLog, visitLog);
        // 保存数据库
        AsyncManager.me().execute(AsyncFactory.recordVisitLog(visitLog));
    } catch (Exception exp) {
        // 记录本地异常日志
        log.error("异常信息:{}", exp.getMessage(), exp);
    }
}
Also used : VLog(com.dimple.framework.aspectj.lang.annotation.VLog) VisitLog(com.dimple.project.log.domain.VisitLog)

Aggregations

VisitLog (com.dimple.project.log.domain.VisitLog)3 VLog (com.dimple.framework.aspectj.lang.annotation.VLog)1 ArrayList (java.util.ArrayList)1