package com.cf.imes.module.executor.dal.mysql.module;

import java.util.*;

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.executor.dal.dataobject.module.ModuleDO;
import org.apache.ibatis.annotations.Mapper;
import com.cf.imes.module.executor.controller.admin.module.vo.*;

import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;

/**
 * 生产单模块 Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface ModuleMapper extends BaseMapperX<ModuleDO> {

    default PageResult<ModuleDO> selectPage(ModulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ModuleDO>()
                .eq(ModuleDO::getOrganId,getUserOrganId())
                .eqIfPresent(ModuleDO::getOrderId, reqVO.getOrderId())
                .likeIfPresent(ModuleDO::getName, reqVO.getName())
                .eqIfPresent(ModuleDO::getParentId, reqVO.getParentId())
                .eqIfPresent(ModuleDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(ModuleDO::getOfferId, reqVO.getOfferId())
                .eqIfPresent(ModuleDO::getType, reqVO.getType())
                .eqIfPresent(ModuleDO::getWidth, reqVO.getWidth())
                .eqIfPresent(ModuleDO::getHeight, reqVO.getHeight())
                .eqIfPresent(ModuleDO::getDepth, reqVO.getDepth())
                .eqIfPresent(ModuleDO::getMultiNum, reqVO.getMultiNum())
                .eqIfPresent(ModuleDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(ModuleDO::getPlateNum, reqVO.getPlateNum())
                .eqIfPresent(ModuleDO::getUnregularNum, reqVO.getUnregularNum())
                .likeIfPresent(ModuleDO::getFilename, reqVO.getFilename())
                .eqIfPresent(ModuleDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ModuleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ModuleDO::getId));
    }

}