package cn.ysk.cashier.repository.product;
import cn.ysk.cashier.pojo.product.TbProductGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
* @website https://eladmin.vip
* @author lyf
* @date 2023-12-16
**/
public interface TbProductGroupRepository extends JpaRepository<TbProductGroup, Integer>, JpaSpecificationExecutor<TbProductGroup> {

//    @Query("SELECT u FROM User u WHERE u.userName = :userName")
//    User findByUserName(@Param("userName") String userName);

    @Query("select groups from TbProductGroup groups where groups.name = :userName and groups.shopId = :shopId")
    TbProductGroup findByName(@Param("userName") String userName, @Param("shopId") Integer shopId);


    @Query("SELECT groups from TbProductGroup groups where groups.id in :productIds order by groups.sort")
    List<TbProductGroup> findByIds(List<Integer> productIds);
}