|
|
|
@ -1,27 +1,30 @@ |
|
|
|
|
package org.jeecg.modules.modulex.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.modules.demo.functionx.entity.Functionx; |
|
|
|
|
import org.jeecg.modules.demo.functionx.mapper.FunctionxMapper; |
|
|
|
|
import org.jeecg.modules.demo.functionx.service.IFunctionxService; |
|
|
|
|
import org.jeecg.modules.demo.rulex.entity.Rulex; |
|
|
|
|
import org.jeecg.modules.demo.rulex.service.IRulexService; |
|
|
|
|
import org.jeecg.modules.fieldx.entity.Fieldx; |
|
|
|
|
import org.jeecg.modules.fieldx.service.IFieldxService; |
|
|
|
|
import org.jeecg.modules.modulex.entity.Modulex; |
|
|
|
|
import org.jeecg.modules.modulex.mapper.ModulexMapper; |
|
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
|
import org.jeecg.modules.tablex.service.ITablexService; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 模块管理 |
|
|
|
@ -44,6 +47,12 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
|
@Autowired |
|
|
|
|
private IRulexService iRulexService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ITablexService iTablexService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IFieldxService iFieldxService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 得到最大的版本号 |
|
|
|
|
*/ |
|
|
|
@ -169,6 +178,66 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
|
modulexMapper.setmodule(id, moduleId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 模块管理中复制功能:新增模块对应的实体和字段、功能和规则 |
|
|
|
|
* |
|
|
|
|
* @param modulex |
|
|
|
|
*/ |
|
|
|
|
@Transactional(readOnly = false, rollbackFor = Exception.class) |
|
|
|
|
@Override |
|
|
|
|
public void copy(Modulex modulex) { |
|
|
|
|
Integer newVersion = this.getMaxVersion(modulex.getVerison()); |
|
|
|
|
modulex.setVerison(newVersion + 1); |
|
|
|
|
modulex.setRelatedBean(null); |
|
|
|
|
//复制模块
|
|
|
|
|
this.save(modulex); |
|
|
|
|
|
|
|
|
|
String id = modulex.getId(); |
|
|
|
|
//复制实体&字段
|
|
|
|
|
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, modulex.getCopyId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(tablex)) { |
|
|
|
|
Tablex tablex1 = new Tablex(); |
|
|
|
|
BeanUtils.copyProperties(tablex, tablex1); |
|
|
|
|
tablex1.setId(null); |
|
|
|
|
tablex1.setModuleId(modulex.getId()); |
|
|
|
|
tablex1.setTableName(modulex.getModuleName()); |
|
|
|
|
tablex1.setTableEnName(modulex.getModuleEnName()); |
|
|
|
|
tablex1.setCreateTime(new Date()); |
|
|
|
|
iTablexService.save(tablex1); |
|
|
|
|
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(fieldxList)) { |
|
|
|
|
List<Fieldx> addList = new LinkedList<>(); |
|
|
|
|
fieldxList.forEach(e -> { |
|
|
|
|
Fieldx fieldx1 = new Fieldx(); |
|
|
|
|
BeanUtils.copyProperties(e, fieldx1); |
|
|
|
|
fieldx1.setId(null); |
|
|
|
|
fieldx1.setTableId(tablex1.getId()); |
|
|
|
|
fieldx1.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
addList.add(fieldx1); |
|
|
|
|
}); |
|
|
|
|
iFieldxService.saveBatch(addList); |
|
|
|
|
} |
|
|
|
|
this.lambdaUpdate().set(Modulex::getRelatedBean, tablex1.getId()).eq(Modulex::getId, id).update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//复制功能
|
|
|
|
|
List<Functionx> functionxList = iFunctionxService.list(new LambdaQueryWrapper<Functionx>().eq(Functionx::getModuleId, modulex.getCopyId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(functionxList)) { |
|
|
|
|
List<Functionx> addList = new LinkedList<>(); |
|
|
|
|
functionxList.forEach(e -> { |
|
|
|
|
Functionx functionx = new Functionx(); |
|
|
|
|
BeanUtils.copyProperties(e, functionx); |
|
|
|
|
functionx.setId(null); |
|
|
|
|
functionx.setModuleId(modulex.getId()); |
|
|
|
|
functionx.setCreateTime(new Date()); |
|
|
|
|
addList.add(functionx); |
|
|
|
|
}); |
|
|
|
|
iFunctionxService.saveBatch(addList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handleStatus(String id, Integer a) { |
|
|
|
|
//先查字模块 先查询父id 等于 这个 id 的数据
|
|
|
|
|