From 2f0e71d3d73b71cba5a0caebfdb9ba79722989c0 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期四, 27 一月 2022 14:54:38 +0800 Subject: [PATCH] [update] [todo 134826, 134662] 調整顧問資料格式、棄用搜尋並改將其功能改到前端算匹配度 --- pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java | 70 +++++++++++++++++++++++++++++----- 1 files changed, 59 insertions(+), 11 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java index d672590..64fb56e 100644 --- a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java @@ -1,5 +1,8 @@ package com.pollex.pam.web.rest; +import com.pollex.pam.domain.Appointment; +import com.pollex.pam.domain.Consultant; +import com.pollex.pam.security.SecurityUtils; import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.ConsultantService; import com.pollex.pam.service.dto.*; @@ -12,9 +15,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.List; @RestController @@ -24,10 +30,25 @@ @Autowired ConsultantService consultantService; + @Autowired + AppointmentService appointmentService; + @GetMapping("/favorite") public ResponseEntity<List<CustomerFavoriteConsultantDTO>> getMyConsultantList() { List<CustomerFavoriteConsultantDTO> myConsultants = consultantService.getMyConsultantList(); return new ResponseEntity<>(myConsultants, HttpStatus.OK); + } + + @GetMapping("/all") + public ResponseEntity<List<ConsultantDTO>> getAllConsultantList() { + List<ConsultantDTO> myConsultants = consultantService.getAllConsultantList(); + return new ResponseEntity<>(myConsultants, HttpStatus.OK); + } + + @PostMapping("/favorite/view") + public ResponseEntity<Void> recordMyConsultantListView() { + consultantService.recordMyConsultantListView(); + return ResponseEntity.noContent().build(); } @GetMapping("/recommend") @@ -48,13 +69,13 @@ return new ResponseEntity<>(HttpStatus.OK); } - + @Deprecated @PostMapping("/strictQuery") public ResponseEntity<List<ConsultantDTO>> strictQueryConsultant(@RequestBody StrictQueryConsultantParam param) { List<ConsultantDTO> queryResult = consultantService.strictQueryConsultant(param); return new ResponseEntity<>(queryResult, HttpStatus.OK); } - + @Deprecated @PostMapping("/fastQuery") public ResponseEntity<List<ConsultantDTO>> fastQueryConsultant(@RequestBody FastQueryConsultantParam param) { List<ConsultantDTO> queryResult = consultantService.fastQueryConsultant(param); @@ -72,15 +93,23 @@ return consultantService.getMyAppointment(); } - @GetMapping(value = "/avatar/{fileName}", produces = MediaType.IMAGE_JPEG_VALUE) - public ResponseEntity<byte[]> getAvatarImage(@PathVariable String fileName) throws IOException { - try { - Resource resource = new ClassPathResource("static/consultant/" + fileName); - InputStream in = resource.getInputStream(); - return new ResponseEntity<>(IOUtils.toByteArray(in), HttpStatus.OK); - } catch (FileNotFoundException e) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } + @GetMapping(value = "/avatar/{agentNo}", produces = MediaType.IMAGE_JPEG_VALUE) + public ResponseEntity<byte[]> getAvatarImage(@PathVariable String agentNo) throws IOException { +// try { +// Resource resource = new ClassPathResource("static/consultant/" + fileName); +// InputStream in = resource.getInputStream(); +// return new ResponseEntity<>(IOUtils.toByteArray(in), HttpStatus.OK); +// } catch (FileNotFoundException e) { +// return new ResponseEntity<>(HttpStatus.NOT_FOUND); +// } + InputStream in = consultantService.getAvatarImage(agentNo); + if(in!=null) { + return new ResponseEntity<>(IOUtils.toByteArray(in), HttpStatus.OK); + }else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + } @PostMapping("/record/allAppointmentsView") @@ -88,4 +117,23 @@ consultantService.recordAllAppointmentsView(); return ResponseEntity.noContent().build(); } + + @PostMapping("/edit") + public ResponseEntity<Consultant> editConsultant(@RequestBody ConsultantEditDTO editDTO) { + if(!editDTO.getAgentNo().equals(SecurityUtils.getAgentNo())) { + throw new IllegalAccessError(); + } + Consultant editResult = consultantService.editConsultant(editDTO); + return new ResponseEntity<>(editResult, HttpStatus.OK); + } + + @PostMapping("/sendSatisfactionToClient/{appointmentId}") + public ResponseEntity<Void> sendSatisfactionToClient(@PathVariable Long appointmentId) { + Appointment appointment = appointmentService.findById(appointmentId); + if(!appointment.getAgentNo().equals(SecurityUtils.getAgentNo())) { + throw new IllegalAccessError(); + } + consultantService.sendSatisfactionToClient(appointment); + return ResponseEntity.noContent().build(); + } } -- Gitblit v1.8.0