package com.yhy.module.core.dal.mysql.infoprice;

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 com.yhy.module.core.controller.admin.infoprice.vo.InfoPriceResourcePageReqVO;
import com.yhy.module.core.dal.dataobject.infoprice.InfoPriceResourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 信息价工料机信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface InfoPriceResourceMapper extends BaseMapperX<InfoPriceResourceDO> {

    default PageResult<InfoPriceResourceDO> selectPage(InfoPriceResourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InfoPriceResourceDO>()
                .eq(InfoPriceResourceDO::getCategoryTreeId, reqVO.getCategoryTreeId())
                .likeIfPresent(InfoPriceResourceDO::getCode, reqVO.getCode())
                .likeIfPresent(InfoPriceResourceDO::getName, reqVO.getName())
                .orderByAsc(InfoPriceResourceDO::getSortOrder));
    }

    default List<InfoPriceResourceDO> selectListByCategoryTreeId(Long categoryTreeId) {
        return selectList(new LambdaQueryWrapperX<InfoPriceResourceDO>()
                .eq(InfoPriceResourceDO::getCategoryTreeId, categoryTreeId)
                .orderByAsc(InfoPriceResourceDO::getSortOrder));
    }

    default InfoPriceResourceDO selectByCategoryTreeIdAndCode(Long categoryTreeId, String code) {
        return selectOne(new LambdaQueryWrapperX<InfoPriceResourceDO>()
                .eq(InfoPriceResourceDO::getCategoryTreeId, categoryTreeId)
                .eq(InfoPriceResourceDO::getCode, code));
    }

}
