package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.Customer;
import com.uas.platform.core.data.repository.GenericRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CustomerDao extends JpaSpecificationExecutor<Customer>, GenericRepository<Customer, Long> {

    /**
     * 获得每种单据状态的未读数量
     *
     * @Param ids 单据id
     * @return
     */
    @Query("select count(p), p.status from Customer p where p.id in :ids group by p.status")
    List<Object[]> getUnreadCountEveryStatus(@Param("ids") List<Long> ids);
}
