From 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 14 五月 2019 11:37:49 +0800 Subject: [PATCH] 合并 --- fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java | 87 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 84 insertions(+), 3 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java index f047af1..6a7ad9b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java @@ -1,5 +1,6 @@ package com.yeshi.fanli.controller.client; +import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; @@ -21,6 +22,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.multipart.MultipartFile; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.IPUtil; import org.yeshi.utils.JsonUtil; @@ -1156,13 +1158,17 @@ } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - AdminUser adminUser = adminUserService.selectByPrimaryKey(4L); + + long[] targetUids = new long[] { 3L, 4L }; Config config = configService.getConfig("extract_code_email_from"); String[] sts = config.getValue().split(","); String account = sts[0]; String pwd = sts[1]; - String msg = "鎻愮幇瀹℃牳閾炬帴:" + url; - boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg); + for (long adminId : targetUids) { + AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId); + String msg = "鎻愮幇瀹℃牳閾炬帴:" + url; + boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg); + } } }); return; @@ -1174,6 +1180,8 @@ out.print(JsonUtil.loadFalseResult("鎻愮幇閲戦澶т簬鎴戠殑绾㈠寘")); } else if (etype == 111) { out.print(JsonUtil.loadFalseResult("鏇存崲浜嗘墜鏈哄彿鍚�7澶╁唴涓嶅厑璁告彁鐜�")); + } else if (etype == 110) { + out.print(JsonUtil.loadFalseResult(Constant.znxConfig.getExtractWrongMsg())); } } @@ -2142,4 +2150,77 @@ } } + + /** + * 鐢ㄦ埛鏇存崲澶村儚 + * @param acceptData + * @param fileList + * @param uid + * @param request + * @param out + */ + @RequestMapping(value = "uploadPortrait") + public void uploadPortrait(AcceptData acceptData, MultipartFile file, Long uid, HttpServletRequest request, PrintWriter out) { + try { + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + if (file == null) { + out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘涓虹┖")); + return; + } + + long fileSize = file.getSize() / 1024 + 1; + if (fileSize > 200) { + out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘澶т簬200kb")); + return; + } + userInfoService.uploadPortrait(file, uid); + out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); + } catch (UserInfoException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (IOException e) { + out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触澶辫触")); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鏇存崲鏄电О + * @param acceptData + * @param nickName + * @param uid + * @param out + */ + @RequestMapping(value = "saveInfo") + public void saveInfo(AcceptData acceptData, String nickName, Long uid, PrintWriter out) { + try { + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + if (StringUtil.isNullOrEmpty(nickName)) { + out.print(JsonUtil.loadFalseResult("鏄电О涓嶈兘涓虹┖")); + return; + } + if (nickName.length() > 200) { + out.print(JsonUtil.loadFalseResult("鏄电О杩囬暱")); + return; + } + userInfoService.saveUserInfo(nickName, uid); + + out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); + } catch (UserInfoException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触")); + e.printStackTrace(); + } + } } -- Gitblit v1.8.0