wangwei 7 years ago
parent
commit
961b52a5b4

+ 11 - 1
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -17,9 +17,11 @@ import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -57,6 +59,12 @@ public class OrgApi {
 
     @Autowired
     OrgService orgService;
+    
+	@Value("${staticResource.rootPath}")
+	private String rootPath;
+	
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
 
     @ApiOperation(value = "查询机构分页带查询", notes = "分页带查询")
     @GetMapping("/all/{curPage}/{pageSize}")
@@ -278,7 +286,9 @@ public class OrgApi {
 	public ResponseEntity importLogo(@PathVariable Long id, HttpServletRequest request,
 			@RequestParam CommonsMultipartFile file) {
 		try {
-			FileUtils.copyInputStreamToFile(file.getInputStream(), new File("D:/Temp/fuck.jpg"));
+			String filePath = rootPath + "/logo/" + id + ".jpg";
+			FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
+			jdbcTemplate.update("update ecs_core_org t set  t.logo=? where t.id=?", filePath, id);
 			return new ResponseEntity("", HttpStatus.OK);
 		} catch (Exception e) {
 			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);