package com.cf.imes.module.system.dal.mysql.process;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessPageReqVO;
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工序信息表 process Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface ProcessMapper extends BaseMapperX<ProcessDO> {

    default PageResult<ProcessDO> selectPage(ProcessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProcessDO>()
                .likeIfPresent(ProcessDO::getName, reqVO.getName())
                .eqIfPresent(ProcessDO::getPieceRate, reqVO.getPieceRate())
                .eqIfPresent(ProcessDO::getPieceType, reqVO.getPieceType())
                .eqIfPresent(ProcessDO::getType, reqVO.getType())
                .eqIfPresent(ProcessDO::getIsCustom, reqVO.getIsCustom())
                .eqIfPresent(ProcessDO::getIsDealer, reqVO.getIsDealer())
                .eqIfPresent(ProcessDO::getSort, reqVO.getSort())
                .eqIfPresent(ProcessDO::getHourCapacity, reqVO.getHourCapacity())
                .eqIfPresent(ProcessDO::getUnit, reqVO.getUnit())
                .eqIfPresent(ProcessDO::getIsEnabled, reqVO.getIsEnabled())
                .betweenIfPresent(ProcessDO::getPrepareTime, reqVO.getPrepareTime())
                .eqIfPresent(ProcessDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(ProcessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProcessDO::getId));
    }

    default List<ProcessDO> selectAll() {
        return selectList(new LambdaQueryWrapperX<ProcessDO>()
                .orderByDesc(ProcessDO::getId));
    }

}