国际化
This commit is contained in:
1 parent
789ccca90e
commit
fc8afe4de7
6 files changed
+47
-1
No files matched your search
+6
@@ -345,6 +345,12 @@ public interface ErrorCodes {
|
||||
/** 钱包类型id不能为空 */
|
||||
String WALLET_TYPE_ID_EMPTY = "wallet.type.id.empty";
|
||||
|
||||
/** 饭卡钱包(展示名) */
|
||||
String WALLET_TYPE_NAME_EAT = "wallet.type.name.eat";
|
||||
|
||||
/** 消费钱包(展示名) */
|
||||
String WALLET_TYPE_NAME_PAY = "wallet.type.name.pay";
|
||||
|
||||
/** 备注不能为空 */
|
||||
String WALLET_REMARK_EMPTY = "wallet.remark.empty";
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ delivery.mch.schedule.title=Scheduled delivery reminder
|
||||
delivery.mch.schedule.body=A scheduled delivery is entering prep time. Please check it.
|
||||
delivery.rider.building.bound=Buildings under this unit already have riders. Unbind first.
|
||||
wallet.type.id.empty=Wallet type ID is required
|
||||
wallet.type.name.eat=Meal Card Wallet
|
||||
wallet.type.name.pay=Spending Wallet
|
||||
wallet.remark.empty=Remark is required
|
||||
wallet.not.found=Wallet not found
|
||||
wallet.freeze.dup=Request already submitted
|
||||
|
||||
@@ -98,6 +98,8 @@ delivery.mch.schedule.title=预约外送提醒
|
||||
delivery.mch.schedule.body=您有一单预约外送即将进入备餐时段,请及时查看
|
||||
delivery.rider.building.bound=该单位下楼栋已绑定骑手,请先解绑
|
||||
wallet.type.id.empty=钱包类型id不能为空
|
||||
wallet.type.name.eat=饭卡钱包
|
||||
wallet.type.name.pay=消费钱包
|
||||
wallet.remark.empty=备注不能为空
|
||||
wallet.not.found=钱包不存在
|
||||
wallet.freeze.dup=已提交申请,请勿重复提交
|
||||
|
||||
@@ -98,6 +98,8 @@ delivery.mch.schedule.title=預約外送提醒
|
||||
delivery.mch.schedule.body=您有一單預約外送即將進入備餐時段,請及時查看
|
||||
delivery.rider.building.bound=該單位下樓棟已綁定騎手,請先解綁
|
||||
wallet.type.id.empty=錢包類型id不能為空
|
||||
wallet.type.name.eat=飯卡錢包
|
||||
wallet.type.name.pay=消費錢包
|
||||
wallet.remark.empty=備註不能為空
|
||||
wallet.not.found=錢包不存在
|
||||
wallet.freeze.dup=已提交申請,請勿重複提交
|
||||
|
||||
+33
-1
@@ -1,7 +1,10 @@
|
||||
package com.bsd.pjcloud.wallet.api.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.MsgUtils;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
@@ -35,13 +38,42 @@ public class WalletDataUtil {
|
||||
public <T extends BaseWalletTypeInterface> T convertWalletType(T v, WalletTypeEntity vo) {
|
||||
if (ObjectUtil.isEmpty(vo)) return v;
|
||||
v.setWalletTypeId(vo.getId());
|
||||
v.setWalletTypeName(vo.getName());
|
||||
v.setWalletTypeUniqueCode(vo.getUniqueCode());
|
||||
v.setWalletTypeName(resolveWalletTypeName(vo.getUniqueCode(), vo.getName()));
|
||||
v.setWalletTypeIcon(vo.getIcon());
|
||||
v.setIsRule(vo.getIsRule());
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按钱包类型唯一编码返回当前语言的展示名;未知类型回退库表名称。
|
||||
*/
|
||||
public String resolveWalletTypeName(String uniqueCode, String fallbackName) {
|
||||
WalletTypeEnum type = WalletTypeEnum.valueOfByCode(uniqueCode);
|
||||
if (type == WalletTypeEnum.EAT) {
|
||||
return MsgUtils.getMessage(ErrorCodes.WALLET_TYPE_NAME_EAT);
|
||||
}
|
||||
if (type == WalletTypeEnum.PAY) {
|
||||
return MsgUtils.getMessage(ErrorCodes.WALLET_TYPE_NAME_PAY);
|
||||
}
|
||||
return fallbackName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对已带 uniqueCode 的列表原地刷新 walletTypeName(覆盖 SQL join 的中文名)。
|
||||
*/
|
||||
public <T extends BaseWalletTypeInterface> void localizeWalletTypeNames(List<T> list) {
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
for (T item : list) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
item.setWalletTypeName(resolveWalletTypeName(item.getWalletTypeUniqueCode(), item.getWalletTypeName()));
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends BaseWalletInterface> List<T> convertWalletList(List<T> list, Map<Long, WalletManageEntity> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertWallet(v, map.get(v.getWalletId())));
|
||||
}
|
||||
|
||||
+2
@@ -683,6 +683,8 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
WalletDataUtil.convertWalletTypeList(list, CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
|
||||
}
|
||||
}
|
||||
// SQL join / 转换后统一按 uniqueCode 做展示名国际化
|
||||
WalletDataUtil.localizeWalletTypeNames(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user