From a802b15b8f885041ea1b862326c91582794ab593 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期五, 12 十一月 2021 17:31:59 +0800
Subject: [PATCH] [update] #todo129741,取得顧問頭像api

---
 pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 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 eb20daf..0323979 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
@@ -2,10 +2,17 @@
 
 import com.pollex.pam.service.ConsultantService;
 import com.pollex.pam.service.dto.*;
+import org.apache.commons.compress.utils.IOUtils;
+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.web.bind.annotation.*;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.List;
 
 @RestController
@@ -53,10 +60,20 @@
         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);
+        }
+    }
 }

--
Gitblit v1.8.0