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

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.orgworker.vo.OrgWorkerPageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工位安排 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface OrgWorkerMapper extends BaseMapperX<OrgWorkerDO> {

    default PageResult<OrgWorkerDO> selectPage(OrgWorkerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrgWorkerDO>()
                .eqIfPresent(OrgWorkerDO::getOrgId, reqVO.getOrgId())
                .eqIfPresent(OrgWorkerDO::getOrgType, reqVO.getOrgType())
                .betweenIfPresent(OrgWorkerDO::getWorkDate, reqVO.getWorkDate())
                .eqIfPresent(OrgWorkerDO::getGroupType, reqVO.getGroupType())
                .eqIfPresent(OrgWorkerDO::getWorkerId, reqVO.getWorkerId())
                .eqIfPresent(OrgWorkerDO::getReportId, reqVO.getReportId())
                .betweenIfPresent(OrgWorkerDO::getCreateTime, reqVO.getCreateTime())
                .in(reqVO.getOrgIds()!=null&&reqVO.getOrgIds().size()>0,OrgWorkerDO::getOrgId, reqVO.getOrgIds())
                .orderByDesc(OrgWorkerDO::getWorkDate));
    }
    default List<OrgWorkerDO> selectList(OrgWorkerPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrgWorkerDO>()
                .eqIfPresent(OrgWorkerDO::getWorkerId, reqVO.getWorkerId())
                .eqIfPresent(OrgWorkerDO::getOrgId, reqVO.getOrgId())
                .eqIfPresent(OrgWorkerDO::getOrgType, reqVO.getOrgType())
                .eqIfPresent(OrgWorkerDO::getGroupType, reqVO.getGroupType())
                .betweenIfPresent(OrgWorkerDO::getWorkDate, reqVO.getWorkDate())
                .betweenIfPresent(OrgWorkerDO::getCreateTime, reqVO.getCreateTime())
                .in(reqVO.getOrgIds()!=null&&reqVO.getOrgIds().size()>0,
                        OrgWorkerDO::getOrgId, reqVO.getOrgIds())
                .in(reqVO.getWorkerIds()!=null&&reqVO.getWorkerIds().size()>0,
                        OrgWorkerDO::getWorkerId, reqVO.getWorkerIds())
                .orderByAsc(OrgWorkerDO::getId));
    }
}