feat(repository): 新增字典值翻译服务实现
- 创建 DictionaryItemTranslateServiceImpl 服务实现类 - 实现多语言字典值查询和翻译功能 - 添加购物车VO中交付方式名称和币种名称字段 - 集成字典翻译服务到购物车控制器中 - 实现按字典项ID和语言代码获取翻译值的方法 - 添加评价选项多语言支持功能
This commit is contained in:
parent
661870ce6d
commit
f37d334641
|
|
@ -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<QuotationShoppingOrderAdjustItem> 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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 汇率
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,4 +36,6 @@ public interface IDictionaryItemTranslateService extends IService<DictionaryItem
|
|||
String getValueByCode(String dictionaryCode, String dictionaryItemCode,String language);
|
||||
|
||||
List<DictionaryItemTranslate> getListByDictionaryCode(String dictionaryCode);
|
||||
|
||||
String getByDictionaryItemId(Long dictionaryItemId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ import javax.annotation.Resource;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典值翻译 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 曹鹏飞
|
||||
* @since 2025-01-20
|
||||
*/
|
||||
|
|
@ -142,4 +142,16 @@ public class DictionaryItemTranslateServiceImpl extends ServiceImpl<DictionaryIt
|
|||
public List<DictionaryItemTranslate> 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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue