删除研发工具相关代码

master
liuqingkun 2 years ago
parent abe964270f
commit 050e7e58a3
  1. 9
      doc/sql/increase.sql
  2. 154
      src/main/java/org/springblade/modules/develop/controller/CodeController.java
  3. 148
      src/main/java/org/springblade/modules/develop/controller/CodeSettingController.java
  4. 140
      src/main/java/org/springblade/modules/develop/controller/DatasourceController.java
  5. 203
      src/main/java/org/springblade/modules/develop/controller/ModelController.java
  6. 146
      src/main/java/org/springblade/modules/develop/controller/ModelPrototypeController.java
  7. 38
      src/main/java/org/springblade/modules/develop/mapper/CodeMapper.java
  8. 23
      src/main/java/org/springblade/modules/develop/mapper/CodeMapper.xml
  9. 38
      src/main/java/org/springblade/modules/develop/mapper/CodeSettingMapper.java
  10. 13
      src/main/java/org/springblade/modules/develop/mapper/CodeSettingMapper.xml
  11. 38
      src/main/java/org/springblade/modules/develop/mapper/DatasourceMapper.java
  12. 22
      src/main/java/org/springblade/modules/develop/mapper/DatasourceMapper.xml
  13. 38
      src/main/java/org/springblade/modules/develop/mapper/ModelMapper.java
  14. 27
      src/main/java/org/springblade/modules/develop/mapper/ModelMapper.xml
  15. 38
      src/main/java/org/springblade/modules/develop/mapper/ModelPrototypeMapper.java
  16. 35
      src/main/java/org/springblade/modules/develop/mapper/ModelPrototypeMapper.xml
  17. 148
      src/main/java/org/springblade/modules/develop/pojo/dto/GeneratorDTO.java
  18. 53
      src/main/java/org/springblade/modules/develop/pojo/dto/ModelDTO.java
  19. 197
      src/main/java/org/springblade/modules/develop/pojo/entity/Code.java
  20. 77
      src/main/java/org/springblade/modules/develop/pojo/entity/CodeSetting.java
  21. 92
      src/main/java/org/springblade/modules/develop/pojo/entity/Datasource.java
  22. 85
      src/main/java/org/springblade/modules/develop/pojo/entity/Model.java
  23. 130
      src/main/java/org/springblade/modules/develop/pojo/entity/ModelPrototype.java
  24. 47
      src/main/java/org/springblade/modules/develop/service/ICodeService.java
  25. 45
      src/main/java/org/springblade/modules/develop/service/ICodeSettingService.java
  26. 38
      src/main/java/org/springblade/modules/develop/service/IDatasourceService.java
  27. 56
      src/main/java/org/springblade/modules/develop/service/IGenerateService.java
  28. 84
      src/main/java/org/springblade/modules/develop/service/IModelPrototypeService.java
  29. 48
      src/main/java/org/springblade/modules/develop/service/IModelService.java
  30. 49
      src/main/java/org/springblade/modules/develop/service/impl/CodeServiceImpl.java
  31. 53
      src/main/java/org/springblade/modules/develop/service/impl/CodeSettingServiceImpl.java
  32. 42
      src/main/java/org/springblade/modules/develop/service/impl/DatasourceServiceImpl.java
  33. 190
      src/main/java/org/springblade/modules/develop/service/impl/GenerateServiceImpl.java
  34. 115
      src/main/java/org/springblade/modules/develop/service/impl/ModelPrototypeServiceImpl.java
  35. 76
      src/main/java/org/springblade/modules/develop/service/impl/ModelServiceImpl.java

@ -0,0 +1,9 @@
-- 2024-12-16
-- 删除研发工具菜单
DELETE
FROM blade_menu
WHERE id = '1123598815738675217'
OR parent_id = 1123598815738675217
OR parent_id IN (
1123598815738675218, 1161272593873321991, 1161272593873321996
)

@ -1,154 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.develop.pojo.dto.GeneratorDTO;
import org.springblade.modules.develop.pojo.entity.Code;
import org.springblade.modules.develop.service.ICodeService;
import org.springblade.modules.develop.service.IGenerateService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 控制器
*
* @author Chill
*/
@NonDS
@Hidden
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/code")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@Tag(name = "代码生成", description = "代码生成")
public class CodeController extends BladeController {
private final ICodeService codeService;
private final IGenerateService generateService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入code")
public R<Code> detail(Code code) {
Code detail = codeService.getOne(Condition.getQueryWrapper(code));
return R.data(detail);
}
/**
* 分页
*/
@GetMapping("/list")
@Parameters({
@Parameter(name = "codeName", description = "模块名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
@Parameter(name = "tableName", description = "表名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
@Parameter(name = "modelName", description = "实体名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
})
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入code")
public R<IPage<Code>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> code, Query query) {
IPage<Code> pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class));
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入code")
public R submit(@Valid @RequestBody Code code) {
return R.status(codeService.submit(code));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(codeService.removeByIds(Func.toLongList(ids)));
}
/**
* 复制
*/
@PostMapping("/copy")
@ApiOperationSupport(order = 5)
@Operation(summary = "复制", description = "传入id")
public R copy(@Parameter(description = "主键", required = true) @RequestParam Long id) {
Code code = codeService.getById(id);
code.setId(null);
code.setCodeName(code.getCodeName() + "-copy");
return R.status(codeService.save(code));
}
/**
* 代码生成
*/
@PostMapping("/gen-code")
@ApiOperationSupport(order = 6)
@Operation(summary = "代码生成", description = "传入ids")
public R genCode(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(generateService.code(Func.toLongList(ids)));
}
/**
* 代码生成
*/
@PostMapping("/gen-code-fast")
@ApiOperationSupport(order = 7)
@Operation(summary = "代码快速生成", description = "传入配置集合")
public R genCodeFast(@Parameter(description = "主键集合", required = true) @RequestBody GeneratorDTO dto) {
return R.status(generateService.codeFast(dto));
}
}

@ -1,148 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.develop.pojo.entity.CodeSetting;
import org.springblade.modules.develop.service.ICodeSettingService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 代码生成器配置表 控制器
*
* @author BladeX
*/
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/code-setting")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@Tag(name = "代码生成器配置表", description = "代码生成器配置表接口")
public class CodeSettingController extends BladeController {
private final ICodeSettingService codeSettingService;
/**
* 代码生成器配置表 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入codeSetting")
public R<CodeSetting> detail(CodeSetting codeSetting) {
CodeSetting detail = codeSettingService.getOne(Condition.getQueryWrapper(codeSetting));
return R.data(detail);
}
/**
* 代码生成器配置表 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入codeSetting")
public R<IPage<CodeSetting>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> codeSetting, Query query) {
IPage<CodeSetting> pages = codeSettingService.page(Condition.getPage(query), Condition.getQueryWrapper(codeSetting, CodeSetting.class));
return R.data(pages);
}
/**
* 代码生成器配置表 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增", description = "传入codeSetting")
public R save(@Valid @RequestBody CodeSetting codeSetting) {
return R.status(codeSettingService.save(codeSetting));
}
/**
* 代码生成器配置表 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 4)
@Operation(summary = "修改", description = "传入codeSetting")
public R update(@Valid @RequestBody CodeSetting codeSetting) {
return R.status(codeSettingService.updateById(codeSetting));
}
/**
* 代码生成器配置表 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@Operation(summary = "新增或修改", description = "传入codeSetting")
public R submit(@Valid @RequestBody CodeSetting codeSetting) {
return R.status(codeSettingService.saveOrUpdate(codeSetting));
}
/**
* 代码生成器配置表 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@Operation(summary = "删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(codeSettingService.removeByIds(Func.toLongList(ids)));
}
/**
* 代码生成器配置表 启用
*/
@PostMapping("/enable")
@ApiOperationSupport(order = 7)
@Operation(summary = "配置启用", description = "传入id")
public R enable(@Parameter(description = "主键", required = true) @RequestParam Long id) {
return R.status(codeSettingService.enable(id));
}
/**
* 代码生成器配置表 启用详情
*/
@GetMapping("/enable-detail")
@ApiOperationSupport(order = 8)
@Operation(summary = "详情", description = "传入codeSetting")
public R<CodeSetting> enableDetail() {
CodeSetting detail = codeSettingService.getOne(Wrappers.<CodeSetting>lambdaQuery().eq(CodeSetting::getStatus, BladeConstant.DB_STATUS_2).eq(CodeSetting::getIsDeleted, BladeConstant.DB_NOT_DELETED));
return R.data(detail);
}
}

@ -1,140 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 数据源配置表 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/datasource")
@Tag(name = "数据源配置表", description = "数据源配置表接口")
public class DatasourceController extends BladeController {
private final IDatasourceService datasourceService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入datasource")
public R<Datasource> detail(Datasource datasource) {
Datasource detail = datasourceService.getOne(Condition.getQueryWrapper(datasource));
return R.data(detail);
}
/**
* 分页 数据源配置表
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入datasource")
public R<IPage<Datasource>> list(Datasource datasource, Query query) {
IPage<Datasource> pages = datasourceService.page(Condition.getPage(query), Condition.getQueryWrapper(datasource));
return R.data(pages);
}
/**
* 新增 数据源配置表
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入datasource")
public R save(@Valid @RequestBody Datasource datasource) {
return R.status(datasourceService.save(datasource));
}
/**
* 修改 数据源配置表
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入datasource")
public R update(@Valid @RequestBody Datasource datasource) {
return R.status(datasourceService.updateById(datasource));
}
/**
* 新增或修改 数据源配置表
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入datasource")
public R submit(@Valid @RequestBody Datasource datasource) {
if (StringUtil.isNotBlank(datasource.getUrl())) {
datasource.setUrl(datasource.getUrl().replace("&amp;", "&"));
}
return R.status(datasourceService.saveOrUpdate(datasource));
}
/**
* 删除 数据源配置表
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(datasourceService.deleteLogic(Func.toLongList(ids)));
}
/**
* 数据源列表
*/
@GetMapping("/select")
@ApiOperationSupport(order = 8)
@Operation(summary = "下拉数据源", description = "查询列表")
public R<List<Datasource>> select() {
List<Datasource> list = datasourceService.list();
return R.data(list);
}
}

@ -1,203 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.pojo.entity.Model;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springblade.modules.develop.service.IModelPrototypeService;
import org.springblade.modules.develop.service.IModelService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* 数据模型表 控制器
*
* @author Chill
*/
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/model")
@Tag(name = "数据模型表", description = "数据模型表接口")
public class ModelController extends BladeController {
private final IModelService modelService;
private final IModelPrototypeService modelPrototypeService;
private final IDatasourceService datasourceService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入model")
public R<Model> detail(Model model) {
Model detail = modelService.getOne(Condition.getQueryWrapper(model));
return R.data(detail);
}
/**
* 分页 数据模型表
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入model")
public R<IPage<Model>> list(Model model, Query query) {
IPage<Model> pages = modelService.page(Condition.getPage(query), Condition.getQueryWrapper(model));
return R.data(pages);
}
/**
* 新增 数据模型表
*/
@PostMapping("/save")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增", description = "传入model")
public R save(@Valid @RequestBody Model model) {
return R.status(modelService.save(model));
}
/**
* 修改 数据模型表
*/
@PostMapping("/update")
@ApiOperationSupport(order = 4)
@Operation(summary = "修改", description = "传入model")
public R update(@Valid @RequestBody Model model) {
return R.status(modelService.updateById(model));
}
/**
* 新增或修改 数据模型表
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@Operation(summary = "新增或修改", description = "传入model")
public R submit(@Valid @RequestBody Model model) {
boolean temp = modelService.saveOrUpdate(model);
if (temp) {
return R.data(model);
} else {
return R.status(Boolean.FALSE);
}
}
/**
* 删除 数据模型表
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(modelService.delete(Func.toLongList(ids)));
}
/**
* 模型列表
*/
@GetMapping("/select")
@ApiOperationSupport(order = 7)
@Operation(summary = "模型列表", description = "模型列表")
public R<List<Model>> select() {
List<Model> list = modelService.list();
list.forEach(model -> model.setModelName(model.getModelTable() + StringPool.COLON + StringPool.SPACE + model.getModelName()));
return R.data(list);
}
/**
* 获取物理表列表
*/
@GetMapping("/table-list")
@ApiOperationSupport(order = 8)
@Operation(summary = "物理表列表", description = "传入datasourceId")
public R<List<TableInfo>> tableList(Long datasourceId) {
Datasource datasource = datasourceService.getById(datasourceId);
ConfigBuilder config = modelPrototypeService.getConfigBuilder(datasource);
List<TableInfo> tableInfoList = config.getTableInfoList().stream()
.filter(tableInfo -> !StringUtil.startsWithIgnoreCase(tableInfo.getName(), "ACT_") && !StringUtil.startsWithIgnoreCase(tableInfo.getName(), "FLW_"))
.map(tableInfo -> tableInfo.setComment(tableInfo.getName() + StringPool.COLON + tableInfo.getComment()))
.collect(Collectors.toList());
return R.data(tableInfoList);
}
/**
* 获取物理表信息
*/
@GetMapping("/table-info")
@ApiOperationSupport(order = 9)
@Operation(summary = "物理表信息", description = "传入model信息")
public R<TableInfo> tableInfo(Long modelId, String tableName, Long datasourceId) {
if (StringUtil.isBlank(tableName)) {
Model model = modelService.getById(modelId);
tableName = model.getModelTable();
}
TableInfo tableInfo = modelPrototypeService.getTableInfo(tableName, datasourceId);
return R.data(tableInfo);
}
/**
* 获取字段信息
*/
@GetMapping("/model-prototype")
@ApiOperationSupport(order = 10)
@Operation(summary = "物理表字段信息", description = "传入modelId与datasourceId")
public R modelPrototype(Long modelId, Long datasourceId) {
List<ModelPrototype> modelPrototypeList = modelPrototypeService.list(Wrappers.<ModelPrototype>query().lambda().eq(ModelPrototype::getModelId, modelId));
if (!modelPrototypeList.isEmpty()) {
return R.data(modelPrototypeList);
}
Model model = modelService.getById(modelId);
String tableName = model.getModelTable();
TableInfo tableInfo = modelPrototypeService.getTableInfo(tableName, datasourceId);
if (tableInfo != null) {
return R.data(tableInfo.getFields());
} else {
return R.fail("未获得相关表信息");
}
}
}

@ -1,146 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import org.springblade.modules.develop.service.IModelPrototypeService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 数据原型表 控制器
*
* @author Chill
*/
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/model-prototype")
@Tag(name = "数据原型表", description = "数据原型表接口")
public class ModelPrototypeController extends BladeController {
private final IModelPrototypeService modelPrototypeService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入modelPrototype")
public R<ModelPrototype> detail(ModelPrototype modelPrototype) {
ModelPrototype detail = modelPrototypeService.getOne(Condition.getQueryWrapper(modelPrototype));
return R.data(detail);
}
/**
* 分页 数据原型表
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入modelPrototype")
public R<IPage<ModelPrototype>> list(ModelPrototype modelPrototype, Query query) {
IPage<ModelPrototype> pages = modelPrototypeService.page(Condition.getPage(query), Condition.getQueryWrapper(modelPrototype));
return R.data(pages);
}
/**
* 新增 数据原型表
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入modelPrototype")
public R save(@Valid @RequestBody ModelPrototype modelPrototype) {
return R.status(modelPrototypeService.save(modelPrototype));
}
/**
* 修改 数据原型表
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入modelPrototype")
public R update(@Valid @RequestBody ModelPrototype modelPrototype) {
return R.status(modelPrototypeService.updateById(modelPrototype));
}
/**
* 新增或修改 数据原型表
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入modelPrototype")
public R submit(@Valid @RequestBody ModelPrototype modelPrototype) {
return R.status(modelPrototypeService.saveOrUpdate(modelPrototype));
}
/**
* 批量新增或修改 数据原型表
*/
@PostMapping("/submit-list")
@ApiOperationSupport(order = 7)
@Operation(summary = "批量新增或修改", description = "传入modelPrototype集合")
public R submitList(@Valid @RequestBody List<ModelPrototype> modelPrototypes) {
return R.status(modelPrototypeService.submitList(modelPrototypes));
}
/**
* 删除 数据原型表
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 8)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(modelPrototypeService.deleteLogic(Func.toLongList(ids)));
}
/**
* 数据原型列表
*/
@GetMapping("/select")
@ApiOperationSupport(order = 9)
@Operation(summary = "数据原型列表", description = "数据原型列表")
public R<List<ModelPrototype>> select(@Parameter(description = "数据模型Id", required = true) @RequestParam Long modelId) {
List<ModelPrototype> list = modelPrototypeService.list(Wrappers.<ModelPrototype>query().lambda().eq(ModelPrototype::getModelId, modelId));
list.forEach(prototype -> prototype.setJdbcComment(prototype.getJdbcName() + StringPool.COLON + StringPool.SPACE + prototype.getJdbcComment()));
return R.data(list);
}
}

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.pojo.entity.Code;
/**
* Mapper 接口
*
* @author Chill
*/
public interface CodeMapper extends BaseMapper<Code> {
}

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.CodeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="codeResultMap" type="org.springblade.modules.develop.pojo.entity.Code">
<id column="id" property="id"/>
<result column="model_id" property="modelId"/>
<result column="menu_id" property="menuId"/>
<result column="service_name" property="serviceName"/>
<result column="code_name" property="codeName"/>
<result column="table_name" property="tableName"/>
<result column="pk_name" property="pkName"/>
<result column="base_mode" property="baseMode"/>
<result column="wrap_mode" property="wrapMode"/>
<result column="table_prefix" property="tablePrefix"/>
<result column="package_name" property="packageName"/>
<result column="api_path" property="apiPath"/>
<result column="web_path" property="webPath"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
</mapper>

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.pojo.entity.CodeSetting;
/**
* 代码生成器配置表 Mapper 接口
*
* @author BladeX
*/
public interface CodeSettingMapper extends BaseMapper<CodeSetting> {
}

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.CodeSettingMapper">
<!-- 通用查询映射结果 -->
<resultMap id="codeSettingResultMap" type="org.springblade.modules.develop.pojo.entity.CodeSetting">
<result column="id" property="id"/>
<result column="settings" property="settings"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
</mapper>

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.pojo.entity.Datasource;
/**
* 数据源配置表 Mapper 接口
*
* @author Chill
*/
public interface DatasourceMapper extends BaseMapper<Datasource> {
}

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.DatasourceMapper">
<!-- 通用查询映射结果 -->
<resultMap id="datasourceResultMap" type="org.springblade.modules.develop.pojo.entity.Datasource">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="driver_class" property="driverClass"/>
<result column="url" property="url"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="remark" property="remark"/>
</resultMap>
</mapper>

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.pojo.entity.Model;
/**
* 数据模型表 Mapper 接口
*
* @author Chill
*/
public interface ModelMapper extends BaseMapper<Model> {
}

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.ModelMapper">
<!-- 通用查询映射结果 -->
<resultMap id="modelResultMap" type="org.springblade.modules.develop.pojo.entity.Model">
<id column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="datasource_id" property="datasourceId"/>
<result column="model_name" property="modelName"/>
<result column="model_code" property="modelCode"/>
<result column="model_table" property="modelTable"/>
<result column="model_class" property="modelClass"/>
<result column="model_remark" property="modelRemark"/>
</resultMap>
<select id="selectModelPage" resultMap="modelResultMap">
select * from blade_model where is_deleted = 0
</select>
</mapper>

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
/**
* 数据原型表 Mapper 接口
*
* @author Chill
*/
public interface ModelPrototypeMapper extends BaseMapper<ModelPrototype> {
}

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.ModelPrototypeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="modelPrototypeResultMap" type="org.springblade.modules.develop.pojo.entity.ModelPrototype">
<id column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="jdbc_name" property="jdbcName"/>
<result column="jdbc_type" property="jdbcType"/>
<result column="jdbc_comment" property="jdbcComment"/>
<result column="property_type" property="propertyType"/>
<result column="property_entity" property="propertyEntity"/>
<result column="property_name" property="propertyName"/>
<result column="is_form" property="isForm"/>
<result column="is_row" property="isRow"/>
<result column="component_type" property="componentType"/>
<result column="dict_code" property="dictCode"/>
<result column="is_required" property="isRequired"/>
<result column="is_list" property="isList"/>
<result column="is_query" property="isQuery"/>
<result column="query_type" property="queryType"/>
</resultMap>
<select id="selectModelPrototypePage" resultMap="modelPrototypeResultMap">
select * from blade_model_prototype where is_deleted = 0
</select>
</mapper>

@ -1,148 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 代码生成DTO
*
* @author Chill
*/
@Data
public class GeneratorDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 上级菜单主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "上级菜单主键")
private Long menuId;
/**
* 数据源主键
*/
@Schema(description = "数据源主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long datasourceId;
/**
* 模型编号
*/
@Schema(description = "模型编号")
private String modelCode;
/**
* 物理表名
*/
@Schema(description = "物理表名")
private String modelTable;
/**
* 模型类名
*/
@Schema(description = "模型类名")
private String modelClass;
/**
* 模块名称
*/
@Schema(description = "服务名称")
private String serviceName;
/**
* 模块名称
*/
@Schema(description = "模块名称")
private String codeName;
/**
* 表名
*/
@Schema(description = "表名")
private String tableName;
/**
* 实体名
*/
@Schema(description = "表前缀")
private String tablePrefix;
/**
* 主键名
*/
@Schema(description = "主键名")
private String pkName;
/**
* 后端包名
*/
@Schema(description = "后端包名")
private String packageName;
/**
* 基础业务模式
*/
@Schema(description = "基础业务模式")
private Integer baseMode;
/**
* 包装器模式
*/
@Schema(description = "包装器模式")
private Integer wrapMode;
/**
* 远程调用模式
*/
@Schema(description = "远程调用模式")
private Integer feignMode;
/**
* 代码风格
*/
@Schema(description = "代码风格")
private String codeStyle;
/**
* 后端路径
*/
@Schema(description = "后端路径")
private String apiPath;
/**
* 前端路径
*/
@Schema(description = "前端路径")
private String webPath;
}

@ -1,53 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.develop.pojo.entity.Model;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import java.io.Serial;
import java.util.List;
/**
* 代码模型DTO
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ModelDTO extends Model {
@Serial
private static final long serialVersionUID = 1L;
/**
* 代码建模原型
*/
private List<ModelPrototype> prototypes;
}

@ -1,197 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_code")
@Schema(description = "Code对象")
public class Code implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 数据模型主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "数据模型主键")
private Long modelId;
/**
* 上级菜单主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "上级菜单主键")
private Long menuId;
/**
* 模块名称
*/
@Schema(description = "服务名称")
private String serviceName;
/**
* 模块名称
*/
@Schema(description = "模块名称")
private String codeName;
/**
* 表名
*/
@Schema(description = "表名")
private String tableName;
/**
* 实体名
*/
@Schema(description = "表前缀")
private String tablePrefix;
/**
* 主键名
*/
@Schema(description = "主键名")
private String pkName;
/**
* 后端包名
*/
@Schema(description = "后端包名")
private String packageName;
/**
* 模版类型
*/
@Schema(description = "模版类型")
private String templateType;
/**
* 作者信息
*/
@Schema(description = "作者信息")
private String author;
/**
* 子表模型主键
*/
@Schema(description = "子表模型主键")
private String subModelId;
/**
* 子表绑定外键
*/
@Schema(description = "子表绑定外键")
private String subFkId;
/**
* 树主键字段
*/
@Schema(description = "树主键字段")
private String treeId;
/**
* 树父主键字段
*/
@Schema(description = "树父主键字段")
private String treePid;
/**
* 树名称字段
*/
@Schema(description = "树名称字段")
private String treeName;
/**
* 基础业务模式
*/
@Schema(description = "基础业务模式")
private Integer baseMode;
/**
* 包装器模式
*/
@Schema(description = "包装器模式")
private Integer wrapMode;
/**
* 远程调用模式
*/
@Schema(description = "远程调用模式")
private Integer feignMode;
/**
* 代码风格
*/
@Schema(description = "代码风格")
private String codeStyle;
/**
* 后端路径
*/
@Schema(description = "后端路径")
private String apiPath;
/**
* 前端路径
*/
@Schema(description = "前端路径")
private String webPath;
/**
* 是否已删除
*/
@TableLogic
@Schema(description = "是否已删除")
private Integer isDeleted;
}

@ -1,77 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.entity;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.io.Serial;
/**
* 代码生成器配置表 实体类
*
* @author BladeX
*/
@Data
@TableName("blade_code_setting")
@Schema(description = "CodeSetting对象")
public class CodeSetting implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@Schema(description = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 配置项
*/
@Schema(description = "配置项")
private String settings;
/**
* 状态[1:正常]
*/
@Schema(description = "业务状态", hidden = true)
private Integer status;
/**
* 是否已删除
*/
@Schema(description = "是否已删除")
private Integer isDeleted;
}

@ -1,92 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
* 数据源配置表实体类
*
* @author Chill
*/
@Data
@TableName("blade_datasource")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "数据源配置表")
public class Datasource extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 数据源类型
*/
@Schema(description = "数据源类型")
private Integer category;
/**
* 名称
*/
@Schema(description = "名称")
private String name;
/**
* 驱动类
*/
@Schema(description = "驱动类")
private String driverClass;
/**
* 连接地址
*/
@Schema(description = "连接地址")
private String url;
/**
* 用户名
*/
@Schema(description = "用户名")
private String username;
/**
* 密码
*/
@Schema(description = "密码")
private String password;
/**
* 分库分表配置
*/
@Schema(description = "分库分表配置")
private String shardingConfig;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
}

@ -1,85 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
* 数据模型表实体类
*
* @author Chill
*/
@Data
@TableName("blade_model")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "数据模型表")
public class Model extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 数据源主键
*/
@Schema(description = "数据源主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long datasourceId;
/**
* 模型名称
*/
@Schema(description = "模型名称")
private String modelName;
/**
* 模型编号
*/
@Schema(description = "模型编号")
private String modelCode;
/**
* 物理表名
*/
@Schema(description = "物理表名")
private String modelTable;
/**
* 模型类名
*/
@Schema(description = "模型类名")
private String modelClass;
/**
* 模型备注
*/
@Schema(description = "模型备注")
private String modelRemark;
}

@ -1,130 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
* 数据原型表实体类
*
* @author Chill
*/
@Data
@TableName("blade_model_prototype")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "数据原型表")
public class ModelPrototype extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 模型主键
*/
@Schema(description = "模型主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long modelId;
/**
* 物理列名
*/
@Schema(description = "物理列名")
private String jdbcName;
/**
* 物理类型
*/
@Schema(description = "物理类型")
private String jdbcType;
/**
* 注释说明
*/
@Schema(description = "注释说明")
private String jdbcComment;
/**
* 实体列名
*/
@Schema(description = "实体列名")
private String propertyName;
/**
* 实体类型
*/
@Schema(description = "实体类型")
private String propertyType;
/**
* 实体类型引用
*/
@Schema(description = "实体类型引用")
private String propertyEntity;
/**
* 列表显示
*/
@Schema(description = "列表显示")
private Integer isList;
/**
* 表单显示
*/
@Schema(description = "表单显示")
private Integer isForm;
/**
* 独占一行
*/
@Schema(description = "独占一行")
private Integer isRow;
/**
* 组件类型
*/
@Schema(description = "组件类型")
private String componentType;
/**
* 字典编码
*/
@Schema(description = "字典编码")
private String dictCode;
/**
* 是否必填
*/
@Schema(description = "是否必填")
private Integer isRequired;
/**
* 查询配置
*/
@Schema(description = "查询配置")
private Integer isQuery;
/**
* 查询类型
*/
@Schema(description = "查询类型")
private String queryType;
}

@ -1,47 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.develop.pojo.entity.Code;
/**
* 服务类
*
* @author Chill
*/
public interface ICodeService extends IService<Code> {
/**
* 提交
*
* @param code
* @return
*/
boolean submit(Code code);
}

@ -1,45 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.develop.pojo.entity.CodeSetting;
/**
* 代码生成器配置表 服务类
*
* @author BladeX
*/
public interface ICodeSettingService extends IService<CodeSetting> {
/**
* 启动配置
*
* @param id
* @return
*/
boolean enable(Long id);
}

@ -1,38 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.develop.pojo.entity.Datasource;
/**
* 数据源配置表 服务类
*
* @author Chill
*/
public interface IDatasourceService extends BaseService<Datasource> {
}

@ -1,56 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import org.springblade.modules.develop.pojo.dto.GeneratorDTO;
import java.util.List;
/**
* 服务类
*
* @author Chill
*/
public interface IGenerateService {
/**
* 生成代码
*
* @param ids 主键集合
* @return boolean
*/
boolean code(List<Long> ids);
/**
* 快速生成代码
*
* @param dto 配置参数
* @return boolean
*/
boolean codeFast(GeneratorDTO dto);
}

@ -1,84 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import java.util.List;
/**
* 数据原型表 服务类
*
* @author Chill
*/
public interface IModelPrototypeService extends BaseService<ModelPrototype> {
/**
* 批量提交
*
* @param modelPrototypes 原型集合
* @return boolean
*/
boolean submitList(List<ModelPrototype> modelPrototypes);
/**
* 原型列表
*
* @param modelId 模型ID
* @return List<ModelPrototype>
*/
List<ModelPrototype> prototypeList(Long modelId);
/**
* 获取表信息
*
* @param tableName 表名
* @param datasourceId 数据源主键
*/
TableInfo getTableInfo(String tableName, Long datasourceId);
/**
* 获取表配置信息
*
* @param datasource 数据源信息
*/
default ConfigBuilder getConfigBuilder(Datasource datasource) {
return getConfigBuilder(datasource, null);
}
/**
* 获取表配置信息
*
* @param datasource 数据源信息
* @param tableName 表名
*/
ConfigBuilder getConfigBuilder(Datasource datasource, String tableName);
}

@ -1,48 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.develop.pojo.entity.Model;
import java.util.List;
/**
* 数据模型表 服务类
*
* @author Chill
*/
public interface IModelService extends BaseService<Model> {
/**
* 删除模型
*
* @param ids 主键集合
* @return boolean
*/
boolean delete(List<Long> ids);
}

@ -1,49 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.modules.develop.pojo.entity.Code;
import org.springblade.modules.develop.mapper.CodeMapper;
import org.springblade.modules.develop.service.ICodeService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements ICodeService {
@Override
public boolean submit(Code code) {
code.setIsDeleted(BladeConstant.DB_NOT_DELETED);
return saveOrUpdate(code);
}
}

@ -1,53 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.modules.develop.mapper.CodeSettingMapper;
import org.springblade.modules.develop.pojo.entity.CodeSetting;
import org.springblade.modules.develop.service.ICodeSettingService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 代码生成器配置表 服务实现类
*
* @author BladeX
*/
@Service
public class CodeSettingServiceImpl extends ServiceImpl<CodeSettingMapper, CodeSetting> implements ICodeSettingService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean enable(Long id) {
// 先禁用
boolean temp1 = this.update(Wrappers.<CodeSetting>update().lambda().set(CodeSetting::getStatus, BladeConstant.DB_STATUS_1));
// 在启用
boolean temp2 = this.update(Wrappers.<CodeSetting>update().lambda().set(CodeSetting::getStatus, BladeConstant.DB_STATUS_2).eq(CodeSetting::getId, id));
return temp1 && temp2;
}
}

@ -1,42 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.mapper.DatasourceMapper;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springframework.stereotype.Service;
/**
* 数据源配置表 服务实现类
*
* @author Chill
*/
@Service
public class DatasourceServiceImpl extends BaseServiceImpl<DatasourceMapper, Datasource> implements IDatasourceService {
}

@ -1,190 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.generator.config.po.TableField;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import lombok.RequiredArgsConstructor;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.develop.constant.DevelopConstant;
import org.springblade.develop.support.BladeCodeGenerator;
import org.springblade.modules.develop.pojo.dto.GeneratorDTO;
import org.springblade.modules.develop.pojo.entity.Code;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.pojo.entity.Model;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import org.springblade.modules.develop.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 服务实现类
*
* @author Chill
*/
@Service
@RequiredArgsConstructor
public class GenerateServiceImpl implements IGenerateService {
private final ICodeService codeService;
private final IDatasourceService datasourceService;
private final IModelService modelService;
private final IModelPrototypeService modelPrototypeService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean code(List<Long> ids) {
Collection<Code> codes = codeService.listByIds(ids);
codes.forEach(code -> {
// 创建代码生成器
BladeCodeGenerator generator = new BladeCodeGenerator();
// 设置菜单数据
this.generateMenu(generator, code);
// 设置配置信息
this.generateTemplate(generator, code);
// 设置基础模型
Model model = modelService.getById(code.getModelId());
this.generateModel(generator, code, model);
// 设置数据源
this.generateDatasource(generator, model);
// 启动代码生成
generator.run();
});
return true;
}
@Override
public boolean codeFast(GeneratorDTO dto) {
// 创建代码生成器
BladeCodeGenerator generator = new BladeCodeGenerator();
Code code = Objects.requireNonNull(BeanUtil.copyProperties(dto, Code.class));
Model model = Objects.requireNonNull(BeanUtil.copyProperties(dto, Model.class));
// 设置菜单数据
this.generateMenu(generator, code);
// 设置配置信息
this.generateTemplate(generator, code);
this.generateModel(generator, code, model);
// 设置数据源
this.generateDatasource(generator, model);
// 启动代码生成
generator.run();
return true;
}
private void generateMenu(BladeCodeGenerator generator, Code code) {
// 设置上级菜单id
generator.setMenuId(String.valueOf(code.getMenuId()));
// 设置是否生成菜单sql
generator.setHasMenuSql(Boolean.TRUE);
}
private void generateTemplate(BladeCodeGenerator generator, Code code) {// 设置基础配置
generator.setCodeStyle(code.getCodeStyle());
generator.setCodeName(code.getCodeName());
generator.setServiceName(code.getServiceName());
generator.setPackageName(code.getPackageName());
generator.setPackageDir(code.getApiPath());
generator.setPackageWebDir(code.getWebPath());
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix()));
generator.setIncludeTables(Func.toStrArray(code.getTableName()));
// 设置模版信息
generator.setTemplateType(Func.toStr(code.getTemplateType(), DevelopConstant.TEMPLATE_CRUD));
generator.setAuthor(code.getAuthor());
generator.setSubModelId(code.getSubModelId());
generator.setSubFkId(code.getSubFkId());
generator.setTreeId(code.getTreeId());
generator.setTreePid(code.getTreePid());
generator.setTreeName(code.getTreeName());
// 设置是否继承基础业务字段
generator.setHasSuperEntity(code.getBaseMode() == 2);
// 设置是否开启包装器模式
generator.setHasWrapper(code.getWrapMode() == 2);
// 设置是否开启远程调用模式
generator.setHasFeign(code.getFeignMode() == 2);
// 设置控制器服务名前缀
generator.setHasServiceName(Boolean.TRUE);
}
private void generateModel(BladeCodeGenerator generator, Code code, Model model) {
generator.setModelCode(model.getModelCode());
generator.setModelClass(model.getModelClass());
generator.setModel(JsonUtil.readMap(JsonUtil.toJson(model)));
// 设置模型集合
if (Func.isNotEmpty(model.getId())) {
List<ModelPrototype> prototypes = modelPrototypeService.prototypeList(model.getId());
generator.setPrototypes(JsonUtil.readListMap(JsonUtil.toJson(prototypes)));
if (StringUtil.isNotBlank(code.getSubModelId()) && StringUtil.equals(code.getTemplateType(), DevelopConstant.TEMPLATE_SUB)) {
Model subModel = modelService.getById(Func.toLong(code.getSubModelId()));
List<ModelPrototype> subPrototypes = modelPrototypeService.prototypeList(subModel.getId());
generator.setSubModel(JsonUtil.readMap(JsonUtil.toJson(subModel)));
generator.setSubPrototypes(JsonUtil.readListMap(JsonUtil.toJson(subPrototypes)));
}
} else {
TableInfo tableInfo = modelPrototypeService.getTableInfo(model.getModelTable(), model.getDatasourceId());
List<TableField> fields = tableInfo.getFields();
List<ModelPrototype> prototypes = convertPrototypes(fields);
generator.setPrototypes(JsonUtil.readListMap(JsonUtil.toJson(prototypes)));
}
}
private void generateDatasource(BladeCodeGenerator generator, Model model) {
Datasource datasource = datasourceService.getById(model.getDatasourceId());
generator.setDriverName(datasource.getDriverClass());
generator.setUrl(datasource.getUrl());
generator.setUsername(datasource.getUsername());
generator.setPassword(datasource.getPassword());
}
/**
* TableField 列表转换为 ModelPrototype 列表
*
* @param tableFields 输入的 TableField 列表
* @return 转换后的 ModelPrototype 列表
*/
public static List<ModelPrototype> convertPrototypes(List<TableField> tableFields) {
return tableFields.stream().map(tableField -> {
ModelPrototype prototype = new ModelPrototype();
prototype.setJdbcName(tableField.getName());
if (tableField.getColumnType() != null) {
prototype.setJdbcType(tableField.getColumnType().getType());
prototype.setPropertyType(tableField.getColumnType().getType());
}
prototype.setJdbcComment(tableField.getComment());
prototype.setPropertyName(tableField.getPropertyName());
prototype.setComponentType("input");
return prototype;
}).collect(Collectors.toList());
}
}

@ -1,115 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import lombok.RequiredArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.develop.pojo.entity.Datasource;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import org.springblade.modules.develop.mapper.ModelPrototypeMapper;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springblade.modules.develop.service.IModelPrototypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Iterator;
import java.util.List;
/**
* 数据原型表 服务实现类
*
* @author Chill
*/
@Service
@RequiredArgsConstructor
public class ModelPrototypeServiceImpl extends BaseServiceImpl<ModelPrototypeMapper, ModelPrototype> implements IModelPrototypeService {
private final IDatasourceService datasourceService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submitList(List<ModelPrototype> modelPrototypes) {
modelPrototypes.forEach(modelPrototype -> {
if (modelPrototype.getId() == null) {
this.save(modelPrototype);
} else {
this.updateById(modelPrototype);
}
});
return true;
}
@Override
public List<ModelPrototype> prototypeList(Long modelId) {
return this.list(Wrappers.<ModelPrototype>lambdaQuery().eq(ModelPrototype::getModelId, modelId));
}
@Override
public TableInfo getTableInfo(String tableName, Long datasourceId) {
Datasource datasource = datasourceService.getById(datasourceId);
ConfigBuilder config = getConfigBuilder(datasource, tableName);
List<TableInfo> tableInfoList = config.getTableInfoList();
TableInfo tableInfo = null;
Iterator<TableInfo> iterator = tableInfoList.stream().filter(table -> table.getName().equals(tableName)).toList().iterator();
if (iterator.hasNext()) {
tableInfo = iterator.next();
if (tableName.contains(StringPool.UNDERSCORE)) {
String entityPrefix = StringUtil.firstCharToUpper(tableName.split(StringPool.UNDERSCORE)[0]);
String entityName = StringUtil.removePrefix(tableInfo.getEntityName(), entityPrefix);
tableInfo.setEntityName(entityName);
} else {
tableInfo.setEntityName(StringUtil.firstCharToUpper(tableName));
}
}
return tableInfo;
}
@Override
public ConfigBuilder getConfigBuilder(Datasource datasource, String tableName) {
StrategyConfig.Builder builder = new StrategyConfig.Builder();
//表前缀过滤,目前官方仅支持一个前缀,可自行修改为sys_或tb_或其他业务表前缀
//builder.likeTable(new LikeTable("blade_", SqlLike.RIGHT));
if (StringUtil.isNotBlank(tableName)) {
builder.addInclude(tableName);
}
StrategyConfig strategyConfig = builder.entityBuilder()
.naming(NamingStrategy.underline_to_camel)
.columnNaming(NamingStrategy.underline_to_camel).build();
DataSourceConfig datasourceConfig = new DataSourceConfig.Builder(
datasource.getUrl(), datasource.getUsername(), datasource.getPassword()
).build();
return new ConfigBuilder(null, datasourceConfig, strategyConfig, null, null, null);
}
}

@ -1,76 +0,0 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.develop.pojo.entity.Code;
import org.springblade.modules.develop.pojo.entity.Model;
import org.springblade.modules.develop.pojo.entity.ModelPrototype;
import org.springblade.modules.develop.mapper.ModelMapper;
import org.springblade.modules.develop.service.ICodeService;
import org.springblade.modules.develop.service.IModelPrototypeService;
import org.springblade.modules.develop.service.IModelService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 数据模型表 服务实现类
*
* @author Chill
*/
@Service
@RequiredArgsConstructor
public class ModelServiceImpl extends BaseServiceImpl<ModelMapper, Model> implements IModelService {
private final IModelPrototypeService modelPrototypeService;
private final ICodeService codeService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<Long> ids) {
boolean modelTemp = this.deleteLogic(ids);
if (modelTemp) {
if (modelPrototypeService.count(Wrappers.<ModelPrototype>lambdaQuery().in(ModelPrototype::getModelId, ids)) > 0) {
boolean prototypeTemp = modelPrototypeService.remove(Wrappers.<ModelPrototype>lambdaQuery().in(ModelPrototype::getModelId, ids));
if (!prototypeTemp) {
throw new ServiceException("删除数据模型成功,关联数据原型删除失败");
}
}
if (codeService.count(Wrappers.<Code>lambdaQuery().in(Code::getModelId, ids)) > 0) {
boolean codeTemp = codeService.remove(Wrappers.<Code>lambdaQuery().in(Code::getModelId, ids));
if (!codeTemp) {
throw new ServiceException("删除数据模型成功,关联代码生成配置删除失败");
}
}
}
return true;
}
}
Loading…
Cancel
Save