All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zznote.basecommon.service.impl.TOperLogServiceImpl Maven / Gradle / Ivy

The newest version!
package com.zznote.basecommon.service.impl;


import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zznote.basecommon.common.page.PageInfo;
import com.zznote.basecommon.common.page.PageQuery;
import com.zznote.basecommon.dao.TOperLogDao;
import com.zznote.basecommon.entity.system.TOperLog;
import com.zznote.basecommon.service.TOperLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service("tOperLogService")
public class TOperLogServiceImpl extends ServiceImpl implements TOperLogService {

    @Override
    public PageInfo selectPageOperLogList(TOperLog operLog, PageQuery pageQuery) {
        Map params = operLog.getParams();
        LambdaQueryWrapper lqw = new LambdaQueryWrapper()
                .like(StringUtils.isNotBlank(operLog.getTitle()), TOperLog::getTitle, operLog.getTitle())
                .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
                        TOperLog::getBusinessType, operLog.getBusinessType())
                .func(f -> {
                    if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
                        f.in(TOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
                    }
                })
                .eq(operLog.getStatus() != null,
                        TOperLog::getStatus, operLog.getStatus())
                .like(StringUtils.isNotBlank(operLog.getOperName()), TOperLog::getOperName, operLog.getOperName())
                .between(params.get("beginTime") != null && params.get("endTime") != null,
                        TOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
        if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
            pageQuery.setOrderByColumn("oper_id");
            pageQuery.setIsAsc("desc");
        }
        Page page = (Page) baseMapper.selectPage(pageQuery.build(), lqw);
        return PageInfo.build(page);
    }

    /**
     * 查询系统操作日志集合
     *
     * @param operLog 操作日志对象
     * @return 操作日志集合
     */
    @Override
    public List selectOperLogList(TOperLog operLog) {
        Map params = operLog.getParams();
        return baseMapper.selectList(new LambdaQueryWrapper()
                .like(StringUtils.isNotBlank(operLog.getTitle()), TOperLog::getTitle, operLog.getTitle())
                .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
                        TOperLog::getBusinessType, operLog.getBusinessType())
                .func(f -> {
                    if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
                        f.in(TOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
                    }
                })
                .eq(operLog.getStatus() != null && operLog.getStatus() > 0,
                        TOperLog::getStatus, operLog.getStatus())
                .like(StringUtils.isNotBlank(operLog.getOperName()), TOperLog::getOperName, operLog.getOperName())
                .between(params.get("beginTime") != null && params.get("endTime") != null,
                        TOperLog::getOperTime, params.get("beginTime"), params.get("endTime"))
                .orderByDesc(TOperLog::getOperId));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy