From 4114e871bcb3dce771b6aed64a1027d0bbb95ca6 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 16 五月 2019 15:28:37 +0800 Subject: [PATCH] 增加动态用户 --- fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java | 157 +++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 118 insertions(+), 39 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 9bfbae8..9cacef4 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; @@ -86,6 +88,7 @@ import com.yeshi.fanli.service.inter.user.BindingAccountService; import com.yeshi.fanli.service.inter.user.ExtractRecordService; import com.yeshi.fanli.service.inter.user.ExtractService; +import com.yeshi.fanli.service.inter.user.MaskKeyService; import com.yeshi.fanli.service.inter.user.ShamUserService; import com.yeshi.fanli.service.inter.user.SpreadUserImgService; import com.yeshi.fanli.service.inter.user.UserAccountService; @@ -202,6 +205,10 @@ @Resource private AccountMessageService accountMessageService; + + @Resource + private MaskKeyService maskKeyService; + private static final String PASSWORD_MAX_ERROR = "password_max_error"; private static final String EXTRACT_MIN_MONEY = "extract_min_money"; @@ -518,7 +525,6 @@ } } } - GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); @@ -577,12 +583,12 @@ int welfareCenterNews = 0; String invitCode = null; UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(user.getId()); - if (userInfoExtra != null ) { - if(userInfoExtra.getCouponNews() != null) { + if (userInfoExtra != null) { + if (userInfoExtra.getCouponNews() != null) { welfareCenterNews = userInfoExtra.getCouponNews(); } - - if(userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { + + if (userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { invitCode = userInfoExtra.getInviteCode(); } } @@ -1052,7 +1058,6 @@ return; } - /** * 鏂扮増鎻愮幇 * @@ -1158,13 +1163,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 +1183,10 @@ out.print(JsonUtil.loadFalseResult("宸茶秴杩囧綋鏃ユ彁鐜伴噾棰�")); } else if (etype == 3) { out.print(JsonUtil.loadFalseResult("鎻愮幇閲戦澶т簬鎴戠殑绾㈠寘")); + } else if (etype == 111) { + out.print(JsonUtil.loadFalseResult("鏇存崲浜嗘墜鏈哄彿鍚�7澶╁唴涓嶅厑璁告彁鐜�")); + } else if (etype == 110) { + out.print(JsonUtil.loadFalseResult(Constant.znxConfig.getExtractWrongMsg())); } } @@ -1650,7 +1663,6 @@ } - /** * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.5.3鏌ヨ鏈夋晥闃熷憳 * @@ -1722,9 +1734,7 @@ e.printStackTrace(); } } - - - + /** * 鐢ㄦ埛闃熷憳缁熻 1.4.1 * @@ -1996,7 +2006,7 @@ e.printStackTrace(); } } - + /** * 鑾峰彇鐢ㄦ埛淇℃伅 * @@ -2014,14 +2024,14 @@ out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; } - + if (uid == null) { out.print(JsonUtil.loadFalseResult("璇锋眰鍙傛暟涓虹┖")); return; } - + UserInfo userInfo = userInfoService.getUserInfo(uid); - + // 娣诲姞鐢ㄦ埛娲昏穬璁板綍 UserActiveLog userActiveLog = new UserActiveLog(); userActiveLog.setChannel(acceptData.getChannel()); @@ -2031,23 +2041,14 @@ userActiveLog.setOsVersion(acceptData.getOsVersion()); userActiveLog.setDeviceType(acceptData.getDeviceType()); userActiveLogService.addUserActiveLog(userActiveLog); - + // 澶勭悊鐢ㄦ埛淇℃伅 outUserInfoHandle(userInfo); - + GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); JSONObject data = new JSONObject(); data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo)); - -// if ("ios".equalsIgnoreCase(acceptData.getPlatform()) -// && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) { -// data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html", -// Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName())); -// } else { -// data.put("inviteList", configService.get("team_list")); -// } -// // 鐣岄潰鐘舵�� UserSettingsVO mySettings = null; try { @@ -2074,19 +2075,18 @@ } data.put("moduleState", mySettings); - int welfareCenterNews = 0; String invitCode = null; UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); - if (userInfoExtra != null ) { - if(userInfoExtra.getCouponNews() != null) { + if (userInfoExtra != null) { + if (userInfoExtra.getCouponNews() != null) { welfareCenterNews = userInfoExtra.getCouponNews(); } - - if(userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { + + if (userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { invitCode = userInfoExtra.getInviteCode(); } - + if (userInfoExtra.getUserRank() != null) { String picture = userInfoExtra.getUserRank().getPicture(); String icon = userInfoExtra.getUserRank().getIcon(); @@ -2097,7 +2097,7 @@ userInfo.setRankIcon(null); } } - + data.put("invitCode", invitCode); // 閭�璇风爜 data.put("welfareCenterNews", welfareCenterNews);// 绂忓埄涓績娑堟伅 out.print(JsonUtil.loadTrueResult(data)); @@ -2120,7 +2120,7 @@ } } }); - + } catch (UserInfoException e) { out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); } catch (Exception e) { @@ -2128,9 +2128,9 @@ e.printStackTrace(); } } - + private void outUserInfoHandle(UserInfo user) { - + // 绾㈠寘澶勭悊 user.setTotalHongBao(new BigDecimal(0)); user.setNoOpenHongBao(new BigDecimal(0)); @@ -2145,7 +2145,7 @@ user.setPhone(phone); } } - + UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { String picture = userInfoExtra.getUserRank().getPicture(); @@ -2154,5 +2154,84 @@ user.setRankIcon(icon); } } + + /** + * 鐢ㄦ埛鏇存崲澶村儚 + * @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; + } + + if(maskKeyService.examineContent(nickName)) { + 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