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

import java.util.List;

@Mapper
public interface ElderlyLifeAssistantInspectionMapper extends BaseMapperX<ElderlyLifeAssistantInspectionDO> {

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

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