feat: bug-658 产品机型热图的部件需要显示当前语言的翻译
This commit is contained in:
parent
2a1420c2ff
commit
e59b3f7b0a
|
|
@ -1,5 +1,5 @@
|
|||
# Nacos 地址
|
||||
nacos.server-addr=${NACOS_SERVER_ADDR:112.74.186.154:8848}
|
||||
nacos.server-addr=${NACOS_SERVER_ADDR:192.168.0.194:8848}
|
||||
#nacos.server-addr=192.168.0.194:8848
|
||||
#spring.cloud.nacos.discovery.username=nacos
|
||||
#spring.cloud.nacos.discovery.password=ZLQ8vgmjoJ4?EPJ4]fs_
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@ public interface IProductModelHotimageService extends IService<ProductModelHotim
|
|||
|
||||
void copyTo(Integer oldId, Integer newId);
|
||||
|
||||
ProductHotImageInfoVO getListByLanguage(Integer modelId);
|
||||
ProductHotImageInfoVO getListByLanguage(Integer modelId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -11,11 +15,15 @@ import com.nflg.mobilebroken.common.pojo.vo.ProductHotImageInfoVO;
|
|||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelHotimage;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductPartInfo;
|
||||
import com.nflg.mobilebroken.repository.mapper.ProductModelHotimageMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelHotimageService;
|
||||
import com.nflg.mobilebroken.repository.service.IProductPartInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -30,6 +38,9 @@ import java.util.Objects;
|
|||
@Service
|
||||
public class ProductModelHotimageServiceImpl extends ServiceImpl<ProductModelHotimageMapper, ProductModelHotimage> implements IProductModelHotimageService {
|
||||
|
||||
@Resource
|
||||
private IProductPartInfoService productPartInfoService;
|
||||
|
||||
@Override
|
||||
public Integer add(ProductModelHotImageAddRequest request) {
|
||||
ProductModelHotimage info=new ProductModelHotimage()
|
||||
|
|
@ -143,10 +154,32 @@ public class ProductModelHotimageServiceImpl extends ServiceImpl<ProductModelHot
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProductHotImageInfoVO getListByLanguage(Integer modelId) {
|
||||
return Convert.convert(ProductHotImageInfoVO.class,lambdaQuery()
|
||||
public ProductHotImageInfoVO getListByLanguage(Integer modelId, String language) {
|
||||
ProductModelHotimage info = lambdaQuery()
|
||||
.eq(ProductModelHotimage::getModelId, modelId)
|
||||
.eq(ProductModelHotimage::getState, PublishState.Published.getState())
|
||||
.one());
|
||||
.one();
|
||||
JSONArray jsonArray = JSONUtil.parseArray(info.getData());
|
||||
List<JSONObject> jsonObjects = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(jsonArray)) {
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
jsonArray.forEach(item -> {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(item);
|
||||
ids.add(jsonObject.getInt("id"));
|
||||
});
|
||||
List<ProductPartInfo> partInfos = productPartInfoService.lambdaQuery().eq(ProductPartInfo::getLanguageCode, language).in(ProductPartInfo::getPartId, ids).list();
|
||||
jsonArray.forEach(obj -> {
|
||||
JSONObject jsonObject = (JSONObject) obj;
|
||||
ProductPartInfo pi = partInfos.stream().filter(partInfo -> Objects.equals(partInfo.getPartId(), jsonObject.getInt("id"))).findFirst().orElse(null);
|
||||
if (Objects.nonNull(pi) && StrUtil.isNotBlank(pi.getName()) && Objects.equals(jsonObject.getInt("id"), pi.getPartId())) {
|
||||
jsonObject.set("name", pi.getName());
|
||||
}
|
||||
jsonObjects.add(jsonObject);
|
||||
});
|
||||
}
|
||||
return new ProductHotImageInfoVO()
|
||||
.setImage(info.getImage())
|
||||
.setImgRect(info.getImgRect())
|
||||
.setData(JSONUtil.toJsonStr(jsonObjects));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
.setDesc(Objects.isNull(intro)?"":intro.getDesc())
|
||||
.setFeature(Objects.isNull(intro)?"":intro.getFeature())
|
||||
.setMerits(Objects.isNull(intro)?"":intro.getMerits())
|
||||
.setHotImage(productModelHotimageService.getListByLanguage(modelId))
|
||||
.setHotImage(productModelHotimageService.getListByLanguage(modelId, language))
|
||||
.setParams(productPartParamsService.getAListByLanguage(modelId, language))
|
||||
.setMainParams(productPartParamsService.getMainListByLanguage(modelId, language))
|
||||
.setImportantParams(productPartParamsService.getImportantListByLanguage(modelId, language))
|
||||
|
|
|
|||
Loading…
Reference in New Issue