保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.pollex.pam.repository;
 
import java.util.List;
import java.util.Optional;
 
import com.pollex.pam.enums.SatisfactionStatusEnum;
import com.pollex.pam.enums.SatisfactionTypeEnum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
 
import com.pollex.pam.domain.Satisfaction;
 
@Repository
public interface SatisfactionRepository extends JpaRepository<Satisfaction, Long>{
 
    List<Satisfaction> findByAgentNoAndType(String agentNo, SatisfactionTypeEnum type);
 
    List<Satisfaction> findByCustomerId(Long customerId);
 
    Optional<Satisfaction> findOneByAppointmentIdAndType(Long appointmentId, SatisfactionTypeEnum type);
 
    List<Satisfaction> findAllByStatusAndType(SatisfactionStatusEnum status, SatisfactionTypeEnum type);
 
    @Query(value = "SELECT avg(score) FROM satisfaction where type='APPOINTMENT'"
            + " and agent_no=:agent_no"
            + " and score is not null"
            , nativeQuery = true)
    Optional<Float> getAgentScoreAvg(@Param("agent_no") String agentNo);
}