mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 13:19:01 +08:00
✨ flowable M1的适配版本
This commit is contained in:
1 parent
43da5a1dbf
commit
b69285c55b
256 files changed
+11295
-411
No files matched your search
+4
-3
@@ -31,12 +31,12 @@ import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.common.xss.core.XssCleanIgnore;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
@@ -63,8 +63,9 @@ public class GenDsConfController {
|
||||
@GetMapping("/page")
|
||||
public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) {
|
||||
return R.ok(datasourceConfService.page(page,
|
||||
Wrappers.<GenDatasourceConf>lambdaQuery().like(StrUtil.isNotBlank(datasourceConf.getDsName()),
|
||||
GenDatasourceConf::getDsName, datasourceConf.getDsName())));
|
||||
Wrappers.<GenDatasourceConf>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName,
|
||||
datasourceConf.getDsName())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -60,8 +60,9 @@ public class GenFieldTypeController {
|
||||
@GetMapping("/page")
|
||||
public R getFieldTypePage(Page page, GenFieldType fieldType) {
|
||||
return R.ok(fieldTypeService.page(page,
|
||||
Wrappers.<GenFieldType>lambdaQuery().like(StrUtil.isNotBlank(fieldType.getColumnType()),
|
||||
GenFieldType::getColumnType, fieldType.getColumnType())));
|
||||
Wrappers.<GenFieldType>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(fieldType.getColumnType()), GenFieldType::getColumnType,
|
||||
fieldType.getColumnType())));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询列表", description = "查询列表")
|
||||
|
||||
+2
-3
@@ -64,9 +64,8 @@ public class GenGroupController {
|
||||
@PreAuthorize("@pms.hasPermission('codegen_group_view')")
|
||||
public R getgenGroupPage(Page page, GenGroupEntity genGroup) {
|
||||
LambdaQueryWrapper<GenGroupEntity> wrapper = Wrappers.<GenGroupEntity>lambdaQuery()
|
||||
.like(genGroup.getId() != null, GenGroupEntity::getId, genGroup.getId())
|
||||
.like(StrUtil.isNotEmpty(genGroup.getGroupName()), GenGroupEntity::getGroupName,
|
||||
genGroup.getGroupName());
|
||||
.like(genGroup.getId() != null, GenGroupEntity::getId, genGroup.getId())
|
||||
.like(StrUtil.isNotEmpty(genGroup.getGroupName()), GenGroupEntity::getGroupName, genGroup.getGroupName());
|
||||
return R.ok(genGroupService.page(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -155,7 +155,8 @@ public class GenTableController {
|
||||
Wrappers.<GenTable>lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName));
|
||||
// 字段配置删除
|
||||
tableColumnService.remove(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName).eq(GenTableColumnEntity::getTableName, tableName));
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName));
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -64,9 +64,9 @@ public class GenTemplateController {
|
||||
@PreAuthorize("@pms.hasPermission('codegen_template_view')")
|
||||
public R getgenTemplatePage(Page page, GenTemplateEntity genTemplate) {
|
||||
LambdaQueryWrapper<GenTemplateEntity> wrapper = Wrappers.<GenTemplateEntity>lambdaQuery()
|
||||
.like(genTemplate.getId() != null, GenTemplateEntity::getId, genTemplate.getId())
|
||||
.like(StrUtil.isNotEmpty(genTemplate.getTemplateName()), GenTemplateEntity::getTemplateName,
|
||||
genTemplate.getTemplateName());
|
||||
.like(genTemplate.getId() != null, GenTemplateEntity::getId, genTemplate.getId())
|
||||
.like(StrUtil.isNotEmpty(genTemplate.getTemplateName()), GenTemplateEntity::getTemplateName,
|
||||
genTemplate.getTemplateName());
|
||||
return R.ok(genTemplateService.page(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
|
||||
public Boolean removeByDsId(Long[] dsIds) {
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
|
||||
this.baseMapper.selectBatchIds(CollUtil.toList(dsIds))
|
||||
.forEach(ds -> dynamicRoutingDataSource.removeDataSource(ds.getName()));
|
||||
.forEach(ds -> dynamicRoutingDataSource.removeDataSource(ds.getName()));
|
||||
this.baseMapper.deleteBatchIds(CollUtil.toList(dsIds));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ public class GenFormConfServiceImpl extends ServiceImpl<GenFormConfMapper, GenFo
|
||||
}
|
||||
else {
|
||||
int span = Optional.ofNullable(json.getJSONObject(VFormConfigConsts.options))
|
||||
.map(options -> options.getInt(VFormConfigConsts.span, 24)).orElse(24);
|
||||
.map(options -> options.getInt(VFormConfigConsts.span, 24))
|
||||
.orElse(24);
|
||||
|
||||
jsonObject.set(VFormConfigConsts.span, span);
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class GenGroupServiceImpl extends ServiceImpl<GenGroupMapper, GenGroupEnt
|
||||
this.removeBatchByIds(CollUtil.toList(ids));
|
||||
// 删除关系
|
||||
genTemplateGroupService
|
||||
.remove(Wrappers.<GenTemplateGroupEntity>lambdaQuery().in(GenTemplateGroupEntity::getGroupId, ids));
|
||||
.remove(Wrappers.<GenTemplateGroupEntity>lambdaQuery().in(GenTemplateGroupEntity::getGroupId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -81,8 +81,9 @@ public class GenTableColumnServiceImpl extends ServiceImpl<GenTableColumnMapper,
|
||||
|
||||
public void updateTableField(String dsName, String tableName, List<GenTableColumnEntity> tableFieldList) {
|
||||
AtomicInteger sort = new AtomicInteger();
|
||||
this.updateBatchById(tableFieldList.stream().peek(field -> field.setSort(sort.getAndIncrement()))
|
||||
.collect(Collectors.toList()));
|
||||
this.updateBatchById(tableFieldList.stream()
|
||||
.peek(field -> field.setSort(sort.getAndIncrement()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-3
@@ -116,9 +116,10 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
genTable = this.tableImport(dsName, tableName);
|
||||
}
|
||||
|
||||
List<GenTableColumnEntity> fieldList = columnService
|
||||
.list(Wrappers.<GenTableColumnEntity>lambdaQuery().eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName).orderByAsc(GenTableColumnEntity::getSort));
|
||||
List<GenTableColumnEntity> fieldList = columnService.list(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName)
|
||||
.orderByAsc(GenTableColumnEntity::getSort));
|
||||
genTable.setFieldList(fieldList);
|
||||
|
||||
// 查询模板分组信息
|
||||
|
||||
+26
-18
@@ -37,7 +37,6 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -185,8 +184,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
// 获取模板信息,Lambda 表达式简化代码
|
||||
GenTemplateEntity genTemplateEntity = Optional
|
||||
.ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_JSON.getTemplateId()))
|
||||
.orElseThrow(() -> new Exception("模板不存在"));
|
||||
.ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_JSON.getTemplateId()))
|
||||
.orElseThrow(() -> new Exception("模板不存在"));
|
||||
|
||||
// 渲染模板并返回结果
|
||||
return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel);
|
||||
@@ -217,8 +216,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
// 获取模板信息
|
||||
GenTemplateEntity genTemplateEntity = Optional
|
||||
.ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_FORM.getTemplateId()))
|
||||
.orElseThrow(() -> new Exception("模板不存在"));
|
||||
.ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_FORM.getTemplateId()))
|
||||
.orElseThrow(() -> new Exception("模板不存在"));
|
||||
|
||||
// 渲染模板并返回结果
|
||||
return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel);
|
||||
@@ -234,9 +233,10 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
GenTable table = tableService.getById(tableId);
|
||||
// 获取字段列表
|
||||
List<GenTableColumnEntity> fieldList = columnService.lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getTableName()).orderByAsc(GenTableColumnEntity::getSort)
|
||||
.list();
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getTableName())
|
||||
.orderByAsc(GenTableColumnEntity::getSort)
|
||||
.list();
|
||||
|
||||
table.setFieldList(fieldList);
|
||||
|
||||
@@ -275,8 +275,9 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
String childTableName = table.getChildTableName();
|
||||
if (StrUtil.isNotBlank(childTableName)) {
|
||||
List<GenTableColumnEntity> childFieldList = columnService.lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getChildTableName()).list();
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getChildTableName())
|
||||
.list();
|
||||
dataModel.put("childFieldList", childFieldList);
|
||||
dataModel.put("childTableName", childTableName);
|
||||
dataModel.put("mainField", NamingCase.toCamelCase(table.getMainField()));
|
||||
@@ -295,17 +296,24 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
*/
|
||||
private void setFieldTypeList(Map<String, Object> dataModel, GenTable table) {
|
||||
// 按字段类型分组,使用 Map 存储不同类型的字段列表
|
||||
Map<Boolean, List<GenTableColumnEntity>> typeMap = table.getFieldList().stream()
|
||||
.collect(Collectors.partitioningBy(GenTableColumnEntity::isPrimaryPk));
|
||||
Map<Boolean, List<GenTableColumnEntity>> typeMap = table.getFieldList()
|
||||
.stream()
|
||||
.collect(Collectors.partitioningBy(GenTableColumnEntity::isPrimaryPk));
|
||||
|
||||
// 从分组后的 Map 中获取不同类型的字段列表
|
||||
List<GenTableColumnEntity> primaryList = typeMap.get(true);
|
||||
List<GenTableColumnEntity> formList = typeMap.get(false).stream().filter(GenTableColumnEntity::isFormItem)
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> gridList = typeMap.get(false).stream().filter(GenTableColumnEntity::isGridItem)
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> queryList = typeMap.get(false).stream().filter(GenTableColumnEntity::isQueryItem)
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> formList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(GenTableColumnEntity::isFormItem)
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> gridList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(GenTableColumnEntity::isGridItem)
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> queryList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(GenTableColumnEntity::isQueryItem)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(primaryList)) {
|
||||
dataModel.put("pk", primaryList.get(0));
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GenKit {
|
||||
// 获取目标数据源数据库类型
|
||||
GenDatasourceConfMapper datasourceConfMapper = SpringContextHolder.getBean(GenDatasourceConfMapper.class);
|
||||
GenDatasourceConf datasourceConf = datasourceConfMapper
|
||||
.selectOne(Wrappers.<GenDatasourceConf>lambdaQuery().eq(GenDatasourceConf::getName, dsName));
|
||||
.selectOne(Wrappers.<GenDatasourceConf>lambdaQuery().eq(GenDatasourceConf::getName, dsName));
|
||||
|
||||
String dbConfType;
|
||||
// 默认MYSQL 数据源
|
||||
|
||||
Reference in new issue
Block a user