保誠-保戶業務員媒合平台
Jack
2021-12-01 ab79329b71e1c962764a6be325a25c3e3a255e35
[ADD] 填寫滿意度問卷
[ADD] 查詢自己所有的滿意度填寫結果
修改3個檔案
新增12個檔案
564 ■■■■■ 已變更過的檔案
pamapi/src/doc/滿意度/客戶填寫滿意度.txt 24 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/滿意度/查詢登入者所有的滿意度問卷.txt 72 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java 114 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/enums/SatisfactionStatusEnum.java 6 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java 18 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java 8 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java 65 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionCustomerCreateDTO.java 22 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionDTO.java 60 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionUpdateDTO.java 43 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java 22 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java 26 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionMapper.java 29 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java 6 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java 49 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/º¡·N«×/«È¤á¶ñ¼gº¡·N«×.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,24 @@
http post :
http://localhost:8080/api/satisfaction/create
request body:
{
    "appointmentId": 67,
    "score":4
}
response body:
{
    "id": 3,
    "customerId": 2,
    "agentNo": "admin",
    "status": "UNFILLED",
    "score": 4
}
pamapi/src/doc/º¡·N«×/¬d¸ßµn¤JªÌ©Ò¦³ªºº¡·N«×°Ý¨÷.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,72 @@
http get :
http://localhost:8080/api/satisfaction/getMySatisfaction
response body:
[
    {
        "id": 4,
        "createdDate": "2021-11-30T12:32:28.943Z",
        "lastModifiedDate": "2021-11-30T12:32:28.943Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 4.0
    },
    {
        "id": 5,
        "createdDate": "2021-11-30T12:34:16.225Z",
        "lastModifiedDate": "2021-11-30T12:34:16.225Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 4.0
    },
    {
        "id": 6,
        "createdDate": "2021-11-30T12:37:27.571Z",
        "lastModifiedDate": "2021-11-30T12:37:27.571Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 4.0
    },
    {
        "id": 7,
        "createdDate": "2021-11-30T12:52:27.709Z",
        "lastModifiedDate": "2021-11-30T12:52:27.709Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 4.0
    },
    {
        "id": 8,
        "createdDate": "2021-11-30T12:52:46.657Z",
        "lastModifiedDate": "2021-11-30T12:52:46.657Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 2.0
    },
    {
        "id": 9,
        "createdDate": "2021-12-01T03:08:50.258Z",
        "lastModifiedDate": "2021-12-01T03:08:50.258Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": 0.0
    },
    {
        "id": 10,
        "createdDate": "2021-12-01T09:48:50.991Z",
        "lastModifiedDate": "2021-12-01T09:48:50.991Z",
        "customerId": 90,
        "agentNo": "B282677963",
        "status": "UNFILLED",
        "score": null
    }
]
pamapi/src/main/java/com/pollex/pam/domain/Satisfaction.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,114 @@
package com.pollex.pam.domain;
import java.io.Serializable;
import java.time.Instant;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pollex.pam.enums.SatisfactionStatusEnum;
@Entity
@Table(name = "satisfaction")
public class Satisfaction implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @CreatedDate
    @Column(name = "created_date", updatable = false)
    @JsonIgnore
    private Instant createdDate = Instant.now();
    @LastModifiedDate
    @Column(name = "last_modified_date")
    @JsonIgnore
    private Instant lastModifiedDate = Instant.now();
    @Column(name = "customer_id")
    private Long customerId;
    @Column(name = "agent_no")
    private String agentNo;
    @Enumerated(EnumType.STRING)
    @Column(name = "status")
    private SatisfactionStatusEnum status;
    @Column(name = "score")
    private Float score;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Instant getCreatedDate() {
        return createdDate;
    }
    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }
    public Instant getLastModifiedDate() {
        return lastModifiedDate;
    }
    public void setLastModifiedDate(Instant lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }
    public Long getCustomerId() {
        return customerId;
    }
    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }
    public String getAgentNo() {
        return agentNo;
    }
    public void setAgentNo(String agentNo) {
        this.agentNo = agentNo;
    }
    public SatisfactionStatusEnum getStatus() {
        return status;
    }
    public void setStatus(SatisfactionStatusEnum status) {
        this.status = status;
    }
    public Float getScore() {
        return score;
    }
    public void setScore(Float score) {
        this.score = score;
    }
}
pamapi/src/main/java/com/pollex/pam/enums/SatisfactionStatusEnum.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,6 @@
package com.pollex.pam.enums;
public enum SatisfactionStatusEnum {
    UNFILLED,
    FILLED
}
pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,18 @@
package com.pollex.pam.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.pollex.pam.domain.Satisfaction;
@Repository
public interface SatisfactionRepository extends JpaRepository<Satisfaction, Long>{
    List<Satisfaction> findByAgentNo(String agentNo);
    List<Satisfaction> findByCustomerId(Long customerId);
}
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -36,23 +36,27 @@
    @Autowired
    AppointmentCustomerViewRepository appointmentCustomerViewRepository;
    @Autowired
    SatisfactionService satisfactionService;
    public void customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
        Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO);
        appointment.setCustomerId(SecurityUtils.getCustomerDBId());
        appointment.setCommunicateStatus(ContactStatusEnum.RESERVED);
        appointmentRepository.save(appointment);
    }
    public List<Appointment> findByAgentNo(String agentNo) {
        return appointmentRepository.findByAgentNo(agentNo);
    }
    public void markAsContacted(Long appointmentId) {
    public Appointment markAsContacted(Long appointmentId) {
        Appointment appointment = appointmentRepository.findById(appointmentId).get();
        appointment.setCommunicateStatus(ContactStatusEnum.CONTACTED);
        appointmentRepository.save(appointment);
        return appointmentRepository.save(appointment);
    }
pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,65 @@
package com.pollex.pam.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.enums.SatisfactionStatusEnum;
import com.pollex.pam.repository.CustomerRepository;
import com.pollex.pam.repository.SatisfactionRepository;
import com.pollex.pam.service.dto.SatisfactionCustomerCreateDTO;
import com.pollex.pam.service.dto.SatisfactionDTO;
import com.pollex.pam.service.mapper.AppointmentMapper;
import com.pollex.pam.service.mapper.SatisfactionDTOMapper;
import com.pollex.pam.service.mapper.SatisfactionMapper;
@Service
@Transactional
public class SatisfactionService {
    @Autowired
    SatisfactionRepository satisfactionRepository;
    @Autowired
    AppointmentMapper appointmentMapper;
    @Autowired
    SatisfactionDTOMapper satisfactionDTOMapper;
    @Autowired
    SatisfactionMapper satisfactionMapper;
    @Autowired
    CustomerRepository customerRepository;
    public Satisfaction createSatisfaction(Satisfaction satisfaction) {
        return satisfactionRepository.save(satisfaction);
    }
    public Satisfaction createSatisfaction(Appointment appointment) {
        Satisfaction satisfaction = appointmentMapper.toSatisfaction(appointment);
        return createSatisfaction(satisfaction);
    }
    public Satisfaction createSatisfaction(SatisfactionCustomerCreateDTO createDTO) {
        // todo : å°šæœªæ¨™è¨˜å·²è¯çµ¡çš„預約單不該可以新增滿意度評分
        // todo : éžè‡ªå·±çš„預約單不該可以進行評分
        Satisfaction satisfaction = satisfactionDTOMapper.toSatisfaction(createDTO);
        return createSatisfaction(satisfaction);
    }
    public List<SatisfactionDTO> getByAgentNo(String agentNo) {
        List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNo(agentNo);
        return satisfactionMapper.toDTO(satisfactionList);
    }
    public List<SatisfactionDTO> getByCustomerId(Long customerDBId) {
        List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerId(customerDBId);
        return satisfactionMapper.toDTO(satisfactionList);
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionCustomerCreateDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,22 @@
package com.pollex.pam.service.dto;
public class SatisfactionCustomerCreateDTO {
    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;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,60 @@
package com.pollex.pam.service.dto;
import java.time.Instant;
import com.pollex.pam.enums.SatisfactionStatusEnum;
public class SatisfactionDTO {
    private Long id;
    private Instant createdDate;
    private Instant lastModifiedDate;
    private Long customerId;
    private String agentNo;
    private SatisfactionStatusEnum status;
    private Float score;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Instant getCreatedDate() {
        return createdDate;
    }
    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }
    public Instant getLastModifiedDate() {
        return lastModifiedDate;
    }
    public void setLastModifiedDate(Instant lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }
    public Long getCustomerId() {
        return customerId;
    }
    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }
    public String getAgentNo() {
        return agentNo;
    }
    public void setAgentNo(String agentNo) {
        this.agentNo = agentNo;
    }
    public SatisfactionStatusEnum getStatus() {
        return status;
    }
    public void setStatus(SatisfactionStatusEnum status) {
        this.status = status;
    }
    public Float getScore() {
        return score;
    }
    public void setScore(Float score) {
        this.score = score;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionUpdateDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,43 @@
package com.pollex.pam.service.dto;
public class SatisfactionUpdateDTO {
    private Long id;
    private Long customerId;
    private String agentNo;
    private String status;
    private String score;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getCustomerId() {
        return customerId;
    }
    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }
    public String getAgentNo() {
        return agentNo;
    }
    public void setAgentNo(String agentNo) {
        this.agentNo = agentNo;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getScore() {
        return score;
    }
    public void setScore(String score) {
        this.score = score;
    }
}
pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
@@ -5,13 +5,21 @@
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.domain.Satisfaction;
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.SatisfactionCustomerCreateDTO;
@Service
public class AppointmentMapper {
    @Autowired
    AppointmentRepository appointmentRepository;
    public AppointmentDTO toAppointmentDTO(Appointment source) {
        AppointmentDTO target = new AppointmentDTO();
@@ -24,4 +32,18 @@
                .map(s -> toAppointmentDTO(s)).collect(toList());
    }
    public Satisfaction toSatisfaction(Appointment appointment) {
        Satisfaction target = new Satisfaction();
        target.setAgentNo(appointment.getAgentNo());
        target.setCustomerId(appointment.getCustomerId());
        return target;
    }
    public Satisfaction toSatisfaction(Long appointmentId) {
        Appointment appointment = appointmentRepository.findById(appointmentId).get();
        return toSatisfaction(appointment);
    }
}
pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,26 @@
package com.pollex.pam.service.mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.enums.SatisfactionStatusEnum;
import com.pollex.pam.service.dto.SatisfactionCustomerCreateDTO;
@Service
public class SatisfactionDTOMapper {
    @Autowired
    AppointmentMapper appointmentMapper;
    public Satisfaction toSatisfaction(SatisfactionCustomerCreateDTO source) {
        Satisfaction satisfaction = appointmentMapper.toSatisfaction(source.getAppointmentId());
        satisfaction.setScore(source.getScore());
        if(satisfaction.getScore()!=null) {
            satisfaction.setStatus(SatisfactionStatusEnum.FILLED);
        }else {
            satisfaction.setStatus(SatisfactionStatusEnum.UNFILLED);
        }
        return satisfaction;
    }
}
pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionMapper.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,29 @@
package com.pollex.pam.service.mapper;
import static java.util.stream.Collectors.toList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.service.dto.SatisfactionDTO;
@Service
public class SatisfactionMapper {
    public SatisfactionDTO toDTO(Satisfaction source) {
        SatisfactionDTO target = new SatisfactionDTO();
        target.setScore(source.getScore());
        BeanUtils.copyProperties(source, target);
        return target;
    }
    public List<SatisfactionDTO> toDTO(List<Satisfaction> satisfactionList) {
        if(satisfactionList==null) return null;
        return satisfactionList.stream()
                .map(s -> toDTO(s))
                .collect(toList());
    }
}
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -1,6 +1,8 @@
package com.pollex.pam.web.rest;
import com.pollex.pam.service.ConsultantService;
import com.pollex.pam.service.SatisfactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -9,6 +11,7 @@
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.AppointmentCustomerView;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.dto.AppointmentCreateDTO;
@@ -20,6 +23,9 @@
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    SatisfactionService satisfactionService;
    @PostMapping("/customer/create")
    public void clientCreateAppointment(@RequestBody AppointmentCreateDTO appointmentCreateDTO) {
pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,49 @@
package com.pollex.pam.web.rest;
import java.util.List;
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.SatisfactionCustomerCreateDTO;
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("/create")
    public Satisfaction createSatisfaction(@RequestBody SatisfactionCustomerCreateDTO createDTO) {
        return satisfactionService.createSatisfaction(createDTO);
    }
    @GetMapping("/getMySatisfaction")
    public List<SatisfactionDTO> getMySatisfaction(){
        if(StringUtils.hasText(SecurityUtils.getAgentNo())) {
            return satisfactionService.getByAgentNo(SecurityUtils.getAgentNo());
        }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");
    }
}