package com.yc.ship.module.resource.dal.mysql.audit;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.resource.controller.admin.audit.vo.AuditPageReqVO;
import com.yc.ship.module.resource.dal.dataobject.audit.AuditDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 审核记录 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface AuditMapper extends BaseMapperX<AuditDO> {

    default PageResult<AuditDO> selectPage(AuditPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AuditDO>()
                .eqIfPresent(AuditDO::getObjId, reqVO.getObjId())
                .eqIfPresent(AuditDO::getAuditType, reqVO.getAuditType())
                .eqIfPresent(AuditDO::getAuditStatus, reqVO.getAuditStatus())
                .betweenIfPresent(AuditDO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(AuditDO::getAuditor, reqVO.getAuditor())
                .betweenIfPresent(AuditDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(AuditDO::getCreateTime));
    }
    default List<AuditDO> getAuditNewInfo(AuditPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AuditDO>()
            .eqIfPresent(AuditDO::getObjId, reqVO.getObjId())
            .eqIfPresent(AuditDO::getAuditType, reqVO.getAuditType())
            .orderByDesc(AuditDO::getCreateTime)
        );
    }

}
