feat: 网页组件翻译导入接口支持自动创建组件功能
This commit is contained in:
parent
0a7d7ac9fd
commit
d96de4b914
|
|
@ -18,6 +18,7 @@ import com.nflg.mobilebroken.common.pojo.request.WebComponentUpdateRequest;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.LanguageVO;
|
import com.nflg.mobilebroken.common.pojo.vo.LanguageVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.WebComponentInfoVO;
|
import com.nflg.mobilebroken.common.pojo.vo.WebComponentInfoVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.WebComponentVO;
|
import com.nflg.mobilebroken.common.pojo.vo.WebComponentVO;
|
||||||
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
||||||
import com.nflg.mobilebroken.common.util.ZipUtils;
|
import com.nflg.mobilebroken.common.util.ZipUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.Language;
|
import com.nflg.mobilebroken.repository.entity.Language;
|
||||||
|
|
@ -48,6 +49,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -210,12 +212,25 @@ public class MultilingualController extends ControllerBase {
|
||||||
String pageCode = (String) d.get("页面编号");
|
String pageCode = (String) d.get("页面编号");
|
||||||
String componentCode = (String) d.get("组件编号");
|
String componentCode = (String) d.get("组件编号");
|
||||||
log.info("模块编号:{},页面编号:{},组件编号:{}",moduleCode,pageCode,componentCode);
|
log.info("模块编号:{},页面编号:{},组件编号:{}",moduleCode,pageCode,componentCode);
|
||||||
WebComponent webComponent = webComponentService.lambdaQuery()
|
if (StrUtil.isNotBlank(moduleCode) && StrUtil.isNotBlank(pageCode) && StrUtil.isNotBlank(componentCode)){
|
||||||
.eq(WebComponent::getModuleCode, moduleCode)
|
WebComponent webComponent = webComponentService.lambdaQuery()
|
||||||
.eq(WebComponent::getPageCode, pageCode)
|
.eq(WebComponent::getModuleCode, moduleCode)
|
||||||
.eq(WebComponent::getComponentCode, componentCode)
|
.eq(WebComponent::getPageCode, pageCode)
|
||||||
.one();
|
.eq(WebComponent::getComponentCode, componentCode)
|
||||||
if (Objects.nonNull(webComponent)) {
|
.one();
|
||||||
|
if (Objects.isNull(webComponent)){
|
||||||
|
webComponent = new WebComponent()
|
||||||
|
.setPageName((String) d.get("页面"))
|
||||||
|
.setPageCode(pageCode)
|
||||||
|
.setModuleName((String) d.get("模块"))
|
||||||
|
.setModuleCode(moduleCode)
|
||||||
|
.setComponentName((String) d.get("组件"))
|
||||||
|
.setComponentCode(componentCode)
|
||||||
|
.setCreateBy(AdminUserUtil.getUserId())
|
||||||
|
.setCreateTime(LocalDateTime.now());
|
||||||
|
webComponentService.save(webComponent);
|
||||||
|
}
|
||||||
|
int componentId = webComponent.getId();
|
||||||
d.remove("模块");
|
d.remove("模块");
|
||||||
d.remove("模块编号");
|
d.remove("模块编号");
|
||||||
d.remove("页面");
|
d.remove("页面");
|
||||||
|
|
@ -223,13 +238,13 @@ public class MultilingualController extends ControllerBase {
|
||||||
d.remove("组件");
|
d.remove("组件");
|
||||||
d.remove("组件编号");
|
d.remove("组件编号");
|
||||||
webComponentTranslateService.remove(new LambdaQueryWrapper<WebComponentTranslate>()
|
webComponentTranslateService.remove(new LambdaQueryWrapper<WebComponentTranslate>()
|
||||||
.eq(WebComponentTranslate::getComponentId, webComponent.getId()));
|
.eq(WebComponentTranslate::getComponentId, componentId));
|
||||||
List<WebComponentTranslate> translates = new ArrayList<>();
|
List<WebComponentTranslate> translates = new ArrayList<>();
|
||||||
d.forEach((k, v) -> {
|
d.forEach((k, v) -> {
|
||||||
Language language = languages.stream().filter(l -> l.getName().equals(k)).findFirst().orElse(null);
|
Language language = languages.stream().filter(l -> l.getName().equals(k)).findFirst().orElse(null);
|
||||||
if (Objects.nonNull(language)) {
|
if (Objects.nonNull(language)) {
|
||||||
WebComponentTranslate webComponentTranslate = new WebComponentTranslate()
|
WebComponentTranslate webComponentTranslate = new WebComponentTranslate()
|
||||||
.setComponentId(webComponent.getId())
|
.setComponentId(componentId)
|
||||||
.setLanguageId(language.getId())
|
.setLanguageId(language.getId())
|
||||||
.setValue(v.toString());
|
.setValue(v.toString());
|
||||||
translates.add(webComponentTranslate);
|
translates.add(webComponentTranslate);
|
||||||
|
|
@ -238,6 +253,8 @@ public class MultilingualController extends ControllerBase {
|
||||||
if (CollectionUtil.isNotEmpty(translates)) {
|
if (CollectionUtil.isNotEmpty(translates)) {
|
||||||
webComponentTranslateService.saveBatch(translates);
|
webComponentTranslateService.saveBatch(translates);
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
log.error("模块编号,页面编号,组件编号都不能为空");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue