pamapi/src/doc/º¡·N«×/«È¤á¶ñ¼gº¡·N«×.txt
@@ -1,6 +1,6 @@ http post : http://localhost:8080/api/satisfaction/create http://localhost:8080/api/satisfaction/score pamapi/src/doc/¹w¬ù³æ/µ²®×API.txt
@@ -1,9 +1,7 @@ http post : æ°å¢çµæ¡æç´°: æ°å¢çµæ¡æç´°, æ´æ°çµæ¡æç´°: http://localhost:8080/api/appointment/close æ´æ°çµæ¡æç´°: http://localhost:8080/api/appointment/close/info/edit request body : pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java
@@ -34,31 +34,23 @@ public void process(AbstractAppointmentProcessDTO dto) { // AbstractAppointmentProcessDTO appointmentProcessDTO = dto; processList.stream().forEach(process ->{ if(process.getProcessType() == dto.getContactStatus()) { process.createProcess(dto); Optional<AppointmentClosedInfo> closedInfoOP = appointmentClosedInfoRepository.findByAppointmentId(dto.getAppointmentId()); if(closedInfoOP.isPresent()) { process.editClosedInfo(dto, closedInfoOP.get()); }else { process.create(dto); } } }); changeAppointmentCommunicateStatus(dto.getAppointmentId(), dto.getContactStatus()); } private void changeAppointmentCommunicateStatus(Long appointmentId, ContactStatusEnum contactStatus) { Appointment appointment = appointmentService.findById(appointmentId); appointment.setCommunicateStatus(contactStatus); appointmentRepository.save(appointment); } public void editClosedInfo(AbstractAppointmentProcessDTO dto) { processList.stream().forEach(process ->{ if(process.getProcessType() == dto.getContactStatus()) { process.editClosedInfo(dto); } }); Appointment appointment = appointmentService.findById(dto.getAppointmentId()); appointment.setCommunicateStatus(dto.getContactStatus()); appointmentRepository.save(appointment); } pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcessInterface.java
@@ -6,8 +6,9 @@ public interface AppointmentProcessInterface { void createProcess(AbstractAppointmentProcessDTO dto); AppointmentClosedInfo editClosedInfo(AbstractAppointmentProcessDTO dto); AppointmentClosedInfo create(AbstractAppointmentProcessDTO dto); AppointmentClosedInfo editClosedInfo(AbstractAppointmentProcessDTO dto , AppointmentClosedInfo closedInfo); ContactStatusEnum getProcessType(); } pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
@@ -1,10 +1,9 @@ package com.pollex.pam.appointment.process; import java.util.Optional; import org.springframework.beans.BeanUtils; 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.AppointmentClosedInfo; @@ -12,12 +11,12 @@ import com.pollex.pam.repository.AppointmentClosedInfoRepository; import com.pollex.pam.service.AppointmentClosedInfoService; import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.SatisfactionService; import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; import com.pollex.pam.service.dto.ClosedProcessDTO; import com.pollex.pam.service.dto.DoneProcessDTO; import com.pollex.pam.web.rest.errors.AppointmentClosedInfoNotFoundException; @Service @Transactional public class ClosedProcess implements AppointmentProcessInterface{ @Autowired @@ -29,14 +28,17 @@ @Autowired AppointmentClosedInfoService appointmentClosedInfoService; @Autowired SatisfactionService satisfactionService; @Override public void createProcess(AbstractAppointmentProcessDTO processDTO) { checkClosedInfo(processDTO.getAppointmentId()); public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) { ClosedProcessDTO closeProcess = toClosedProcessDTO(processDTO); AppointmentClosedInfo closedInfo = new AppointmentClosedInfo(); BeanUtils.copyProperties(closeProcess, closedInfo); appointmentClosedInfoRepository.save(closedInfo); Appointment appointment = appointmentService.findById(processDTO.getAppointmentId()); satisfactionService.createSatisfaction(appointment); return appointmentClosedInfoRepository.save(closedInfo); } private ClosedProcessDTO toClosedProcessDTO(AbstractAppointmentProcessDTO processDTO) { @@ -45,23 +47,16 @@ return closeProcess; } private void checkClosedInfo(Long appointmentId) { Optional<AppointmentClosedInfo> closedInfo = appointmentClosedInfoRepository.findByAppointmentId(appointmentId); if(closedInfo.isPresent()) { throw new IllegalArgumentException("appointment closed info exist"); } } @Override public ContactStatusEnum getProcessType() { return ContactStatusEnum.CLOSED; } @Override public AppointmentClosedInfo editClosedInfo(AbstractAppointmentProcessDTO abstractDTO) { public AppointmentClosedInfo editClosedInfo( AbstractAppointmentProcessDTO abstractDTO , AppointmentClosedInfo closedInfo) { ClosedProcessDTO closeProcess = toClosedProcessDTO(abstractDTO); AppointmentClosedInfo closedInfo = appointmentClosedInfoService.findByAppointmentId(abstractDTO.getAppointmentId()); BeanUtils.copyProperties(closeProcess, closedInfo); return appointmentClosedInfoRepository.save(closedInfo); } pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
@@ -1,21 +1,22 @@ package com.pollex.pam.appointment.process; import java.util.Optional; import org.springframework.beans.BeanUtils; 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.AppointmentClosedInfo; import com.pollex.pam.enums.ContactStatusEnum; import com.pollex.pam.repository.AppointmentClosedInfoRepository; import com.pollex.pam.service.AppointmentClosedInfoService; import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.SatisfactionService; import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; import com.pollex.pam.service.dto.ClosedProcessDTO; import com.pollex.pam.service.dto.DoneProcessDTO; import com.pollex.pam.web.rest.errors.AppointmentClosedInfoNotFoundException; @Service @Transactional public class DoneProcess implements AppointmentProcessInterface{ @Autowired @@ -24,13 +25,20 @@ @Autowired AppointmentClosedInfoService appointmentClosedInfoService; @Autowired SatisfactionService satisfactionService; @Autowired AppointmentService appointmentService; @Override public void createProcess(AbstractAppointmentProcessDTO processDTO) { checkClosedInfo(processDTO.getAppointmentId()); public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) { DoneProcessDTO doneProcess = toDoneProcessDTO(processDTO); AppointmentClosedInfo closedInfo = new AppointmentClosedInfo(); BeanUtils.copyProperties(doneProcess, closedInfo); appointmentClosedInfoRepository.save(closedInfo); Appointment appointment = appointmentService.findById(processDTO.getAppointmentId()); satisfactionService.createSatisfaction(appointment); return appointmentClosedInfoRepository.save(closedInfo); } @Override @@ -38,23 +46,16 @@ return ContactStatusEnum.DONE; } private void checkClosedInfo(Long appointmentId) { Optional<AppointmentClosedInfo> closedInfo = appointmentClosedInfoRepository.findByAppointmentId(appointmentId); if(closedInfo.isPresent()) { throw new IllegalArgumentException("appointment closed info exist"); } } @Override public AppointmentClosedInfo editClosedInfo(AbstractAppointmentProcessDTO abstractDTO) { public AppointmentClosedInfo editClosedInfo( AbstractAppointmentProcessDTO abstractDTO , AppointmentClosedInfo closedInfo) { DoneProcessDTO doneProcess = toDoneProcessDTO(abstractDTO); AppointmentClosedInfo closedInfo = appointmentClosedInfoService.findByAppointmentId(abstractDTO.getAppointmentId()); BeanUtils.copyProperties(doneProcess, closedInfo); return appointmentClosedInfoRepository.save(closedInfo); } private DoneProcessDTO toDoneProcessDTO(AbstractAppointmentProcessDTO abstractDTO) { DoneProcessDTO doneProcess = (DoneProcessDTO)abstractDTO; BeanUtils.copyProperties(abstractDTO, doneProcess); return doneProcess; pamapi/src/main/java/com/pollex/pam/repository/SatisfactionRepository.java
@@ -20,6 +20,7 @@ Optional<Satisfaction> findOneByAppointmentId(Long appointmentId); @Query(value = "SELECT avg(score) FROM satisfaction where agent_no=:agent_no" + " and score is not null" , nativeQuery = true) Float getAgentScoreAvg(@Param("agent_no") String agentNo); } pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -6,14 +6,18 @@ import java.util.Optional; import java.util.stream.Collectors; import com.pollex.pam.appointment.process.AppointmentProcess; import com.pollex.pam.config.ApplicationProperties; import com.pollex.pam.service.dto.AppointmentUpdateDTO; import com.pollex.pam.service.dto.ClosedProcessDTO; import com.pollex.pam.service.dto.DoneProcessDTO; import com.pollex.pam.service.dto.InterviewRecordDTO; import com.pollex.pam.web.rest.errors.SendEmailFailException; import com.pollex.pam.web.rest.errors.SendSMSFailException; import io.jsonwebtoken.lang.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,6 +30,7 @@ import com.pollex.pam.repository.AppointmentCustomerViewRepository; import com.pollex.pam.repository.AppointmentRepository; import com.pollex.pam.security.SecurityUtils; import com.pollex.pam.service.dto.AppointmentCloseDTO; import com.pollex.pam.service.dto.AppointmentCreateDTO; import com.pollex.pam.service.dto.AppointmentCustomerViewDTO; import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper; @@ -75,6 +80,9 @@ @Autowired InterviewRecordService interviewRecordService; @Autowired AppointmentProcess abstractAppointmentProcess; public Appointment customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) { Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO); @@ -142,7 +150,6 @@ .map(appointmentCustomerView -> { AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentCustomerView); setSatisfactionScore(dto, appointmentCustomerView.getId()); return dto; }) .collect(Collectors.toList()); @@ -261,4 +268,16 @@ return appointmentRepository.findById(id) .orElseThrow(AppointmentNotFoundException::new); } public void closeAppointment(AppointmentCloseDTO closeDTO) { if(closeDTO.getContactStatus() == ContactStatusEnum.DONE) { DoneProcessDTO dto = new DoneProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.process(dto); }else if(closeDTO.getContactStatus() == ContactStatusEnum.CLOSED){ ClosedProcessDTO dto = new ClosedProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.process(dto); } } } pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -5,10 +5,12 @@ import com.pollex.pam.domain.AppointmentCustomerView; import com.pollex.pam.domain.Consultant; import com.pollex.pam.domain.CustomerFavoriteConsultant; import com.pollex.pam.domain.Satisfaction; import com.pollex.pam.enums.ContactStatusEnum; import com.pollex.pam.enums.LoginResult; import com.pollex.pam.repository.ConsultantRepository; import com.pollex.pam.repository.CustomerFavoriteConsultantRepository; import com.pollex.pam.repository.SatisfactionRepository; import com.pollex.pam.security.SecurityUtils; import com.pollex.pam.service.dto.*; import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper; @@ -30,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.time.Instant; import java.util.Comparator; import java.util.List; @@ -82,6 +85,9 @@ @Autowired ConsultantService consultantService; @Autowired SatisfactionRepository satisfactionRepository; public List<CustomerFavoriteConsultantDTO> getMyConsultantList() { Long customerId = SecurityUtils.getCustomerDBId(); @@ -288,4 +294,19 @@ public String getSendSatisfactionToClientUrl(Long appointmentId) { return applicationProperties.getFrontEndDomain() + "/?appointmentId=" + appointmentId; } public void setConsultantAvgScore(Satisfaction satisfaction) { float avgScore = getAgentAvgScore(satisfaction.getAgentNo()); Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) .get(); consultant.setAvgScore(avgScore); consultantRepository.save(consultant); } public float getAgentAvgScore(String agentNo) { Float avgScore = satisfactionRepository.getAgentScoreAvg(agentNo); if(avgScore==null)return 0; BigDecimal bigDecimal = new BigDecimal(avgScore); return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); } } pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
@@ -1,6 +1,5 @@ package com.pollex.pam.service; import java.math.BigDecimal; import java.util.List; import java.util.Optional; @@ -9,16 +8,18 @@ import org.springframework.transaction.annotation.Transactional; import com.pollex.pam.domain.Appointment; import com.pollex.pam.domain.Consultant; import com.pollex.pam.domain.Satisfaction; import com.pollex.pam.enums.SatisfactionStatusEnum; import com.pollex.pam.repository.ConsultantRepository; 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.SatisfactionCustomerScoreDTO; 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; import com.pollex.pam.web.rest.errors.SatisfactionAlreadyExistException; import com.pollex.pam.web.rest.errors.SatisfactionNotFoundException; @Service @Transactional @@ -41,44 +42,38 @@ @Autowired ConsultantRepository consultantRepository; @Autowired ConsultantService consultantService; public Satisfaction createSatisfaction(Satisfaction satisfaction) { public Satisfaction save(Satisfaction satisfaction) { satisfaction = satisfactionRepository.save(satisfaction); setConsultantAvgScore(satisfaction); consultantService.setConsultantAvgScore(satisfaction); return satisfaction; } private void setConsultantAvgScore(Satisfaction satisfaction) { float avgScore = getAgentAvgScore(satisfaction); Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) .get(); consultant.setAvgScore(avgScore); consultantRepository.save(consultant); } private float getAgentAvgScore(Satisfaction satisfaction) { Float avgScore = satisfactionRepository.getAgentScoreAvg(satisfaction.getAgentNo()); BigDecimal bigDecimal = new BigDecimal(avgScore); return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); } public Satisfaction scorefaction(SatisfactionCustomerScoreDTO scoreDTO) { Optional<Satisfaction> satisfactionOP = getByAppointmentId(scoreDTO.getAppointmentId()); Satisfaction satisfaction = satisfactionOP.orElseThrow(SatisfactionNotFoundException::new); satisfaction.setScore(scoreDTO.getScore()); satisfaction.setStatus(SatisfactionStatusEnum.FILLED); return save(satisfaction); } public Satisfaction createSatisfaction(Appointment appointment) { boolean isexist = getByAppointmentId(appointment.getId()).isPresent(); if(isexist) { throw new SatisfactionAlreadyExistException(); } Satisfaction satisfaction = appointmentMapper.toSatisfaction(appointment); return createSatisfaction(satisfaction); return save(satisfaction); } public Satisfaction createSatisfaction(SatisfactionCustomerCreateDTO createDTO) { // todo : å°æªæ¨è¨å·²è¯çµ¡çé ç´å®ä¸è©²å¯ä»¥æ°å¢æ»¿æåº¦è©å // todo : éèªå·±çé ç´å®ä¸è©²å¯ä»¥é²è¡è©å Satisfaction satisfaction = satisfactionDTOMapper.toSatisfaction(createDTO); return createSatisfaction(satisfaction); } // // public Satisfaction createSatisfaction(SatisfactionCustomerScoreDTO createDTO) { // Satisfaction satisfaction = satisfactionDTOMapper.toSatisfaction(createDTO); // return save(satisfaction); // } public List<SatisfactionDTO> getByAgentNo(String agentNo) { List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNo(agentNo); pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionCustomerScoreDTO.java
File was renamed from pamapi/src/main/java/com/pollex/pam/service/dto/SatisfactionCustomerCreateDTO.java @@ -1,6 +1,6 @@ package com.pollex.pam.service.dto; public class SatisfactionCustomerCreateDTO { public class SatisfactionCustomerScoreDTO { private Long appointmentId; private Float score; pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
@@ -13,7 +13,7 @@ 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; import com.pollex.pam.service.dto.SatisfactionCustomerScoreDTO; @Service public class AppointmentMapper { @@ -37,6 +37,7 @@ target.setAppointmentId(appointment.getId()); target.setAgentNo(appointment.getAgentNo()); target.setCustomerId(appointment.getCustomerId()); target.setStatus(SatisfactionStatusEnum.UNFILLED); return target; } pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionDTOMapper.java
@@ -5,7 +5,7 @@ import com.pollex.pam.domain.Satisfaction; import com.pollex.pam.enums.SatisfactionStatusEnum; import com.pollex.pam.service.dto.SatisfactionCustomerCreateDTO; import com.pollex.pam.service.dto.SatisfactionCustomerScoreDTO; @Service public class SatisfactionDTOMapper { @@ -13,7 +13,7 @@ @Autowired AppointmentMapper appointmentMapper; public Satisfaction toSatisfaction(SatisfactionCustomerCreateDTO source) { public Satisfaction toSatisfaction(SatisfactionCustomerScoreDTO source) { Satisfaction satisfaction = appointmentMapper.toSatisfaction(source.getAppointmentId()); satisfaction.setScore(source.getScore()); if(satisfaction.getScore()!=null) { pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -73,37 +73,25 @@ @PostMapping("/close") public ResponseEntity<Void> closeAppointment(@RequestBody AppointmentCloseDTO closeDTO) { if(closeDTO.getContactStatus() == ContactStatusEnum.DONE) { DoneProcessDTO dto = new DoneProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.process(dto); }else if(closeDTO.getContactStatus() == ContactStatusEnum.CLOSED){ ClosedProcessDTO dto = new ClosedProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.process(dto); }else { return ResponseEntity.notFound().build(); } appointmentService.closeAppointment(closeDTO); return ResponseEntity.noContent().build(); } @PostMapping("/close/info/edit") public ResponseEntity<Void> editAppointmentClosedInfo(@RequestBody AppointmentCloseDTO closeDTO) { if(closeDTO.getContactStatus() == ContactStatusEnum.DONE) { DoneProcessDTO dto = new DoneProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.editClosedInfo(dto); }else if(closeDTO.getContactStatus() == ContactStatusEnum.CLOSED){ ClosedProcessDTO dto = new ClosedProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.editClosedInfo(dto); }else { return ResponseEntity.notFound().build(); } return ResponseEntity.noContent().build(); } // @PostMapping("/close/info/edit") // public ResponseEntity<Void> editAppointmentClosedInfo(@RequestBody AppointmentCloseDTO closeDTO) { // // if(closeDTO.getContactStatus() == ContactStatusEnum.DONE) { // DoneProcessDTO dto = new DoneProcessDTO(); // BeanUtils.copyProperties(closeDTO, dto); // abstractAppointmentProcess.editClosedInfo(dto); // }else if(closeDTO.getContactStatus() == ContactStatusEnum.CLOSED){ // ClosedProcessDTO dto = new ClosedProcessDTO(); // BeanUtils.copyProperties(closeDTO, dto); // abstractAppointmentProcess.editClosedInfo(dto); // }else { // return ResponseEntity.notFound().build(); // } // // return ResponseEntity.noContent().build(); // } } pamapi/src/main/java/com/pollex/pam/web/rest/SatisfactionResource.java
@@ -17,7 +17,7 @@ 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.SatisfactionCustomerScoreDTO; import com.pollex.pam.service.dto.SatisfactionDTO; import com.pollex.pam.service.dto.SatisfactionUpdateDTO; @@ -31,9 +31,9 @@ @Autowired SatisfactionService satisfactionService; @PostMapping("/create") public Satisfaction createSatisfaction(@RequestBody SatisfactionCustomerCreateDTO createDTO) { return satisfactionService.createSatisfaction(createDTO); @PostMapping("/score") public Satisfaction scorefaction(@RequestBody SatisfactionCustomerScoreDTO scoreDTO) { return satisfactionService.scorefaction(scoreDTO); } @GetMapping("/getMySatisfaction") pamapi/src/main/java/com/pollex/pam/web/rest/errors/SatisfactionAlreadyExistException.java
¤ñ¹ï·sÀÉ®× @@ -0,0 +1,13 @@ package com.pollex.pam.web.rest.errors; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR, reason = "Satisfaction already exist") public class SatisfactionAlreadyExistException extends RuntimeException{ /** * */ private static final long serialVersionUID = 1L; } pamapi/src/main/java/com/pollex/pam/web/rest/errors/SatisfactionNotFoundException.java
¤ñ¹ï·sÀÉ®× @@ -0,0 +1,13 @@ package com.pollex.pam.web.rest.errors; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Satisfaction not found") public class SatisfactionNotFoundException extends RuntimeException{ /** * */ private static final long serialVersionUID = 1L; }