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

import java.util.List;

/**
 * 长者护理记录 Mapper
 */
@Mapper
public interface ElderlyNursingLogMapper extends BaseMapperX<ElderlyNursingLogDO> {

    default PageResult<ElderlyNursingLogDO> selectPage(ElderlyNursingLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ElderlyNursingLogDO>()
                .betweenIfPresent(ElderlyNursingLogDO::getNurseDate, reqVO.getNurseDate())
                .inIfPresent(ElderlyNursingLogDO::getTenantId, reqVO.getTenantIds())
                .orderByDesc(ElderlyNursingLogDO::getNurseDate)
                .orderByDesc(ElderlyNursingLogDO::getId));
    }

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