保誠-保戶業務員媒合平台
Jack
2021-12-03 0e73f60f5e9acede5438b0c38332183916f9d552
pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
@@ -2,26 +2,30 @@
import com.pollex.pam.service.ConsultantService;
import com.pollex.pam.service.dto.*;
import org.apache.commons.compress.utils.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@RestController
@RequestMapping("/api/consultant")
public class ConsultantResource {
    private final ConsultantService consultantService;
    public ConsultantResource(ConsultantService consultantService) {
        this.consultantService = consultantService;
    }
    @Autowired
    ConsultantService consultantService;
    @GetMapping("/favorite")
    public ResponseEntity<List<ConsultantDTO>> getMyConsultantList() {
        List<ConsultantDTO> myConsultants = consultantService.getMyConsultantList();
    public ResponseEntity<List<CustomerFavoriteConsultantDTO>> getMyConsultantList() {
        List<CustomerFavoriteConsultantDTO> myConsultants = consultantService.getMyConsultantList();
        return new ResponseEntity<>(myConsultants, HttpStatus.OK);
    }
@@ -37,21 +41,50 @@
        return new ResponseEntity<>(HttpStatus.ACCEPTED);
    }
    @GetMapping("/strictQuery")
    @DeleteMapping("/favorite/{agentNo}")
    public ResponseEntity<Void> removeConsultantFromCustomList(@PathVariable String agentNo) {
        consultantService.removeConsultantFromCustomList(agentNo);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping("/strictQuery")
    public ResponseEntity<List<ConsultantDTO>> strictQueryConsultant(@RequestBody StrictQueryConsultantParam param) {
        List<ConsultantDTO> queryResult = consultantService.strictQueryConsultant(param);
        return new ResponseEntity<>(queryResult, HttpStatus.OK);
    }
    @GetMapping("/fastQuery")
    @PostMapping("/fastQuery")
    public ResponseEntity<List<ConsultantDTO>> fastQueryConsultant(@RequestBody FastQueryConsultantParam param) {
        List<ConsultantDTO> queryResult = consultantService.fastQueryConsultant(param);
        return new ResponseEntity<>(queryResult, HttpStatus.OK);
    }
    @GetMapping("/detail/{agentNo}")
    public ResponseEntity<ConsultantDetailDTO> getConsultantDetail(@PathVariable String agentNo) {
    @GetMapping("/detail")
    public ResponseEntity<ConsultantDetailDTO> getConsultantDetail(@RequestParam("agentNo") String agentNo) {
        ConsultantDetailDTO result = consultantService.getConsultantDetail(agentNo);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }
    @GetMapping("/getMyAppointment")
    public List<AppointmentCustomerViewDTO> getMyAppointment() {
       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);
        }
    }
    @PostMapping("/record/allAppointmentsView")
    public ResponseEntity<Void> recordAllAppointmentsView() {
        consultantService.recordAllAppointmentsView();
        return ResponseEntity.noContent().build();
    }
}