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

import java.util.List;

/**
 * 专护服务记录 Mapper
 */
@Mapper
public interface ElderlySpecialServiceMapper extends BaseMapperX<ElderlySpecialServiceDO> {

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

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

