init
This commit is contained in:
59
blade-ops/blade-develop/pom.xml
Normal file
59
blade-ops/blade-develop/pom.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-ops</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>blade-develop</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!--Blade-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-develop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-dict-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-develop-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.develop;
|
||||
|
||||
import org.springblade.core.cloud.client.BladeCloudApplication;
|
||||
import org.springblade.core.launch.BladeApplication;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* Develop启动器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@BladeCloudApplication
|
||||
public class DevelopApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BladeApplication.run(AppConstant.APPLICATION_DEVELOP_NAME, DevelopApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* 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.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.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.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.develop.pojo.dto.GeneratorDTO;
|
||||
import org.springblade.develop.pojo.entity.Code;
|
||||
import org.springblade.develop.service.ICodeService;
|
||||
import org.springblade.develop.service.IGenerateService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/code")
|
||||
@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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* 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.develop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
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.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.xss.annotation.XssIgnore;
|
||||
import org.springblade.develop.pojo.entity.CodeSetting;
|
||||
import org.springblade.develop.service.ICodeSettingService;
|
||||
import org.springblade.develop.service.IModelPrototypeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 代码生成器配置表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/code-setting")
|
||||
@Tag(name = "代码生成器配置表", description = "代码生成器配置表接口")
|
||||
public class CodeSettingController extends BladeController {
|
||||
|
||||
private final ICodeSettingService codeSettingService;
|
||||
private final IModelPrototypeService modelPrototypeService;
|
||||
|
||||
/**
|
||||
* 代码生成器配置表 详情
|
||||
*/
|
||||
@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).orderByDesc("id"));
|
||||
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));
|
||||
}
|
||||
|
||||
@XssIgnore
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入codeSetting")
|
||||
public R submit(@Valid @RequestBody CodeSetting codeSetting) {
|
||||
boolean temp = codeSettingService.saveOrUpdate(codeSetting);
|
||||
if (temp) {
|
||||
return R.data(codeSetting);
|
||||
} 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(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单设计器选择
|
||||
*/
|
||||
@GetMapping("/table-form")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "表单设计器选择", description = "tableName")
|
||||
public R<List<CodeSetting>> formSelect(String tableName) {
|
||||
return R.data(codeSettingService.list(Wrappers.<CodeSetting>lambdaQuery().eq(CodeSetting::getCode, tableName).eq(CodeSetting::getCategory, 2)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字段信息
|
||||
*/
|
||||
@GetMapping("/table-prototype")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "物理表字段信息", description = "传入tableName与datasourceId")
|
||||
public R tablePrototype(String tableName, Long datasourceId) {
|
||||
TableInfo tableInfo = modelPrototypeService.getTableInfo(tableName, datasourceId);
|
||||
if (tableInfo != null) {
|
||||
return R.data(tableInfo.getFields());
|
||||
} else {
|
||||
return R.fail("未获得相关表信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* 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.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.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
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.core.xss.annotation.XssIgnore;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
import org.springblade.develop.service.IDatasourceService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源配置表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 数据源配置表
|
||||
*/
|
||||
@XssIgnore
|
||||
@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("&", "&"));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
* 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.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.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
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.develop.pojo.entity.Datasource;
|
||||
import org.springblade.develop.pojo.entity.Model;
|
||||
import org.springblade.develop.pojo.entity.ModelPrototype;
|
||||
import org.springblade.develop.service.IDatasourceService;
|
||||
import org.springblade.develop.service.IModelPrototypeService;
|
||||
import org.springblade.develop.service.IModelService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据模型表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/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("未获得相关表信息");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* 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.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.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.develop.pojo.entity.ModelPrototype;
|
||||
import org.springblade.develop.service.IModelPrototypeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据原型表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 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.develop.feign;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
import org.springblade.develop.service.IDatasourceService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源远程调用服务
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class DatasourceClient implements IDatasourceClient {
|
||||
|
||||
private final IDatasourceService datasourceService;
|
||||
|
||||
/**
|
||||
* 获取数据源详情
|
||||
*/
|
||||
@GetMapping(GET_DETAIL)
|
||||
public R<Datasource> detail(@RequestParam("id") Long id) {
|
||||
Datasource datasource = datasourceService.getById(id);
|
||||
if (datasource == null) {
|
||||
return R.fail("数据源不存在");
|
||||
}
|
||||
return R.data(datasource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据源列表
|
||||
*/
|
||||
@GetMapping(GET_LIST)
|
||||
public R<List<Datasource>> list() {
|
||||
return R.data(datasourceService.list());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.develop.pojo.entity.Code;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface CodeMapper extends BaseMapper<Code> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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.develop.mapper.CodeMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="codeResultMap" type="org.springblade.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>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.develop.pojo.entity.CodeSetting;
|
||||
|
||||
/**
|
||||
* 代码生成器配置表 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface CodeSettingMapper extends BaseMapper<CodeSetting> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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.develop.mapper.CodeSettingMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="codeSettingResultMap" type="org.springblade.develop.pojo.entity.CodeSetting">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="settings" property="settings"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
|
||||
/**
|
||||
* 数据源配置表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface DatasourceMapper extends BaseMapper<Datasource> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.develop.mapper.DatasourceMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="datasourceResultMap" type="org.springblade.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>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.develop.pojo.entity.Model;
|
||||
|
||||
/**
|
||||
* 数据模型表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ModelMapper extends BaseMapper<Model> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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.develop.mapper.ModelMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="modelResultMap" type="org.springblade.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>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.develop.pojo.entity.ModelPrototype;
|
||||
|
||||
/**
|
||||
* 数据原型表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ModelPrototypeMapper extends BaseMapper<ModelPrototype> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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.develop.mapper.ModelPrototypeMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="modelPrototypeResultMap" type="org.springblade.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>
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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.develop.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springblade.develop.pojo.entity.Code;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ICodeService extends IService<Code> {
|
||||
|
||||
/**
|
||||
* 提交
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
boolean submit(Code code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.develop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springblade.develop.pojo.entity.CodeSetting;
|
||||
|
||||
/**
|
||||
* 代码生成器配置表 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface ICodeSettingService extends IService<CodeSetting> {
|
||||
|
||||
/**
|
||||
* 启动配置
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean enable(Long id);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.develop.service;
|
||||
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
|
||||
/**
|
||||
* 数据源配置表 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface IDatasourceService extends BaseService<Datasource> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.develop.service;
|
||||
|
||||
|
||||
import org.springblade.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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* 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.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.develop.pojo.entity.Datasource;
|
||||
import org.springblade.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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.develop.service;
|
||||
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.develop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.develop.pojo.entity.Code;
|
||||
import org.springblade.develop.mapper.CodeMapper;
|
||||
import org.springblade.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.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.develop.mapper.CodeSettingMapper;
|
||||
import org.springblade.develop.pojo.entity.CodeSetting;
|
||||
import org.springblade.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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.develop.service.impl;
|
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
import org.springblade.develop.mapper.DatasourceMapper;
|
||||
import org.springblade.develop.service.IDatasourceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据源配置表 服务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Service
|
||||
public class DatasourceServiceImpl extends BaseServiceImpl<DatasourceMapper, Datasource> implements IDatasourceService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* 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.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.pojo.dto.GeneratorDTO;
|
||||
import org.springblade.develop.pojo.entity.*;
|
||||
import org.springblade.develop.service.*;
|
||||
import org.springblade.develop.support.BladeCodeGenerator;
|
||||
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 ICodeSettingService codeSettingService;
|
||||
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));
|
||||
String modelForm = dto.getModelForm();
|
||||
// 设置菜单数据
|
||||
this.generateMenu(generator, code);
|
||||
// 设置配置信息
|
||||
this.generateForm(generator, modelForm);
|
||||
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 generateForm(BladeCodeGenerator generator, String modelForm) {
|
||||
if (StringUtil.isNotBlank(modelForm)) {
|
||||
CodeSetting codeSetting = codeSettingService.getById(Func.toLong(modelForm));
|
||||
if (codeSetting != null) {
|
||||
generator.setModelFormOption(codeSetting.getSettings());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.FALSE);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* 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.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.develop.mapper.ModelPrototypeMapper;
|
||||
import org.springblade.develop.pojo.entity.Datasource;
|
||||
import org.springblade.develop.pojo.entity.ModelPrototype;
|
||||
import org.springblade.develop.service.IDatasourceService;
|
||||
import org.springblade.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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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.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.develop.pojo.entity.Code;
|
||||
import org.springblade.develop.pojo.entity.Model;
|
||||
import org.springblade.develop.pojo.entity.ModelPrototype;
|
||||
import org.springblade.develop.mapper.ModelMapper;
|
||||
import org.springblade.develop.service.ICodeService;
|
||||
import org.springblade.develop.service.IModelPrototypeService;
|
||||
import org.springblade.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 7007
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.dev.url}
|
||||
username: ${blade.datasource.dev.username}
|
||||
password: ${blade.datasource.dev.password}
|
||||
@@ -0,0 +1,11 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 7007
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.prod.url}
|
||||
username: ${blade.datasource.prod.username}
|
||||
password: ${blade.datasource.prod.password}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 7007
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.test.url}
|
||||
username: ${blade.datasource.test.username}
|
||||
password: ${blade.datasource.test.password}
|
||||
@@ -0,0 +1,5 @@
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
author=BladeX
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* 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.test;
|
||||
|
||||
|
||||
import org.springblade.develop.constant.DevelopConstant;
|
||||
import org.springblade.develop.support.BladeFastCodeGenerator;
|
||||
|
||||
public class CodeGenerator {
|
||||
|
||||
/**
|
||||
* 代码生成的系统类型(Boot/Cloud)
|
||||
*/
|
||||
public static String SYSTEM_NAME = DevelopConstant.CLOUD_NAME;
|
||||
/**
|
||||
* 代码生成的模块名
|
||||
*/
|
||||
public static String CODE_NAME = "自定义模块";
|
||||
/**
|
||||
* 代码所在服务名
|
||||
*/
|
||||
public static String SERVICE_NAME = "blade-desk";
|
||||
/**
|
||||
* 代码生成的包名
|
||||
*/
|
||||
public static String PACKAGE_NAME = "org.springblade.desk";
|
||||
/**
|
||||
* 需要去掉的表前缀
|
||||
*/
|
||||
public static String[] TABLE_PREFIX = {"blade_"};
|
||||
/**
|
||||
* 需要生成的表名(两者只能取其一)
|
||||
*/
|
||||
public static String[] INCLUDE_TABLES = {"blade_notice"};
|
||||
/**
|
||||
* 需要排除的表名(两者只能取其一)
|
||||
*/
|
||||
public static String[] EXCLUDE_TABLES = {};
|
||||
/**
|
||||
* 是否包含基础业务字段
|
||||
*/
|
||||
public static Boolean HAS_SUPER_ENTITY = Boolean.TRUE;
|
||||
/**
|
||||
* 基础业务字段
|
||||
*/
|
||||
public static String[] SUPER_ENTITY_COLUMNS = {"id", "create_time", "create_user", "create_dept", "update_time", "update_user", "status", "is_deleted"};
|
||||
|
||||
/**
|
||||
* RUN THIS
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
BladeFastCodeGenerator generator = new BladeFastCodeGenerator();
|
||||
generator.setSystemName(SYSTEM_NAME);
|
||||
generator.setCodeName(CODE_NAME);
|
||||
generator.setServiceName(SERVICE_NAME);
|
||||
generator.setPackageName(PACKAGE_NAME);
|
||||
generator.setTablePrefix(TABLE_PREFIX);
|
||||
generator.setIncludeTables(INCLUDE_TABLES);
|
||||
generator.setExcludeTables(EXCLUDE_TABLES);
|
||||
generator.setHasSuperEntity(HAS_SUPER_ENTITY);
|
||||
generator.setSuperEntityColumns(SUPER_ENTITY_COLUMNS);
|
||||
generator.run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* 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 ${package.Controller};
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
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.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import ${packageName!}.pojo.vo.${entityKey!}VO;
|
||||
import ${packageName!}.excel.${entityKey!}Excel;
|
||||
#if(hasWrapper) {
|
||||
import ${packageName!}.wrapper.${entityKey!}Wrapper;
|
||||
#}
|
||||
import ${packageName!}.service.${table.serviceName!};
|
||||
#if(isNotEmpty(superControllerClassPackage)){
|
||||
import ${superControllerClassPackage!};
|
||||
#}
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.excel.util.ExcelUtil;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 控制器
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
#if(hasServiceName) {
|
||||
@RequestMapping("${serviceName!}/${entityKeyPath!}")
|
||||
#}else{
|
||||
@RequestMapping("/${entityKeyPath!}")
|
||||
#}
|
||||
@Tag(name = "${table.comment!}", description = "${table.comment!}接口")
|
||||
#if(isNotEmpty(superControllerClass)){
|
||||
public class ${table.controllerName!} extends ${superControllerClass!} {
|
||||
#}
|
||||
#else{
|
||||
public class ${table.controllerName!} {
|
||||
#}
|
||||
|
||||
private final ${table.serviceName!} ${entityKeyPath!}Service;
|
||||
|
||||
#if(hasWrapper){
|
||||
/**
|
||||
* ${table.comment!} 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入${entityKeyPath!}")
|
||||
public R<${entityKey!}VO> detail(${entityKey!}Entity ${entityKeyPath!}) {
|
||||
${entityKey!}Entity detail = ${entityKeyPath!}Service.getOne(Condition.getQueryWrapper(${entityKeyPath!}));
|
||||
return R.data(${entityKey!}Wrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入${entityKeyPath!}")
|
||||
public R<IPage<${entityKey!}VO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, Query query) {
|
||||
IPage<${entityKey!}Entity> pages = ${entityKeyPath!}Service.page(Condition.getPage(query), Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}Entity.class));
|
||||
return R.data(${entityKey!}Wrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
#}else{
|
||||
/**
|
||||
* ${table.comment!} 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入${entityKeyPath!}")
|
||||
public R<${entityKey!}Entity> detail(${entityKey!}Entity ${entityKeyPath!}) {
|
||||
${entityKey!}Entity detail = ${entityKeyPath!}Service.getOne(Condition.getQueryWrapper(${entityKeyPath!}));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入${entityKeyPath!}")
|
||||
public R<IPage<${entityKey!}Entity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, Query query) {
|
||||
IPage<${entityKey!}Entity> pages = ${entityKeyPath!}Service.page(Condition.getPage(query), Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}Entity.class));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
#}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入${entityKeyPath!}")
|
||||
public R<IPage<${entityKey!}VO>> page(${entityKey!}VO ${entityKeyPath!}, Query query) {
|
||||
IPage<${entityKey!}VO> pages = ${entityKeyPath!}Service.select${entityKey!}Page(Condition.getPage(query), ${entityKeyPath!});
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入${entityKeyPath!}")
|
||||
public R save(@Valid @RequestBody ${entityKey!}Entity ${entityKeyPath!}) {
|
||||
return R.status(${entityKeyPath!}Service.save(${entityKeyPath!}));
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入${entityKeyPath!}")
|
||||
public R update(@Valid @RequestBody ${entityKey!}Entity ${entityKeyPath!}) {
|
||||
return R.status(${entityKeyPath!}Service.updateById(${entityKeyPath!}));
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment!} 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入${entityKeyPath!}")
|
||||
public R submit(@Valid @RequestBody ${entityKey!}Entity ${entityKeyPath!}) {
|
||||
return R.status(${entityKeyPath!}Service.saveOrUpdate(${entityKeyPath!}));
|
||||
}
|
||||
|
||||
#if(hasSuperEntity){
|
||||
/**
|
||||
* ${table.comment!} 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(${entityKeyPath!}Service.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
#}else{
|
||||
/**
|
||||
* ${table.comment!} 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(${entityKeyPath!}Service.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
#}
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/export-${entityKeyPath!}")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "导出数据", description = "传入${entityKeyPath!}")
|
||||
public void export${entityKey!}(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, BladeUser bladeUser, HttpServletResponse response) {
|
||||
QueryWrapper<${entityKey!}Entity> queryWrapper = Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}Entity.class);
|
||||
//if (!AuthUtil.isAdministrator()) {
|
||||
// queryWrapper.lambda().eq(${entity!}::getTenantId, bladeUser.getTenantId());
|
||||
//}
|
||||
//queryWrapper.lambda().eq(${entityKey!}Entity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
|
||||
List<${entityKey!}Excel> list = ${entityKeyPath!}Service.export${entityKey!}(queryWrapper);
|
||||
ExcelUtil.export(response, "${table.comment!}数据" + DateUtil.time(), "${table.comment!}数据表", list, ${entityKey!}Excel.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* 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 ${package.Entity!};
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
#for(x in table.importPackages){
|
||||
#if(isNotEmpty(x)){
|
||||
#if(hasSuperEntity&&!strutil.contain(x,"Serializable")){
|
||||
import ${x!};
|
||||
#}
|
||||
#if(!hasSuperEntity&&!strutil.contain(x,"TenantEntity")){
|
||||
import ${x!};
|
||||
#}
|
||||
#}
|
||||
#}
|
||||
#if(hasSuperEntity){
|
||||
import lombok.EqualsAndHashCode;
|
||||
#}else{
|
||||
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.Serial;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 实体类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@Data
|
||||
@TableName("${table.name!}")
|
||||
@Schema(description = "${entity!}对象")
|
||||
#if(hasSuperEntity){
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ${entityKey!}Entity extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
#}else{
|
||||
public class ${entityKey!}Entity 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;
|
||||
#}
|
||||
|
||||
#for(x in table.fields) {
|
||||
#if(hasSuperEntity){
|
||||
#if(x.propertyName!="id"&&x.propertyName!="createUser"&&x.propertyName!="createDept"&&x.propertyName!="createTime"&&x.propertyName!="updateUser"&&x.propertyName!="updateTime"&&x.propertyName!="status"&&x.propertyName!="isDeleted"&&x.propertyName!="tenantId"){
|
||||
/**
|
||||
* ${x.comment!}
|
||||
*/
|
||||
@Schema(description = "${x.comment!}")
|
||||
private ${x.propertyType!} ${x.propertyName!};
|
||||
#}
|
||||
#}else{
|
||||
#if(x.propertyName!="id"){
|
||||
/**
|
||||
* ${x.comment!}
|
||||
*/
|
||||
@Schema(description = "${x.comment!}")
|
||||
private ${x.propertyType!} ${x.propertyName!};
|
||||
#}
|
||||
#}
|
||||
#}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 ${strutil.replace(package.Entity,"entity","dto")};
|
||||
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 数据传输对象实体类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ${entityKey!}DTO extends ${entityKey!}Entity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 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 ${strutil.replace(package.Entity,"pojo.entity","excel")};
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
#for(x in table.importPackages){
|
||||
#if(isNotEmpty(x)&&!strutil.contain(x,"TableName")&&!strutil.contain(x,"TenantEntity")){
|
||||
import ${x!};
|
||||
#}
|
||||
#}
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
/**
|
||||
* ${table.comment!} Excel实体类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(25)
|
||||
@HeadRowHeight(20)
|
||||
@ContentRowHeight(18)
|
||||
public class ${entityKey!}Excel implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#for(x in table.fields) {
|
||||
#if(x.propertyName!="createUser"&&x.propertyName!="createDept"&&x.propertyName!="createTime"&&x.propertyName!="updateUser"&&x.propertyName!="updateTime"){
|
||||
/**
|
||||
* ${x.comment!}
|
||||
*/
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty("${x.comment!}")
|
||||
private ${x.propertyType!} ${x.propertyName!};
|
||||
#}
|
||||
#}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 ${strutil.replace(package.Entity,"entity","vo")};
|
||||
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 视图实体类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ${entityKey!}VO extends ${entityKey!}Entity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* 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 ${package.Mapper!};
|
||||
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import ${packageName!}.pojo.vo.${entityKey!}VO;
|
||||
import ${packageName!}.excel.${entityKey!}Excel;
|
||||
import ${superMapperClassPackage!};
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!} Mapper 接口
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
public interface ${table.mapperName!} extends ${superMapperClass!}<${entityKey!}Entity> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param ${entityKeyPath!} 查询参数
|
||||
* @return List<${entityKey!}VO>
|
||||
*/
|
||||
List<${entityKey!}VO> select${entityKey!}Page(IPage page, ${entityKey!}VO ${entityKeyPath!});
|
||||
|
||||
/**
|
||||
* 获取导出数据
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return List<${entityKey!}Excel>
|
||||
*/
|
||||
List<${entityKey!}Excel> export${entityKey!}(@Param("ew") Wrapper<${entityKey!}Entity> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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="${package.Mapper!}.${table.mapperName!}">
|
||||
|
||||
#if(enableCache){
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
#}
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="${entityKeyPath!}ResultMap" type="${package.Entity!}.${entityKey!}Entity">
|
||||
#for(x in table.fields) {
|
||||
<result column="${x.name!}" property="${x.propertyName!}"/>
|
||||
#}
|
||||
</resultMap>
|
||||
|
||||
<select id="select${entityKey!}Page" resultMap="${entityKeyPath!}ResultMap">
|
||||
select * from ${table.name} where is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="export${entityKey!}" resultType="${packageName!}.excel.${entityKey!}Excel">
|
||||
SELECT * FROM ${table.name!} \${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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 ${package.Service!};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import ${packageName!}.pojo.vo.${entityKey!}VO;
|
||||
import ${packageName!}.excel.${entityKey!}Excel;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
#if(hasSuperEntity){
|
||||
import ${superServiceClassPackage!};
|
||||
#}else{
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
#}
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 服务类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
#if(hasSuperEntity){
|
||||
public interface ${table.serviceName!} extends ${superServiceClass!}<${entity!}> {
|
||||
#}else{
|
||||
public interface ${table.serviceName!} extends IService<${entity!}> {
|
||||
#}
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param ${entityKeyPath!} 查询参数
|
||||
* @return IPage<${entityKey!}VO>
|
||||
*/
|
||||
IPage<${entityKey!}VO> select${entityKey!}Page(IPage<${entityKey!}VO> page, ${entityKey!}VO ${entityKeyPath!});
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return List<${entityKey!}Excel>
|
||||
*/
|
||||
List<${entityKey!}Excel> export${entityKey!}(Wrapper<${entityKey!}Entity> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 ${package.ServiceImpl!};
|
||||
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import ${packageName!}.pojo.vo.${entityKey!}VO;
|
||||
import ${packageName!}.excel.${entityKey!}Excel;
|
||||
import ${packageName!}.mapper.${table.mapperName!};
|
||||
import ${packageName!}.service.${table.serviceName!};
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
#if(hasSuperEntity){
|
||||
import ${superServiceImplClassPackage!};
|
||||
#}else{
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
#}
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 服务实现类
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
@Service
|
||||
#if(hasSuperEntity){
|
||||
public class ${table.serviceImplName!} extends ${superServiceImplClass!}<${table.mapperName!}, ${entity!}> implements ${table.serviceName!} {
|
||||
#}else{
|
||||
public class ${table.serviceImplName!} extends ServiceImpl<${table.mapperName!}, ${entity!}> implements ${table.serviceName!} {
|
||||
#}
|
||||
|
||||
@Override
|
||||
public IPage<${entityKey!}VO> select${entityKey!}Page(IPage<${entityKey!}VO> page, ${entityKey!}VO ${entityKeyPath!}) {
|
||||
return page.setRecords(baseMapper.select${entityKey!}Page(page, ${entityKeyPath!}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${entityKey!}Excel> export${entityKey!}(Wrapper<${entityKey!}Entity> queryWrapper) {
|
||||
List<${entityKey!}Excel> ${entityKeyPath!}List = baseMapper.export${entityKey!}(queryWrapper);
|
||||
//${entityKeyPath!}List.forEach(${entityKeyPath!} -> {
|
||||
// ${entityKeyPath!}.setTypeName(DictCache.getValue(DictEnum.YES_NO, ${entity!}.getType()));
|
||||
//});
|
||||
return ${entityKeyPath!}List;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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 ${strutil.replace(package.Entity,"pojo.entity","wrapper")};
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import ${packageName!}.pojo.entity.${entityKey!}Entity;
|
||||
import ${packageName!}.pojo.vo.${entityKey!}VO;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* ${table.comment!} 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author ${author!}
|
||||
* @since ${date!}
|
||||
*/
|
||||
public class ${entityKey!}Wrapper extends BaseEntityWrapper<${entityKey!}Entity, ${entityKey!}VO> {
|
||||
|
||||
public static ${entityKey!}Wrapper build() {
|
||||
return new ${entityKey!}Wrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${entityKey!}VO entityVO(${entityKey!}Entity ${entityKeyPath!}) {
|
||||
${entityKey!}VO ${entityKeyPath!}VO = Objects.requireNonNull(BeanUtil.copyProperties(${entityKeyPath!}, ${entityKey!}VO.class));
|
||||
|
||||
//User createUser = UserCache.getUser(${entityKeyPath!}.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(${entityKeyPath!}.getUpdateUser());
|
||||
//${entityKeyPath!}VO.setCreateUserName(createUser.getName());
|
||||
//${entityKeyPath!}VO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return ${entityKeyPath!}VO;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
author=BladeX
|
||||
Reference in New Issue
Block a user