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

import java.util.List;

/**
 * 九防措施单 Mapper
 */
@Mapper
public interface NinePreventiveMeasuresMapper extends BaseMapperX<NinePreventiveMeasuresDO> {

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

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