package com.rf.psychological.miniapp.praise.repository;

import com.rf.psychological.base.repository.BaseRepository;
import com.rf.psychological.miniapp.praise.model.PraiseEntity;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @Description:点赞接口
 * @Author: mimang
 * @Date: 2023/5/26
 */
public interface PraiseRepository extends BaseRepository<PraiseEntity,String> {

    @Query(value = "select type,count(type) as num from t_praise_log where business_id =:businessId and status=0 group by type",nativeQuery = true)
    List<Map> queryAllByBusinessIdGroupByType(String businessId);

    PraiseEntity findByBusinessIdAndUserIdAndTypeAndStatus(String businessId, String userId, String type, String defaultValueOne);
    PraiseEntity findByBusinessIdAndUserIdAndStatus(String businessId, String userId,  String defaultValueOne);
}
