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

import java.util.List;

/**
 * 日常照顾记录 Mapper
 */
@Mapper
public interface ElderlyDailyCareMapper extends BaseMapperX<ElderlyDailyCareDO> {

    default PageResult<ElderlyDailyCareDO> selectPage(ElderlyDailyCarePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ElderlyDailyCareDO>()
                .eqIfPresent(ElderlyDailyCareDO::getRecordMonth, reqVO.getRecordMonth())
                .inIfPresent(ElderlyDailyCareDO::getTenantId, reqVO.getTenantIds())
                .orderByDesc(ElderlyDailyCareDO::getRecordMonth)
                .orderByDesc(ElderlyDailyCareDO::getId));
    }

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

