Search in sources :

Example 1 with VLog

use of com.dimple.framework.aspectj.lang.annotation.VLog in project DimpleBlog by martin-chips.

the class FrontController method blogDetail.

@GetMapping("/blog/{id}")
@VLog(title = "查看博客", pageId = "#id")
public AjaxResult blogDetail(@PathVariable Long id) {
    Blog blog = frontService.selectBlogDetailById(id);
    frontService.incrementBlogClick(id);
    return AjaxResult.success(blog);
}
Also used : Blog(com.dimple.project.blog.domain.Blog) GetMapping(org.springframework.web.bind.annotation.GetMapping) VLog(com.dimple.framework.aspectj.lang.annotation.VLog)

Example 2 with VLog

use of com.dimple.framework.aspectj.lang.annotation.VLog 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

VLog (com.dimple.framework.aspectj.lang.annotation.VLog)2 Blog (com.dimple.project.blog.domain.Blog)1 VisitLog (com.dimple.project.log.domain.VisitLog)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1