package cn.iocoder.yudao.module.visit.dal.mysql.product;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.visit.dal.dataobject.product.ProductDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.visit.controller.admin.product.vo.*;

/**
 * 产品 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ProductMapper extends BaseMapperX<ProductDO> {

    default ProductDO selectByProductParam(String productName, String specification, String packageName) {
        return selectOne(ProductDO::getProductName, productName,  ProductDO::getSpecification, specification, ProductDO::getPackageName, packageName);
    }

    default PageResult<ProductDO> selectPage(ProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>()
                .likeIfPresent(ProductDO::getProductName, reqVO.getProductName())
                .eqIfPresent(ProductDO::getPackageName, reqVO.getPackageName())
                .eqIfPresent(ProductDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(ProductDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductDO::getId));
    }

}