package cn.iocoder.yudao.module.server.dal.mysql.workorderType;

import java.util.*;

import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.server.dal.dataobject.workorderType.WorkorderTypeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.server.controller.admin.workorderType.vo.*;

/**
 * 工单类型 Mapper
 *
 * @author wyj
 */
@Mapper
public interface WorkorderTypeMapper extends BaseMapperX<WorkorderTypeDO> {

    default List<WorkorderTypeDO> selectList(WorkorderTypeListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WorkorderTypeDO>()
                .eqIfPresent(WorkorderTypeDO::getParentId, reqVO.getParentId())
                .likeIfPresent(WorkorderTypeDO::getName, reqVO.getName())
                .eqIfPresent(WorkorderTypeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(WorkorderTypeDO::getSuplier, reqVO.getSuplier())
                .likeIfPresent(WorkorderTypeDO::getRequirement, reqVO.getRequirement())
                .likeIfPresent(WorkorderTypeDO::getUploadInfo, reqVO.getUploadInfo())
                .eqIfPresent(WorkorderTypeDO::getProcessType, reqVO.getProcessType())
                .betweenIfPresent(WorkorderTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkorderTypeDO::getId));
    }

    default List<WorkorderTypeDO> selectListWorkorder(WorkorderTypeListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WorkorderTypeDO>()
                .eqIfPresent(WorkorderTypeDO::getParentId, reqVO.getParentId())
                .likeIfPresent(WorkorderTypeDO::getName, reqVO.getName())
                .neIfPresent(WorkorderTypeDO::getStatus, 0)
                .eqIfPresent(WorkorderTypeDO::getSuplier, reqVO.getSuplier())
                .likeIfPresent(WorkorderTypeDO::getRequirement, reqVO.getRequirement())
                .likeIfPresent(WorkorderTypeDO::getUploadInfo, reqVO.getUploadInfo())
                .eqIfPresent(WorkorderTypeDO::getProcessType, reqVO.getProcessType())
                .betweenIfPresent(WorkorderTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkorderTypeDO::getId));
    }

	default WorkorderTypeDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(WorkorderTypeDO::getParentId, parentId, WorkorderTypeDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(WorkorderTypeDO::getParentId, parentId);
    }

}