package cn.iocoder.yudao.module.system.dal.mysql.biz;


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.system.controller.admin.biz.vo.MedicationPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.MedicationDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 长者用药 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface MedicationMapper extends BaseMapperX<MedicationDO> {

    default PageResult<MedicationDO> selectPage(MedicationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MedicationDO>()
                .eqIfPresent(MedicationDO::getElderId, reqVO.getElderId())
                .likeIfPresent(MedicationDO::getDrugName, reqVO.getDrugName())
                .eqIfPresent(MedicationDO::getByodRegistrationDrugId, reqVO.getByodRegistrationDrugId())
                .eqIfPresent(MedicationDO::getDosage, reqVO.getDosage())
                .eqIfPresent(MedicationDO::getFrequency, reqVO.getFrequency())
                .betweenIfPresent(MedicationDO::getAdministrationTime, reqVO.getAdministrationTime())
                .eqIfPresent(MedicationDO::getAdministrationRoute, reqVO.getAdministrationRoute())
                .betweenIfPresent(MedicationDO::getEnabledTime, reqVO.getEnabledTime())
                .eqIfPresent(MedicationDO::getEnableDoctorId, reqVO.getEnableDoctorId())
                .likeIfPresent(MedicationDO::getEnableDoctorName, reqVO.getEnableDoctorName())
                .likeIfPresent(MedicationDO::getStopUsingMedicalName, reqVO.getStopUsingMedicalName())
                .eqIfPresent(MedicationDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(MedicationDO::getType, reqVO.getType())
                .eqIfPresent(MedicationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MedicationDO::getCreatedTime, reqVO.getCreatedTime())
                .eqIfPresent(MedicationDO::getCreatedBy, reqVO.getCreatedBy())
                .eqIfPresent(MedicationDO::getUpdateBy, reqVO.getUpdateBy())
                .orderByDesc(MedicationDO::getCreatedTime));
    }

}