保誠-保戶業務員媒合平台
wayne
2022-02-17 34b08e1c461f5e08675fcff95525956d7c4bef11
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.pollex.pam.web.rest;
 
import java.util.List;
 
import com.pollex.pam.enums.SatisfactionTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.security.SecurityUtils;
import com.pollex.pam.service.SatisfactionService;
import com.pollex.pam.service.dto.SatisfactionCustomerScoreDTO;
import com.pollex.pam.service.dto.SatisfactionDTO;
 
@RestController
@RequestMapping("/api/satisfaction")
public class SatisfactionResource {
 
    private final Logger log = LoggerFactory.getLogger(SatisfactionResource.class);
 
 
    @Autowired
    SatisfactionService satisfactionService;
 
    @PostMapping("/score")
    public Satisfaction scorefaction(@RequestBody SatisfactionCustomerScoreDTO scoreDTO) {
        return satisfactionService.scorefaction(scoreDTO);
    }
 
    @PostMapping("/score/all")
    public List<Satisfaction> scoreAllfaction(@RequestBody List<SatisfactionCustomerScoreDTO> scoreDTO) {
        return satisfactionService.scoreAllfaction(scoreDTO);
    }
 
    @GetMapping("/getMySatisfaction")
    public List<SatisfactionDTO> getMySatisfaction(){
        if(StringUtils.hasText(SecurityUtils.getAgentNo())) {
            return satisfactionService.getByAgentNoAndType(SecurityUtils.getAgentNo(), SatisfactionTypeEnum.APPOINTMENT);
        }else if(SecurityUtils.getCustomerDBId()!=null){
            return satisfactionService.getByCustomerId(SecurityUtils.getCustomerDBId());
        }
        log.error("Not has agent code and customer id");
        throw new IllegalArgumentException("Not has agent code and customer id");
    }
}