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

import java.util.*;
import java.util.stream.Collectors;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.zjtype.ZjTypeDO;
import com.alibaba.excel.util.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mes.controller.admin.zjtype.vo.*;

/**
 * 质量管理-检验类型 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface ZjTypeMapper extends BaseMapperX<ZjTypeDO> {

    default PageResult<ZjTypeDO> selectPage(ZjTypePageReqVO reqVO) {
        LambdaQueryWrapperX<ZjTypeDO> zjTypeDOLambdaQueryWrapperX = new LambdaQueryWrapperX<>();
        zjTypeDOLambdaQueryWrapperX
                .eqIfPresent(ZjTypeDO::getCode, reqVO.getCode())
                .likeIfPresent(ZjTypeDO::getName, reqVO.getName())
                .likeIfPresent(ZjTypeDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ZjTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ZjTypeDO::getId);

        if (StringUtils.isNotBlank(reqVO.getIds())) {
            List<Long> idList = Arrays.stream(reqVO.getIds().split(","))
                    .map(String::trim)
                    .map(Long::valueOf)
                    .collect(Collectors.toList());
            zjTypeDOLambdaQueryWrapperX.in(ZjTypeDO::getId, idList);
        }

        return selectPage(reqVO,zjTypeDOLambdaQueryWrapperX );
    }

}