package com.pollex.pam.web.rest;
|
|
import java.util.List;
|
|
import com.pollex.pam.business.aop.logging.audit.AuditLoggingInject;
|
import com.pollex.pam.business.aop.logging.audit.AuditLoggingType;
|
import com.pollex.pam.business.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.business.domain.Satisfaction;
|
import com.pollex.pam.business.security.SecurityUtils;
|
import com.pollex.pam.business.service.SatisfactionService;
|
import com.pollex.pam.business.service.dto.SatisfactionCustomerScoreDTO;
|
import com.pollex.pam.business.service.dto.SatisfactionDTO;
|
|
@RestController
|
@RequestMapping("/api/satisfaction")
|
public class SatisfactionResource {
|
|
private final Logger log = LoggerFactory.getLogger(SatisfactionResource.class);
|
|
|
@Autowired
|
SatisfactionService satisfactionService;
|
|
@AuditLoggingInject(type = AuditLoggingType.CUSTOMER_FILL_SATISFACTION)
|
@PostMapping("/score")
|
public Satisfaction scorefaction(@RequestBody SatisfactionCustomerScoreDTO scoreDTO) {
|
return satisfactionService.scorefaction(scoreDTO);
|
}
|
|
@AuditLoggingInject(type = AuditLoggingType.CUSTOMER_FILL_SATISFACTION)
|
@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");
|
}
|
}
|