提交 20664b92 编写于 作者: zhouweidong's avatar zhouweidong

初始化module

上级 91c6d4ae
......@@ -2,12 +2,14 @@ package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.domain.MetaField;
import cn.ibizlab.core.lite.domain.MetaModule;
import cn.ibizlab.core.lite.domain.MetaRelationship;
import cn.ibizlab.core.lite.extensions.domain.MetaEntityModel;
import cn.ibizlab.core.lite.extensions.domain.SysModel;
import cn.ibizlab.core.lite.extensions.mapping.MetaEntityMapping;
import cn.ibizlab.core.lite.service.IMetaEntityService;
import cn.ibizlab.core.lite.service.IMetaFieldService;
import cn.ibizlab.core.lite.service.IMetaModuleService;
import cn.ibizlab.core.lite.service.IMetaRelationshipService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -44,6 +46,9 @@ public class LiteCoreService {
@Lazy
MetaEntityMapping entityMapping;
@Autowired
@Lazy
IMetaModuleService moduleService;
@Transactional
public boolean syncSysModel(SysModel sysModel) {
......@@ -69,21 +74,36 @@ public class LiteCoreService {
*/
private void syncDE(SysModel sysModel) {
Map<String,Integer> delDE = new HashMap<>();
Map<String,Integer> delModule = new HashMap<>();
entityService.list(new QueryWrapper<MetaEntity>().select("entityid").eq("systemid",sysModel.getSystemid())).forEach(entity -> delDE.put(entity.getEntityId(),1));
moduleService.list(new QueryWrapper<MetaModule>().select("moduleid").eq("systemid",sysModel.getSystemid())).forEach(module -> delModule.put(module.getId(),1));
List<MetaEntityModel> metaEntityModels = sysModel.getEntities();
Set<MetaEntity> entities=new HashSet<>();
Set<MetaModule> modules=new HashSet<>();
if(!ObjectUtils.isEmpty(metaEntityModels)){
entities.addAll(entityMapping.toDomain(metaEntityModels));
}
entities.forEach(entity -> {
delDE.remove(entity.getEntityId());
if(!ObjectUtils.isEmpty(entity.getModuleId()) && !ObjectUtils.isEmpty(entity.getModuleName())){
delModule.remove(entity.getModuleId());
MetaModule module =new MetaModule();
module.setCodeName(entity.getModuleId());
module.setName(entity.getModuleName());
module.setSystemId(sysModel.getSystemid());
modules.add(module);
}
});
//移除无效资源
if(delDE.size()>0)
entityService.removeBatch(delDE.keySet());
if(delModule.size()>0)
moduleService.removeBatch(delModule.keySet());
//存储或更新资源saveOrUpdate
if(entities.size()>0)
entityService.saveBatch(entities);
if(modules.size()>0)
moduleService.saveBatch(modules);
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册