package cn.iocoder.yudao.module.mes.dal.mysql.record;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mes.controller.admin.record.vo.RecordTemplatePageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.record.RecordTemplateDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 记录表 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface RecordTemplateMapper extends BaseMapperX<RecordTemplateDO> {

    default PageResult<RecordTemplateDO> selectPage(RecordTemplatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecordTemplateDO>()
                .likeIfPresent(RecordTemplateDO::getName, reqVO.getName())
                .eqIfPresent(RecordTemplateDO::getOrganizationId, reqVO.getOrganizationId())
                .eqIfPresent(RecordTemplateDO::getMachineId, reqVO.getMachineId())
                .eqIfPresent(RecordTemplateDO::getWorkTeamId, reqVO.getWorkTeamId())
                .betweenIfPresent(RecordTemplateDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(RecordTemplateDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(RecordTemplateDO::getGroupManagerApproveId1, reqVO.getGroupManagerApproveId1())
                .eqIfPresent(RecordTemplateDO::getGroupManagerApproveId2, reqVO.getGroupManagerApproveId2())
                .eqIfPresent(RecordTemplateDO::getProductionManagerApproveId1, reqVO.getProductionManagerApproveId1())
                .eqIfPresent(RecordTemplateDO::getProductionManagerApproveId2, reqVO.getProductionManagerApproveId2())
                .eqIfPresent(RecordTemplateDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .eqIfPresent(RecordTemplateDO::getStatus, reqVO.getStatus())
                .eqIfPresent(RecordTemplateDO::getRecordType, reqVO.getRecordType())
                .eqIfPresent(RecordTemplateDO::getRemark, reqVO.getRemark())
                .eqIfPresent(RecordTemplateDO::getIsEnable, reqVO.getIsEnable())
                .betweenIfPresent(RecordTemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecordTemplateDO::getId));
    }

}