package cn.ysk.cashier.cons.repository;

import cn.ysk.cashier.cons.domain.TbConsType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
* @website https://eladmin.vip
* @author admin
* @date 2024-06-22
**/
public interface TbConsTypeRepository extends JpaRepository<TbConsType, Integer>, JpaSpecificationExecutor<TbConsType> {

    int countByConTypeCode(String conTypeCode);

    TbConsType findByConTypeCode(String conTypeCode);

    @Query("SELECT count(*) FROM TbProskuCon c LEFT JOIN TbConsInfo i ON c.conInfoId = i.id WHERE i.conTypeId = :id")
    int countProByTypeId(Integer id);
}
