package cn.iocoder.yudao.module.basic.dal.mysql.goodscategory;

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.basic.dal.dataobject.goodscategory.GoodsCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.basic.controller.admin.goodscategory.vo.*;

/**
 * 商品分类表。分类的编号为 C 开头，如：C100001 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface GoodsCategoryMapper extends BaseMapperX<GoodsCategoryDO> {

    default PageResult<GoodsCategoryDO> selectPage(GoodsCategoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GoodsCategoryDO>()
                .likeIfPresent(GoodsCategoryDO::getName, reqVO.getName())
                .eqIfPresent(GoodsCategoryDO::getPid, reqVO.getPid())
                .eqIfPresent(GoodsCategoryDO::getParentIdPath, reqVO.getParentIdPath())
                .eqIfPresent(GoodsCategoryDO::getLevel, reqVO.getLevel())
                .eqIfPresent(GoodsCategoryDO::getSequence, reqVO.getSequence())
                .betweenIfPresent(GoodsCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GoodsCategoryDO::getId));
    }

    default List<GoodsCategoryDO> selectList(GoodsCategoryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GoodsCategoryDO>()
                .likeIfPresent(GoodsCategoryDO::getName, reqVO.getName())
                .eqIfPresent(GoodsCategoryDO::getPid, reqVO.getPid())
                .eqIfPresent(GoodsCategoryDO::getParentIdPath, reqVO.getParentIdPath())
                .eqIfPresent(GoodsCategoryDO::getLevel, reqVO.getLevel())
                .eqIfPresent(GoodsCategoryDO::getSequence, reqVO.getSequence())
                .betweenIfPresent(GoodsCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GoodsCategoryDO::getId));
    }

}
