From b3d3e276eaeee5705e90169c7fa369dc13f63cf5 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 20 Nov 2025 19:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9D=E8=A7=84=E6=8F=90=E7=A4=BA=E9=98=BF?= =?UTF-8?q?=E8=AF=AD=E5=8C=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/RoomViolationAdjustCmdExe.java | 38 +++++++++++++++---- .../room/RoomViolationWarningCmdExe.java | 37 ++++++++++++++---- .../user/UserViolationAdjustCmdExe.java | 30 ++++++++++++--- .../user/UserViolationWarningCmdExe.java | 30 ++++++++++++--- 4 files changed, 111 insertions(+), 24 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java index 675fe4b4..e94ffe39 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java @@ -14,6 +14,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum; import com.red.circle.other.app.enums.violation.ViolationTypeEnum; import com.red.circle.other.app.service.room.RoomThemeService; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway; import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.violation.ViolationRecord; @@ -51,6 +52,7 @@ public class RoomViolationAdjustCmdExe { private final RoomProfileManagerService roomProfileManagerService; private final AdministratorAuthService administratorAuthService; private final OfficialNoticeClient officialNoticeClient; + private final UserRegionGateway userRegionGateway; private final UserProfileGateway userProfileGateway; private final EnumConfigCacheService enumConfigCacheService; private final AdministratorService administratorService; @@ -182,7 +184,7 @@ public class RoomViolationAdjustCmdExe { * 发送调整通知 */ private void sendAdjustNotification(Long userId, ViolationTypeEnum violationType, String adjustedContent) { - String content = getAdjustNotificationContent(violationType, adjustedContent); + String content = getAdjustNotificationContent(userId, violationType, adjustedContent); Map titleMap = new HashMap<>(); titleMap.put("type", "violation_adjust"); @@ -200,13 +202,35 @@ public class RoomViolationAdjustCmdExe { /** * 获取调整通知内容 */ - private String getAdjustNotificationContent(ViolationTypeEnum violationType, String adjustedContent) { + private String getAdjustNotificationContent(Long userId, ViolationTypeEnum violationType, String adjustedContent) { + boolean isArabic = isArabicRegion(userId); + return switch (violationType) { - case ROOM_NICKNAME -> String.format("Your room name has been changed to '%s' due to violation of rules.", adjustedContent); - case ROOM_COVER -> "Your room profile picture has been changed to the default image due to violation of rules."; - case ROOM_NOTICE -> String.format("Your room notice has been changed to '%s' due to violation of regulations.", adjustedContent); - case ROOM_THEME -> "Your room theme has been changed to the default theme due to violation of rules."; - default -> "Your room information has been adjusted due to violation of rules."; + case ROOM_NICKNAME -> isArabic ? + String.format("تم تغيير اسم الغرفة إلى '%s' بسبب انتهاك القواعد.", adjustedContent) : + String.format("Your room name has been changed to '%s' due to violation of rules.", adjustedContent); + case ROOM_COVER -> isArabic ? + "تم تغيير صورة ملف الغرفة إلى الصورة الافتراضية بسبب انتهاك القواعد." : + "Your room profile picture has been changed to the default image due to violation of rules."; + case ROOM_NOTICE -> isArabic ? + String.format("تم تغيير إشعار الغرفة إلى '%s' بسبب انتهاك اللوائح.", adjustedContent) : + String.format("Your room notice has been changed to '%s' due to violation of regulations.", adjustedContent); + case ROOM_THEME -> isArabic ? + "تم تغيير سمة الغرفة إلى السمة الافتراضية بسبب انتهاك القواعد." : + "Your room theme has been changed to the default theme due to violation of rules."; + default -> isArabic ? + "تم تعديل معلومات الغرفة بسبب انتهاك القواعد." : + "Your room information has been adjusted due to violation of rules."; }; } + + private boolean isArabicRegion(Long userId) { + String regionCode = userRegionGateway.getRegionConfigByUserId(userId).getRegionCode(); + try { + return "ar".equalsIgnoreCase(regionCode); + } catch (Exception e) { + log.warn("Failed to get user region, userId={}", userId, e); + return false; + } + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationWarningCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationWarningCmdExe.java index ede6ae58..addc38e0 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationWarningCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationWarningCmdExe.java @@ -18,6 +18,7 @@ import com.red.circle.other.domain.violation.ViolationRecord; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; import com.red.circle.other.inner.asserts.RoomErrorCode; import lombok.RequiredArgsConstructor; @@ -39,6 +40,7 @@ public class RoomViolationWarningCmdExe { private final RoomProfileManagerService roomProfileManagerService; private final AdministratorAuthService administratorAuthService; private final OfficialNoticeClient officialNoticeClient; + private final UserRegionGateway userRegionGateway; private final UserProfileGateway userProfileGateway; private final AdministratorService administratorService; @@ -101,7 +103,7 @@ public class RoomViolationWarningCmdExe { * 发送警告消息 */ private void sendWarningMessage(Long userId, ViolationTypeEnum violationType) { - String content = getWarningContent(violationType); + String content = getWarningContent(userId, violationType); Map titleMap = new HashMap<>(); titleMap.put("type", "violation_warning"); @@ -119,13 +121,34 @@ public class RoomViolationWarningCmdExe { /** * 获取警告内容 */ - private String getWarningContent(ViolationTypeEnum violationType) { + private String getWarningContent(Long userId, ViolationTypeEnum violationType) { + boolean isArabic = isArabicRegion(userId); + return switch (violationType) { - case ROOM_NICKNAME -> "Your room name is in violation of the rules. Please correct the current room name immediately."; - case ROOM_COVER -> "Your room profile picture violates the rules. Please change your current room profile picture immediately."; - case ROOM_NOTICE -> "Your room notice is in violation of regulations. Please rectify it immediately."; - case ROOM_THEME -> "Your room theme violates the rules. Please rectify it immediately."; - default -> "Your room information is in violation of the rules. Please correct it immediately."; + case ROOM_NICKNAME -> isArabic ? + "اسم الغرفة ينتهك القواعد. يرجى تصحيح اسم الغرفة الحالي على الفور." : + "Your room name is in violation of the rules. Please correct the current room name immediately."; + case ROOM_COVER -> isArabic ? + "صورة ملف الغرفة تنتهك القواعد. يرجى تغيير صورة ملف الغرفة الحالية على الفور." : + "Your room profile picture violates the rules. Please change your current room profile picture immediately."; + case ROOM_NOTICE -> isArabic ? + "إشعار الغرفة ينتهك اللوائح. يرجى تصحيحه على الفور." : + "Your room notice is in violation of regulations. Please rectify it immediately."; + case ROOM_THEME -> isArabic ? + "سمة الغرفة تنتهك القواعد. يرجى تصحيحها على الفور." : + "Your room theme violates the rules. Please rectify it immediately."; + default -> isArabic ? + "معلومات الغرفة تنتهك القواعد. يرجى تصحيحها على الفور." : + "Your room information is in violation of the rules. Please correct it immediately."; }; } + + private boolean isArabicRegion(Long userId) { + try { + return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName()); + } catch (Exception e) { + log.warn("Failed to get user region, userId={}", userId, e); + return false; + } + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationAdjustCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationAdjustCmdExe.java index 058bd5d4..8d37c624 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationAdjustCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationAdjustCmdExe.java @@ -13,6 +13,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum; import com.red.circle.other.app.enums.violation.ViolationTypeEnum; import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.violation.ViolationRecord; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; @@ -45,6 +46,7 @@ public class UserViolationAdjustCmdExe { private final OfficialNoticeClient officialNoticeClient; private final EnumConfigCacheService enumConfigCacheService; private final AdministratorService administratorService; + private final UserRegionGateway userRegionGateway; @Transactional(rollbackFor = Exception.class) public ViolationHandleResultCO execute(UserViolationHandleCmd cmd) { @@ -128,7 +130,7 @@ public class UserViolationAdjustCmdExe { } private void sendAdjustMessage(Long userId, ViolationTypeEnum violationType) { - String content = buildAdjustContent(violationType); + String content = buildAdjustContent(userId, violationType); officialNoticeClient.send( NoticeExtTemplateCustomizeCmd.builder() .toAccount(userId) @@ -138,14 +140,32 @@ public class UserViolationAdjustCmdExe { .build()); } - private String buildAdjustContent(ViolationTypeEnum violationType) { + private String buildAdjustContent(Long userId, ViolationTypeEnum violationType) { + // 获取用户区域信息 + boolean isArabic = isArabicRegion(userId); + switch (violationType) { case USER_NICKNAME: - return "Your username has been adjusted due to rule violations. Please update your username as soon as possible."; + return isArabic ? + "تم تعديل اسم المستخدم الخاص بك بسبب انتهاك القواعد. يرجى تحديث اسم المستخدم الخاص بك في أقرب وقت ممكن." : + "Your username has been adjusted due to rule violations. Please update your username as soon as possible."; case USER_AVATAR: - return "Your profile picture has been adjusted due to rule violations. Please update your profile picture as soon as possible."; + return isArabic ? + "تم تعديل صورة ملفك الشخصي بسبب انتهاك القواعد. يرجى تحديث صورة ملفك الشخصي في أقرب وقت ممكن." : + "Your profile picture has been adjusted due to rule violations. Please update your profile picture as soon as possible."; default: - return "Your information has been adjusted due to rule violations. Please update it as soon as possible."; + return isArabic ? + "تم تعديل معلوماتك بسبب انتهاك القواعد. يرجى تحديثها في أقرب وقت ممكن." : + "Your information has been adjusted due to rule violations. Please update it as soon as possible."; + } + } + + private boolean isArabicRegion(Long userId) { + try { + return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName()); + } catch (Exception e) { + log.warn("Failed to get user region, userId={}", userId, e); + return false; } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationWarningCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationWarningCmdExe.java index 20823b07..cc7c7f28 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationWarningCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/user/UserViolationWarningCmdExe.java @@ -13,6 +13,7 @@ import com.red.circle.other.app.enums.violation.TargetTypeEnum; import com.red.circle.other.app.enums.violation.ViolationTypeEnum; import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.violation.ViolationRecord; import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService; @@ -42,6 +43,7 @@ public class UserViolationWarningCmdExe { private final AdministratorAuthService administratorAuthService; private final AdministratorService administratorService; private final OfficialNoticeClient officialNoticeClient; + private final UserRegionGateway userRegionGateway; @Transactional(rollbackFor = Exception.class) public ViolationHandleResultCO execute(UserViolationHandleCmd cmd) { @@ -91,7 +93,7 @@ public class UserViolationWarningCmdExe { } private void sendWarningMessage(Long userId, ViolationTypeEnum violationType) { - String content = buildWarningContent(violationType); + String content = buildWarningContent(userId, violationType); officialNoticeClient.send( NoticeExtTemplateCustomizeCmd.builder() .toAccount(userId) @@ -101,14 +103,32 @@ public class UserViolationWarningCmdExe { .build()); } - private String buildWarningContent(ViolationTypeEnum violationType) { + private String buildWarningContent(Long userId, ViolationTypeEnum violationType) { + // 获取用户区域信息 + boolean isArabic = isArabicRegion(userId); + switch (violationType) { case USER_NICKNAME: - return "Your username is in violation of the rules. Please correct the current username immediately."; + return isArabic ? + "اسم المستخدم الخاص بك ينتهك القواعد. يرجى تصحيح اسم المستخدم الحالي على الفور." : + "Your username is in violation of the rules. Please correct the current username immediately."; case USER_AVATAR: - return "Your user profile picture is in violation of the rules. Please correct your current user profile picture immediately."; + return isArabic ? + "صورة ملفك الشخصي تنتهك القواعد. يرجى تصحيح صورة ملفك الشخصي الحالية على الفور." : + "Your user profile picture is in violation of the rules. Please correct your current user profile picture immediately."; default: - return "Your information violates the rules. Please correct it immediately."; + return isArabic ? + "معلوماتك تنتهك القواعد. يرجى تصحيحها على الفور." : + "Your information violates the rules. Please correct it immediately."; + } + } + + private boolean isArabicRegion(Long userId) { + try { + return "ar".equalsIgnoreCase(userRegionGateway.getRegionConfigByUserId(userId).getRegionName()); + } catch (Exception e) { + log.warn("Failed to get user region, userId={}", userId, e); + return false; } }