package fcb.project.manager.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import fcb.project.manager.base.dao.TmAuditLogDao;
import fcb.project.manager.base.entity.TmAuditLog;
import fcb.project.manager.base.enums.AuditStatus;
import fcb.project.manager.base.service.ITmAuditLogService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * Created by Hb_zzZ on 2021/5/31.
 */
@Service
@Log4j2
public class TmAuditLogServiceImpl extends ServiceImpl<TmAuditLogDao, TmAuditLog> implements ITmAuditLogService {

    public IPage<TmAuditLog> queryAuditLogList(Long pageNum , Long pageSize , String houseId){
        IPage<TmAuditLog> page = new Page<>(pageNum , pageSize);
        LambdaQueryWrapper<TmAuditLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.ne(TmAuditLog::getAuditStatus , AuditStatus.WAITING_AUDIT.getCode());
        lambdaQueryWrapper.ne(TmAuditLog::getAuditStatus , AuditStatus.SHOOT_AUDIT.getCode());
        lambdaQueryWrapper.eq(TmAuditLog::getVrId , houseId);

        lambdaQueryWrapper.or(wrapper -> wrapper.eq(TmAuditLog::getAuditType, 0).eq(TmAuditLog::getVrId , houseId));
        lambdaQueryWrapper.orderByDesc(TmAuditLog::getAuditTime);
        return getBaseMapper().selectPage(page , lambdaQueryWrapper);
    }
}
