|
|
@ -22,9 +22,9 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.*; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 模块管理 |
|
|
|
* @Description: 模块管理 |
|
|
@ -186,6 +186,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
@Transactional(readOnly = false, rollbackFor = Exception.class) |
|
|
|
@Transactional(readOnly = false, rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void copy(Modulex modulex) { |
|
|
|
public void copy(Modulex modulex) { |
|
|
|
|
|
|
|
final String copyId = modulex.getCopyId(); |
|
|
|
Integer newVersion = this.getMaxVersion(modulex.getVerison()); |
|
|
|
Integer newVersion = this.getMaxVersion(modulex.getVerison()); |
|
|
|
modulex.setVerison(newVersion + 1); |
|
|
|
modulex.setVerison(newVersion + 1); |
|
|
|
modulex.setRelatedBean(null); |
|
|
|
modulex.setRelatedBean(null); |
|
|
@ -195,6 +196,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
String id = modulex.getId(); |
|
|
|
String id = modulex.getId(); |
|
|
|
//复制实体&字段
|
|
|
|
//复制实体&字段
|
|
|
|
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, modulex.getCopyId())); |
|
|
|
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, modulex.getCopyId())); |
|
|
|
|
|
|
|
String tableId = null; |
|
|
|
if (!ObjectUtils.isEmpty(tablex)) { |
|
|
|
if (!ObjectUtils.isEmpty(tablex)) { |
|
|
|
Tablex tablex1 = new Tablex(); |
|
|
|
Tablex tablex1 = new Tablex(); |
|
|
|
BeanUtils.copyProperties(tablex, tablex1); |
|
|
|
BeanUtils.copyProperties(tablex, tablex1); |
|
|
@ -204,6 +206,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
tablex1.setTableEnName(modulex.getModuleEnName()); |
|
|
|
tablex1.setTableEnName(modulex.getModuleEnName()); |
|
|
|
tablex1.setCreateTime(new Date()); |
|
|
|
tablex1.setCreateTime(new Date()); |
|
|
|
iTablexService.save(tablex1); |
|
|
|
iTablexService.save(tablex1); |
|
|
|
|
|
|
|
tableId = tablex1.getId(); |
|
|
|
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId())); |
|
|
|
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId())); |
|
|
|
if (!ObjectUtils.isEmpty(fieldxList)) { |
|
|
|
if (!ObjectUtils.isEmpty(fieldxList)) { |
|
|
|
List<Fieldx> addList = new LinkedList<>(); |
|
|
|
List<Fieldx> addList = new LinkedList<>(); |
|
|
@ -234,8 +237,35 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
addList.add(functionx); |
|
|
|
addList.add(functionx); |
|
|
|
}); |
|
|
|
}); |
|
|
|
iFunctionxService.saveBatch(addList); |
|
|
|
iFunctionxService.saveBatch(addList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//复制每个功能的规则
|
|
|
|
|
|
|
|
List<Rulex> rulexList = iRulexService.list(new LambdaQueryWrapper<Rulex>().eq(Rulex::getModuleId, copyId)); |
|
|
|
|
|
|
|
List<Rulex> ruleAddList = new LinkedList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ObjectUtils.isEmpty(rulexList)) { |
|
|
|
|
|
|
|
String finalTableId1 = tableId; |
|
|
|
|
|
|
|
rulexList.stream().forEach(e -> { |
|
|
|
|
|
|
|
//根据原已有规则funtion_id,查找该规则所属功能
|
|
|
|
|
|
|
|
Functionx functionx = iFunctionxService.getById(e.getFunctionId()); |
|
|
|
|
|
|
|
//根据原功能名称查询,已复制对象的功能
|
|
|
|
|
|
|
|
Functionx functionx1 = iFunctionxService.getOne(new LambdaQueryWrapper<Functionx>().eq(Functionx::getModuleId, id).eq(Functionx::getFunctionName, functionx.getFunctionName())); |
|
|
|
|
|
|
|
Rulex rulex = new Rulex(); |
|
|
|
|
|
|
|
BeanUtils.copyProperties(e, rulex); |
|
|
|
|
|
|
|
rulex.setId(null); |
|
|
|
|
|
|
|
rulex.setModuleId(id); |
|
|
|
|
|
|
|
rulex.setTableId(finalTableId1); |
|
|
|
|
|
|
|
rulex.setFunctionId(functionx1.getId()); |
|
|
|
|
|
|
|
//根据原已有规则的field_id,查找该规则字段
|
|
|
|
|
|
|
|
Fieldx fieldx = iFieldxService.getById(e.getFieldId()); |
|
|
|
|
|
|
|
//根据源字段名称,查询对应字段id
|
|
|
|
|
|
|
|
Fieldx fieldx1 = iFieldxService.getOne(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, finalTableId1).eq(Fieldx::getFieldEnName, fieldx.getFieldEnName())); |
|
|
|
|
|
|
|
rulex.setFieldId(fieldx1.getId()); |
|
|
|
|
|
|
|
rulex.setCreateTime(new Date()); |
|
|
|
|
|
|
|
ruleAddList.add(rulex); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
iRulexService.saveBatch(ruleAddList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|