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();
}
}
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;
}
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);
}
Aggregations