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

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.elderly.vo.ElderlyNasalFeedingPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.elderly.ElderlyNasalFeedingDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 鼻饲记录 Mapper
 */
@Mapper
public interface ElderlyNasalFeedingMapper extends BaseMapperX<ElderlyNasalFeedingDO> {

    default PageResult<ElderlyNasalFeedingDO> selectPage(ElderlyNasalFeedingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ElderlyNasalFeedingDO>()
                .betweenIfPresent(ElderlyNasalFeedingDO::getRecordDate, reqVO.getRecordDate())
                .inIfPresent(ElderlyNasalFeedingDO::getTenantId, reqVO.getTenantIds())
                .orderByDesc(ElderlyNasalFeedingDO::getRecordDate)
                .orderByDesc(ElderlyNasalFeedingDO::getId));
    }

    default List<ElderlyNasalFeedingDO> selectByElderId(Long elderId) {
        return selectList(new LambdaQueryWrapper<ElderlyNasalFeedingDO>()
                .eq(ElderlyNasalFeedingDO::getElderId, elderId)
                .orderByDesc(ElderlyNasalFeedingDO::getRecordDate));
    }
}

