package cn.iocoder.yudao.module.system.dal.mysql.biz;

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.api.bpm.vo.PriceChangeRecordReqVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.PriceChangeRecordPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.PriceChangeRecordDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * @Author: jinyd
 * @CreateTime: 2024/8/29  10:14
 * @Description:
 * @Version: 4.0
 */

@Mapper
public interface PriceChangeRecordMapper extends BaseMapperX<PriceChangeRecordDO> {

    default PageResult<PriceChangeRecordDO> selectPage(PriceChangeRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PriceChangeRecordDO>()
                .eqIfPresent(PriceChangeRecordDO::getChangeId, reqVO.getChangeId())
                .eqIfPresent(PriceChangeRecordDO::getOriginalId, reqVO.getOriginalId())
                .likeIfPresent(PriceChangeRecordDO::getOriginalName, reqVO.getOriginalName())
                .eqIfPresent(PriceChangeRecordDO::getAmount, reqVO.getAmount())
                .betweenIfPresent(PriceChangeRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PriceChangeRecordDO::getId));
    }

    List<PriceChangeRecordReqVO> selectListByChangeId(@Param("elderlyId") Long elderlyId,
                                                      @Param("changeDate") LocalDate changeDate);
}
