package com.jojubanking.boot.module.system.dal.mysql.dztype;

import java.util.*;

import com.jojubanking.boot.framework.common.pojo.PageResult;
import com.jojubanking.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jojubanking.boot.framework.mybatis.core.mapper.BaseMapperX;
import com.jojubanking.boot.module.system.dal.dataobject.dztype.DzTypeDO;
import org.apache.ibatis.annotations.Mapper;
import com.jojubanking.boot.module.system.controller.admin.dztype.vo.*;

/**
 * 导诊类型 Mapper
 *
 * @author admin
 */
@Mapper
public interface DzTypeMapper extends BaseMapperX<DzTypeDO> {

    default PageResult<DzTypeDO> selectPage(DzTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DzTypeDO>()
                .eqIfPresent(DzTypeDO::getBodyAreaType, reqVO.getBodyAreaType())
                .likeIfPresent(DzTypeDO::getBodyAreaName, reqVO.getBodyAreaName())
                .eqIfPresent(DzTypeDO::getQuestionType, reqVO.getQuestionType())
                .likeIfPresent(DzTypeDO::getQuestionTypeName, reqVO.getQuestionTypeName())
                .betweenIfPresent(DzTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DzTypeDO::getId));
    }

    default PageResult<DzTypeDO> selectPage1(DzTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DzTypeDO>()
                .eqIfPresent(DzTypeDO::getBodyAreaType, reqVO.getBodyAreaType())
                .likeIfPresent(DzTypeDO::getBodyAreaName, reqVO.getBodyAreaName())
                .eqIfPresent(DzTypeDO::getQuestionType, reqVO.getQuestionType())
                .likeIfPresent(DzTypeDO::getQuestionTypeName, reqVO.getQuestionTypeName())
                .betweenIfPresent(DzTypeDO::getCreateTime, reqVO.getCreateTime())
                .last("group by body_area_type ORDER BY id"));
    }
    default PageResult<DzTypeDO> selectPage2(DzTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DzTypeDO>()
                .eqIfPresent(DzTypeDO::getBodyAreaType, reqVO.getBodyAreaType())
                .likeIfPresent(DzTypeDO::getBodyAreaName, reqVO.getBodyAreaName())
                .eqIfPresent(DzTypeDO::getQuestionType, reqVO.getQuestionType())
                .likeIfPresent(DzTypeDO::getQuestionTypeName, reqVO.getQuestionTypeName())
                .betweenIfPresent(DzTypeDO::getCreateTime, reqVO.getCreateTime())
                .last("ORDER BY question_type"));
    }

    default List<DzTypeDO> selectList(DzTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DzTypeDO>()
                .eqIfPresent(DzTypeDO::getBodyAreaType, reqVO.getBodyAreaType())
                .likeIfPresent(DzTypeDO::getBodyAreaName, reqVO.getBodyAreaName())
                .eqIfPresent(DzTypeDO::getQuestionType, reqVO.getQuestionType())
                .likeIfPresent(DzTypeDO::getQuestionTypeName, reqVO.getQuestionTypeName())
                .betweenIfPresent(DzTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DzTypeDO::getId));
    }

}
