From f37d3346418c9c10b5afcf634bb2a35b28616e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 2 Apr 2026 15:44:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(repository):=20=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E5=80=BC=E7=BF=BB=E8=AF=91=E6=9C=8D=E5=8A=A1=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建 DictionaryItemTranslateServiceImpl 服务实现类 - 实现多语言字典值查询和翻译功能 - 添加购物车VO中交付方式名称和币种名称字段 - 集成字典翻译服务到购物车控制器中 - 实现按字典项ID和语言代码获取翻译值的方法 - 添加评价选项多语言支持功能 --- .../controller/app/ShoppingController.java | 5 +++ .../quotation/pojo/vo/ShoppingCartVO.java | 10 ++++++ .../IDictionaryItemTranslateService.java | 2 ++ .../DictionaryItemTranslateServiceImpl.java | 32 +++++++++++++------ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java index 3e1ec635..74773ad6 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java @@ -121,6 +121,9 @@ public class ShoppingController extends ControllerBase { @Resource private StringRedisTemplate stringRedisTemplate; + @Resource + private IDictionaryItemTranslateService dictionaryItemTranslateService; + /** * 购物车-获取报价对象 */ @@ -565,6 +568,8 @@ public class ShoppingController extends ControllerBase { List adjustItems = shoppingOrderAdjustItemService.getParts(id); carts.forEach(cart -> { ShoppingCartVO cartVO = Convert.convert(ShoppingCartVO.class, cart); + cartVO.setDeliveryMethodName(dictionaryItemTranslateService.getByDictionaryItemId(cartVO.getDeliveryMethod(), MultilingualUtil.getLanguage())); + cartVO.setCurrencyName(dictionaryItemTranslateService.getByDictionaryItemId(cartVO.getCurrency(), MultilingualUtil.getLanguage())); QuotationShoppingOrderAdjustItem adjustItem = adjustItems.stream() .filter(item -> item.getCartId().equals(cart.getId()) && item.getConfigItemId().equals(0L)) .findFirst() diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/ShoppingCartVO.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/ShoppingCartVO.java index 9b68a5cd..1081aaf4 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/ShoppingCartVO.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/ShoppingCartVO.java @@ -115,6 +115,11 @@ public class ShoppingCartVO { */ private Long deliveryMethod; + /** + * 交货方式名称 + */ + private String deliveryMethodName; + /** * 交货时间 */ @@ -145,6 +150,11 @@ public class ShoppingCartVO { */ private Long currency; + /** + * 币种名称 + */ + private String currencyName; + /** * 汇率 */ diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IDictionaryItemTranslateService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IDictionaryItemTranslateService.java index a91394c5..a272060d 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IDictionaryItemTranslateService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IDictionaryItemTranslateService.java @@ -36,4 +36,6 @@ public interface IDictionaryItemTranslateService extends IService getListByDictionaryCode(String dictionaryCode); + + String getByDictionaryItemId(Long dictionaryItemId, String language); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DictionaryItemTranslateServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DictionaryItemTranslateServiceImpl.java index ccb13392..eff54099 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DictionaryItemTranslateServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DictionaryItemTranslateServiceImpl.java @@ -25,12 +25,12 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; /** *

* 字典值翻译 服务实现类 *

- * * @author 曹鹏飞 * @since 2025-01-20 */ @@ -48,12 +48,12 @@ public class DictionaryItemTranslateServiceImpl extends ServiceImpl getListByDictionaryItemId(Long id) { - List datas=baseMapper.getListByDictionaryItemId(id); - List languages=languageService.getLanguages(); - languages.forEach(l->{ - DictionaryItemTranslateVO vo=datas.stream().filter(d->StrUtil.equals(l.getCode(),d.getCode())).findFirst().orElse(null); - if (Objects.isNull(vo)){ - vo=new DictionaryItemTranslateVO() + List datas = baseMapper.getListByDictionaryItemId(id); + List languages = languageService.getLanguages(); + languages.forEach(l -> { + DictionaryItemTranslateVO vo = datas.stream().filter(d -> StrUtil.equals(l.getCode(), d.getCode())).findFirst().orElse(null); + if (Objects.isNull(vo)) { + vo = new DictionaryItemTranslateVO() .setCode(l.getCode()) .setName(l.getName()); datas.add(vo); @@ -130,9 +130,9 @@ public class DictionaryItemTranslateServiceImpl extends ServiceImpl getListByDictionaryCode(String dictionaryCode) { return baseMapper.getByDictionaryCode(dictionaryCode); } + + @Override + public String getByDictionaryItemId(Long dictionaryItemId, String language) { + DictionaryItemTranslate translate = lambdaQuery() + .eq(DictionaryItemTranslate::getDictionaryItemId, dictionaryItemId) + .eq(DictionaryItemTranslate::getLanguageCode, language) + .one(); + if (Objects.isNull(translate)) { + return ""; + } + return translate.getValue(); + } } \ No newline at end of file