package cn.iocoder.byzs.module.infra.dal.mysql.demo;

import java.util.*;

import pojo.cn.iocoder.byzs.framework.common.PageResult;
import query.core.mybatis.cn.iocoder.byzs.framework.LambdaQueryWrapperX;
import mapper.core.mybatis.cn.iocoder.byzs.framework.BaseMapperX;
import cn.iocoder.byzs.module.infra.dal.dataobject.demo.InfraCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.byzs.module.infra.controller.admin.demo.vo.*;

/**
 * 分类 Mapper
 *
 * @author 博雅智算源码
 */
@Mapper
public interface InfraCategoryMapper extends BaseMapperX<InfraCategoryDO> {

    default List<InfraCategoryDO> selectList(InfraCategoryListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InfraCategoryDO>()
                .likeIfPresent(InfraCategoryDO::getName, reqVO.getName())
                .orderByDesc(InfraCategoryDO::getId));
    }

	default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(InfraCategoryDO::getParentId, parentId);
    }

}