Search in sources :

Example 1 with SysLog

use of com.zyd.blog.persistence.beans.SysLog in project OneBlog by zhangyd-c.

the class SysLogServiceImpl method asyncSaveSystemLog.

@Async
@Override
public void asyncSaveSystemLog(PlatformEnum platform, String bussinessName) {
    String ua = RequestUtil.getUa();
    Log sysLog = new Log();
    sysLog.setLogLevel(LogLevelEnum.INFO);
    sysLog.setType(platform.equals(PlatformEnum.WEB) ? LogTypeEnum.VISIT : LogTypeEnum.SYSTEM);
    sysLog.setIp(RequestUtil.getIp());
    sysLog.setReferer(RequestUtil.getReferer());
    sysLog.setRequestUrl(RequestUtil.getRequestUrl());
    sysLog.setUa(ua);
    sysLog.setSpiderType(WebSpiderUtils.parseUa(ua));
    sysLog.setParams(JSONObject.toJSONString(RequestUtil.getParametersMap()));
    User user = SessionUtil.getUser();
    if (user != null) {
        sysLog.setUserId(user.getId());
        sysLog.setContent(String.format("用户: [%s] | 操作: %s", user.getUsername(), bussinessName));
    } else {
        sysLog.setContent(String.format("访客: [%s] | 操作: %s", sysLog.getIp(), bussinessName));
    }
    try {
        UserAgent agent = UserAgent.parseUserAgentString(ua);
        sysLog.setBrowser(agent.getBrowser().getName());
        sysLog.setOs(agent.getOperatingSystem().getName());
        this.insert(sysLog);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : User(com.zyd.blog.business.entity.User) SysLog(com.zyd.blog.persistence.beans.SysLog) Log(com.zyd.blog.business.entity.Log) UserAgent(eu.bitwalker.useragentutils.UserAgent) Async(org.springframework.scheduling.annotation.Async)

Example 2 with SysLog

use of com.zyd.blog.persistence.beans.SysLog in project OneBlog by zhangyd-c.

the class SysLogServiceImpl method findPageBreakByCondition.

@Override
public PageInfo<Log> findPageBreakByCondition(LogConditionVO vo) {
    PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
    List<SysLog> list = sysLogMapper.findPageBreakByCondition(vo);
    if (CollectionUtils.isEmpty(list)) {
        return null;
    }
    List<Log> boList = new ArrayList<>();
    for (SysLog sysLog : list) {
        boList.add(new Log(sysLog));
    }
    PageInfo bean = new PageInfo<SysLog>(list);
    bean.setList(boList);
    return bean;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) SysLog(com.zyd.blog.persistence.beans.SysLog) Log(com.zyd.blog.business.entity.Log) SysLog(com.zyd.blog.persistence.beans.SysLog) ArrayList(java.util.ArrayList)

Example 3 with SysLog

use of com.zyd.blog.persistence.beans.SysLog in project OneBlog by zhangyd-c.

the class SysLogServiceImpl method getByPrimaryKey.

@Override
public Log getByPrimaryKey(Integer primaryKey) {
    Assert.notNull(primaryKey, "PrimaryKey不可为空!");
    SysLog entity = sysLogMapper.selectByPrimaryKey(primaryKey);
    return null == entity ? null : new Log(entity);
}
Also used : SysLog(com.zyd.blog.persistence.beans.SysLog) Log(com.zyd.blog.business.entity.Log) SysLog(com.zyd.blog.persistence.beans.SysLog)

Aggregations

Log (com.zyd.blog.business.entity.Log)3 SysLog (com.zyd.blog.persistence.beans.SysLog)3 PageInfo (com.github.pagehelper.PageInfo)1 User (com.zyd.blog.business.entity.User)1 UserAgent (eu.bitwalker.useragentutils.UserAgent)1 ArrayList (java.util.ArrayList)1 Async (org.springframework.scheduling.annotation.Async)1