From 463ba2f5b7e5ae094c33b1692a74b7f7aa58aad5 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期二, 08 二月 2022 12:20:56 +0800
Subject: [PATCH] [add] [todo 134582] 系統滿意度填寫api

---
 pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java      |   20 ++--
 pamapi/src/doc/sql/20220126_w.sql                                               |    6 +
 pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java                    |   14 +++
 pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java      |   10 +-
 pamapi/src/doc/滿意度/客戶填寫顧問滿意度.txt                                                |    0 
 pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java        |   16 ++--
 pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java       |    9 +-
 pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java            |    8 +
 pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java    |    4 
 pamapi/src/doc/滿意度/客戶填寫平台滿意度.txt                                                |   22 +++++
 pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java   |    6 
 pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java            |   30 +++++--
 pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionSystemScoreDTO.java |   23 +++++
 pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java          |   24 +++--
 14 files changed, 140 insertions(+), 52 deletions(-)

diff --git a/pamapi/src/doc/sql/20220126_w.sql b/pamapi/src/doc/sql/20220126_w.sql
new file mode 100644
index 0000000..7b79825
--- /dev/null
+++ b/pamapi/src/doc/sql/20220126_w.sql
@@ -0,0 +1,6 @@
+ALTER TABLE public.satisfaction ALTER COLUMN customer_id DROP NOT NULL;
+ALTER TABLE public.satisfaction ADD "type" varchar NULL;
+
+-- Auto-generated SQL script #202201261717
+UPDATE public.satisfaction SET "type"='APPOINTMENT';
+
diff --git "a/pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\345\271\263\345\217\260\346\273\277\346\204\217\345\272\246.txt" "b/pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\345\271\263\345\217\260\346\273\277\346\204\217\345\272\246.txt"
new file mode 100644
index 0000000..53bed96
--- /dev/null
+++ "b/pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\345\271\263\345\217\260\346\273\277\346\204\217\345\272\246.txt"
@@ -0,0 +1,22 @@
+http post :
+http://localhost:8080/api/satisfaction/system/score
+
+
+憛怠神銝�蝑�:
+request body:
+{
+    "appointmentId": 67,
+    "score":4
+}
+
+
+response body:
+{
+    "id": 93,
+    "customerId": 165,
+    "agentNo": null,
+    "status": "FILLED",
+    "score": 4.0,
+    "appointmentId": 482,
+    "type": "SYSTEM"
+}
diff --git "a/pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\346\273\277\346\204\217\345\272\246.txt" "b/pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\351\241\247\345\225\217\346\273\277\346\204\217\345\272\246.txt"
similarity index 100%
rename from "pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\346\273\277\346\204\217\345\272\246.txt"
rename to "pamapi/src/doc/\346\273\277\346\204\217\345\272\246/\345\256\242\346\210\266\345\241\253\345\257\253\351\241\247\345\225\217\346\273\277\346\204\217\345\272\246.txt"
diff --git a/pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java b/pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
index b6c70ce..69dbd24 100644
--- a/pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
+++ b/pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
@@ -18,29 +18,29 @@
 @Service
 @Transactional
 public class ClosedProcess implements AppointmentProcessInterface{
-	
+
 	@Autowired
 	AppointmentClosedInfoRepository appointmentClosedInfoRepository;
-	
+
 	@Autowired
 	AppointmentService appointmentService;
-	
+
 	@Autowired
 	AppointmentClosedInfoService appointmentClosedInfoService;
-	
+
 	@Autowired
 	SatisfactionService satisfactionService;
-	
+
 	@Override
 	public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) {
 		ClosedProcessDTO closeProcess = toClosedProcessDTO(processDTO);
 		AppointmentClosedInfo closedInfo = new AppointmentClosedInfo();
 		BeanUtils.copyProperties(closeProcess, closedInfo);
 		Appointment appointment = appointmentService.findById(processDTO.getAppointmentId());
-		satisfactionService.createSatisfaction(appointment);
+		satisfactionService.createAppointmentSatisfaction(appointment);
 		return appointmentClosedInfoRepository.save(closedInfo);
 	}
-	
+
 	private ClosedProcessDTO toClosedProcessDTO(AbstractAppointmentProcessDTO processDTO) {
 		ClosedProcessDTO closeProcess = (ClosedProcessDTO)processDTO;
 		BeanUtils.copyProperties(processDTO, closeProcess);
@@ -51,7 +51,7 @@
 	public ContactStatusEnum getProcessType() {
 		return ContactStatusEnum.CLOSED;
 	}
-	
+
 	@Override
 	public AppointmentClosedInfo editClosedInfo(
 			AbstractAppointmentProcessDTO abstractDTO
@@ -60,6 +60,6 @@
 		BeanUtils.copyProperties(closeProcess, closedInfo);
 		return appointmentClosedInfoRepository.save(closedInfo);
 	}
-	
-	
+
+
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java b/pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
index b4d628f..f42257e 100644
--- a/pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
+++ b/pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
@@ -18,26 +18,26 @@
 @Service
 @Transactional
 public class DoneProcess implements AppointmentProcessInterface{
-	
+
 	@Autowired
 	AppointmentClosedInfoRepository appointmentClosedInfoRepository;
-	
+
 	@Autowired
 	AppointmentClosedInfoService appointmentClosedInfoService;
-	
+
 	@Autowired
 	SatisfactionService satisfactionService;
-	
+
 	@Autowired
 	AppointmentService appointmentService;
-	
+
 	@Override
 	public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) {
 		DoneProcessDTO doneProcess = toDoneProcessDTO(processDTO);
 		AppointmentClosedInfo closedInfo = new AppointmentClosedInfo();
 		BeanUtils.copyProperties(doneProcess, closedInfo);
 		Appointment appointment = appointmentService.findById(processDTO.getAppointmentId());
-		satisfactionService.createSatisfaction(appointment);
+		satisfactionService.createAppointmentSatisfaction(appointment);
 		return appointmentClosedInfoRepository.save(closedInfo);
 	}
 
@@ -45,7 +45,7 @@
 	public ContactStatusEnum getProcessType() {
 		return ContactStatusEnum.DONE;
 	}
-	
+
 	@Override
 	public AppointmentClosedInfo editClosedInfo(
 			AbstractAppointmentProcessDTO abstractDTO
@@ -60,5 +60,5 @@
 		BeanUtils.copyProperties(abstractDTO, doneProcess);
 		return doneProcess;
 	}
-	
+
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java b/pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java
index 95a0944..530bc06 100644
--- a/pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java
+++ b/pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java
@@ -12,6 +12,8 @@
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import com.pollex.pam.enums.PersonalNotificationRoleEnum;
+import com.pollex.pam.enums.SatisfactionTypeEnum;
 import org.springframework.data.annotation.CreatedDate;
 import org.springframework.data.annotation.LastModifiedDate;
 
@@ -56,6 +58,10 @@
 
     @Column(name = "appointment_id")
     private Long appointmentId;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "type")
+    private SatisfactionTypeEnum type;
 
 	public Long getId() {
 		return id;
@@ -120,4 +126,12 @@
     public void setAppointmentId(Long appointmentId) {
         this.appointmentId = appointmentId;
     }
+
+    public SatisfactionTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(SatisfactionTypeEnum type) {
+        this.type = type;
+    }
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java b/pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java
index 5b0a284..b04f9fe 100644
--- a/pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java
+++ b/pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java
@@ -4,6 +4,7 @@
 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;
@@ -14,15 +15,16 @@
 @Repository
 public interface SatisfactionRepository extends JpaRepository<Satisfaction, Long>{
 
-	List<Satisfaction> findByAgentNo(String agentNo);
+	List<Satisfaction> findByAgentNoAndType(String agentNo, SatisfactionTypeEnum type);
 
-	List<Satisfaction> findByCustomerId(Long customerId);
+	List<Satisfaction> findByCustomerIdAndType(Long customerId, SatisfactionTypeEnum type);
 
 	Optional<Satisfaction> findOneByAppointmentId(Long appointmentId);
 
-    List<Satisfaction> findAllByStatus(SatisfactionStatusEnum status);
+    List<Satisfaction> findAllByStatusAndType(SatisfactionStatusEnum status, SatisfactionTypeEnum type);
 
-	@Query(value = "SELECT avg(score) FROM satisfaction where agent_no=:agent_no"
+	@Query(value = "SELECT avg(score) FROM satisfaction where type='APPOINTMENT'"
+            + " and agent_no=:agent_no"
 			+ " and score is not null"
 			, nativeQuery = true)
 	Float getAgentScoreAvg(@Param("agent_no") String agentNo);
diff --git a/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java
index 5a4d09a..3fa7b67 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java
@@ -73,7 +73,7 @@
 		personalNotificationRepository.save(entity);
 	}
 
-    public void createNotFillSatisfactionSumToCustomer(Long customerId, int notFillSatisfactionSum) {
+    public void createNotFillAppointmentSatisfactionNumberToCustomer(Long customerId, int notFillSatisfactionSum) {
         PersonalNotification entity = new PersonalNotification();
 
         String content = "���� "+notFillSatisfactionSum+" 蝑“���遛��漲��閬‵撖�";
@@ -144,7 +144,7 @@
 			readAllNotification(PersonalNotificationRoleEnum.CUSTOMER, SecurityUtils.getCustomerDBId());
 		}
 	}
-	
+
 	public void readAllNotification(PersonalNotificationRoleEnum ownerRole
 			, Long ownerId) {
 		List<PersonalNotification> allNotification = personalNotificationRepository.findAllByOwnerRoleAndOwnerId(ownerRole, ownerId);
diff --git a/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java b/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
index 9911f04..0fa1b91 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
@@ -4,6 +4,9 @@
 import java.util.List;
 import java.util.Optional;
 
+import com.pollex.pam.enums.SatisfactionTypeEnum;
+import com.pollex.pam.security.SecurityUtils;
+import com.pollex.pam.service.dto.SatisfactionSystemScoreDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -61,17 +64,18 @@
 		Satisfaction satisfaction = satisfactionOP.orElseThrow(SatisfactionNotFoundException::new);
 		satisfaction.setScore(scoreDTO.getScore());
 		satisfaction.setStatus(SatisfactionStatusEnum.FILLED);
+        satisfaction.setType(SatisfactionTypeEnum.APPOINTMENT);
 		save(satisfaction);
 		personalNotificationService.createScorefactionToConsultant(satisfaction);
 		return satisfaction;
 	}
 
-	public Satisfaction createSatisfaction(Appointment appointment) {
+	public Satisfaction createAppointmentSatisfaction(Appointment appointment) {
 		boolean isexist = getByAppointmentId(appointment.getId()).isPresent();
 		if(isexist) {
 			throw new SatisfactionAlreadyExistException();
 		}
-		Satisfaction satisfaction = appointmentMapper.toSatisfaction(appointment);
+		Satisfaction satisfaction = appointmentMapper.toAppointmentSatisfaction(appointment);
 		return save(satisfaction);
 	}
 //
@@ -80,13 +84,13 @@
 //		return save(satisfaction);
 //	}
 
-	public List<SatisfactionDTO> getByAgentNo(String agentNo) {
-		List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNo(agentNo);
+	public List<SatisfactionDTO> getByAgentNoAndType(String agentNo, SatisfactionTypeEnum type) {
+		List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNoAndType(agentNo, type);
 		return satisfactionMapper.toDTO(satisfactionList);
 	}
 
-	public List<SatisfactionDTO> getByCustomerId(Long customerDBId) {
-		List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerId(customerDBId);
+	public List<SatisfactionDTO> getByCustomerIdAndType(Long customerDBId, SatisfactionTypeEnum type) {
+		List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerIdAndType(customerDBId, type);
 		return satisfactionMapper.toDTO(satisfactionList);
 	}
 
@@ -94,8 +98,8 @@
         return satisfactionRepository.findOneByAppointmentId(appointmentId);
     }
 
-    public List<Satisfaction> getByStatus(SatisfactionStatusEnum status) {
-        return satisfactionRepository.findAllByStatus(status);
+    public List<Satisfaction> getByStatusAndType(SatisfactionStatusEnum status, SatisfactionTypeEnum type) {
+        return satisfactionRepository.findAllByStatusAndType(status, type);
     }
 
 	public List<Satisfaction> scoreAllfaction(List<SatisfactionCustomerScoreDTO> scoreDTO) {
@@ -105,4 +109,14 @@
 		});
 		return satisfactionList;
 	}
+
+    public Satisfaction createSystemSatisfaction(SatisfactionSystemScoreDTO scoreDTO) {
+        Satisfaction satisfaction = new Satisfaction();
+        satisfaction.setCustomerId(SecurityUtils.getCustomerDBId());
+        satisfaction.setAppointmentId(scoreDTO.getAppointmentId());
+        satisfaction.setStatus(SatisfactionStatusEnum.FILLED);
+        satisfaction.setScore(scoreDTO.getScore());
+        satisfaction.setType(SatisfactionTypeEnum.SYSTEM);
+        return satisfactionRepository.save(satisfaction);
+    }
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java b/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
index 57324b5..627aeb4 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
@@ -6,6 +6,7 @@
 import com.pollex.pam.enums.AppointmentStatusEnum;
 import com.pollex.pam.enums.ContactStatusEnum;
 import com.pollex.pam.enums.SatisfactionStatusEnum;
+import com.pollex.pam.enums.SatisfactionTypeEnum;
 import com.pollex.pam.repository.AppointmentCustomerViewRepository;
 import com.pollex.pam.repository.AppointmentExpiringNotifyRecordRepository;
 import org.slf4j.Logger;
@@ -127,13 +128,14 @@
 
     // todo ��蝣箄�府����, otis todo=134497
     @Scheduled(cron = "0 30 8 * * *")
-    public void sendNotFillSatisfactionToPersonalNotification() {
-        Map<Long, List<Satisfaction>> customerNotFillSatisfactions = satisfactionService.getByStatus(SatisfactionStatusEnum.UNFILLED)
+    public void sendNotFillAppointmentSatisfactionToPersonalNotification() {
+        Map<Long, List<Satisfaction>> customerNotFillSatisfactions =
+            satisfactionService.getByStatusAndType(SatisfactionStatusEnum.UNFILLED, SatisfactionTypeEnum.APPOINTMENT)
                 .stream()
                 .collect(Collectors.groupingBy(Satisfaction::getCustomerId));
 
         customerNotFillSatisfactions.forEach((customerId, notFillSatisfactions) ->
-            personalNotificationService.createNotFillSatisfactionSumToCustomer(customerId, notFillSatisfactions.size())
+            personalNotificationService.createNotFillAppointmentSatisfactionNumberToCustomer(customerId, notFillSatisfactions.size())
         );
     }
 
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionSystemScoreDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionSystemScoreDTO.java
new file mode 100644
index 0000000..32090c0
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionSystemScoreDTO.java
@@ -0,0 +1,23 @@
+package com.pollex.pam.service.dto;
+
+public class SatisfactionSystemScoreDTO {
+
+    private Long appointmentId;
+    private Float score;
+
+    public Long getAppointmentId() {
+        return appointmentId;
+    }
+
+    public void setAppointmentId(Long appointmentId) {
+        this.appointmentId = appointmentId;
+    }
+
+    public Float getScore() {
+        return score;
+    }
+
+    public void setScore(Float score) {
+        this.score = score;
+    }
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
index f92aac5..5526738 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
@@ -4,6 +4,7 @@
 
 import java.util.List;
 
+import com.pollex.pam.enums.SatisfactionTypeEnum;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -13,7 +14,6 @@
 import com.pollex.pam.enums.SatisfactionStatusEnum;
 import com.pollex.pam.repository.AppointmentRepository;
 import com.pollex.pam.service.dto.AppointmentDTO;
-import com.pollex.pam.service.dto.SatisfactionCustomerScoreDTO;
 
 @Service
 public class AppointmentMapper {
@@ -32,18 +32,19 @@
 				.map(s -> toAppointmentDTO(s)).collect(toList());
 	}
 
-	public Satisfaction toSatisfaction(Appointment appointment) {
+	public Satisfaction toAppointmentSatisfaction(Appointment appointment) {
 		Satisfaction target = new Satisfaction();
         target.setAppointmentId(appointment.getId());
 		target.setAgentNo(appointment.getAgentNo());
 		target.setCustomerId(appointment.getCustomerId());
+        target.setType(SatisfactionTypeEnum.APPOINTMENT);
 		target.setStatus(SatisfactionStatusEnum.UNFILLED);
 		return target;
 	}
 
-	public Satisfaction toSatisfaction(Long appointmentId) {
+	public Satisfaction toAppointmentSatisfaction(Long appointmentId) {
 		Appointment appointment = appointmentRepository.findById(appointmentId).get();
-		return toSatisfaction(appointment);
+		return toAppointmentSatisfaction(appointment);
 	}
 
 
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java
index 4fb7434..0fd2a60 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java
@@ -9,12 +9,12 @@
 
 @Service
 public class SatisfactionDTOMapper {
-	
+
 	@Autowired
 	AppointmentMapper appointmentMapper;
-	
+
 	public Satisfaction toSatisfaction(SatisfactionCustomerScoreDTO source) {
-		Satisfaction satisfaction = appointmentMapper.toSatisfaction(source.getAppointmentId());
+		Satisfaction satisfaction = appointmentMapper.toAppointmentSatisfaction(source.getAppointmentId());
 		satisfaction.setScore(source.getScore());
 		if(satisfaction.getScore()!=null) {
 			satisfaction.setStatus(SatisfactionStatusEnum.FILLED);
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java
index 092579b..2289880 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java
@@ -2,53 +2,57 @@
 
 import java.util.List;
 
+import com.pollex.pam.enums.SatisfactionTypeEnum;
+import com.pollex.pam.service.dto.SatisfactionSystemScoreDTO;
 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.PathVariable;
 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.Appointment;
 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;
-import com.pollex.pam.service.dto.SatisfactionUpdateDTO;
 
 @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.getByAgentNo(SecurityUtils.getAgentNo());
+			return satisfactionService.getByAgentNoAndType(SecurityUtils.getAgentNo(), SatisfactionTypeEnum.APPOINTMENT);
 		}else if(SecurityUtils.getCustomerDBId()!=null){
-			return satisfactionService.getByCustomerId(SecurityUtils.getCustomerDBId());
+			return satisfactionService.getByCustomerIdAndType(SecurityUtils.getCustomerDBId(), SatisfactionTypeEnum.APPOINTMENT);
 		}
 		log.error("Not has agent code and customer id");
 		throw new IllegalArgumentException("Not has agent code and customer id");
 	}
+
+    @PostMapping("/system/score")
+    public Satisfaction createSystemSatisfaction(@RequestBody SatisfactionSystemScoreDTO scoreDTO) {
+        return satisfactionService.createSystemSatisfaction(scoreDTO);
+    }
 }

--
Gitblit v1.8.0