蔡德晨 пре 5 година
родитељ
комит
2659edb478

+ 8 - 30
src/main/java/com/jeeplus/modules/sys/web/UserController.java

@@ -6,6 +6,7 @@ package com.jeeplus.modules.sys.web;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.jeeplus.common.beanvalidator.BeanValidators;
+import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.json.ComNameJson;
@@ -765,39 +766,16 @@ public class UserController extends BaseController {
     @RequestMapping(value = "imageUpload")
     public String imageUpload( HttpServletRequest request, HttpServletResponse response,MultipartFile file) throws IllegalStateException, IOException {
         User currentUser = UserUtils.getUser();
-        String oldPhoto = currentUser.getPhoto();
-        String key = "";
-        if(StringUtils.isNotBlank(oldPhoto)){
-            String aliyunUrl = Global.getAliyunUrl();
-            String aliDownloadUrl = Global.getAliDownloadUrl();
-            String cons = "";
-            if (oldPhoto.contains(aliyunUrl)){
-                cons = aliyunUrl;
-            }else if (oldPhoto.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
-                cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
-            }else {
-                cons = aliDownloadUrl;
-            }
-            String[] arr = oldPhoto.split(cons+"/");
-            key = arr[1];
-        }
-        OSSClientUtil ossUtil =new OSSClientUtil();
-        // 判断文件是否为空
-        if (!file.isEmpty()) {
-            String filepath= ossUtil.uploadFile2OSS(file, "photo");
-            ossUtil.deleteSingleObject(key);
-            // 文件保存路径
-//            	String realPath = Global.USERFILES_BASE_URL
-//        		+ UserUtils.getPrincipal() + "/images/" ;
-//                // 转存文件
-//            	FileUtils.createDirectory(Global.getUserfilesBaseDir()+realPath);
-//            	file.transferTo(new File( Global.getUserfilesBaseDir() +realPath +  file.getOriginalFilename()));
-//            	currentUser.setPhoto(request.getContextPath()+realPath + file.getOriginalFilename());
-            currentUser.setPhoto(filepath);
+        if(file != null && file.getSize()>0){
+            String path = new StringBuilder("/headImg/")
+                    .append(currentUser.getName()).append(".png").toString();
+            InputStream inputStream = file.getInputStream();
+            BOSClientUtil bosClientUtil = new BOSClientUtil();
+            String url = bosClientUtil.upload(path, inputStream);
+            currentUser.setPhoto(url);
             currentUser.setDefaultPhoto("1");
             systemService.updateUserInfo(currentUser);
         }
-
         return "modules/sys/userImageEdit";
     }
 

+ 1 - 1
src/main/java/com/jeeplus/modules/workstaff/web/WorkStaffBasicInfoController.java

@@ -226,7 +226,7 @@ public class WorkStaffBasicInfoController extends BaseController {
 		}
 		MultipartFile pictureFile = workStaffBasicInfo.getPictureFile();
 		if(pictureFile != null && pictureFile.getSize()>0){
-			String path = new StringBuilder("/headImg/")
+			String path = new StringBuilder("/employeeImg/")
 			.append(workStaffBasicInfo.getName()).append(".png").toString();
 			InputStream inputStream = pictureFile.getInputStream();
 			BOSClientUtil bosClientUtil = new BOSClientUtil();

+ 2 - 3
src/main/webapp/webpage/modules/sys/userInfo.jsp

@@ -126,8 +126,7 @@
                     type: 2,
                     area: [width, height],
                     title: "上传头像",
-                    content: "${ctx}/sys/user/imageEdit",
-                    //  btn: ['确定', '关闭'],
+                    content: "${ctx}/sys/user/imageEdit", //  btn: ['确定', '关闭'],
                     yes: function (index, layero) {
                         var body = top.layer.getChildFrame('body', index);
                         var inputForm = body.find('#inputForm');
@@ -495,7 +494,7 @@
                                                         <c:choose>
                                                             <c:when test="${not empty workStaffBasicInfo.picture}">
                                                                 <%--<span id="this_upload_close_1" class="pic_close glyphicon glyphicon-remove" onclick="this_close_img(1)"></span>--%>
-                                                                <img alt="_blank" id="this_upload_image_1" class="upload_ico" style="cursor:pointer;"  src="${workStaffBasicInfo.picture}?x-oss-process=image/resize,w_150,limit_0" />
+                                                                <img alt="_blank" id="this_upload_image_1" class="upload_ico" style="cursor:pointer;"  src="${workStaffBasicInfo.picture}" />
                                                             </c:when>
                                                             <c:otherwise>
                                                                 <img alt="_blank" id="this_upload_image_1" class="upload_ico" style="cursor:pointer;"  src="${pageContext.request.contextPath}/static/common/img/pic_add.png" />

+ 1 - 0
src/main/webapp/webpage/modules/workstaff/workStaffBasicInfoForm.jsp

@@ -77,6 +77,7 @@
                 }
             });
 
+
             var layDateArr = $(".layer-date");
             for(var i=0;i<layDateArr.length;i++){
                 var id = '#'+$(layDateArr[i]).attr("id");