| | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.dto.OperLogDTO; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.OperLogService; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.ip.AddressUtils; |
| | | import com.ruoyi.common.log.event.OperLogEvent; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | import com.ruoyi.system.mapper.SysOperLogMapper; |
| | | import com.ruoyi.system.service.ISysOperLogService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.event.EventListener; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, SysOperLog, SysOperLog> implements ISysOperLogService, OperLogService { |
| | | public class SysOperLogServiceImpl implements ISysOperLogService { |
| | | |
| | | private final SysOperLogMapper baseMapper; |
| | | |
| | | /** |
| | | * 操作日志记录 |
| | | * |
| | | * @param operLogDTO 操作日志信息 |
| | | * @param operLogEvent 操作日志事件 |
| | | */ |
| | | @Async |
| | | @Override |
| | | public void recordOper(final OperLogDTO operLogDTO) { |
| | | SysOperLog operLog = BeanUtil.toBean(operLogDTO, SysOperLog.class); |
| | | @EventListener |
| | | public void recordOper(OperLogEvent operLogEvent) { |
| | | SysOperLog operLog = BeanUtil.toBean(operLogEvent, SysOperLog.class); |
| | | // 远程查询操作地点 |
| | | operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); |
| | | insertOperlog(operLog); |
| | |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")); |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id").setIsAsc("desc"); |
| | | if (StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id"); |
| | | pageQuery.setIsAsc("desc"); |
| | | } |
| | | Page<SysOperLog> page = page(PageUtils.buildPage(pageQuery), lqw); |
| | | return PageUtils.buildDataInfo(page); |
| | | Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void insertOperlog(SysOperLog operLog) { |
| | | operLog.setOperTime(new Date()); |
| | | save(operLog); |
| | | baseMapper.insert(operLog); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | return list(new LambdaQueryWrapper<SysOperLog>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | |
| | | */ |
| | | @Override |
| | | public SysOperLog selectOperLogById(Long operId) { |
| | | return getById(operId); |
| | | return baseMapper.selectById(operId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void cleanOperLog() { |
| | | remove(new LambdaQueryWrapper<>()); |
| | | baseMapper.delete(new LambdaQueryWrapper<>()); |
| | | } |
| | | } |