[ADD] 填寫滿意度問卷
[ADD] 查詢自己所有的滿意度填寫結果
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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 |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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 |
| | | } |
| | | ] |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | package com.pollex.pam.enums; |
| | | |
| | | public enum SatisfactionStatusEnum { |
| | | UNFILLED, |
| | | FILLED |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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); |
| | | } |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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(); |
| | |
| | | .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); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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; |
| | | } |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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()); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | |
| | | @Autowired |
| | | SatisfactionService satisfactionService; |
| | | |
| | | @PostMapping("/customer/create") |
| | | public void clientCreateAppointment(@RequestBody AppointmentCreateDTO appointmentCreateDTO) { |
¤ñ¹ï·sÀÉ®× |
| | |
| | | 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"); |
| | | } |
| | | } |