修改个人键盘多语言兜底策略

This commit is contained in:
2026-04-03 16:43:43 +08:00
parent dbc7ee365d
commit 02dd37ffaf
2 changed files with 7 additions and 1 deletions

View File

@@ -159,6 +159,9 @@ public class KeyboardCharacterServiceImpl extends ServiceImpl<KeyboardCharacterM
public List<KeyboardUserCharacterVO> selectListByUserId(String acceptLanguage) {
long loginId = StpUtil.getLoginIdAsLong();
String locale = RequestLocaleUtils.resolveLanguage(acceptLanguage);
if (!StringUtils.hasText(locale)) {
locale = DEFAULT_FALLBACK_LOCALE;
}
return keyboardUserCharacterMapper.selectByUserId(loginId, locale);
}

View File

@@ -9,7 +9,7 @@
SELECT
kuc.id,
kuc.character_id,
kci.character_name,
COALESCE(kci.character_name, kci_en.character_name) AS character_name,
kuc.emoji
FROM keyboard_user_character kuc
JOIN keyboard_user_sort kus
@@ -17,6 +17,9 @@
LEFT JOIN keyboard_character_i18n kci
ON kuc.character_id = kci.character_id
AND kci."locale" = #{locale}
LEFT JOIN keyboard_character_i18n kci_en
ON kuc.character_id = kci_en.character_id
AND kci_en."locale" = 'en'
WHERE kuc.user_id = #{loginId}
AND kuc.deleted = FALSE
ORDER BY array_position(kus.user_characteu_id_sort, kuc.id) NULLS LAST;