From a5ef6c9bc6667bb32eca58542f39e0709173a6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Mon, 28 Apr 2025 10:37:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90bug-108=E3=80=91=E7=BB=99?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E9=85=8D=E7=BD=AE=E7=9A=84=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E8=B6=85=E5=87=BA72=E5=B0=8F=E6=97=B6=E6=B2=A1=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E5=B0=B1=E6=B2=A1=E5=8A=9E=E6=B3=95=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E9=9C=80=E8=A6=81=E5=A2=9E=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E5=8F=91=E6=BF=80=E6=B4=BB=E9=82=AE=E4=BB=B6=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户端和管理端都加上 --- .../admin/controller/AppUserController.java | 30 +++++++++++----- .../cfs/controller/UserController.java | 34 +++++++++++++------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java index d09a0285..144f38ef 100644 --- a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java +++ b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java @@ -386,14 +386,28 @@ public class AppUserController extends ControllerBase { public ApiResult sendResetPasswordEmail(@Valid @RequestBody @NotEmpty List ids){ try { for (Integer id : ids) { - String password=RandomUtil.randomString(6); - AppUser appUser=appUserService.resetPassword(id,password); - String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode()); - String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode()) - .replace("${loginName}",appUser.getLoginName()) - .replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail()+"|0").getBytes())) - .replace("${password}",password); - emailService.sendEmail(appUser.getEmail(), subject, content); + AppUser appUser = appUserService.getById(id); + if (Objects.nonNull(appUser)) { + if (Objects.equals(appUser.getState().intValue(), 1)) { + String password = RandomUtil.randomString(6); + appUserService.resetPassword(id, password); + String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode()); + String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode()) + .replace("${loginName}", appUser.getLoginName()) + .replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes())) + .replace("${password}", password); + emailService.sendEmail(appUser.getEmail(), subject, content); + } else if(Objects.equals(appUser.getState().intValue(), 0)){ + String password = RandomUtil.randomString(6); + String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, appUser.getLanguageCode()); + String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, appUser.getLanguageCode()) + .replace("${loginName}", appUser.getEmail()) + .replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes())) + .replace("${password}", password) + .replace("${website}", websiteUrl); + emailService.sendEmail(appUser.getEmail(), subject, content); + } + } } }catch (Exception ex){ throw new NflgException(STATE.BusinessError,"发送邮件失败:"+ex.getMessage()); diff --git a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java index 2f839ca2..41750927 100644 --- a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java +++ b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java @@ -291,7 +291,7 @@ public class UserController extends ControllerBase { String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode()); String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode()) .replace("${loginName}",appUser.getLoginName()) - .replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(email.getBytes())) + .replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((email+"|0").getBytes())) .replace("${password}",password); emailService.sendEmail(email, subject,content); } catch (Exception ex) { @@ -310,15 +310,29 @@ public class UserController extends ControllerBase { public ApiResult sendResetPasswordEmail(@Valid @RequestBody @NotEmpty List ids){ try { for (Integer id : ids) { - String password=RandomUtil.randomString(6); - AppUser appUser=appUserService.resetPassword(id,password); - String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode()); - String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode()) - .replace("${loginName}",appUser.getLoginName()) - .replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(appUser.getEmail().getBytes())) - .replace("${password}",password) - .replace("${website}",websiteUrl); - emailService.sendEmail(appUser.getEmail(), subject, content); + AppUser appUser = appUserService.getById(id); + if (Objects.nonNull(appUser)) { + if (Objects.equals(appUser.getState().intValue(), 1)) { + String password = RandomUtil.randomString(6); + appUserService.resetPassword(id, password); + String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode()); + String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode()) + .replace("${loginName}", appUser.getLoginName()) + .replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail()+"|0").getBytes())) + .replace("${password}", password) + .replace("${website}", websiteUrl); + emailService.sendEmail(appUser.getEmail(), subject, content); + } else if(Objects.equals(appUser.getState().intValue(), 0)){ + String password = RandomUtil.randomString(6); + String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, appUser.getLanguageCode()); + String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, appUser.getLanguageCode()) + .replace("${loginName}", appUser.getEmail()) + .replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes())) + .replace("${password}", password) + .replace("${website}", websiteUrl); + emailService.sendEmail(appUser.getEmail(), subject, content); + } + } } }catch (Exception ex){ throw new NflgException(STATE.BusinessError,"发送邮件失败:"+ex.getMessage());