This commit is contained in:
parent
a7a1ef77b4
commit
5e929e565f
|
|
@ -1,243 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<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>
|
|
||||||
<artifactId>ebts</artifactId>
|
|
||||||
<groupId>com.ebts</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ebts-generator</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
generator代码生成
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!--velocity代码生成使用模板 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.velocity</groupId>
|
|
||||||
<artifactId>velocity</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- FTP上传文件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-net</groupId>
|
|
||||||
<artifactId>commons-net</artifactId>
|
|
||||||
<version>3.7</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring框架基本的核心工具 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context-support</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringWeb模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- spring security 安全认证 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- pagehelper 分页插件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.pagehelper</groupId>
|
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 自定义验证注解 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--常用工具类 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JSON工具类 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 阿里JSON解析器 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- io常用工具类 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 文件上传工具类 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-fileupload</groupId>
|
|
||||||
<artifactId>commons-fileupload</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- excel工具 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- yml解析器 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.yaml</groupId>
|
|
||||||
<artifactId>snakeyaml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--Token生成与解析-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- redis 缓存操作 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- pool 对象池 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-pool2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 解析客户端操作系统、浏览器等 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.bitwalker</groupId>
|
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- servlet包 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- swagger2-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-annotations</artifactId>
|
|
||||||
<version>1.5.21</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-models</artifactId>
|
|
||||||
<version>1.5.21</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- swagger2-UI-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- 通用工具-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ebts</groupId>
|
|
||||||
<artifactId>ebts-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.wvengen</groupId>
|
|
||||||
<artifactId>proguard-maven-plugin</artifactId>
|
|
||||||
<version>2.0.14</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- ProGuard混淆插件 -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.github.wvengen</groupId>
|
|
||||||
<artifactId>proguard-maven-plugin</artifactId>
|
|
||||||
<version>2.0.14</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>proguard</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<!-- 将混淆后的pg包自动部署到maven上-->
|
|
||||||
<attach>true</attach>
|
|
||||||
<attachArtifactClassifier>pg</attachArtifactClassifier>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>log4j-api</artifactId>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
<options>
|
|
||||||
<option>-dontshrink</option>
|
|
||||||
<!-- 不忽略指定jars中的非public calsses-->
|
|
||||||
<option>-dontskipnonpubliclibraryclasses</option>
|
|
||||||
<!-- 不忽略指定类库的public类成员-->
|
|
||||||
<option>-dontskipnonpubliclibraryclassmembers</option>
|
|
||||||
<option>-optimizations !field/propagation/value</option>
|
|
||||||
<option>-keepdirectories</option>
|
|
||||||
<!-- 保留继承了注释的类-->
|
|
||||||
<option>-keep class * extends java.lang.annotation.Annotation {*;}</option>
|
|
||||||
<option>-keepattributes InnerClasses,Signature,LineNumberTable,*Annotation*,Exceptions</option>
|
|
||||||
<option>
|
|
||||||
-keepclassmembers class * implements java.io.Serializable {
|
|
||||||
static final long serialVersionUID;
|
|
||||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
|
||||||
private void
|
|
||||||
writeObject(java.io.ObjectOutputStream);
|
|
||||||
private void readObject(java.io.ObjectInputStream);
|
|
||||||
java.lang.Object writeReplace();
|
|
||||||
java.lang.Object readResolve();
|
|
||||||
}
|
|
||||||
</option>
|
|
||||||
<!-- <option>-->
|
|
||||||
<!-- -dontwarn lib/log4j-api-2.11.2.jar-->
|
|
||||||
<!-- </option>-->
|
|
||||||
<option>
|
|
||||||
-libraryjars lib/log4j-api-2.11.2.jar(!META-INF/versions/9/**.class,!module-info.class)
|
|
||||||
-libraryjars lib/log4j-core-2.11.2.jar
|
|
||||||
-libraryjars lib/log4j-jcl-2.11.2.jar
|
|
||||||
-libraryjars lib/log4j-web-2.11.2.jar
|
|
||||||
</option>
|
|
||||||
<!-- <option>-->
|
|
||||||
<!-- -libraryjars lib/byte-buddy-1.9.16.jars/9/**.class,(!META-INF/version!module-info.class)-->
|
|
||||||
<!-- </option>-->
|
|
||||||
<!-- <option>-libraryjars-->
|
|
||||||
<!-- ${settings.localRepository}/net/bytebuddy/byte-buddy/1.9.16/byte-buddy-1.9.16.jar(!META-INF/versions/9/module-info.class)-->
|
|
||||||
<!-- </option>-->
|
|
||||||
</options>
|
|
||||||
<libs>
|
|
||||||
<lib>D:/Java/jdk1.8/lib/rt.jar</lib>
|
|
||||||
<lib>D:/Java/jdk1.8/lib/jce.jar</lib>
|
|
||||||
</libs>
|
|
||||||
<!-- <outjar>C:/Users/18209/Desktop/新建文件夹/ebts-generator.jar</outjar>-->
|
|
||||||
|
|
||||||
<injar>ebts-generator-1.0.0.jar</injar>
|
|
||||||
<outjar>ebts-generator.jar</outjar>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.ebts.generator.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/23 15:48
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@ConfigurationProperties(prefix = "ebts")
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传路径
|
|
||||||
*/
|
|
||||||
private static String profile;
|
|
||||||
|
|
||||||
|
|
||||||
public static String getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取下载路径
|
|
||||||
*/
|
|
||||||
public static String getDownloadPath() {
|
|
||||||
return getProfile() + "/download/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
package com.ebts.generator.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.PropertySource;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取代码生成相关配置
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@ConfigurationProperties(prefix = "gen")
|
|
||||||
@PropertySource(value = {"classpath:generator.yml"})
|
|
||||||
public class GenConfig {
|
|
||||||
/**
|
|
||||||
* 作者
|
|
||||||
*/
|
|
||||||
public static String author;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成包路径
|
|
||||||
*/
|
|
||||||
public static String packageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动去除表前缀,默认是false
|
|
||||||
*/
|
|
||||||
public static boolean autoRemovePre;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表前缀(类名不会包含表前缀)
|
|
||||||
*/
|
|
||||||
public static String tablePrefix;
|
|
||||||
|
|
||||||
public static String getAuthor() {
|
|
||||||
return author;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${author}")
|
|
||||||
public void setAuthor(String author) {
|
|
||||||
GenConfig.author = author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${packageName}")
|
|
||||||
public void setPackageName(String packageName) {
|
|
||||||
GenConfig.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getAutoRemovePre() {
|
|
||||||
return autoRemovePre;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${autoRemovePre}")
|
|
||||||
public void setAutoRemovePre(boolean autoRemovePre) {
|
|
||||||
GenConfig.autoRemovePre = autoRemovePre;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getTablePrefix() {
|
|
||||||
return tablePrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${tablePrefix}")
|
|
||||||
public void setTablePrefix(String tablePrefix) {
|
|
||||||
GenConfig.tablePrefix = tablePrefix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,168 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.service.ApiClassService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口类名Controller
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/apiclass")
|
|
||||||
public class ApiClassController extends BaseController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(ApiClassController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApiClassService apiClassService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到api类的select选项
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('tool:apiclass:querylist')")
|
|
||||||
@GetMapping("querylist")
|
|
||||||
public AjaxResult queryList() {
|
|
||||||
ServerResult<List<ApiClass>> ServerResult = apiClassService.selectApiclassList(new ApiClass());
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable list(ApiClass apiclass) {
|
|
||||||
startPage();
|
|
||||||
ServerResult<List<ApiClass>> ServerResult = apiClassService.selectApiclassList(apiclass);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出接口类名列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:export')")
|
|
||||||
@Log(title = "接口类名", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(ApiClass apiclass) {
|
|
||||||
ServerResult<List<ApiClass>> ServerResult = apiClassService.selectApiclassList(apiclass);
|
|
||||||
ExcelUtil<ApiClass> util = new ExcelUtil<>(ApiClass.class);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return util.exportExcel(ServerResult.getData(), "apiclass");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取接口类名详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<ApiClass> ServerResult = apiClassService.selectApiclassById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口类名
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:add')")
|
|
||||||
@Log(title = "接口类名", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody ApiClass apiclass) {
|
|
||||||
if (apiclass.getmId() == null || apiclass.getmId() < 0) {
|
|
||||||
return AjaxResult.error("模块id不能为空!");
|
|
||||||
}
|
|
||||||
if (apiclass.getcName() == null || apiclass.getcName().equals("")) {
|
|
||||||
return AjaxResult.error("类名不能为空!");
|
|
||||||
}
|
|
||||||
if (apiclass.getcDescribe() == null || apiclass.getcDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("类描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = apiClassService.insertApiclass(apiclass);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口类名
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:edit')")
|
|
||||||
@Log(title = "接口类名", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody ApiClass apiclass) {
|
|
||||||
if (apiclass.getmId() == null || apiclass.getmId() < 0) {
|
|
||||||
return AjaxResult.error("模块id不能为空!");
|
|
||||||
}
|
|
||||||
if (apiclass.getcName() == null || apiclass.getcName().equals("")) {
|
|
||||||
return AjaxResult.error("类名不能为空!");
|
|
||||||
}
|
|
||||||
if (apiclass.getcDescribe() == null || apiclass.getcDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("类描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = apiClassService.updateApiclass(apiclass);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口类名
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:apiclass:remove')")
|
|
||||||
@Log(title = "接口类名", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
||||||
if (ids.length < 0) {
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = apiClassService.deleteApiclassByIds(ids);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,226 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.core.page.TableDataInfo;
|
|
||||||
import com.ebts.common.core.text.Convert;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
import com.ebts.generator.service.GenTableColumnService;
|
|
||||||
import com.ebts.generator.service.GenTableService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成 操作处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/gen")
|
|
||||||
public class GenController extends BaseController {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(GenController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GenTableService genTableService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GenTableColumnService genTableColumnService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询代码生成列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable genList(GenTable genTable) {
|
|
||||||
startPage();
|
|
||||||
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改代码生成业务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:query')")
|
|
||||||
@GetMapping(value = "/{talbleId}")
|
|
||||||
public AjaxResult getInfo(@PathVariable Long talbleId) {
|
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
map.put("info", table);
|
|
||||||
map.put("rows", list);
|
|
||||||
map.put("tables", tables);
|
|
||||||
return AjaxResult.success(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询数据库列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
|
|
||||||
@GetMapping("/db/list")
|
|
||||||
public Serializable dataList(GenTable genTable) {
|
|
||||||
startPage();
|
|
||||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询数据表字段列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
|
|
||||||
@GetMapping(value = "/column/{talbleId}")
|
|
||||||
public Serializable columnList(Long tableId) {
|
|
||||||
TableDataInfo dataInfo = new TableDataInfo();
|
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
|
||||||
dataInfo.setRows(list);
|
|
||||||
dataInfo.setTotal(list.size());
|
|
||||||
return dataInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入表结构(保存)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
|
||||||
@PostMapping("/importTable")
|
|
||||||
public AjaxResult importTableSave(String tables) {
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
|
||||||
// 查询表信息
|
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
|
||||||
genTableService.importGenTable(tableList);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo
|
|
||||||
* 修改保存代码生成业务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:edit')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult editSave(@Validated @RequestBody GenTable genTable) {
|
|
||||||
genTableService.validateEdit(genTable);
|
|
||||||
genTableService.updateGenTable(genTable);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除代码生成
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:remove')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{tableIds}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
|
||||||
try {
|
|
||||||
ServerResult<Integer> ServerResult = genTableService.deleteGenTableByIds(tableIds);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:preview')")
|
|
||||||
@GetMapping("/preview/{tableId}")
|
|
||||||
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
|
|
||||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
|
||||||
return AjaxResult.success(dataMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(下载方式)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:code')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/download/{tableName}")
|
|
||||||
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
|
|
||||||
byte[] data = genTableService.downloadCode(tableName);
|
|
||||||
genCode(response, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(自定义路径)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:code')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/genCode/{tableName}")
|
|
||||||
public AjaxResult genCode(@PathVariable("tableName") String tableName) {
|
|
||||||
boolean start = genTableService.generatorCode(tableName);
|
|
||||||
if (start) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error("模板渲染失败!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同步数据库
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:edit')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
|
||||||
@GetMapping("/synchDb/{tableName}")
|
|
||||||
public AjaxResult synchDb(@PathVariable("tableName") String tableName) {
|
|
||||||
genTableService.synchDb(tableName);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量生成代码
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:gen:code')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/batchGenCode")
|
|
||||||
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
|
||||||
byte[] data = genTableService.downloadCode(tableNames);
|
|
||||||
genCode(response, data);
|
|
||||||
// if (compress(data)){
|
|
||||||
// return AjaxResult.success("ebts.zip");
|
|
||||||
// }else {
|
|
||||||
// return AjaxResult.error();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成zip文件
|
|
||||||
*/
|
|
||||||
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
|
|
||||||
response.reset();
|
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"ebts.zip\"");
|
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
|
||||||
IOUtils.write(data, response.getOutputStream());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,254 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dto.InterTableDto;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
import com.ebts.generator.service.InterTableService;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口信息Controller
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-25
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/generator/intertable")
|
|
||||||
public class InterTableController extends BaseController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(InterTableController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private InterTableService interTableService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口信息列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable list(InterTable interTable) {
|
|
||||||
ServerResult<Map<String, Object>> ServerResult = interTableService.selectInterTableList(interTable);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码(工作流)
|
|
||||||
*/
|
|
||||||
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:classpreview')")
|
|
||||||
@Log(title = "预览代码(工作流)", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/classpreview/{id}")
|
|
||||||
public AjaxResult classPreview(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<Map<String, String>> ServerResult = interTableService.previewCodeCalss(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码(工作台)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:modulepreview')")
|
|
||||||
@Log(title = "预览代码(工作台)", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/modulepreview/{id}")
|
|
||||||
public AjaxResult modulePreview(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<Map<String, Object>> ServerResult = interTableService.previewCodeMoudle(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(工作流)
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:classgen')")
|
|
||||||
@Log(title = "生成代码(工作流)", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/classgen/{id}")
|
|
||||||
public AjaxResult classGenerator(@PathVariable("id") Long id, HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
ServerResult<byte[]> ServerResult = interTableService.generatorCodeClass(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
genCode(response, ServerResult.getData());
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return AjaxResult.error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(工作台)
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param response
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:moudlegen')")
|
|
||||||
@Log(title = "生成代码(工作台)", businessType = BusinessType.GENCODE)
|
|
||||||
@GetMapping("/moudlegen/{id}")
|
|
||||||
public AjaxResult moudleGenerator(@PathVariable("id") Long id, HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
ServerResult<byte[]> ServerResult = interTableService.generatorCodeMoudle(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
genCode(response, ServerResult.getData());
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
} catch (RuntimeException | IOException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('generator:intertable:edit')")
|
|
||||||
@Log(title = "接口信息", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody InterTableDto interTableDto) {
|
|
||||||
ServerResult<Integer> ServerResult = interTableService.updateInterTable(interTableDto);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成zip文件
|
|
||||||
*/
|
|
||||||
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
|
|
||||||
response.reset();
|
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"ebts.zip\"");
|
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
|
||||||
IOUtils.write(data, response.getOutputStream());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 导出接口信息列表
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ebts.hasPermi('generator:intertable:export')")
|
|
||||||
// @Log(title = "接口信息", businessType = BusinessType.EXPORT)
|
|
||||||
// @GetMapping("/export")
|
|
||||||
// public GenResult export(InterTable interTable) {
|
|
||||||
// try {
|
|
||||||
// ServerResult<List<InterTable>> serverResult = interTableService.selectInterTableList(interTable);
|
|
||||||
// GenExcelUtil<InterTable> util = new GenExcelUtil<InterTable>(InterTable. class);
|
|
||||||
// if (serverResult.isStart()) {
|
|
||||||
// return util.exportExcel(serverResult.getData(), "intertable");
|
|
||||||
// } else {
|
|
||||||
// return GenResult.error(serverResult.getMsg());
|
|
||||||
// }
|
|
||||||
// } catch (RuntimeException e) {
|
|
||||||
// logger.error(e.getMessage());
|
|
||||||
// return GenResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 获取接口信息详细信息
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ebts.hasPermi('generator:intertable:query')")
|
|
||||||
// @GetMapping(value = "/{id}")
|
|
||||||
// public GenResult Info(@PathVariable("id") Long id) {
|
|
||||||
// try {
|
|
||||||
// ServerResult<InterTable> serverResult = interTableService.selectInterTableById(id);
|
|
||||||
// if (serverResult.isStart()) {
|
|
||||||
// return GenResult.success(serverResult.getData());
|
|
||||||
// } else {
|
|
||||||
// return GenResult.info(serverResult.getMsg());
|
|
||||||
// }
|
|
||||||
// } catch (RuntimeException e) {
|
|
||||||
// logger.error(e.getMessage());
|
|
||||||
// return GenResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 新增接口信息
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ebts.hasPermi('generator:intertable:add')")
|
|
||||||
// @Log(title = "接口信息", businessType = BusinessType.INSERT)
|
|
||||||
// @PostMapping
|
|
||||||
// public GenResult add(@RequestBody InterTable interTable) {
|
|
||||||
// try {
|
|
||||||
// ServerResult<Integer> serverResult = interTableService.insertInterTable(interTable);
|
|
||||||
// if (serverResult.isStart()) {
|
|
||||||
// return GenResult.success();
|
|
||||||
// } else {
|
|
||||||
// return GenResult.error(serverResult.getMsg());
|
|
||||||
// }
|
|
||||||
// } catch (RuntimeException e) {
|
|
||||||
// logger.error(e.getMessage());
|
|
||||||
// return GenResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 删除接口信息
|
|
||||||
// */
|
|
||||||
// @PreAuthorize("@ebts.hasPermi('generator:intertable:remove')")
|
|
||||||
// @Log(title = "接口信息", businessType = BusinessType.DELETE)
|
|
||||||
// @DeleteMapping("/{ids}")
|
|
||||||
// public GenResult remove(@PathVariable Long[] ids) {
|
|
||||||
// try {
|
|
||||||
// if (ids.length<0){
|
|
||||||
// return GenResult.error("id不能为空!");
|
|
||||||
// }
|
|
||||||
// ServerResult<Integer> serverResult = interTableService.deleteInterTableByIds(ids);
|
|
||||||
// if (serverResult.isStart()) {
|
|
||||||
// return GenResult.success();
|
|
||||||
// } else {
|
|
||||||
// return GenResult.error(serverResult.getMsg());
|
|
||||||
// }
|
|
||||||
// }catch (RuntimeException e){
|
|
||||||
// logger.error(e.getMessage());
|
|
||||||
// return GenResult.error(ReturnConstants.SYS_ERROR);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
import com.ebts.generator.service.ModuleService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块管理Controller
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/module")
|
|
||||||
public class ModuleController extends BaseController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(ModuleController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ModuleService moduleService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到api类的select选项
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('tool:module:querylist')")
|
|
||||||
@GetMapping("querylist")
|
|
||||||
public AjaxResult queryList() {
|
|
||||||
ServerResult<List<Module>> ServerResult = moduleService.selectModuleList(new Module());
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询模块管理列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable list(Module module) {
|
|
||||||
startPage();
|
|
||||||
ServerResult<List<Module>> ServerResult = moduleService.selectModuleList(module);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出模块管理列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:export')")
|
|
||||||
@Log(title = "模块管理", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(Module module) {
|
|
||||||
ServerResult<List<Module>> ServerResult = moduleService.selectModuleList(module);
|
|
||||||
ExcelUtil<Module> util = new ExcelUtil<Module>(Module.class);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return util.exportExcel(ServerResult.getData(), "module");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取模块管理详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<Module> ServerResult = moduleService.selectModuleById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增模块管理
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:add')")
|
|
||||||
@Log(title = "模块管理", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody Module module) {
|
|
||||||
if (module.getmName() == null || module.getmName().equals("")) {
|
|
||||||
return AjaxResult.error("模块名称不能为空!");
|
|
||||||
}
|
|
||||||
if (module.getmDescribe() == null || module.getmDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("模块描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = moduleService.insertModule(module);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改模块管理
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:edit')")
|
|
||||||
@Log(title = "模块管理", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody Module module) {
|
|
||||||
if (module.getmName() == null || module.getmName().equals("")) {
|
|
||||||
return AjaxResult.error("模块名称不能为空!");
|
|
||||||
}
|
|
||||||
if (module.getmDescribe() == null || module.getmDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("模块描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = moduleService.updateModule(module);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除模块管理
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:module:remove')")
|
|
||||||
@Log(title = "模块管理", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
||||||
if (ids.length < 0) {
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = moduleService.deleteModuleByIds(ids);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.utils.MapExcelUtil;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.utils.sql.GenSqlUtil;
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import com.ebts.generator.entity.UniCon;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
import com.ebts.generator.service.QueryService;
|
|
||||||
import com.ebts.generator.utils.*;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author 18209
|
|
||||||
* Date 2021/1/30 18:25
|
|
||||||
* Version 1.0
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/query")
|
|
||||||
public class QueryController extends BaseController {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(QueryController.class);
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private QueryService queryService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo 获取编辑sql的基本信息
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('query:list')")
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public AjaxResult Info(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<UniQuery> ServerResult = queryService.selectQueryById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
UniQuery uniQuery = ServerResult.getData();
|
|
||||||
Map<String, Object> modeMap = new HashMap<>();
|
|
||||||
List<UniCon> uniCons = uniQuery.getUniCons();
|
|
||||||
uniQuery.setUniCons(null);
|
|
||||||
modeMap.put("info", uniQuery);
|
|
||||||
modeMap.put("list", uniCons);
|
|
||||||
return AjaxResult.success(modeMap);
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新万能查询编辑信息 info 和查询信息
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('query:edit')")
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody UniQuery uniQuery) {
|
|
||||||
ServerResult ServerResult = queryService.updateQueryInfo(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出预览数据
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('query:export')")
|
|
||||||
@PutMapping("export")
|
|
||||||
public AjaxResult export(@Validated @RequestBody UniQuery uniQuery) {
|
|
||||||
ServerResult<List<Map<String, Object>>> ServerResult = queryService.previewQuery(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return new MapExcelUtil().exportExcel(ServerResult.getData(), uniQuery.getUqName());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回预览信息
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('query:preview')")
|
|
||||||
@PutMapping("preview")
|
|
||||||
public Serializable Preview(@Validated @RequestBody UniQuery uniQuery) {
|
|
||||||
startPage(uniQuery);
|
|
||||||
ServerResult<List<Map<String, Object>>> ServerResult = queryService.previewQuery(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发布上线
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('query:release')")
|
|
||||||
@PutMapping("/release")
|
|
||||||
public AjaxResult Release(@RequestBody UniQuery uniQuery) {
|
|
||||||
if (uniQuery.getId() == null) {
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
} else {
|
|
||||||
if (uniQuery.getIsRelease() == 1 || uniQuery.getIsRelease() == 2) {
|
|
||||||
ServerResult<Integer> ServerResult = queryService.Release(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error("状态输入错误!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置请求分页数据
|
|
||||||
*/
|
|
||||||
protected void startPage(UniQuery uniQuery) {
|
|
||||||
Integer pageNum = uniQuery.getPageNum();
|
|
||||||
Integer pageSize = uniQuery.getPageSize();
|
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
|
||||||
String orderBy = GenSqlUtil.escapeOrderBySql("");
|
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ebts.generator.entity.Regular;
|
|
||||||
import com.ebts.generator.service.RegularService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验规则Controller
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-18
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/regular")
|
|
||||||
public class RegularController extends BaseController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(RegularController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RegularService regularService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则列表
|
|
||||||
*
|
|
||||||
* @param regular
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable list(Regular regular) {
|
|
||||||
startPage();
|
|
||||||
ServerResult<List<Regular>> ServerResult = regularService.selectRegularList(regular);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:option')")
|
|
||||||
@GetMapping("/option")
|
|
||||||
public Serializable option() {
|
|
||||||
startPage();
|
|
||||||
ServerResult<List<Regular>> ServerResult = regularService.selectRegularOption();
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出校验规则列表
|
|
||||||
*
|
|
||||||
* @param regular
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:export')")
|
|
||||||
@Log(title = "校验规则", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(Regular regular) {
|
|
||||||
ServerResult<List<Regular>> ServerResult = regularService.selectRegularList(regular);
|
|
||||||
ExcelUtil<Regular> util = new ExcelUtil<Regular>(Regular.class);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return util.exportExcel(ServerResult.getData(), "regular");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取校验规则详细信息
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<Regular> ServerResult = regularService.selectRegularById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增校验规则
|
|
||||||
*
|
|
||||||
* @param regular
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:add')")
|
|
||||||
@Log(title = "校验规则", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody Regular regular) {
|
|
||||||
if (regular.getName() == null || regular.getName().equals("")) {
|
|
||||||
return AjaxResult.error("正则名称不能为空!");
|
|
||||||
}
|
|
||||||
if (regular.getRegular() == null || regular.getRegular().equals("")) {
|
|
||||||
return AjaxResult.error("正则内容不能为空!");
|
|
||||||
}
|
|
||||||
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
|
||||||
return AjaxResult.error("是否启用不能为空!");
|
|
||||||
}
|
|
||||||
if (!verifyRegular(regular)) {
|
|
||||||
return AjaxResult.error("正则表达式校验不通过!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = regularService.insertRegular(regular);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改校验规则
|
|
||||||
*
|
|
||||||
* @param regular
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:edit')")
|
|
||||||
@Log(title = "校验规则", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody Regular regular) {
|
|
||||||
if (regular.getName() == null || regular.getName().equals("")) {
|
|
||||||
return AjaxResult.error("正则名称不能为空!");
|
|
||||||
}
|
|
||||||
if (regular.getRegular() == null || regular.getRegular().equals("")) {
|
|
||||||
return AjaxResult.error("正则内容不能为空!");
|
|
||||||
}
|
|
||||||
if (regular.getEnable() == null || regular.getEnable() < 0) {
|
|
||||||
return AjaxResult.error("是否启用不能为空!");
|
|
||||||
}
|
|
||||||
if (!verifyRegular(regular)) {
|
|
||||||
return AjaxResult.error("正则表达式校验不通过!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = regularService.updateRegular(regular);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除校验规则
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:regular:remove')")
|
|
||||||
@Log(title = "校验规则", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
||||||
if (ids.length == 0) {
|
|
||||||
return AjaxResult.error("需要删除id数不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = regularService.deleteRegularByIds(ids);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean verifyRegular(Regular regular) {
|
|
||||||
return Pattern.matches(regular.getRegular(), regular.getValidation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.RelColumn;
|
|
||||||
import com.ebts.generator.entity.RelTable;
|
|
||||||
import com.ebts.generator.service.RelService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/24 16:22
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/rel")
|
|
||||||
public class RelController {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(RelController.class);
|
|
||||||
@Autowired
|
|
||||||
private RelService relService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取表的基础信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('rel:tableinfo')")
|
|
||||||
@GetMapping("/tableinfo")
|
|
||||||
public AjaxResult tableinfos() {
|
|
||||||
ServerResult<List<Map<String, Object>>> ServerResult = relService.tableInfos();
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取表的字段信息
|
|
||||||
*
|
|
||||||
* @param tableName
|
|
||||||
* @param relId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('rel:tableinfo')")
|
|
||||||
@GetMapping("/{tableName}/{relId}")
|
|
||||||
public AjaxResult relColumns(@PathVariable("tableName") String tableName, @PathVariable("relId") Long relId) {
|
|
||||||
ServerResult<List<RelColumn>> ServerResult = relService.relColumns(tableName, relId);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('rel:colums')")
|
|
||||||
@GetMapping("/{tableName}")
|
|
||||||
public AjaxResult tableColumns(@PathVariable("tableName") String tableName) {
|
|
||||||
ServerResult<List<Map<String, Object>>> ServerResult = relService.tableColumns(tableName);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ebts.hasAnyPermi('rel:colums')")
|
|
||||||
@GetMapping("/colums/{tableId}")
|
|
||||||
public AjaxResult relTableByTableId(@PathVariable("tableId") Long tableId) {
|
|
||||||
ServerResult<List<RelTable>> ServerResult = relService.relTableByTableId(tableId);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.dto.TopResult;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
import com.ebts.generator.service.TopQueryService;
|
|
||||||
import com.ebts.generator.service.UniQueryService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/23 21:36
|
|
||||||
* @description:TopQueryController
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/top")
|
|
||||||
public class TopQueryController extends BaseController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UniQueryService uniQueryService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TopQueryService topQueryService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取基本信息
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('top:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<UniQuery> ServerResult = uniQueryService.selectUniQueryById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/online/{id}")
|
|
||||||
public AjaxResult online(@PathVariable("id") Long id){
|
|
||||||
// ServerResult ServerResult = queryService.updateQueryInfo(uniQuery);
|
|
||||||
// if (ServerResult.isStart()) {
|
|
||||||
// return AjaxResult.success(ServerResult.getData());
|
|
||||||
// } else {
|
|
||||||
// return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
// }
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取基本信息
|
|
||||||
*
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('top:table')")
|
|
||||||
@GetMapping("/table")
|
|
||||||
public AjaxResult table() {
|
|
||||||
return AjaxResult.success(topQueryService.selectTopSearchTables());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简单修改top万能能查询
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('top:edit')")
|
|
||||||
@Log(title = "top万能查询", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody UniQuery uniQuery) {
|
|
||||||
if (uniQuery.getId()<0){
|
|
||||||
return AjaxResult.error("缺少关键字段");
|
|
||||||
}
|
|
||||||
if (StringUtils.isNull(uniQuery.getTopJson())){
|
|
||||||
return AjaxResult.error("缺少关键字段");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = uniQueryService.updateUniQuery(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 简单修改top万能能查询
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('top:preview')")
|
|
||||||
@Log(title = "top预览", businessType = BusinessType.OTHER)
|
|
||||||
@PostMapping("/preview")
|
|
||||||
public Serializable preview(@RequestBody Map<String,String> params){
|
|
||||||
if (StringUtils.isNull(params.get("jsonData"))){
|
|
||||||
return AjaxResult.error("缺少必要参数!");
|
|
||||||
}
|
|
||||||
ServerResult<TopResult> serverResult = topQueryService.preview(params.get("jsonData"),params.get("id"));
|
|
||||||
if (serverResult.isStart()){
|
|
||||||
return getDataTable(serverResult.getData().getDataMap(),serverResult.getData().getUniCons());
|
|
||||||
}else {
|
|
||||||
return AjaxResult.error(serverResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.core.controller.EBTSController;
|
|
||||||
import com.ebts.common.core.text.Convert;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.generator.entity.TopSearchTable;
|
|
||||||
import com.ebts.generator.service.TopSearchTableService;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询主Controller
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/table")
|
|
||||||
public class TopSearchTableController extends EBTSController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(TopSearchTableController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TopSearchTableService topSearchTableService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:list')")
|
|
||||||
@PostMapping("/list")
|
|
||||||
public Serializable list(@Validated @RequestBody TopSearchTable topSearchTable) {
|
|
||||||
startPage(topSearchTable.getPageInfo());
|
|
||||||
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return getDataTable(genServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:cloumns')")
|
|
||||||
@GetMapping("/columns/{id}")
|
|
||||||
public AjaxResult columns(@PathVariable("id") Long id){
|
|
||||||
return AjaxResult.success(topSearchTableService.selectTableColumns(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:info')")
|
|
||||||
@PostMapping("/info")
|
|
||||||
public Serializable info() {
|
|
||||||
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableInfo();
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return getDataTable(genServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出top万能查询主列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:export')")
|
|
||||||
@Log(title = "top万能查询主", businessType = BusinessType.EXPORT)
|
|
||||||
@PostMapping("/export")
|
|
||||||
public AjaxResult export(@Validated @RequestBody TopSearchTable topSearchTable) {
|
|
||||||
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
|
|
||||||
ExcelUtil<TopSearchTable> util = new ExcelUtil<TopSearchTable>(TopSearchTable. class);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return util.exportExcel(genServerResult.getData(), "table");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取top万能查询主详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<TopSearchTable> genServerResult = topSearchTableService.selectTopSearchTableById(id);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(genServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询主
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:add')")
|
|
||||||
@Log(title = "top万能查询主", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@Validated @RequestBody TopSearchTable topSearchTable) {
|
|
||||||
ServerResult<Integer> genServerResult = topSearchTableService.insertTopSearchTable(topSearchTable);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改top万能查询主
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:edit')")
|
|
||||||
@Log(title = "top万能查询主", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody TopSearchTable topSearchTable) {
|
|
||||||
if (topSearchTable.getRoleIds().length==0){
|
|
||||||
return AjaxResult.error("角色不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询主
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:remove')")
|
|
||||||
@Log(title = "top万能查询主", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
||||||
if (ids.length<0){
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> genServerResult = topSearchTableService.deleteTopSearchTableByIds(ids);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 导入表结构(保存)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:import')")
|
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
|
||||||
@PostMapping("/importTopTable")
|
|
||||||
public AjaxResult importTableSave(String tables) {
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
|
||||||
// 查询表信息
|
|
||||||
List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames);
|
|
||||||
topSearchTableService.importGenTable(tableList);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入表结构(获取)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:table:db:list')")
|
|
||||||
@PostMapping("/db/list")
|
|
||||||
public Serializable dbList(@RequestBody Map<String,Object> params){
|
|
||||||
startPage(params);
|
|
||||||
List<Map<String,Object>> list = topSearchTableService.selectDbTableList(params);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
||||||
package com.ebts.generator.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
import com.ebts.generator.service.UniQueryService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询Controller
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/tool/query")
|
|
||||||
public class UniQueryController extends BaseController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(UniQueryController.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UniQueryService uniQueryService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Serializable list(UniQuery uniQuery) {
|
|
||||||
startPage();
|
|
||||||
ServerResult<List<UniQuery>> ServerResult = uniQueryService.selectUniQueryList(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return getDataTable(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出万能查询列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:export')")
|
|
||||||
@Log(title = "万能查询", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(UniQuery uniQuery) {
|
|
||||||
ServerResult<List<UniQuery>> ServerResult = uniQueryService.selectUniQueryList(uniQuery);
|
|
||||||
ExcelUtil<UniQuery> util = new ExcelUtil<UniQuery>(UniQuery.class);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return util.exportExcel(ServerResult.getData(), "query");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取万能查询详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:query')")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
||||||
ServerResult<UniQuery> ServerResult = uniQueryService.selectUniQueryById(id);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(ServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增万能查询
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:add')")
|
|
||||||
@Log(title = "万能查询", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody UniQuery uniQuery) {
|
|
||||||
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
|
|
||||||
return AjaxResult.error("名称不能为空!");
|
|
||||||
}
|
|
||||||
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = uniQueryService.insertUniQuery(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简单修改万能能查询
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:edit')")
|
|
||||||
@Log(title = "万能查询", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody UniQuery uniQuery) {
|
|
||||||
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
|
|
||||||
return AjaxResult.error("名称不能为空!");
|
|
||||||
}
|
|
||||||
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
|
|
||||||
return AjaxResult.error("描述不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = uniQueryService.updateUniQuery(uniQuery);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除万能查询
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ebts.hasPermi('tool:query:remove')")
|
|
||||||
@Log(title = "万能查询", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
||||||
if (ids.length < 0) {
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> ServerResult = uniQueryService.deleteUniQueryByIds(ids);
|
|
||||||
if (ServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(ServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口类名Mapper接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public interface ApiClassDao {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 接口类名
|
|
||||||
*/
|
|
||||||
ApiClass selectApiclassById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名列表
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 接口类名集合
|
|
||||||
*/
|
|
||||||
List<ApiClass> selectApiclassList(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertApiclass(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateApiclass(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口类名
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteApiclassById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口类名
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteApiclassByIds(Long[] ids);
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务字段 数据层
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public interface GenTableColumnDao {
|
|
||||||
/**
|
|
||||||
* 根据表名称查询列信息
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 列信息
|
|
||||||
*/
|
|
||||||
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务字段列表
|
|
||||||
*
|
|
||||||
* @param tableId 业务字段编号
|
|
||||||
* @return 业务字段集合
|
|
||||||
*/
|
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumns 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateGenTableColumn(List<GenTableColumn> genTableColumns);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumns 列数据
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除业务字段
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteGenTableColumnByIds(Long[] ids);
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务 数据层
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public interface GenTableDao {
|
|
||||||
/**
|
|
||||||
* 查询业务列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 业务集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param tableNames 表名称组
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表信息
|
|
||||||
*
|
|
||||||
* @return 表信息集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询表ID业务信息
|
|
||||||
*
|
|
||||||
* @param id 业务ID
|
|
||||||
* @return 业务信息
|
|
||||||
*/
|
|
||||||
public GenTable selectGenTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询表名称业务信息
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 业务信息
|
|
||||||
*/
|
|
||||||
public GenTable selectGenTableByName(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertGenTable(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateGenTable(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除业务
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteGenTableByIds(Long[] ids);
|
|
||||||
|
|
||||||
int insertMenu(@Param("paramSQL") String sql);
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口信息Mapper接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-25
|
|
||||||
*/
|
|
||||||
public interface InterTableDao {
|
|
||||||
/**
|
|
||||||
* 查询接口信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 接口信息
|
|
||||||
*/
|
|
||||||
InterTable selectInterTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口信息列表
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 接口信息集合
|
|
||||||
*/
|
|
||||||
List<InterTable> selectInterTableList(InterTable interTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口信息
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertInterTable(InterTable interTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增接口信息
|
|
||||||
*
|
|
||||||
* @param interTables
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int insertInterTables(List<InterTable> interTables);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过类id删除接口
|
|
||||||
*
|
|
||||||
* @param cId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int deleteInterTableByClassId(Long cId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过模块id删除接口
|
|
||||||
*
|
|
||||||
* @param mId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int deleteInterTableByModuleId(Long mId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口信息
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateInterTable(InterTable interTable);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteInterTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口信息
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteInterTableByIds(Long[] ids);
|
|
||||||
|
|
||||||
ApiClass selectInterTableClass(Long id);
|
|
||||||
|
|
||||||
List<InterTable> selectInterTableModule(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块管理Mapper接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public interface ModuleDao {
|
|
||||||
/**
|
|
||||||
* 查询模块管理
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 模块管理
|
|
||||||
*/
|
|
||||||
Module selectModuleById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询模块管理列表
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 模块管理集合
|
|
||||||
*/
|
|
||||||
List<Module> selectModuleList(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertModule(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateModule(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除模块管理
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteModuleById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除模块管理
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteModuleByIds(Long[] ids);
|
|
||||||
}
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.entity.Menu;
|
|
||||||
import com.ebts.generator.entity.UniCon;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/1/30 18:52
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
public interface QueryDao {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过id获取到万能查询的基本信息
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
UniQuery selectQueryInfo(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除万能查询
|
|
||||||
* @param uqId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteUniCon(Long uqId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增万能查询
|
|
||||||
* @param uniCons
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertUniCon(List<UniCon> uniCons);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取查询信息
|
|
||||||
* @param paramSQL
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> UniQuery(String paramSQL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询是否发布
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer Release(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 改变发布状态
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer changeRelease(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 插入到菜单
|
|
||||||
* @param menu
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertMenu(Menu menu);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除菜单
|
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteMenu(String path);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.Regular;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验规则Dao接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-18
|
|
||||||
*/
|
|
||||||
public interface RegularDao {
|
|
||||||
/**
|
|
||||||
* 查询校验规则
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 校验规则
|
|
||||||
*/
|
|
||||||
Regular selectRegularById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则列表
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 校验规则集合
|
|
||||||
*/
|
|
||||||
List<Regular> selectRegularList(Regular regular);
|
|
||||||
/**
|
|
||||||
* 查询校验规则下拉框列表
|
|
||||||
*
|
|
||||||
* @return 校验规则集合
|
|
||||||
*/
|
|
||||||
List<Regular> selectRegularOption();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertRegular(Regular regular);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateRegular(Regular regular);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除校验规则
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteRegularById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除校验规则
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteRegularByIds(Long[] ids);
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.RelColumn;
|
|
||||||
import com.ebts.generator.entity.RelTable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/24 16:21
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
public interface RelDao {
|
|
||||||
/**
|
|
||||||
* 获取表信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Map<String,Object>> tableInfos();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取表字段信息
|
|
||||||
*
|
|
||||||
* @param tableName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<RelColumn> selectTableColumn(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量增加字段信息
|
|
||||||
*
|
|
||||||
* @param relColumns
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertRelColumns(List<RelColumn> relColumns);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量增加子表字段
|
|
||||||
* @param relTables
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertRelTables(List<RelTable> relTables);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过tableName获取到column信息
|
|
||||||
*
|
|
||||||
* @param tableName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Map<String,Object>> tableColumns(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过主表id查询子表信息
|
|
||||||
* @param tableId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<RelTable> relTableByTableId(Long tableId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过relId删除RelColumn信息
|
|
||||||
* @param relId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteRelColumnByRelId(Long relId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过tableid删除RelTable信息
|
|
||||||
* @param tableId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteRelTableByTableId(Long tableId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ebts.generator.entity.RelationalMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询关系映射Mapper接口
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-21
|
|
||||||
*/
|
|
||||||
public interface RelationalMapDao {
|
|
||||||
/**
|
|
||||||
* 查询top万能查询关系映射
|
|
||||||
*
|
|
||||||
* @param mainId top万能查询关系映射ID
|
|
||||||
* @return top万能查询关系映射
|
|
||||||
*/
|
|
||||||
RelationalMap selectRelationalMapById(Long mainId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询关系映射列表
|
|
||||||
*
|
|
||||||
* @param relationalMap top万能查询关系映射
|
|
||||||
* @return top万能查询关系映射集合
|
|
||||||
*/
|
|
||||||
List<RelationalMap> selectRelationalMapList(RelationalMap relationalMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询关系映射
|
|
||||||
*
|
|
||||||
* @param relationalMap top万能查询关系映射
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertRelationalMap(RelationalMap relationalMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改top万能查询关系映射
|
|
||||||
*
|
|
||||||
* @param relationalMap top万能查询关系映射
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateRelationalMap(RelationalMap relationalMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询关系映射
|
|
||||||
*
|
|
||||||
* @param mainId top万能查询关系映射ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteRelationalMapById(Long mainId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除top万能查询关系映射
|
|
||||||
*
|
|
||||||
* @param mainIds 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteRelationalMapByIds(Long[] mainIds);
|
|
||||||
int batchRelationalMap(List<RelationalMap> relationalMaps);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ebts.generator.entity.SearchTableRole;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询角色关系Mapper接口
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-21
|
|
||||||
*/
|
|
||||||
public interface SearchTableRoleDao {
|
|
||||||
/**
|
|
||||||
* 查询top万能查询角色关系列表
|
|
||||||
*
|
|
||||||
* @param searchTableRole top万能查询角色关系
|
|
||||||
* @return top万能查询角色关系集合
|
|
||||||
*/
|
|
||||||
List<SearchTableRole> selectSearchTableRoleList(SearchTableRole searchTableRole);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询角色关系
|
|
||||||
*
|
|
||||||
* @param searchTableId top万能查询角色关系ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteSearchTableRoleById(Long searchTableId);
|
|
||||||
int deleteSearchTableRoleByIds(Long[] searchTableIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加top万能查询角色关系
|
|
||||||
*
|
|
||||||
* @param roleList
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int batchSearchTableRole(List<SearchTableRole> roleList);
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import com.ebts.generator.entity.TopSearchTable;
|
|
||||||
import com.ebts.generator.entity.TopSearchColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询主Mapper接口
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
public interface TopSearchTableDao {
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return top万能查询主
|
|
||||||
*/
|
|
||||||
TopSearchTable selectTopSearchTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主列表
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return top万能查询主集合
|
|
||||||
*/
|
|
||||||
List<TopSearchTable> selectTopSearchTableList(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取top万能查询基础表格信息
|
|
||||||
* @param roleIds
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<TopSearchTable> selectTopSearchTables(String[] roleIds);
|
|
||||||
|
|
||||||
|
|
||||||
List<TopSearchColumn> selectTableColumns(Long id);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<TopSearchTable> selectTopSearchTableInfo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param tableNames 表名称组
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据库表信息
|
|
||||||
*
|
|
||||||
* @param params 表名称组
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
|
|
||||||
/**
|
|
||||||
* 根据表名查询列
|
|
||||||
* @param tableName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<TopSearchColumn> selectDbTableColumnsByName(String tableName);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertTopSearchTable(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateTopSearchTable(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询主
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteTopSearchTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除top万能查询主
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteTopSearchTableByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除top万能查询字段
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteTopSearchColumnBySearchTableIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增top万能查询字段
|
|
||||||
*
|
|
||||||
* @param topSearchColumnList top万能查询字段列表
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int batchTopSearchColumn(List<TopSearchColumn> topSearchColumnList);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过top万能查询主ID删除top万能查询字段信息
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteTopSearchColumnBySearchTableId(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
package com.ebts.generator.dao;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询Mapper接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
public interface UniQueryDao {
|
|
||||||
/**
|
|
||||||
* 查询万能查询
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 万能查询
|
|
||||||
*/
|
|
||||||
UniQuery selectUniQueryById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询列表
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 万能查询集合
|
|
||||||
*/
|
|
||||||
List<UniQuery> selectUniQueryList(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertUniQuery(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateUniQuery(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除万能查询
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteUniQueryById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除万能查询
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteUniQueryByIds(Long[] ids);
|
|
||||||
|
|
||||||
int deleteUniQueryByUqId(Long id);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package com.ebts.generator.dto;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class InterTableDto {
|
|
||||||
|
|
||||||
private ApiClass apiclass;
|
|
||||||
|
|
||||||
private Module module;
|
|
||||||
|
|
||||||
private List<InterTable> interTables;
|
|
||||||
|
|
||||||
public Module getModule() {
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModule(Module module) {
|
|
||||||
this.module = module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiClass getApiclass() {
|
|
||||||
return apiclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiclass(ApiClass apiclass) {
|
|
||||||
this.apiclass = apiclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InterTable> getInterTables() {
|
|
||||||
return interTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterTables(List<InterTable> interTables) {
|
|
||||||
this.interTables = interTables;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
package com.ebts.generator.dto;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.UniCon;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/27 19:26
|
|
||||||
* @description:TopResult
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
public class TopResult {
|
|
||||||
private List<Map<String, Object>> dataMap;
|
|
||||||
private List<UniCon> uniCons;
|
|
||||||
|
|
||||||
|
|
||||||
public TopResult(List<Map<String, Object>> dataMap, List<UniCon> uniCons) {
|
|
||||||
this.dataMap = dataMap;
|
|
||||||
this.uniCons = uniCons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<String, Object>> getDataMap() {
|
|
||||||
return dataMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataMap(List<Map<String, Object>> dataMap) {
|
|
||||||
this.dataMap = dataMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UniCon> getUniCons() {
|
|
||||||
return uniCons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUniCons(List<UniCon> uniCons) {
|
|
||||||
this.uniCons = uniCons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口类名对象 sys_apiclass
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public class ApiClass extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块id
|
|
||||||
*/
|
|
||||||
@Excel(name = "模块id")
|
|
||||||
private Long mId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类名
|
|
||||||
*/
|
|
||||||
@Excel(name = "类名")
|
|
||||||
private String cName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类描述
|
|
||||||
*/
|
|
||||||
@Excel(name = "类描述")
|
|
||||||
private String cDescribe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 包名
|
|
||||||
*/
|
|
||||||
@Excel(name = "包名")
|
|
||||||
private String packageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前缀
|
|
||||||
*/
|
|
||||||
@Excel(name = "前缀")
|
|
||||||
private String prefix;
|
|
||||||
/**
|
|
||||||
* 作者
|
|
||||||
*/
|
|
||||||
@Excel(name = "作者")
|
|
||||||
private String author;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电子邮件
|
|
||||||
*/
|
|
||||||
@Excel(name = "电子邮件")
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块类
|
|
||||||
*/
|
|
||||||
private Module module;
|
|
||||||
|
|
||||||
private List<InterTable> interTables;
|
|
||||||
|
|
||||||
public List<InterTable> getInterTables() {
|
|
||||||
return interTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterTables(List<InterTable> interTables) {
|
|
||||||
if (interTables == null) {
|
|
||||||
interTables = new ArrayList<InterTable>();
|
|
||||||
}
|
|
||||||
this.interTables = interTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefix() {
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefix(String prefix) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Module getModule() {
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModule(Module module) {
|
|
||||||
this.module = module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmId(Long mId) {
|
|
||||||
this.mId = mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getmId() {
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setcName(String cName) {
|
|
||||||
this.cName = cName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getcName() {
|
|
||||||
return cName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setcDescribe(String cDescribe) {
|
|
||||||
this.cDescribe = cDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getcDescribe() {
|
|
||||||
return cDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthor() {
|
|
||||||
return author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthor(String author) {
|
|
||||||
this.author = author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("mId", getmId())
|
|
||||||
.append("cName", getcName())
|
|
||||||
.append("cDescribe", getcDescribe())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,429 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.utils.constant.GenConstants;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务表 gen_table
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class GenTable extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private Long tableId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表名称
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "表名称不能为空")
|
|
||||||
private String tableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表描述
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "表描述不能为空")
|
|
||||||
private String tableComment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联父表的表名
|
|
||||||
*/
|
|
||||||
private String subTableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 本表关联父表的外键名
|
|
||||||
*/
|
|
||||||
private String subTableFkName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实体类名称(首字母大写)
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "实体类名称不能为空")
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作)
|
|
||||||
*/
|
|
||||||
private String tplCategory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成包路径
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "生成包路径不能为空")
|
|
||||||
private String packageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成模块名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "生成模块名不能为空")
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成业务名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "生成业务名不能为空")
|
|
||||||
private String businessName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成功能名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "生成功能名不能为空")
|
|
||||||
private String functionName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成作者
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "作者不能为空")
|
|
||||||
private String functionAuthor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码方式(0zip压缩包 1自定义路径)
|
|
||||||
*/
|
|
||||||
private String genType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成路径(不填默认项目路径)
|
|
||||||
*/
|
|
||||||
private String genPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键信息
|
|
||||||
*/
|
|
||||||
private GenTableColumn pkColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 子表信息
|
|
||||||
*/
|
|
||||||
private GenTable subTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表列信息
|
|
||||||
*/
|
|
||||||
@Valid
|
|
||||||
private List<GenTableColumn> columns;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
private List<RelTable> relTables;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 其它生成选项
|
|
||||||
*/
|
|
||||||
private String options;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树编码字段
|
|
||||||
*/
|
|
||||||
private String treeCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树父编码字段
|
|
||||||
*/
|
|
||||||
private String treeParentCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树名称字段
|
|
||||||
*/
|
|
||||||
private String treeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单ID字段
|
|
||||||
*/
|
|
||||||
private String parentMenuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单名称字段
|
|
||||||
*/
|
|
||||||
private String parentMenuName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联表名
|
|
||||||
*/
|
|
||||||
private String assTableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主表字段
|
|
||||||
*/
|
|
||||||
private String assTableColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联表key
|
|
||||||
*/
|
|
||||||
private String assTableFkColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联查询方式
|
|
||||||
*/
|
|
||||||
private String assQueryType;
|
|
||||||
|
|
||||||
public List<RelTable> getRelTables() {
|
|
||||||
return relTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelTables(List<RelTable> relTables) {
|
|
||||||
this.relTables = relTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssQueryType() {
|
|
||||||
return assQueryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssQueryType(String assQueryType) {
|
|
||||||
this.assQueryType = assQueryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssTableName() {
|
|
||||||
return assTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssTableName(String assTableName) {
|
|
||||||
this.assTableName = assTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssTableColumn() {
|
|
||||||
return assTableColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssTableColumn(String assTableColumn) {
|
|
||||||
this.assTableColumn = assTableColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssTableFkColumn() {
|
|
||||||
return assTableFkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssTableFkColumn(String assTableFkColumn) {
|
|
||||||
this.assTableFkColumn = assTableFkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTableId() {
|
|
||||||
return tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableId(Long tableId) {
|
|
||||||
this.tableId = tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableName() {
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
|
||||||
this.tableName = tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableComment() {
|
|
||||||
return tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableComment(String tableComment) {
|
|
||||||
this.tableComment = tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubTableName() {
|
|
||||||
return subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableName(String subTableName) {
|
|
||||||
this.subTableName = subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubTableFkName() {
|
|
||||||
return subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableFkName(String subTableFkName) {
|
|
||||||
this.subTableFkName = subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className) {
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTplCategory() {
|
|
||||||
return tplCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTplCategory(String tplCategory) {
|
|
||||||
this.tplCategory = tplCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModuleName() {
|
|
||||||
return moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModuleName(String moduleName) {
|
|
||||||
this.moduleName = moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBusinessName() {
|
|
||||||
return businessName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBusinessName(String businessName) {
|
|
||||||
this.businessName = businessName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunctionName() {
|
|
||||||
return functionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFunctionName(String functionName) {
|
|
||||||
this.functionName = functionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunctionAuthor() {
|
|
||||||
return functionAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFunctionAuthor(String functionAuthor) {
|
|
||||||
this.functionAuthor = functionAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenType() {
|
|
||||||
return genType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGenType(String genType) {
|
|
||||||
this.genType = genType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenPath() {
|
|
||||||
return genPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGenPath(String genPath) {
|
|
||||||
this.genPath = genPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenTableColumn getPkColumn() {
|
|
||||||
return pkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPkColumn(GenTableColumn pkColumn) {
|
|
||||||
this.pkColumn = pkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenTable getSubTable() {
|
|
||||||
return subTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTable(GenTable subTable) {
|
|
||||||
this.subTable = subTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GenTableColumn> getColumns() {
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumns(List<GenTableColumn> columns) {
|
|
||||||
this.columns = columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOptions() {
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptions(String options) {
|
|
||||||
this.options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeCode() {
|
|
||||||
return treeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeCode(String treeCode) {
|
|
||||||
this.treeCode = treeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeParentCode() {
|
|
||||||
return treeParentCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeParentCode(String treeParentCode) {
|
|
||||||
this.treeParentCode = treeParentCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeName() {
|
|
||||||
return treeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeName(String treeName) {
|
|
||||||
this.treeName = treeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentMenuId() {
|
|
||||||
return parentMenuId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentMenuId(String parentMenuId) {
|
|
||||||
this.parentMenuId = parentMenuId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentMenuName() {
|
|
||||||
return parentMenuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentMenuName(String parentMenuName) {
|
|
||||||
this.parentMenuName = parentMenuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSub() {
|
|
||||||
return isSub(this.tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSub(String tplCategory) {
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTree() {
|
|
||||||
return isTree(this.tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTree(String tplCategory) {
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCrud() {
|
|
||||||
return isCrud(this.tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCrud(String tplCategory) {
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuperColumn(String javaField) {
|
|
||||||
return isSuperColumn(this.tplCategory, javaField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSuperColumn(String tplCategory, String javaField) {
|
|
||||||
if (isTree(tplCategory)) {
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField,
|
|
||||||
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
|
|
||||||
}
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,376 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成业务字段表 gen_table_column
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class GenTableColumn extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private Long columnId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 归属表编号
|
|
||||||
*/
|
|
||||||
private Long tableId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列名称
|
|
||||||
*/
|
|
||||||
private String columnName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列描述
|
|
||||||
*/
|
|
||||||
private String columnComment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列类型
|
|
||||||
*/
|
|
||||||
private String columnType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JAVA类型
|
|
||||||
*/
|
|
||||||
private String javaType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JAVA字段名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "Java属性不能为空")
|
|
||||||
private String javaField;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否主键(1是)
|
|
||||||
*/
|
|
||||||
private String isPk;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否自增(1是)
|
|
||||||
*/
|
|
||||||
private String isIncrement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否必填(1是)
|
|
||||||
*/
|
|
||||||
private String isRequired;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为插入字段(1是)
|
|
||||||
*/
|
|
||||||
private String isInsert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否编辑字段(1是)
|
|
||||||
*/
|
|
||||||
private String isEdit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否列表字段(1是)
|
|
||||||
*/
|
|
||||||
private String isList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否查询字段(1是)
|
|
||||||
*/
|
|
||||||
private String isQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否正则(1否)
|
|
||||||
*/
|
|
||||||
private Long isRegular;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则表达式内容
|
|
||||||
*/
|
|
||||||
private String regular;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)
|
|
||||||
*/
|
|
||||||
private String queryType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件)
|
|
||||||
*/
|
|
||||||
private String htmlType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型
|
|
||||||
*/
|
|
||||||
private String dictType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
|
|
||||||
public Long getIsRegular() {
|
|
||||||
return isRegular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsRegular(Long isRegular) {
|
|
||||||
this.isRegular = isRegular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRegular() {
|
|
||||||
return regular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegular(String regular) {
|
|
||||||
this.regular = regular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnId(Long columnId) {
|
|
||||||
this.columnId = columnId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getColumnId() {
|
|
||||||
return columnId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableId(Long tableId) {
|
|
||||||
this.tableId = tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTableId() {
|
|
||||||
return tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnName(String columnName) {
|
|
||||||
this.columnName = columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnName() {
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnComment(String columnComment) {
|
|
||||||
this.columnComment = columnComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnComment() {
|
|
||||||
return columnComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnType(String columnType) {
|
|
||||||
this.columnType = columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnType() {
|
|
||||||
return columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJavaType(String javaType) {
|
|
||||||
this.javaType = javaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJavaType() {
|
|
||||||
return javaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJavaField(String javaField) {
|
|
||||||
this.javaField = javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJavaField() {
|
|
||||||
return javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCapJavaField() {
|
|
||||||
return StringUtils.capitalize(javaField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPk(String isPk) {
|
|
||||||
this.isPk = isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsPk() {
|
|
||||||
return isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPk() {
|
|
||||||
return isPk(this.isPk);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPk(String isPk) {
|
|
||||||
return isPk != null && StringUtils.equals("1", isPk);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsIncrement() {
|
|
||||||
return isIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsIncrement(String isIncrement) {
|
|
||||||
this.isIncrement = isIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIncrement() {
|
|
||||||
return isIncrement(this.isIncrement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIncrement(String isIncrement) {
|
|
||||||
return isIncrement != null && StringUtils.equals("1", isIncrement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsRequired(String isRequired) {
|
|
||||||
this.isRequired = isRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsRequired() {
|
|
||||||
return isRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRequired() {
|
|
||||||
return isRequired(this.isRequired);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRequired(String isRequired) {
|
|
||||||
return isRequired != null && StringUtils.equals("1", isRequired);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsInsert(String isInsert) {
|
|
||||||
this.isInsert = isInsert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsInsert() {
|
|
||||||
return isInsert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInsert() {
|
|
||||||
return isInsert(this.isInsert);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInsert(String isInsert) {
|
|
||||||
return isInsert != null && StringUtils.equals("1", isInsert);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsEdit(String isEdit) {
|
|
||||||
this.isEdit = isEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsEdit() {
|
|
||||||
return isEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEdit() {
|
|
||||||
return isInsert(this.isEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEdit(String isEdit) {
|
|
||||||
return isEdit != null && StringUtils.equals("1", isEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsList(String isList) {
|
|
||||||
this.isList = isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsList() {
|
|
||||||
return isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isList() {
|
|
||||||
return isList(this.isList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isList(String isList) {
|
|
||||||
return isList != null && StringUtils.equals("1", isList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsQuery(String isQuery) {
|
|
||||||
this.isQuery = isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsQuery() {
|
|
||||||
return isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isQuery() {
|
|
||||||
return isQuery(this.isQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isQuery(String isQuery) {
|
|
||||||
return isQuery != null && StringUtils.equals("1", isQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQueryType(String queryType) {
|
|
||||||
this.queryType = queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQueryType() {
|
|
||||||
return queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHtmlType() {
|
|
||||||
return htmlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHtmlType(String htmlType) {
|
|
||||||
this.htmlType = htmlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDictType(String dictType) {
|
|
||||||
this.dictType = dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDictType() {
|
|
||||||
return dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSort(Integer sort) {
|
|
||||||
this.sort = sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSort() {
|
|
||||||
return sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuperColumn() {
|
|
||||||
return isSuperColumn(this.javaField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSuperColumn(String javaField) {
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField,
|
|
||||||
// BaseEntity
|
|
||||||
"createBy", "createTime", "updateBy", "updateTime", "remark",
|
|
||||||
// TreeEntity
|
|
||||||
"parentName", "parentId", "orderNum", "ancestors");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUsableColumn() {
|
|
||||||
return isUsableColumn(javaField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUsableColumn(String javaField) {
|
|
||||||
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String readConverterExp() {
|
|
||||||
String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
if (StringUtils.isNotEmpty(remarks)) {
|
|
||||||
for (String value : remarks.split(" ")) {
|
|
||||||
if (StringUtils.isNotEmpty(value)) {
|
|
||||||
Object startStr = value.subSequence(0, 1);
|
|
||||||
String endStr = value.substring(1);
|
|
||||||
sb.append("").append(startStr).append("=").append(endStr).append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.deleteCharAt(sb.length() - 1).toString();
|
|
||||||
} else {
|
|
||||||
return this.columnComment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,213 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口信息对象 sys_inter_table
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-25
|
|
||||||
*/
|
|
||||||
@ApiModel("接口信息")
|
|
||||||
public class InterTable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块id
|
|
||||||
*/
|
|
||||||
@Excel(name = "模块id")
|
|
||||||
private Long mId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类id
|
|
||||||
*/
|
|
||||||
@Excel(name = "类id")
|
|
||||||
private Long cId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口名称
|
|
||||||
*/
|
|
||||||
@Excel(name = "接口名称")
|
|
||||||
private String itName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
@Excel(name = "描述")
|
|
||||||
private String itDescribe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否设置许可
|
|
||||||
*/
|
|
||||||
@Excel(name = "是否设置许可")
|
|
||||||
private String isPermission;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求路径
|
|
||||||
*/
|
|
||||||
@Excel(name = "请求路径")
|
|
||||||
private String requrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求方式
|
|
||||||
*/
|
|
||||||
@Excel(name = "请求方式")
|
|
||||||
private String method;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否生成
|
|
||||||
*/
|
|
||||||
@Excel(name = "是否生成")
|
|
||||||
private String isGenerate;
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private Integer type;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private Long createBy;
|
|
||||||
|
|
||||||
private String mName;
|
|
||||||
private ApiClass apiclass;
|
|
||||||
|
|
||||||
public ApiClass getApiclass() {
|
|
||||||
return apiclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiclass(ApiClass apiclass) {
|
|
||||||
this.apiclass = apiclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getmName() {
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmName(String mName) {
|
|
||||||
this.mName = mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreateTime() {
|
|
||||||
return createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateTime(Date createTime) {
|
|
||||||
this.createTime = createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCreateBy() {
|
|
||||||
return createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateBy(Long createBy) {
|
|
||||||
this.createBy = createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItName() {
|
|
||||||
return itName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItName(String itName) {
|
|
||||||
this.itName = itName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmId(Long mId) {
|
|
||||||
this.mId = mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getmId() {
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setcId(Long cId) {
|
|
||||||
this.cId = cId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getcId() {
|
|
||||||
return cId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItDescribe(String itDescribe) {
|
|
||||||
this.itDescribe = itDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItDescribe() {
|
|
||||||
return itDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequrl(String requrl) {
|
|
||||||
this.requrl = requrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRequrl() {
|
|
||||||
return requrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethod(String method) {
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsPermission() {
|
|
||||||
return isPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPermission(String isPermission) {
|
|
||||||
this.isPermission = isPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsGenerate() {
|
|
||||||
return isGenerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsGenerate(String isGenerate) {
|
|
||||||
this.isGenerate = isGenerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("mId", getmId())
|
|
||||||
.append("cId", getcId())
|
|
||||||
.append("itDescribe", getItDescribe())
|
|
||||||
.append("requrl", getRequrl())
|
|
||||||
.append("method", getMethod())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块管理对象 sys_module
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public class Module extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块名称
|
|
||||||
*/
|
|
||||||
@Excel(name = "模块名称")
|
|
||||||
private String mName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块描述
|
|
||||||
*/
|
|
||||||
@Excel(name = "模块描述")
|
|
||||||
private String mDescribe;
|
|
||||||
|
|
||||||
private List<ApiClass> apiClassList;
|
|
||||||
|
|
||||||
public List<ApiClass> getApiclassList() {
|
|
||||||
return apiClassList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiclassList(List<ApiClass> apiClassList) {
|
|
||||||
this.apiClassList = apiClassList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmName(String mName) {
|
|
||||||
this.mName = mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getmName() {
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmDescribe(String mDescribe) {
|
|
||||||
this.mDescribe = mDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getmDescribe() {
|
|
||||||
return mDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("mName", getmName())
|
|
||||||
.append("mDescribe", getmDescribe())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验规则对象 sys_regular
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-18
|
|
||||||
*/
|
|
||||||
public class Regular extends BaseEntity {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则名称
|
|
||||||
*/
|
|
||||||
@Excel(name = "正则名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则内容
|
|
||||||
*/
|
|
||||||
@Excel(name = "正则内容")
|
|
||||||
private String regular;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证内容
|
|
||||||
*/
|
|
||||||
@Excel(name = "验证内容")
|
|
||||||
private String validation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否启用 1:启动 2:关闭
|
|
||||||
*/
|
|
||||||
@Excel(name = "是否启用 1:启动 2:关闭")
|
|
||||||
private Integer enable;
|
|
||||||
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegular(String regular) {
|
|
||||||
this.regular = regular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRegular() {
|
|
||||||
return regular;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidation(String validation) {
|
|
||||||
this.validation = validation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValidation() {
|
|
||||||
return validation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnable(Integer enable) {
|
|
||||||
this.enable = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getEnable() {
|
|
||||||
return enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("name", getName())
|
|
||||||
.append("regular", getRegular())
|
|
||||||
.append("validation", getValidation())
|
|
||||||
.append("enable", getEnable())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
public class RelColumn {
|
|
||||||
|
|
||||||
//表id
|
|
||||||
private long id;
|
|
||||||
//父表id
|
|
||||||
private long relId;
|
|
||||||
//列名称
|
|
||||||
private String columnName;
|
|
||||||
//列描述
|
|
||||||
private String columnComment;
|
|
||||||
//列类型
|
|
||||||
private String columnType;
|
|
||||||
//java类型
|
|
||||||
private String javaType;
|
|
||||||
//java字段名
|
|
||||||
private String javaField;
|
|
||||||
//是否列表显示(1是)
|
|
||||||
private String isList;
|
|
||||||
//是否可查询(1可)
|
|
||||||
private String isQuery;
|
|
||||||
//查询方式(等于,不等于,小于,大于,区间)
|
|
||||||
private String queryType;
|
|
||||||
//控件显示类型
|
|
||||||
private String htmlType;
|
|
||||||
//字典类型
|
|
||||||
private String dictType;
|
|
||||||
//排序
|
|
||||||
private Integer sort;
|
|
||||||
//创建时间
|
|
||||||
private long createBy;
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRelId() {
|
|
||||||
return relId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelId(long relId) {
|
|
||||||
this.relId = relId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnName() {
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnName(String columnName) {
|
|
||||||
this.columnName = columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnComment() {
|
|
||||||
return columnComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnComment(String columnComment) {
|
|
||||||
this.columnComment = columnComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnType() {
|
|
||||||
return columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnType(String columnType) {
|
|
||||||
this.columnType = columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJavaType() {
|
|
||||||
return javaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJavaType(String javaType) {
|
|
||||||
this.javaType = javaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJavaField() {
|
|
||||||
return javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJavaField(String javaField) {
|
|
||||||
this.javaField = javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsList() {
|
|
||||||
return isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsList(String isList) {
|
|
||||||
this.isList = isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsQuery() {
|
|
||||||
return isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsQuery(String isQuery) {
|
|
||||||
this.isQuery = isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQueryType() {
|
|
||||||
return queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQueryType(String queryType) {
|
|
||||||
this.queryType = queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHtmlType() {
|
|
||||||
return htmlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHtmlType(String htmlType) {
|
|
||||||
this.htmlType = htmlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDictType() {
|
|
||||||
if (dictType == null) {
|
|
||||||
dictType = "";
|
|
||||||
}
|
|
||||||
return dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDictType(String dictType) {
|
|
||||||
if (dictType == null) {
|
|
||||||
dictType = "";
|
|
||||||
}
|
|
||||||
this.dictType = dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSort() {
|
|
||||||
return sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSort(Integer sort) {
|
|
||||||
this.sort = sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCreateBy() {
|
|
||||||
return createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateBy(long createBy) {
|
|
||||||
this.createBy = createBy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,158 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RelTable {
|
|
||||||
|
|
||||||
|
|
||||||
//表id
|
|
||||||
private long id;
|
|
||||||
//主表id
|
|
||||||
private long tableId;
|
|
||||||
//关联子表表名
|
|
||||||
private String relName;
|
|
||||||
//子表表名称简写
|
|
||||||
private String relAs;
|
|
||||||
//父表名称
|
|
||||||
private String tableName;
|
|
||||||
//父表名称简写
|
|
||||||
private String tableAs;
|
|
||||||
//关联子表描述
|
|
||||||
private String relComment;
|
|
||||||
//关联子表的字段
|
|
||||||
private String relColumn;
|
|
||||||
//关联父表字段
|
|
||||||
private String tableColumn;
|
|
||||||
//实体类名称(子表)
|
|
||||||
private String relClass;
|
|
||||||
//实体小写类名称(子表)
|
|
||||||
private String relclass;
|
|
||||||
//查询方式
|
|
||||||
private String queryType;
|
|
||||||
//排序
|
|
||||||
private Integer sort;
|
|
||||||
//创建者
|
|
||||||
private long createBy;
|
|
||||||
|
|
||||||
private List<RelColumn> relColumns;
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTableId() {
|
|
||||||
return tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableId(long tableId) {
|
|
||||||
this.tableId = tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelName() {
|
|
||||||
return relName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelName(String relName) {
|
|
||||||
this.relName = relName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelAs() {
|
|
||||||
return relAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelAs(String relAs) {
|
|
||||||
this.relAs = relAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableName() {
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
|
||||||
this.tableName = tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableAs() {
|
|
||||||
return tableAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableAs(String tableAs) {
|
|
||||||
this.tableAs = tableAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelComment() {
|
|
||||||
return relComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelComment(String relComment) {
|
|
||||||
this.relComment = relComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelColumn() {
|
|
||||||
return relColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelColumn(String relColumn) {
|
|
||||||
this.relColumn = relColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableColumn() {
|
|
||||||
return tableColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableColumn(String tableColumn) {
|
|
||||||
this.tableColumn = tableColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelClass() {
|
|
||||||
return relClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelClass(String relClass) {
|
|
||||||
this.relClass = relClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelclass() {
|
|
||||||
return relclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelclass(String relclass) {
|
|
||||||
this.relclass = relclass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQueryType() {
|
|
||||||
return queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQueryType(String queryType) {
|
|
||||||
this.queryType = queryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSort() {
|
|
||||||
return sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSort(Integer sort) {
|
|
||||||
this.sort = sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCreateBy() {
|
|
||||||
return createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateBy(long createBy) {
|
|
||||||
this.createBy = createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RelColumn> getRelColumns() {
|
|
||||||
return relColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelColumns(List<RelColumn> relColumns) {
|
|
||||||
this.relColumns = relColumns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询关系映射对象 gen_relational_mapping
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-21
|
|
||||||
*/
|
|
||||||
public class RelationalMap extends BaseEntity{
|
|
||||||
|
|
||||||
/** 主表id */
|
|
||||||
private Long mainId;
|
|
||||||
|
|
||||||
/** 字表id */
|
|
||||||
private Long childId;
|
|
||||||
|
|
||||||
/** 主表字段 */
|
|
||||||
private String mainKey;
|
|
||||||
|
|
||||||
/** 字表字段 */
|
|
||||||
private String childKey;
|
|
||||||
|
|
||||||
/** 关系 1:hasOne 2:hasMany 3: belongsTo */
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
|
|
||||||
public void setMainId(Long mainId){
|
|
||||||
this.mainId = mainId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getMainId(){
|
|
||||||
return mainId;
|
|
||||||
}
|
|
||||||
public void setChildId(Long childId){
|
|
||||||
this.childId = childId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getChildId(){
|
|
||||||
return childId;
|
|
||||||
}
|
|
||||||
public void setMainKey(String mainKey){
|
|
||||||
this.mainKey = mainKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMainKey(){
|
|
||||||
return mainKey;
|
|
||||||
}
|
|
||||||
public void setChildKey(String childKey){
|
|
||||||
this.childKey = childKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChildKey(){
|
|
||||||
return childKey;
|
|
||||||
}
|
|
||||||
public void setType(String type){
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType(){
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("mainId", getMainId())
|
|
||||||
.append("childId", getChildId())
|
|
||||||
.append("mainKey", getMainKey())
|
|
||||||
.append("childKey", getChildKey())
|
|
||||||
.append("type", getType())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询角色关系对象 gen_search_table_role
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-21
|
|
||||||
*/
|
|
||||||
public class SearchTableRole extends BaseEntity{
|
|
||||||
|
|
||||||
/** 表格id */
|
|
||||||
private Long searchTableId;
|
|
||||||
|
|
||||||
/** 角色id */
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
public SearchTableRole(Long searchTableId, Long roleId) {
|
|
||||||
this.searchTableId = searchTableId;
|
|
||||||
this.roleId = roleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchTableRole() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSearchTableId(Long searchTableId){
|
|
||||||
this.searchTableId = searchTableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSearchTableId(){
|
|
||||||
return searchTableId;
|
|
||||||
}
|
|
||||||
public void setRoleId(Long roleId){
|
|
||||||
this.roleId = roleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getRoleId(){
|
|
||||||
return roleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("searchTableId", getSearchTableId())
|
|
||||||
.append("roleId", getRoleId())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/26 16:04
|
|
||||||
* @description:TopEdge
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
public class TopEdge {
|
|
||||||
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String source;
|
|
||||||
private String sourceEdge;
|
|
||||||
private String target;
|
|
||||||
private JSONObject appConfig;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TopEdge() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TopEdge(String id,String source, String target, JSONObject appConfig) {
|
|
||||||
this.id = id;
|
|
||||||
this.source = source;
|
|
||||||
this.target = target;
|
|
||||||
this.appConfig = appConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSourceEdge() {
|
|
||||||
return sourceEdge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceEdge(String sourceEdge) {
|
|
||||||
this.sourceEdge = sourceEdge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSource() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSource(String source) {
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTarget() {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTarget(String target) {
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject getAppConfig() {
|
|
||||||
return appConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppConfig(JSONObject appConfig) {
|
|
||||||
this.appConfig = appConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,121 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/26 17:26
|
|
||||||
* @description:TopNode
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
public class TopNode {
|
|
||||||
private String id;
|
|
||||||
private String table;
|
|
||||||
private String relTable;
|
|
||||||
private StringBuffer tableSQL = new StringBuffer(" ");
|
|
||||||
private StringBuffer querySql = new StringBuffer(" ");
|
|
||||||
private JSONArray columns;
|
|
||||||
|
|
||||||
public String getQuerySql() {
|
|
||||||
return querySql.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelTable() {
|
|
||||||
return relTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableSQL() {
|
|
||||||
return tableSQL.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTable() {
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTable(String table) {
|
|
||||||
this.table = table;
|
|
||||||
this.relTable = StringUtils.sqlFormat(table);
|
|
||||||
boolean start = false;
|
|
||||||
for (int i = 0; i < this.columns.size(); i++) {
|
|
||||||
JSONObject column = this.columns.getJSONObject(i);
|
|
||||||
if (column.getInteger("isUse") == 1) {
|
|
||||||
if (start) {
|
|
||||||
tableSQL.append(", ");
|
|
||||||
}
|
|
||||||
tableSQL.append(this.relTable).append(".").append(column.getString("columnName"));
|
|
||||||
if (StringUtils.isNotNull(column.getString("columnComment"))) {
|
|
||||||
tableSQL.append(" as ").append("'").append(column.getString("columnComment")).append("'");
|
|
||||||
}
|
|
||||||
start = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column.getInteger("isQuery") == 1 ) {
|
|
||||||
String sql = " and " + relTable + "." + column.getString("columnName");
|
|
||||||
switch (column.getString("ucCon")) {
|
|
||||||
case "EQ":
|
|
||||||
sql += " = '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "NE":
|
|
||||||
sql += " != '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "GT":
|
|
||||||
sql += " > '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "GTE":
|
|
||||||
sql += " >= '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "LT":
|
|
||||||
sql += " < '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "LTE":
|
|
||||||
sql += " <= '" + column.getString("ucMock") + "'";
|
|
||||||
break;
|
|
||||||
case "LIKE":
|
|
||||||
sql += " like '%" + column.getString("ucMock") + "%'";
|
|
||||||
break;
|
|
||||||
case "BETWEEN":
|
|
||||||
try {
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(column.getString("ucMock"));
|
|
||||||
if ("input".equals(column.getString("ucType"))) {
|
|
||||||
Object begin = jsonObject.get("begin");
|
|
||||||
Object end = jsonObject.get("end");
|
|
||||||
if (begin != null && end != null) {
|
|
||||||
sql += " between '" + begin + "' AND '" + end + "'";
|
|
||||||
} else {
|
|
||||||
sql = "";
|
|
||||||
}
|
|
||||||
} else if ("datetime".equals(column.getString("ucType"))) {
|
|
||||||
Object startTime = jsonObject.get("startTime");
|
|
||||||
Object endTime = jsonObject.get("endTime");
|
|
||||||
sql += " between '" + startTime + "' AND '" + endTime + "'";
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
sql = "";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
querySql.append(sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONArray getColumns() {
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumns(JSONArray columns) {
|
|
||||||
this.columns = columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询字段对象 gen_top_search_column
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
public class TopSearchColumn extends BaseEntity{
|
|
||||||
|
|
||||||
/** 主键id */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** top万能查询表格主键id */
|
|
||||||
@Excel(name = "top万能查询表格主键id")
|
|
||||||
private Long searchTableId;
|
|
||||||
|
|
||||||
/** 列名称 */
|
|
||||||
@Excel(name = "列名称")
|
|
||||||
private String columnName;
|
|
||||||
|
|
||||||
/** 列描述 */
|
|
||||||
@Excel(name = "列描述")
|
|
||||||
private String columnComment;
|
|
||||||
|
|
||||||
/** 列类型 */
|
|
||||||
@Excel(name = "列类型")
|
|
||||||
private String columnType;
|
|
||||||
|
|
||||||
/** 是否使用 */
|
|
||||||
@Excel(name = "是否使用")
|
|
||||||
private Integer isUse;
|
|
||||||
private Integer isPk;
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
public Integer getSort() {
|
|
||||||
return sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIsPk() {
|
|
||||||
return isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPk(Integer isPk) {
|
|
||||||
this.isPk = isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id){
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId(){
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setSearchTableId(Long searchTableId){
|
|
||||||
this.searchTableId = searchTableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSearchTableId(){
|
|
||||||
return searchTableId;
|
|
||||||
}
|
|
||||||
public void setColumnName(String columnName){
|
|
||||||
this.columnName = columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnName(){
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
public void setColumnComment(String columnComment){
|
|
||||||
this.columnComment = columnComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnComment(){
|
|
||||||
return columnComment;
|
|
||||||
}
|
|
||||||
public void setColumnType(String columnType){
|
|
||||||
this.columnType = columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnType(){
|
|
||||||
return columnType;
|
|
||||||
}
|
|
||||||
public void setIsUse(Integer isUse){
|
|
||||||
this.isUse = isUse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIsUse(){
|
|
||||||
return isUse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("searchTableId", getSearchTableId())
|
|
||||||
.append("columnName", getColumnName())
|
|
||||||
.append("columnComment", getColumnComment())
|
|
||||||
.append("columnType", getColumnType())
|
|
||||||
.append("isUse", getIsUse())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询主对象 gen_top_search_table
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
public class TopSearchTable extends BaseEntity{
|
|
||||||
|
|
||||||
/** 主键id */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 表名 */
|
|
||||||
private String tableName;
|
|
||||||
|
|
||||||
/** 表描述 */
|
|
||||||
private String tableComment;
|
|
||||||
|
|
||||||
/** top万能查询字段信息 */
|
|
||||||
private List<TopSearchColumn> topSearchColumnList;
|
|
||||||
|
|
||||||
private Long[] roleIds;
|
|
||||||
|
|
||||||
private List<RelationalMap> relationalMapList;
|
|
||||||
|
|
||||||
public List<RelationalMap> getRelationalMapList() {
|
|
||||||
return relationalMapList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelationalMapList(List<RelationalMap> relationalMapList) {
|
|
||||||
this.relationalMapList = relationalMapList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long[] getRoleIds() {
|
|
||||||
return roleIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoleIds(Long[] roleIds) {
|
|
||||||
this.roleIds = roleIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id){
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId(){
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setTableName(String tableName){
|
|
||||||
this.tableName = tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableName(){
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
public void setTableComment(String tableComment){
|
|
||||||
this.tableComment = tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableComment(){
|
|
||||||
return tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TopSearchColumn> getTopSearchColumnList(){
|
|
||||||
return topSearchColumnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTopSearchColumnList(List<TopSearchColumn> topSearchColumnList){
|
|
||||||
this.topSearchColumnList = topSearchColumnList;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("tableName", getTableName())
|
|
||||||
.append("tableComment", getTableComment())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("topSearchColumnList", getTopSearchColumnList())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询条件对象 sys_uni_con
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
public class UniCon {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询tableid
|
|
||||||
*/
|
|
||||||
private Long uqId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称(lable)
|
|
||||||
*/
|
|
||||||
private String ucName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关键字
|
|
||||||
*/
|
|
||||||
private String ucKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询条件
|
|
||||||
*/
|
|
||||||
private String ucCon;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模拟数据
|
|
||||||
*/
|
|
||||||
private String ucMock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 真实数据
|
|
||||||
*/
|
|
||||||
private Object ucReal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String ucDescribe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输入类型
|
|
||||||
*/
|
|
||||||
private String ucType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示类型
|
|
||||||
*/
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
public UniCon() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public UniCon(Long uqId, String ucName, String ucKey, String ucCon, String ucType, Integer type) {
|
|
||||||
this.uqId = uqId;
|
|
||||||
this.ucName = ucName;
|
|
||||||
this.ucKey = ucKey;
|
|
||||||
this.ucCon = ucCon;
|
|
||||||
this.ucType = ucType;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcType() {
|
|
||||||
return ucType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcType(String ucType) {
|
|
||||||
this.ucType = ucType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUqId(Long uqId) {
|
|
||||||
this.uqId = uqId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUqId() {
|
|
||||||
return uqId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcName(String ucName) {
|
|
||||||
this.ucName = ucName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcName() {
|
|
||||||
return ucName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcKey(String ucKey) {
|
|
||||||
this.ucKey = ucKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcKey() {
|
|
||||||
return ucKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcCon(String ucCon) {
|
|
||||||
this.ucCon = ucCon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcCon() {
|
|
||||||
return ucCon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcMock() {
|
|
||||||
return ucMock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcMock(String ucMock) {
|
|
||||||
this.ucMock = ucMock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUcDescribe() {
|
|
||||||
return ucDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcDescribe(String ucDescribe) {
|
|
||||||
this.ucDescribe = ucDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getUcReal() {
|
|
||||||
return ucReal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUcReal(Object ucReal) {
|
|
||||||
this.ucReal = ucReal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,162 +0,0 @@
|
||||||
package com.ebts.generator.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询对象 sys_uni_query
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
public class UniQuery extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
private String uqName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sql语句
|
|
||||||
*/
|
|
||||||
private String uqSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String uqDescribe;
|
|
||||||
|
|
||||||
private String topJson;
|
|
||||||
|
|
||||||
|
|
||||||
private int type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否发布(0:否,1:发布)
|
|
||||||
*/
|
|
||||||
private Integer isRelease;
|
|
||||||
|
|
||||||
private Integer isPreview;
|
|
||||||
|
|
||||||
private List<UniCon> uniCons;
|
|
||||||
|
|
||||||
private Integer pageNum;
|
|
||||||
|
|
||||||
private Integer pageSize;
|
|
||||||
|
|
||||||
public String getTopJson() {
|
|
||||||
return topJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Integer getIsPreview() {
|
|
||||||
return isPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPreview(Integer isPreview) {
|
|
||||||
this.isPreview = isPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTopJson(String topJson) {
|
|
||||||
this.topJson = topJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIsRelease() {
|
|
||||||
return isRelease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsRelease(Integer isRelease) {
|
|
||||||
this.isRelease = isRelease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageNum() {
|
|
||||||
return pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageNum(Integer pageNum) {
|
|
||||||
this.pageNum = pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageSize() {
|
|
||||||
return pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageSize(Integer pageSize) {
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UniCon> getUniCons() {
|
|
||||||
if (uniCons == null) {
|
|
||||||
return uniCons = new ArrayList<UniCon>();
|
|
||||||
} else {
|
|
||||||
return uniCons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUniCons(List<UniCon> uniCons) {
|
|
||||||
this.uniCons = uniCons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUqName(String uqName) {
|
|
||||||
this.uqName = uqName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUqName() {
|
|
||||||
return uqName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUqSql(String uqSql) {
|
|
||||||
this.uqSql = uqSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUqSql() {
|
|
||||||
return uqSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUqDescribe(String uqDescribe) {
|
|
||||||
this.uqDescribe = uqDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUqDescribe() {
|
|
||||||
return uqDescribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("uqName", getUqName())
|
|
||||||
.append("uqSql", getUqSql())
|
|
||||||
.append("uqDescribe", getUqDescribe())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口类名Service接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public interface ApiClassService {
|
|
||||||
/**
|
|
||||||
* 查询接口类名
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 接口类名
|
|
||||||
*/
|
|
||||||
ServerResult<ApiClass> selectApiclassById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名列表
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 接口类名集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<ApiClass>> selectApiclassList(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertApiclass(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateApiclass(ApiClass apiclass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口类名
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的接口类名ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteApiclassByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口类名信息
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteApiclassById(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务字段 服务层
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public interface GenTableColumnService {
|
|
||||||
/**
|
|
||||||
* 查询业务字段列表
|
|
||||||
*
|
|
||||||
* @param tableId 业务字段编号
|
|
||||||
* @return 业务字段集合
|
|
||||||
*/
|
|
||||||
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insertGenTableColumn(GenTableColumn genTableColumn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int updateGenTableColumn(GenTableColumn genTableColumn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除业务字段信息
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int deleteGenTableColumnByIds(String ids);
|
|
||||||
}
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务 服务层
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public interface GenTableService {
|
|
||||||
/**
|
|
||||||
* 查询业务列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 业务集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param tableNames 表名称组
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表信息
|
|
||||||
*
|
|
||||||
* @return 表信息集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务信息
|
|
||||||
*
|
|
||||||
* @param id 业务ID
|
|
||||||
* @return 业务信息
|
|
||||||
*/
|
|
||||||
public GenTable selectGenTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void updateGenTable(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除业务信息
|
|
||||||
*
|
|
||||||
* @param tableIds 需要删除的表数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public ServerResult<Integer> deleteGenTableByIds(Long[] tableIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入表结构
|
|
||||||
*
|
|
||||||
* @param tableList 导入表列表
|
|
||||||
*/
|
|
||||||
public void importGenTable(List<GenTable> tableList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码
|
|
||||||
*
|
|
||||||
* @param tableId 表编号
|
|
||||||
* @return 预览数据列表
|
|
||||||
*/
|
|
||||||
public Map<String, String> previewCode(Long tableId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(下载方式)
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 数据
|
|
||||||
*/
|
|
||||||
public byte[] downloadCode(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(自定义路径)
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 数据
|
|
||||||
*/
|
|
||||||
public boolean generatorCode(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同步数据库
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
*/
|
|
||||||
public void synchDb(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量生成代码(下载方式)
|
|
||||||
*
|
|
||||||
* @param tableNames 表数组
|
|
||||||
* @return 数据
|
|
||||||
*/
|
|
||||||
public byte[] downloadCode(String[] tableNames);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改保存参数校验
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
*/
|
|
||||||
public void validateEdit(GenTable genTable);
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dto.InterTableDto;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口信息Service接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-25
|
|
||||||
*/
|
|
||||||
public interface InterTableService {
|
|
||||||
/**
|
|
||||||
* 查询接口信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 接口信息
|
|
||||||
*/
|
|
||||||
ServerResult<InterTable> selectInterTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口信息列表
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 接口信息集合
|
|
||||||
*/
|
|
||||||
ServerResult<Map<String, Object>> selectInterTableList(InterTable interTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口信息
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertInterTable(InterTable interTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口信息
|
|
||||||
*
|
|
||||||
* @param interTableDto 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateInterTable(InterTableDto interTableDto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口信息
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的接口信息ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteInterTableByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口信息信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteInterTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码(工作流)
|
|
||||||
*
|
|
||||||
* @param cid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<Map<String, String>> previewCodeCalss(Long cid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码()工作台
|
|
||||||
*
|
|
||||||
* @param mid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<Map<String, Object>> previewCodeMoudle(Long mid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(工作流)
|
|
||||||
*
|
|
||||||
* @param cid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<byte[]> generatorCodeClass(Long cid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(工作台)
|
|
||||||
*
|
|
||||||
* @param mid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<byte[]> generatorCodeMoudle(Long mid);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块管理Service接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
public interface ModuleService {
|
|
||||||
/**
|
|
||||||
* 查询模块管理
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 模块管理
|
|
||||||
*/
|
|
||||||
ServerResult<Module> selectModuleById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询模块管理列表
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 模块管理集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<Module>> selectModuleList(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertModule(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateModule(Module module);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除模块管理
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的模块管理ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteModuleByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除模块管理信息
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteModuleById(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/1/30 18:54
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
public interface QueryService {
|
|
||||||
/**
|
|
||||||
* 通过id查询基础信息
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<UniQuery> selectQueryById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改基础信息
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateQueryInfo(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览万能查询数据
|
|
||||||
*
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<Map<String, Object>>> previewQuery(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param uniQuery
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> Release(UniQuery uniQuery);
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.Regular;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验规则Service接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-18
|
|
||||||
*/
|
|
||||||
public interface RegularService {
|
|
||||||
/**
|
|
||||||
* 查询校验规则
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 校验规则
|
|
||||||
*/
|
|
||||||
ServerResult<Regular> selectRegularById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则列表
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 校验规则集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<Regular>> selectRegularList(Regular regular);
|
|
||||||
/**
|
|
||||||
* 查询校验规则下拉框列表
|
|
||||||
*
|
|
||||||
* @return 校验规则集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<Regular>> selectRegularOption();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertRegular(Regular regular);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateRegular(Regular regular);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除校验规则
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的校验规则ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteRegularByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除校验规则信息
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteRegularById(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.RelColumn;
|
|
||||||
import com.ebts.generator.entity.RelTable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/24 16:21
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
public interface RelService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到数据库表信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<Map<String, Object>>> tableInfos();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到关联边字段信息
|
|
||||||
*
|
|
||||||
* @param tableName 关联表表名
|
|
||||||
* @param relId 关联关系id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<RelColumn>> relColumns(String tableName, Long relId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过tableName获取到字段信息
|
|
||||||
*
|
|
||||||
* @param tableName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<Map<String,Object>>> tableColumns(String tableName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过主表id查询子表信息
|
|
||||||
*
|
|
||||||
* @param tableId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<RelTable>> relTableByTableId(Long tableId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dto.TopResult;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/23 21:51
|
|
||||||
* @description:TopQueryService
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
public interface TopQueryService {
|
|
||||||
|
|
||||||
Map<String, Object> selectTopSearchTables();
|
|
||||||
|
|
||||||
ServerResult<TopResult> preview(String jsonData, String id);
|
|
||||||
|
|
||||||
ServerResult<String> online(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.TopSearchColumn;
|
|
||||||
import com.ebts.generator.entity.TopSearchTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询主Service接口
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
public interface TopSearchTableService {
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return top万能查询主
|
|
||||||
*/
|
|
||||||
ServerResult<TopSearchTable> selectTopSearchTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主列表
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return top万能查询主集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ServerResult<List<TopSearchTable>> selectTopSearchTableInfo();
|
|
||||||
|
|
||||||
List<TopSearchColumn> selectTableColumns(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable);
|
|
||||||
|
|
||||||
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
|
|
||||||
|
|
||||||
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
|
|
||||||
|
|
||||||
void importGenTable(List<TopSearchTable> tableList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除top万能查询主
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询主信息
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteTopSearchTableById(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
package com.ebts.generator.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询Service接口
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
public interface UniQueryService {
|
|
||||||
/**
|
|
||||||
* 查询万能查询
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 万能查询
|
|
||||||
*/
|
|
||||||
ServerResult<UniQuery> selectUniQueryById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询列表
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 万能查询集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insertUniQuery(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> updateUniQuery(UniQuery uniQuery);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除万能查询
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的万能查询ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteUniQueryByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除万能查询信息
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> deleteUniQueryById(Long id);
|
|
||||||
}
|
|
||||||
|
|
@ -1,157 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.ApiClassDao;
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.service.ApiClassService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口类名Service业务层处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class ApiClassServiceImpl implements ApiClassService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(ApiClassServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApiClassDao apiclassDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 接口类名
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<ApiClass> selectApiclassById(Long id) {
|
|
||||||
try {
|
|
||||||
ApiClass apiclass = apiclassDao.selectApiclassById(id);
|
|
||||||
if (apiclass != null) {
|
|
||||||
return new ServerResult<>(true, apiclass);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口类名列表
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 接口类名
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<ApiClass>> selectApiclassList(ApiClass apiclass) {
|
|
||||||
try {
|
|
||||||
List<ApiClass> apiClassList = apiclassDao.selectApiclassList(apiclass);
|
|
||||||
if (apiClassList.size() > 0) {
|
|
||||||
return new ServerResult<>(true, apiClassList);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertApiclass(ApiClass apiclass) {
|
|
||||||
try {
|
|
||||||
apiclass.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = apiclassDao.insertApiclass(apiclass);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口类名
|
|
||||||
*
|
|
||||||
* @param apiclass 接口类名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> updateApiclass(ApiClass apiclass) {
|
|
||||||
try {
|
|
||||||
apiclass.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = apiclassDao.updateApiclass(apiclass);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口类名
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的接口类名ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteApiclassByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
Integer renewal = apiclassDao.deleteApiclassByIds(ids);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口类名信息
|
|
||||||
*
|
|
||||||
* @param id 接口类名ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteApiclassById(Long id) {
|
|
||||||
try {
|
|
||||||
Integer renewal = apiclassDao.deleteApiclassById(id);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.text.Convert;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.generator.service.GenTableColumnService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
import com.ebts.generator.dao.GenTableColumnDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务字段 服务层实现
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class GenTableColumnServiceImpl implements GenTableColumnService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(GenTableColumnServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GenTableColumnDao genTableColumnDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务字段列表
|
|
||||||
*
|
|
||||||
* @param tableId 业务字段编号
|
|
||||||
* @return 业务字段集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
|
||||||
try {
|
|
||||||
return genTableColumnDao.selectGenTableColumnListByTableId(tableId);
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn) {
|
|
||||||
try {
|
|
||||||
return genTableColumnDao.insertGenTableColumn(genTableColumn);
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn) {
|
|
||||||
try {
|
|
||||||
List<GenTableColumn> genTableColumns = new ArrayList<GenTableColumn>();
|
|
||||||
genTableColumns.add(genTableColumn);
|
|
||||||
return genTableColumnDao.updateGenTableColumn(genTableColumns);
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除业务字段对象
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteGenTableColumnByIds(String ids) {
|
|
||||||
try {
|
|
||||||
return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,648 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.Constants;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.text.CharsetKit;
|
|
||||||
import com.ebts.common.exception.CustomException;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.dao.RelDao;
|
|
||||||
import com.ebts.generator.entity.*;
|
|
||||||
import com.ebts.generator.service.GenTableService;
|
|
||||||
import com.ebts.generator.utils.*;
|
|
||||||
import com.ebts.generator.utils.constant.GenConstants;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.velocity.Template;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import org.apache.velocity.app.Velocity;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ebts.generator.dao.GenTableColumnDao;
|
|
||||||
import com.ebts.generator.dao.GenTableDao;
|
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务 服务层实现
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class GenTableServiceImpl implements GenTableService {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GenTableDao genTableDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GenTableColumnDao genTableColumnDao;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RelDao relDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务信息
|
|
||||||
*
|
|
||||||
* @param id 业务ID
|
|
||||||
* @return 业务信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public GenTable selectGenTableById(Long id) {
|
|
||||||
try {
|
|
||||||
GenTable genTable = genTableDao.selectGenTableById(id);
|
|
||||||
setTableFromOptions(genTable);
|
|
||||||
return genTable;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 业务集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable) {
|
|
||||||
try {
|
|
||||||
return genTableDao.selectGenTableList(genTable);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable) {
|
|
||||||
try {
|
|
||||||
return genTableDao.selectDbTableList(genTable);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询据库列表
|
|
||||||
*
|
|
||||||
* @param tableNames 表名称组
|
|
||||||
* @return 数据库表集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames) {
|
|
||||||
try {
|
|
||||||
return genTableDao.selectDbTableListByNames(tableNames);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表信息
|
|
||||||
*
|
|
||||||
* @return 表信息集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTable> selectGenTableAll() {
|
|
||||||
try {
|
|
||||||
return genTableDao.selectGenTableAll();
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo 修改业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateGenTable(GenTable genTable) {
|
|
||||||
try {
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
|
||||||
genTable.setOptions(options);
|
|
||||||
int row = genTableDao.updateGenTable(genTable);
|
|
||||||
if (row > 0) {
|
|
||||||
genTableColumnDao.updateGenTableColumn(genTable.getColumns());
|
|
||||||
if (genTable.getTplCategory().equals("rel")){
|
|
||||||
List<RelTable> relTables = relDao.relTableByTableId(genTable.getTableId());
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
relDao.deleteRelColumnByRelId(relTable.getId());
|
|
||||||
}
|
|
||||||
relDao.deleteRelTableByTableId(genTable.getTableId());
|
|
||||||
relTables = genTable.getRelTables();
|
|
||||||
for (int i = 0; i < relTables.size(); i++) {
|
|
||||||
RelTable relTable = relTables.get(i);
|
|
||||||
relTable.setTableAs(StringUtils.sqlFormat(relTable.getTableName()));
|
|
||||||
relTable.setRelAs(StringUtils.sqlFormat(relTable.getRelName()));
|
|
||||||
relTable.setRelClass(GenUtils.convertClassName(relTable.getRelName()));
|
|
||||||
relTable.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
relTable.setRelclass(StringUtils.uncapitalize(relTable.getRelClass()));
|
|
||||||
relTables.set(i,relTable);
|
|
||||||
}
|
|
||||||
if (relTables != null) {
|
|
||||||
relDao.insertRelTables(relTables);
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
relDao.insertRelColumns(relTable.getRelColumns());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CustomException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除业务对象
|
|
||||||
*
|
|
||||||
* @param tableIds 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ServerResult<Integer> deleteGenTableByIds(Long[] tableIds) {
|
|
||||||
try {
|
|
||||||
genTableDao.deleteGenTableByIds(tableIds);
|
|
||||||
genTableColumnDao.deleteGenTableColumnByIds(tableIds);
|
|
||||||
for (Long tableId : tableIds) {
|
|
||||||
List<RelTable> relTables = relDao.relTableByTableId(tableId);
|
|
||||||
if (relTables.size()>0){
|
|
||||||
relDao.deleteRelTableByTableId(tableId);
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
relDao.deleteRelColumnByRelId(relTable.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ServerResult<>(true);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入表结构
|
|
||||||
*
|
|
||||||
* @param tableList 导入表列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void importGenTable(List<GenTable> tableList) {
|
|
||||||
Long operName = SecurityUtils.getUserId();
|
|
||||||
try {
|
|
||||||
for (GenTable table : tableList) {
|
|
||||||
String tableName = table.getTableName();
|
|
||||||
GenUtils.initTable(table, operName);
|
|
||||||
int row = genTableDao.insertGenTable(table);
|
|
||||||
if (row > 0) {
|
|
||||||
// 保存列信息
|
|
||||||
List<GenTableColumn> genTableColumns = genTableColumnDao.selectDbTableColumnsByName(tableName);
|
|
||||||
for (GenTableColumn column : genTableColumns) {
|
|
||||||
GenUtils.initColumnField(column, table);
|
|
||||||
genTableColumnDao.insertGenTableColumn(column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("导入失败:" + e.getMessage(),e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览代码
|
|
||||||
*
|
|
||||||
* @param tableId 表编号
|
|
||||||
* @return 预览数据列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<String, String> previewCode(Long tableId) {
|
|
||||||
try {
|
|
||||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
|
||||||
// 查询表信息
|
|
||||||
GenTable table = genTableDao.selectGenTableById(tableId);
|
|
||||||
if (table.getTplCategory().equals(GenConstants.TPL_SUB)) {
|
|
||||||
// 设置主子表信息
|
|
||||||
setSubTable(table);
|
|
||||||
}
|
|
||||||
if (table.getTplCategory().equals(GenConstants.TPL_REL)) {
|
|
||||||
List<RelTable> relTables = relDao.relTableByTableId(tableId);
|
|
||||||
relTables = relTables.stream().sorted(Comparator.comparing(RelTable::getSort)).collect(Collectors.toList());
|
|
||||||
table.setRelTables(relTables);
|
|
||||||
}
|
|
||||||
// 设置主键列信息
|
|
||||||
setPkColumn(table);
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
|
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
|
||||||
|
|
||||||
// 获取模板列表
|
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
|
||||||
for (String template : templates) {
|
|
||||||
// 渲染模板
|
|
||||||
if (template.equals("vm/java/rel-entity.java.vm")){
|
|
||||||
List<RelTable> relTables = table.getRelTables();
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
List<RelColumn> relColumns = relTable.getRelColumns();
|
|
||||||
relColumns = relColumns.stream().sorted(Comparator.comparing(RelColumn::getSort)).collect(Collectors.toList());
|
|
||||||
relTable.setRelColumns(relColumns);
|
|
||||||
context.put("relTable",relTable);
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
Template temp = Velocity.getTemplate(template,Constants.UTF8);
|
|
||||||
temp.merge(context,stringWriter);
|
|
||||||
dataMap.put(VelocityUtils.getPreviewName(template,relTable.getRelClass()),stringWriter.toString());
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
|
||||||
tpl.merge(context, sw);
|
|
||||||
dataMap.put(VelocityUtils.getPreviewName(template,table.getClassName()), sw.toString());
|
|
||||||
}
|
|
||||||
return dataMap;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(下载方式)
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 数据
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public byte[] downloadCode(String tableName) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
||||||
generatorCode(tableName, zip);
|
|
||||||
IOUtils.closeQuietly(zip);
|
|
||||||
return outputStream.toByteArray();
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成代码(自定义路径)
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean generatorCode(String tableName) {
|
|
||||||
try {
|
|
||||||
// 查询表信息
|
|
||||||
GenTable table = genTableDao.selectGenTableByName(tableName);
|
|
||||||
// 设置主子表信息
|
|
||||||
setSubTable(table);
|
|
||||||
// 设置主键列信息
|
|
||||||
setPkColumn(table);
|
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
|
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
|
||||||
|
|
||||||
// 获取模板列表
|
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
|
||||||
for (String template : templates) {
|
|
||||||
if (!StringUtils.containsAny(template, "table.sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
|
|
||||||
// 渲染模板
|
|
||||||
if (template.equals("vm/java/rel-entity.java.vm")){
|
|
||||||
List<RelTable> relTables = table.getRelTables();
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
List<RelColumn> relColumns = relTable.getRelColumns();
|
|
||||||
relColumns = relColumns.stream().sorted(Comparator.comparing(RelColumn::getSort)).collect(Collectors.toList());
|
|
||||||
relTable.setRelColumns(relColumns);
|
|
||||||
context.put("relTable",relTable);
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
Template temp = Velocity.getTemplate(template,Constants.UTF8);
|
|
||||||
temp.merge(context,stringWriter);
|
|
||||||
try {
|
|
||||||
String path = getGenPath(table, template);
|
|
||||||
FileUtils.writeStringToFile(new File(path), stringWriter.toString(), CharsetKit.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("渲染模板失败,表名:" + table.getTableName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
|
||||||
tpl.merge(context, sw);
|
|
||||||
if (template.equals("vm/sql/table.sql.vm")) {
|
|
||||||
Boolean start = insertMenuItem(sw);
|
|
||||||
if (start) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
String path = getGenPath(table, template);
|
|
||||||
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("渲染模板失败,表名:" + table.getTableName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同步数据库
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void synchDb(String tableName) {
|
|
||||||
try {
|
|
||||||
GenTable table = genTableDao.selectGenTableByName(tableName);
|
|
||||||
List<GenTableColumn> tableColumns = table.getColumns();
|
|
||||||
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<GenTableColumn> dbTableColumns = genTableColumnDao.selectDbTableColumnsByName(tableName);
|
|
||||||
if (StringUtils.isEmpty(dbTableColumns)) {
|
|
||||||
throw new CustomException("同步数据失败,原表结构不存在");
|
|
||||||
}
|
|
||||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
|
||||||
|
|
||||||
dbTableColumns.forEach(column -> {
|
|
||||||
if (!tableColumnNames.contains(column.getColumnName())) {
|
|
||||||
GenUtils.initColumnField(column, table);
|
|
||||||
genTableColumnDao.insertGenTableColumn(column);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
|
||||||
if (StringUtils.isNotEmpty(delColumns)) {
|
|
||||||
genTableColumnDao.deleteGenTableColumns(delColumns);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量生成代码(下载方式)
|
|
||||||
*
|
|
||||||
* @param tableNames 表数组
|
|
||||||
* @return 数据
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public byte[] downloadCode(String[] tableNames) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
||||||
for (String tableName : tableNames) {
|
|
||||||
zip = generatorCode(tableName, zip);
|
|
||||||
// generatorCode(tableName, zip);
|
|
||||||
if (zip == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IOUtils.closeQuietly(zip);
|
|
||||||
return outputStream.toByteArray();
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
boolean insertMenuItem(StringWriter stringWriter) {
|
|
||||||
try {
|
|
||||||
String sql = stringWriter.toString();
|
|
||||||
int start = genTableDao.insertMenu(sql);
|
|
||||||
if (start > 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo 查询表信息并生成代码
|
|
||||||
*/
|
|
||||||
private ZipOutputStream generatorCode(String tableName, ZipOutputStream zip) {
|
|
||||||
// 查询表信息
|
|
||||||
GenTable table = genTableDao.selectGenTableByName(tableName);
|
|
||||||
// 设置主子表信息
|
|
||||||
setSubTable(table);
|
|
||||||
// 设置主键列信息
|
|
||||||
setPkColumn(table);
|
|
||||||
if (table.getTplCategory().equals(GenConstants.TPL_REL)) {
|
|
||||||
List<RelTable> relTables = relDao.relTableByTableId(table.getTableId());
|
|
||||||
relTables = relTables.stream().sorted(Comparator.comparing(RelTable::getSort)).collect(Collectors.toList());
|
|
||||||
table.setRelTables(relTables);
|
|
||||||
}
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
|
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
|
||||||
|
|
||||||
// 获取模板列表
|
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
|
||||||
for (String template : templates) {
|
|
||||||
|
|
||||||
// 渲染模板
|
|
||||||
if (template.equals("vm/java/rel-entity.java.vm")){
|
|
||||||
List<RelTable> relTables = table.getRelTables();
|
|
||||||
for (RelTable relTable : relTables) {
|
|
||||||
List<RelColumn> relColumns = relTable.getRelColumns();
|
|
||||||
relColumns = relColumns.stream().sorted(Comparator.comparing(RelColumn::getSort)).collect(Collectors.toList());
|
|
||||||
relTable.setRelColumns(relColumns);
|
|
||||||
context.put("relTable",relTable);
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
Template temp = Velocity.getTemplate(template,Constants.UTF8);
|
|
||||||
temp.merge(context,stringWriter);
|
|
||||||
try {
|
|
||||||
// 添加到zip
|
|
||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getRelFileName(template, table,relTable)));
|
|
||||||
IOUtils.write(stringWriter.toString(), zip, Constants.UTF8);
|
|
||||||
IOUtils.closeQuietly(stringWriter);
|
|
||||||
zip.flush();
|
|
||||||
zip.closeEntry();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("渲染模板失败,表名:" + table.getTableName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
|
||||||
tpl.merge(context, sw);
|
|
||||||
|
|
||||||
if (template.equals("vm/sql/table.sql.vm")) {
|
|
||||||
Boolean start = insertMenuItem(sw);
|
|
||||||
if (start) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// 添加到zip
|
|
||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
|
||||||
IOUtils.closeQuietly(sw);
|
|
||||||
zip.flush();
|
|
||||||
zip.closeEntry();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("渲染模板失败,表名:" + table.getTableName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return zip;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* todo 修改保存参数校验
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void validateEdit(GenTable genTable) {
|
|
||||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
|
||||||
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
|
|
||||||
throw new CustomException("树编码字段不能为空");
|
|
||||||
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
|
|
||||||
throw new CustomException("树父编码字段不能为空");
|
|
||||||
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
|
|
||||||
throw new CustomException("树名称字段不能为空");
|
|
||||||
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
|
|
||||||
if (StringUtils.isEmpty(genTable.getSubTableName())) {
|
|
||||||
throw new CustomException("关联子表的表名不能为空");
|
|
||||||
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
|
|
||||||
throw new CustomException("子表关联的外键名不能为空");
|
|
||||||
}
|
|
||||||
} else if (GenConstants.TPL_ASS.equals(genTable.getTplCategory())) {
|
|
||||||
// todo 规则校验
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置主键列信息
|
|
||||||
*
|
|
||||||
* @param table 业务表信息
|
|
||||||
*/
|
|
||||||
public void setPkColumn(GenTable table) {
|
|
||||||
for (GenTableColumn column : table.getColumns()) {
|
|
||||||
if (column.isPk()) {
|
|
||||||
table.setPkColumn(column);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isNull(table.getPkColumn())) {
|
|
||||||
table.setPkColumn(table.getColumns().get(0));
|
|
||||||
}
|
|
||||||
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
|
|
||||||
for (GenTableColumn column : table.getSubTable().getColumns()) {
|
|
||||||
if (column.isPk()) {
|
|
||||||
table.getSubTable().setPkColumn(column);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
|
|
||||||
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置主子表信息
|
|
||||||
*
|
|
||||||
* @param table 业务表信息
|
|
||||||
*/
|
|
||||||
public void setSubTable(GenTable table) {
|
|
||||||
String subTableName = table.getSubTableName();
|
|
||||||
if (StringUtils.isNotEmpty(subTableName)) {
|
|
||||||
table.setSubTable(genTableDao.selectGenTableByName(subTableName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置代码生成其他选项值
|
|
||||||
*
|
|
||||||
* @param genTable 设置后的生成对象
|
|
||||||
*/
|
|
||||||
public void setTableFromOptions(GenTable genTable) {
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
|
|
||||||
if (StringUtils.isNotNull(paramsObj)) {
|
|
||||||
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
|
||||||
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
|
||||||
String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
|
||||||
String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
|
||||||
|
|
||||||
genTable.setTreeCode(treeCode);
|
|
||||||
genTable.setTreeParentCode(treeParentCode);
|
|
||||||
genTable.setTreeName(treeName);
|
|
||||||
genTable.setParentMenuId(parentMenuId);
|
|
||||||
genTable.setParentMenuName(parentMenuName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取代码生成地址
|
|
||||||
*
|
|
||||||
* @param table 业务表信息
|
|
||||||
* @param template 模板文件路径
|
|
||||||
* @return 生成地址
|
|
||||||
*/
|
|
||||||
public static String getGenPath(GenTable table, String template) {
|
|
||||||
String genPath = table.getGenPath();
|
|
||||||
if (StringUtils.equals(genPath, "/")) {
|
|
||||||
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
|
||||||
}
|
|
||||||
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,364 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.Constants;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.ApiClassDao;
|
|
||||||
import com.ebts.generator.dao.GenTableDao;
|
|
||||||
import com.ebts.generator.dao.ModuleDao;
|
|
||||||
import com.ebts.generator.dto.InterTableDto;
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
import com.ebts.generator.utils.*;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.velocity.Template;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import org.apache.velocity.app.Velocity;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.ebts.generator.dao.InterTableDao;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
import com.ebts.generator.service.InterTableService;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口信息Service业务层处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-25
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class InterTableServiceImpl implements InterTableService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(InterTableServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private InterTableDao interTableDao;
|
|
||||||
@Autowired
|
|
||||||
private ApiClassDao apiclassDao;
|
|
||||||
@Autowired
|
|
||||||
private ModuleDao moduleDao;
|
|
||||||
@Autowired
|
|
||||||
private GenTableDao genTableDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 接口信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<InterTable> selectInterTableById(Long id) {
|
|
||||||
try {
|
|
||||||
InterTable interTable = interTableDao.selectInterTableById(id);
|
|
||||||
if (interTable != null) {
|
|
||||||
return new ServerResult<InterTable>(true, interTable);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<InterTable>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询接口信息列表
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 接口信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Map<String, Object>> selectInterTableList(InterTable interTable) {
|
|
||||||
try {
|
|
||||||
Map<String, Object> modeMap = new HashMap<String, Object>();
|
|
||||||
if (interTable.getType() == 1) {
|
|
||||||
Module module = moduleDao.selectModuleById(interTable.getmId());
|
|
||||||
modeMap.put("info", module);
|
|
||||||
} else if (interTable.getType() == 2) {
|
|
||||||
ApiClass apiclass = apiclassDao.selectApiclassById(interTable.getcId());
|
|
||||||
modeMap.put("info", apiclass);
|
|
||||||
}
|
|
||||||
List<InterTable> interTableList = interTableDao.selectInterTableList(interTable);
|
|
||||||
modeMap.put("rows", interTableList);
|
|
||||||
return new ServerResult<Map<String, Object>>(true, modeMap);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增接口信息
|
|
||||||
*
|
|
||||||
* @param interTable 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertInterTable(InterTable interTable) {
|
|
||||||
try {
|
|
||||||
interTable.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = interTableDao.insertInterTable(interTable);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口信息
|
|
||||||
*
|
|
||||||
* @param interTableDto 接口信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ServerResult<Integer> updateInterTable(InterTableDto interTableDto) {
|
|
||||||
try {
|
|
||||||
List<InterTable> interTables = interTableDto.getInterTables();
|
|
||||||
Integer renewal = 0;
|
|
||||||
if (interTableDto.getModule() == null) {
|
|
||||||
ApiClass apiclass = interTableDto.getApiclass();
|
|
||||||
renewal = apiclassDao.updateApiclass(apiclass);
|
|
||||||
interTableDao.deleteInterTableByClassId(apiclass.getId());
|
|
||||||
} else if (interTableDto.getApiclass() == null) {
|
|
||||||
Module module = interTableDto.getModule();
|
|
||||||
renewal = moduleDao.updateModule(module);
|
|
||||||
interTableDao.deleteInterTableByModuleId(module.getId());
|
|
||||||
}
|
|
||||||
Integer renewalTables = 0;
|
|
||||||
if (interTables.size() > 0) {
|
|
||||||
for (int i = 0; i < interTables.size(); i++) {
|
|
||||||
interTables.get(i).setCreateBy(SecurityUtils.getUserId());
|
|
||||||
}
|
|
||||||
renewalTables = interTableDao.insertInterTables(interTables);
|
|
||||||
}
|
|
||||||
if (renewalTables > 0 || renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewalTables);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除接口信息
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的接口信息ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteInterTableByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
Integer renewal = interTableDao.deleteInterTableByIds(ids);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口信息信息
|
|
||||||
*
|
|
||||||
* @param id 接口信息ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteInterTableById(Long id) {
|
|
||||||
try {
|
|
||||||
Integer renewal = interTableDao.deleteInterTableById(id);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<Map<String, String>> previewCodeCalss(Long cid) {
|
|
||||||
try {
|
|
||||||
Map<String, String> dataMap = new LinkedHashMap<String, String>();
|
|
||||||
ApiClass apiclass = interTableDao.selectInterTableClass(cid);
|
|
||||||
if (apiclass == null) {
|
|
||||||
return new ServerResult<Map<String, String>>(false, ReturnConstants.INTER_NULL);
|
|
||||||
}
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
VelocityContext context = InterTableUtils.prepareClassContext(apiclass);
|
|
||||||
Map<String, String> templates = InterTableUtils.getTemplateList(2);
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template template = Velocity.getTemplate(templates.get("java"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
dataMap.put(getJavaClassName(apiclass.getcName()), sw.toString());
|
|
||||||
|
|
||||||
sw = new StringWriter();
|
|
||||||
template = Velocity.getTemplate(templates.get("sql"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
dataMap.put(getSqlName(apiclass.getcName()), sw.toString());
|
|
||||||
return new ServerResult<Map<String, String>>(true, dataMap);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<Map<String, Object>> previewCodeMoudle(Long mid) {
|
|
||||||
try {
|
|
||||||
Map<String, Object> dataMap = new LinkedHashMap<String, Object>();
|
|
||||||
List<InterTable> interTableList = interTableDao.selectInterTableModule(mid);
|
|
||||||
if (interTableList.size() == 0) {
|
|
||||||
return new ServerResult<Map<String, Object>>(false, "该模块下接口为空,请先创建接口!");
|
|
||||||
}
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
List<VelocityContext> contextList = InterTableUtils.prepareMoudleContext(interTableList);
|
|
||||||
Map<String, String> templates = InterTableUtils.getTemplateList(2);
|
|
||||||
StringWriter sqlsw = new StringWriter();
|
|
||||||
Template sqltemplate = Velocity.getTemplate(templates.get("sql"), Constants.UTF8);
|
|
||||||
for (VelocityContext context : contextList) {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template template = Velocity.getTemplate(templates.get("java"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
sqltemplate.merge(context, sqlsw);
|
|
||||||
dataMap.put(getJavaClassName((String) context.get("ClassName")), sw.toString());
|
|
||||||
}
|
|
||||||
dataMap.put(getSqlName("module"), sqlsw.toString());
|
|
||||||
return new ServerResult<Map<String, Object>>(true, dataMap);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ServerResult<byte[]> generatorCodeClass(Long cid) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
||||||
ApiClass apiclass = interTableDao.selectInterTableClass(cid);
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
VelocityContext context = InterTableUtils.prepareClassContext(apiclass);
|
|
||||||
Map<String, String> templates = InterTableUtils.getTemplateList(2);
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template template = Velocity.getTemplate(templates.get("java"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
zip = genCode(getJavaClassName(apiclass.getcName()), zip, sw);
|
|
||||||
if (zip == null) {
|
|
||||||
return new ServerResult<byte[]>(false, "代码生成失败!");
|
|
||||||
}
|
|
||||||
sw = new StringWriter();
|
|
||||||
template = Velocity.getTemplate(templates.get("sql"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
|
|
||||||
zip = genCode(getSqlName(apiclass.getcName()), zip, sw);
|
|
||||||
if (zip == null) {
|
|
||||||
return new ServerResult<byte[]>(false, "代码生成失败!");
|
|
||||||
}
|
|
||||||
int start = genTableDao.insertMenu(sw.toString());
|
|
||||||
if (!(start > 0)) {
|
|
||||||
return new ServerResult<byte[]>(false, ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
IOUtils.closeQuietly(zip);
|
|
||||||
return new ServerResult<byte[]>(true, outputStream.toByteArray());
|
|
||||||
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
throw new EbtsException("代码生成失败!",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ServerResult<byte[]> generatorCodeMoudle(Long mid) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
||||||
List<InterTable> interTableList = interTableDao.selectInterTableModule(mid);
|
|
||||||
if (interTableList.size() == 0) {
|
|
||||||
return new ServerResult<byte[]>(false, "该模块下接口为空,请先创建接口!");
|
|
||||||
}
|
|
||||||
VelocityInitializer.initVelocity();
|
|
||||||
List<VelocityContext> contextList = InterTableUtils.prepareMoudleContext(interTableList);
|
|
||||||
Map<String, String> templates = InterTableUtils.getTemplateList(2);
|
|
||||||
StringWriter sqlsw = new StringWriter();
|
|
||||||
Template sqltemplate = Velocity.getTemplate(templates.get("sql"), Constants.UTF8);
|
|
||||||
for (VelocityContext context : contextList) {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
Template template = Velocity.getTemplate(templates.get("java"), Constants.UTF8);
|
|
||||||
template.merge(context, sw);
|
|
||||||
sqltemplate.merge(context, sqlsw);
|
|
||||||
zip = genCode(getJavaClassName((String) context.get("ClassName")), zip, sw);
|
|
||||||
}
|
|
||||||
zip = genCode(getSqlName("module"), zip, sqlsw);
|
|
||||||
if (zip != null) {
|
|
||||||
int start = genTableDao.insertMenu(sqlsw.toString());
|
|
||||||
if (!(start > 0)) {
|
|
||||||
return new ServerResult<byte[]>(false, ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IOUtils.closeQuietly(zip);
|
|
||||||
return new ServerResult<byte[]>(true, outputStream.toByteArray());
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
throw new EbtsException("代码生成失败!",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ZipOutputStream genCode(String className, ZipOutputStream zip, StringWriter sw) {
|
|
||||||
try {
|
|
||||||
zip.putNextEntry(new ZipEntry(className));
|
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
|
||||||
IOUtils.closeQuietly(sw);
|
|
||||||
zip.flush();
|
|
||||||
zip.closeEntry();
|
|
||||||
return zip;
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getJavaClassName(String cName) {
|
|
||||||
return InterTableUtils.getUpperCase(cName) + "Controller.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSqlName(String cName) {
|
|
||||||
return InterTableUtils.getUpperCase(cName) + ".sql";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,157 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.ModuleDao;
|
|
||||||
import com.ebts.generator.entity.Module;
|
|
||||||
import com.ebts.generator.service.ModuleService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模块管理Service业务层处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-24
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class ModuleServiceImpl implements ModuleService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(ModuleServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ModuleDao moduleDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询模块管理
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 模块管理
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Module> selectModuleById(Long id) {
|
|
||||||
try {
|
|
||||||
Module module = moduleDao.selectModuleById(id);
|
|
||||||
if (module != null) {
|
|
||||||
return new ServerResult<Module>(true, module);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Module>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询模块管理列表
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 模块管理
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Module>> selectModuleList(Module module) {
|
|
||||||
try {
|
|
||||||
List<Module> moduleList = moduleDao.selectModuleList(module);
|
|
||||||
if (moduleList.size() > 0) {
|
|
||||||
return new ServerResult<List<Module>>(true, moduleList);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<List<Module>>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertModule(Module module) {
|
|
||||||
try {
|
|
||||||
module.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = moduleDao.insertModule(module);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改模块管理
|
|
||||||
*
|
|
||||||
* @param module 模块管理
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> updateModule(Module module) {
|
|
||||||
try {
|
|
||||||
module.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = moduleDao.updateModule(module);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除模块管理
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的模块管理ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteModuleByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
Integer renewal = moduleDao.deleteModuleByIds(ids);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除模块管理信息
|
|
||||||
*
|
|
||||||
* @param id 模块管理ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteModuleById(Long id) {
|
|
||||||
try {
|
|
||||||
Integer renewal = moduleDao.deleteModuleById(id);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,200 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.entity.entity.Menu;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.QueryDao;
|
|
||||||
import com.ebts.generator.dao.UniQueryDao;
|
|
||||||
import com.ebts.generator.entity.UniCon;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
import com.ebts.generator.service.QueryService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author 18209
|
|
||||||
* Date 2021/1/30 18:54
|
|
||||||
* Version 1.0
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class QueryServiceImpl implements QueryService {
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(QueryServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private QueryDao queryDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UniQueryDao uniQueryDao;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询的基本信息和条件信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<UniQuery> selectQueryById(Long id) {
|
|
||||||
try {
|
|
||||||
UniQuery uniQuery = queryDao.selectQueryInfo(id);
|
|
||||||
if (uniQuery != null) {
|
|
||||||
return new ServerResult<>(true, uniQuery);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public ServerResult<Integer> Release(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
Integer isRelease = queryDao.Release(uniQuery.getId());
|
|
||||||
if ((isRelease == 1 && uniQuery.getIsRelease() == 2) || (isRelease == 2 && uniQuery.getIsRelease() == 1)) {
|
|
||||||
if (uniQuery.getIsRelease() == 1) {
|
|
||||||
UniQuery query = uniQueryDao.selectUniQueryById(uniQuery.getId());
|
|
||||||
Menu Menu = new Menu(query.getId(), query.getUqName(), SecurityUtils.getUserId());
|
|
||||||
Integer insermenu = queryDao.insertMenu(Menu);
|
|
||||||
if (insermenu == 0) {
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Integer deleteMenu = queryDao.deleteMenu("data/" + uniQuery.getId());
|
|
||||||
if (deleteMenu == 0) {
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Integer release = queryDao.changeRelease(uniQuery);
|
|
||||||
if (release > 0) {
|
|
||||||
return new ServerResult<>(true);
|
|
||||||
} else {
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.STATE_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新万能查询基本信息和条件
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public ServerResult<Integer> updateQueryInfo(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
int uqrenewal = uniQueryDao.updateUniQuery(uniQuery);
|
|
||||||
if (uqrenewal > 0) {
|
|
||||||
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
|
|
||||||
queryDao.deleteUniCon(uniQuery.getId());
|
|
||||||
Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons());
|
|
||||||
if (ucrenewal == 0) {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ServerResult<>(true);
|
|
||||||
}
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Map<String, Object>>> previewQuery(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
StringBuilder sql = new StringBuilder(uniQuery.getUqSql().toLowerCase());
|
|
||||||
List<UniCon> uniConList = uniQuery.getUniCons();
|
|
||||||
if (sql.toString().contains("insert") || sql.toString().contains("delete ") || sql.toString().contains("update ") ||
|
|
||||||
sql.toString().contains("drop ") || sql.toString().contains("database ") || sql.toString().contains("create ") ||
|
|
||||||
sql.toString().contains("view ") || sql.toString().contains("alter ") || sql.toString().contains("gen_")) {
|
|
||||||
return new ServerResult<>(false, "sql语句含有insert,delete,update,drop,database,view,alter,gen_等特殊字符!");
|
|
||||||
}
|
|
||||||
if (uniConList.size() > 0) {
|
|
||||||
sql.append(" where 1 = 1");
|
|
||||||
for (UniCon uniCon : uniConList) {
|
|
||||||
if (!uniCon.getUcMock().equals("") && uniCon.getUcMock() != null) {
|
|
||||||
sql.append(conversionPreview(uniCon));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
|
|
||||||
return new ServerResult<>(true, dataMap);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return new ServerResult<>(false, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览模式下拼接sql
|
|
||||||
*
|
|
||||||
* @param uniCon
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String conversionPreview(UniCon uniCon) {
|
|
||||||
String sql = " and ";
|
|
||||||
switch (uniCon.getUcCon()) {
|
|
||||||
case "EQ":
|
|
||||||
sql += uniCon.getUcKey() + " = '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "NE":
|
|
||||||
sql += uniCon.getUcKey() + " != '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "GT":
|
|
||||||
sql += uniCon.getUcKey() + " > '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "GTE":
|
|
||||||
sql += uniCon.getUcKey() + " >= '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "LT":
|
|
||||||
sql += uniCon.getUcKey() + " < '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "LTE":
|
|
||||||
sql += uniCon.getUcKey() + " <= '" + uniCon.getUcMock() + "'";
|
|
||||||
break;
|
|
||||||
case "LIKE":
|
|
||||||
sql += uniCon.getUcKey() + " like '%" + uniCon.getUcMock() + "%'";
|
|
||||||
break;
|
|
||||||
case "BETWEEN":
|
|
||||||
try {
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(uniCon.getUcMock());
|
|
||||||
if (uniCon.getUcType().equals("input")) {
|
|
||||||
Object begin = jsonObject.get("begin");
|
|
||||||
Object end = jsonObject.get("end");
|
|
||||||
if (begin != null && end != null) {
|
|
||||||
sql += uniCon.getUcKey() + " between '" + begin + "' AND '" + end + "'";
|
|
||||||
} else {
|
|
||||||
sql = "";
|
|
||||||
}
|
|
||||||
} else if (uniCon.getUcType().equals("datetime")) {
|
|
||||||
Object startTime = jsonObject.get("startTime");
|
|
||||||
Object endTime = jsonObject.get("endTime");
|
|
||||||
sql += uniCon.getUcKey() + " between '" + startTime + "' AND '" + endTime + "'";
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
sql = "";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return sql;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.DateUtils;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.RegularDao;
|
|
||||||
import com.ebts.generator.entity.Regular;
|
|
||||||
import com.ebts.generator.service.RegularService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验规则Service业务层处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-18
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class RegularServiceImpl implements RegularService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(RegularServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RegularDao regularDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 校验规则
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Regular> selectRegularById(Long id) {
|
|
||||||
try {
|
|
||||||
Regular regular = regularDao.selectRegularById(id);
|
|
||||||
if (regular != null) {
|
|
||||||
return new ServerResult<>(true, regular);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询校验规则列表
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 校验规则
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Regular>> selectRegularList(Regular regular) {
|
|
||||||
try {
|
|
||||||
List<Regular> regulars = regularDao.selectRegularList(regular);
|
|
||||||
if (regulars.size() > 0) {
|
|
||||||
return new ServerResult<>(true, regulars);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 查询校验规则下拉框列表
|
|
||||||
*
|
|
||||||
* @return 校验规则
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Regular>> selectRegularOption() {
|
|
||||||
try {
|
|
||||||
List<Regular> regulars = regularDao.selectRegularOption();
|
|
||||||
if (regulars.size() > 0) {
|
|
||||||
return new ServerResult<>(true, regulars);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertRegular(Regular regular) {
|
|
||||||
try {
|
|
||||||
regular.setCreateTime(DateUtils.getNowDate());
|
|
||||||
regular.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
int renewal = regularDao.insertRegular(regular);
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改校验规则
|
|
||||||
*
|
|
||||||
* @param regular 校验规则
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> updateRegular(Regular regular) {
|
|
||||||
try {
|
|
||||||
regular.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
regular.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
int renewal = regularDao.updateRegular(regular);
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除校验规则
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的校验规则ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteRegularByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
Integer renewals = regularDao.deleteRegularByIds(ids);
|
|
||||||
return new ServerResult<>(true, renewals);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除校验规则信息
|
|
||||||
*
|
|
||||||
* @param id 校验规则ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteRegularById(Long id) {
|
|
||||||
try {
|
|
||||||
Integer renewal = regularDao.deleteRegularById(id);
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.RelDao;
|
|
||||||
import com.ebts.generator.entity.RelColumn;
|
|
||||||
import com.ebts.generator.entity.RelTable;
|
|
||||||
import com.ebts.generator.service.RelService;
|
|
||||||
import com.ebts.generator.utils.RelUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/24 16:21
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class RelServiceImpl implements RelService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(RelServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RelDao relDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到数据库表信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Map<String, Object>>> tableInfos() {
|
|
||||||
try {
|
|
||||||
List<Map<String, Object>> dataMap = relDao.tableInfos();
|
|
||||||
return new ServerResult<>(dataMap);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("获取数据库表信息错误",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到关联边字段信息
|
|
||||||
*
|
|
||||||
* @param tableName 关联表表名
|
|
||||||
* @param relId 关联关系id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<RelColumn>> relColumns(String tableName, Long relId) {
|
|
||||||
try {
|
|
||||||
List<RelColumn> relColumns = relDao.selectTableColumn(tableName);
|
|
||||||
for (RelColumn relColumn : relColumns) {
|
|
||||||
RelUtil.initRelColumn(relColumn, relId);
|
|
||||||
}
|
|
||||||
return new ServerResult<>(relColumns);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("获取关联边字段信息错误",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<Map<String, Object>>> tableColumns(String tableName) {
|
|
||||||
try {
|
|
||||||
List<Map<String,Object>> columns = relDao.tableColumns(tableName);
|
|
||||||
return new ServerResult<>(columns);
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("获取字段信息错误",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<RelTable>> relTableByTableId(Long tableId) {
|
|
||||||
try {
|
|
||||||
List<RelTable> relTables = relDao.relTableByTableId(tableId);
|
|
||||||
return new ServerResult<>(relTables);
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("获取关联数据错误",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,228 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.QueryDao;
|
|
||||||
import com.ebts.generator.dao.RelationalMapDao;
|
|
||||||
import com.ebts.generator.dao.TopSearchTableDao;
|
|
||||||
import com.ebts.generator.dao.UniQueryDao;
|
|
||||||
import com.ebts.generator.dto.TopResult;
|
|
||||||
import com.ebts.generator.entity.*;
|
|
||||||
import com.ebts.generator.service.TopQueryService;
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @date: 2021/7/23 21:51
|
|
||||||
* @description:TopQueryServiceImpl
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class TopQueryServiceImpl implements TopQueryService {
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TopQueryServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TopSearchTableDao topSearchTableDao;
|
|
||||||
@Autowired
|
|
||||||
private RelationalMapDao relationalMapDao;
|
|
||||||
@Autowired
|
|
||||||
private QueryDao queryDao;
|
|
||||||
@Autowired
|
|
||||||
private UniQueryDao uniQueryDao;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> selectTopSearchTables() {
|
|
||||||
Map<String, Object> modeMap = new HashMap<>();
|
|
||||||
//采用原子式获取到forEach中的值,原子式能够允许其他线程进行尝试性的修改值
|
|
||||||
AtomicReference<String> roleIds = new AtomicReference<>("");
|
|
||||||
SecurityUtils.getLoginUser().getUser().getRoles().forEach(role->{
|
|
||||||
roleIds.updateAndGet(v -> v + role.getRoleId()+",");
|
|
||||||
});
|
|
||||||
modeMap.put("tables", topSearchTableDao.selectTopSearchTables(roleIds.get().substring(0,roleIds.get().length()-1).split(",")));
|
|
||||||
modeMap.put("relationalMap", relationalMapDao.selectRelationalMapList(new RelationalMap()));
|
|
||||||
return modeMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public ServerResult<TopResult> preview(String jsonData, String id) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
JSONObject graphData = JSON.parseObject(jsonData);
|
|
||||||
//将数据格式化为自定义的java类列表
|
|
||||||
List<TopEdge> topEdges = JSON.parseArray(graphData.getString("edges"), TopEdge.class);
|
|
||||||
List<TopNode> topNodes = JSON.parseArray(graphData.getString("nodes"), TopNode.class);
|
|
||||||
if (topNodes.size() == 0) {
|
|
||||||
return new ServerResult<>(false, "top图结构有误,请整理后在试");
|
|
||||||
}
|
|
||||||
//整理连线的关系
|
|
||||||
StringBuffer sql = new StringBuffer("");
|
|
||||||
StringBuilder selectSql = new StringBuilder("select ");
|
|
||||||
StringBuilder selectQuery = new StringBuilder(" where 1=1 ");
|
|
||||||
TopNode mainNode = null;
|
|
||||||
if (topNodes.size() > 1) {
|
|
||||||
for (int i = 0; i < topEdges.size(); i++) {
|
|
||||||
for (int j = 0; j < topEdges.size(); j++) {
|
|
||||||
if (i != j) {
|
|
||||||
TopEdge topEdgeJ = topEdges.get(j);
|
|
||||||
if (topEdges.get(i).getSource().equals(topEdgeJ.getTarget())) {
|
|
||||||
topEdges.get(i).setSourceEdge(topEdgeJ.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 解析出top图中与主表的连线,可能为多条
|
|
||||||
List<TopEdge> targets = new ArrayList<>();
|
|
||||||
for (int i = 0; i < topEdges.size(); i++) {
|
|
||||||
if (topEdges.get(i).getSourceEdge() == null) {
|
|
||||||
targets.add(topEdges.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mainNode = getNode(topNodes, targets.get(0).getSource());
|
|
||||||
// 组合查询字段信息
|
|
||||||
ParseSelectSQL(mainNode, topNodes, selectSql, selectQuery);
|
|
||||||
|
|
||||||
// 组合表与表之间得到关联关系sql
|
|
||||||
String relSql = "";
|
|
||||||
for (int i = 0; i < targets.size(); i++) {
|
|
||||||
relSql += getRelSql(topNodes, topEdges, targets.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
|
|
||||||
.append(mainNode.getRelTable()).append(relSql);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mainNode = topNodes.get(0);
|
|
||||||
selectSql.append(mainNode.getTableSQL());
|
|
||||||
selectQuery.append(mainNode.getQuerySql());
|
|
||||||
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
|
|
||||||
.append(mainNode.getRelTable());
|
|
||||||
}
|
|
||||||
UniQuery uniQuery = new UniQuery();
|
|
||||||
uniQuery.setId(Long.valueOf(id));
|
|
||||||
uniQuery.setUqSql(sql.toString());
|
|
||||||
uniQuery.setIsPreview(1);
|
|
||||||
List<UniCon> uniCons = uniQuery.getUniCons();
|
|
||||||
for (TopNode node : topNodes) {
|
|
||||||
JSONArray columns = node.getColumns();
|
|
||||||
for (int i = 0; i < columns.size(); i++) {
|
|
||||||
if (columns.getJSONObject(i).getInteger("isQuery") == 1) {
|
|
||||||
JSONObject column = columns.getJSONObject(i);
|
|
||||||
UniCon uniCon = new UniCon(uniQuery.getId(), column.getString("ucName"), node.getRelTable() + "." + column.getString("columnName"), column.getString("ucCon"), column.getString("ucType"), column.getInteger("type"));
|
|
||||||
uniCons.add(uniCon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int query = uniQueryDao.updateUniQuery(uniQuery);
|
|
||||||
if (query > 0) {
|
|
||||||
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
|
|
||||||
queryDao.deleteUniCon(uniQuery.getId());
|
|
||||||
queryDao.insertUniCon(uniCons);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sql.append(selectQuery);
|
|
||||||
PageHelper.startPage(1, 10, "");
|
|
||||||
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
|
|
||||||
TopResult topResult = new TopResult(dataMap,uniCons);
|
|
||||||
return new ServerResult<>(true, topResult);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return new ServerResult<>(false, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<String> online(Long id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseSelectSQL(TopNode mainNode, List<TopNode> topNodes, StringBuilder selectSql, StringBuilder selectQuery) {
|
|
||||||
selectSql.append(mainNode.getTableSQL());
|
|
||||||
selectQuery.append(mainNode.getQuerySql());
|
|
||||||
for (TopNode node : topNodes) {
|
|
||||||
if (node.getId().equals(mainNode.getId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (node.getTableSQL().trim().equals("")){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
selectSql.append(", ").append(node.getTableSQL());
|
|
||||||
selectQuery.append(node.getQuerySql());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TopNode getNode(List<TopNode> nodes, String id) {
|
|
||||||
for (int i = 0; i < nodes.size(); i++) {
|
|
||||||
if (nodes.get(i).getId().equals(id)) {
|
|
||||||
return nodes.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TopEdge> getEdgeListById(List<TopEdge> edges, String id) {
|
|
||||||
List<TopEdge> targetEdge = new ArrayList<>();
|
|
||||||
for (TopEdge edge : edges) {
|
|
||||||
if (edge.getSource().equals(id)) {
|
|
||||||
targetEdge.add(edge);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return targetEdge;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getRelSql(List<TopNode> nodes, List<TopEdge> edges, TopEdge edge) {
|
|
||||||
int i = 0;
|
|
||||||
// 定义sql 变量
|
|
||||||
StringBuffer sql = new StringBuffer("");
|
|
||||||
List<TopEdge> targetEdge;
|
|
||||||
while (true) {
|
|
||||||
// 获取到连线的两个表
|
|
||||||
TopNode source = getNode(nodes, edge.getSource());
|
|
||||||
TopNode target = getNode(nodes, edge.getTarget());
|
|
||||||
//进行sql拼接
|
|
||||||
sql.append(" ").append(edge.getAppConfig().getString("associated")).append(" join ")
|
|
||||||
.append(target.getTable()).append(" ").append(target.getRelTable()).append(" on ")
|
|
||||||
.append(target.getRelTable()).append(".").append(edge.getAppConfig()
|
|
||||||
.getString("relComment")).append(" = ").append(source.getRelTable())
|
|
||||||
.append(".").append(edge.getAppConfig().getString("tableComment"));
|
|
||||||
// 获取到target 连接表的连线
|
|
||||||
targetEdge = getEdgeListById(edges, edge.getTarget());
|
|
||||||
// 判断连线条数
|
|
||||||
if (targetEdge.size() == 1) {
|
|
||||||
edge = targetEdge.get(0);
|
|
||||||
} else if (targetEdge.size() > 1) {
|
|
||||||
//多条则进行递归解析
|
|
||||||
while (i < targetEdge.size()) {
|
|
||||||
sql.append(getRelSql(nodes, edges, targetEdge.get(i)));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
//没有则退出循环返回解析好的sql
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sql.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,320 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import com.ebts.generator.dao.RelationalMapDao;
|
|
||||||
import com.ebts.generator.dao.SearchTableRoleDao;
|
|
||||||
import com.ebts.generator.entity.RelationalMap;
|
|
||||||
import com.ebts.generator.entity.SearchTableRole;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import com.ebts.generator.entity.TopSearchColumn;
|
|
||||||
import com.ebts.generator.dao.TopSearchTableDao;
|
|
||||||
import com.ebts.generator.entity.TopSearchTable;
|
|
||||||
import com.ebts.generator.service.TopSearchTableService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* top万能查询主Service业务层处理
|
|
||||||
*
|
|
||||||
* @author clay
|
|
||||||
* @date 2021-07-20
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(TopSearchTableServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TopSearchTableDao topSearchTableDao;
|
|
||||||
@Autowired
|
|
||||||
private SearchTableRoleDao searchTableRoleDao;
|
|
||||||
@Autowired
|
|
||||||
private RelationalMapDao relationalMapDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return top万能查询主
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<TopSearchTable> selectTopSearchTableById(Long id) {
|
|
||||||
try {
|
|
||||||
TopSearchTable topSearchTable = topSearchTableDao.selectTopSearchTableById(id);
|
|
||||||
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole(id, null));
|
|
||||||
Long[] roles = new Long[roleList.size()];
|
|
||||||
for (int i = 0; i < roleList.size(); i++) {
|
|
||||||
roles[i] = roleList.get(i).getRoleId();
|
|
||||||
}
|
|
||||||
topSearchTable.setRoleIds(roles);
|
|
||||||
if (topSearchTable != null) {
|
|
||||||
return new ServerResult<>(true, topSearchTable);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询top万能查询主列表
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return top万能查询主
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable) {
|
|
||||||
try {
|
|
||||||
List<TopSearchTable> topSearchTableList = topSearchTableDao.selectTopSearchTableList(topSearchTable);
|
|
||||||
if (topSearchTableList.size() > 0) {
|
|
||||||
return new ServerResult<>(true, topSearchTableList);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<TopSearchTable>> selectTopSearchTableInfo() {
|
|
||||||
try {
|
|
||||||
List<TopSearchTable> tableList = topSearchTableDao.selectTopSearchTableInfo();
|
|
||||||
return new ServerResult<>(true, tableList);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TopSearchColumn> selectTableColumns(Long id) {
|
|
||||||
return topSearchTableDao.selectTableColumns(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable) {
|
|
||||||
try {
|
|
||||||
topSearchTable.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
int renewal = topSearchTableDao.insertTopSearchTable(topSearchTable);
|
|
||||||
if (insertTopSearchColumn(topSearchTable)) {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改top万能查询主
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable) {
|
|
||||||
try {
|
|
||||||
topSearchTable.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
topSearchTableDao.deleteTopSearchColumnBySearchTableId(topSearchTable.getId());
|
|
||||||
if (insertTopSearchColumn(topSearchTable)) {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
List<SearchTableRole> searchTableRoles = new ArrayList<>();
|
|
||||||
for (Long roleId : topSearchTable.getRoleIds()) {
|
|
||||||
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(), roleId));
|
|
||||||
}
|
|
||||||
relationalMapDao.deleteRelationalMapById(topSearchTable.getId());
|
|
||||||
List<RelationalMap> relationalMapList = topSearchTable.getRelationalMapList();
|
|
||||||
for (RelationalMap relationalMap : relationalMapList) {
|
|
||||||
relationalMap.setMainId(topSearchTable.getId());
|
|
||||||
}
|
|
||||||
insertRelationalMap(relationalMapList);
|
|
||||||
|
|
||||||
|
|
||||||
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
|
|
||||||
boolean renewalRole = inserTopTableRole(searchTableRoles);
|
|
||||||
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
|
|
||||||
if (renewal > 0 && renewalRole) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// void deleteSearchTableRoleById(Long id){
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// }catch (RuntimeException e){
|
|
||||||
// logger.error("无数据");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) {
|
|
||||||
try {
|
|
||||||
return topSearchTableDao.selectDbTableListByNames(tableNames);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> selectDbTableList(Map<String, Object> params) {
|
|
||||||
try {
|
|
||||||
return topSearchTableDao.selectDbTableList(params);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void importGenTable(List<TopSearchTable> tableList) {
|
|
||||||
try {
|
|
||||||
Long createBy = SecurityUtils.getUserId();
|
|
||||||
for (TopSearchTable table : tableList) {
|
|
||||||
String tableName = table.getTableName();
|
|
||||||
table.setCreateBy(createBy);
|
|
||||||
int row = topSearchTableDao.insertTopSearchTable(table);
|
|
||||||
if (row > 0) {
|
|
||||||
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
|
|
||||||
for (TopSearchColumn searchColumn : searchColumns) {
|
|
||||||
searchColumn.setSearchTableId(table.getId());
|
|
||||||
}
|
|
||||||
if (searchColumns.size() > 0) {
|
|
||||||
topSearchTableDao.batchTopSearchColumn(searchColumns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException("导入失败:" + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除top万能查询主
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
//批量删除子表数据
|
|
||||||
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
|
|
||||||
searchTableRoleDao.deleteSearchTableRoleByIds(ids);
|
|
||||||
Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除top万能查询主信息
|
|
||||||
*
|
|
||||||
* @param id top万能查询主ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> deleteTopSearchTableById(Long id) {
|
|
||||||
try {
|
|
||||||
//删除子表数据
|
|
||||||
topSearchTableDao.deleteTopSearchColumnBySearchTableId(id);
|
|
||||||
Integer renewal = topSearchTableDao.deleteTopSearchTableById(id);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean inserTopTableRole(List<SearchTableRole> roleList) {
|
|
||||||
if (StringUtils.isNotNull(roleList)) {
|
|
||||||
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean insertRelationalMap(List<RelationalMap> relationalMaps) {
|
|
||||||
if (StringUtils.isNotNull(relationalMaps) && relationalMaps.size() > 0) {
|
|
||||||
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增top万能查询字段信息
|
|
||||||
*
|
|
||||||
* @param topSearchTable top万能查询主对象
|
|
||||||
*/
|
|
||||||
public boolean insertTopSearchColumn(TopSearchTable topSearchTable) {
|
|
||||||
List<TopSearchColumn> topSearchColumnList = topSearchTable.getTopSearchColumnList();
|
|
||||||
Long id = topSearchTable.getId();
|
|
||||||
if (StringUtils.isNotNull(topSearchColumnList)) {
|
|
||||||
List<TopSearchColumn> list = new ArrayList<TopSearchColumn>();
|
|
||||||
for (TopSearchColumn topSearchColumn : topSearchColumnList) {
|
|
||||||
topSearchColumn.setSearchTableId(id);
|
|
||||||
list.add(topSearchColumn);
|
|
||||||
}
|
|
||||||
if (list.size() > 0) {
|
|
||||||
Integer renewal = topSearchTableDao.batchTopSearchColumn(list);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,166 +0,0 @@
|
||||||
package com.ebts.generator.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.ebts.generator.dao.UniQueryDao;
|
|
||||||
import com.ebts.generator.entity.UniQuery;
|
|
||||||
import com.ebts.generator.service.UniQueryService;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 万能查询Service业务层处理
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
* @date 2021-01-30
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class UniQueryServiceImpl implements UniQueryService {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(UniQueryServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UniQueryDao uniQueryDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 万能查询
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<UniQuery> selectUniQueryById(Long id) {
|
|
||||||
try {
|
|
||||||
UniQuery uniQuery = uniQueryDao.selectUniQueryById(id);
|
|
||||||
if (uniQuery != null) {
|
|
||||||
return new ServerResult<UniQuery>(true, uniQuery);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<UniQuery>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询万能查询列表
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 万能查询
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
List<UniQuery> uniQueryList = uniQueryDao.selectUniQueryList(uniQuery);
|
|
||||||
if (uniQueryList.size() > 0) {
|
|
||||||
return new ServerResult<List<UniQuery>>(true, uniQueryList);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<List<UniQuery>>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insertUniQuery(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
uniQuery.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = uniQueryDao.insertUniQuery(uniQuery);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改万能查询
|
|
||||||
*
|
|
||||||
* @param uniQuery 万能查询
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> updateUniQuery(UniQuery uniQuery) {
|
|
||||||
try {
|
|
||||||
uniQuery.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
Integer renewal = uniQueryDao.updateUniQuery(uniQuery);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<Integer>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除万能查询
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的万能查询ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public ServerResult<Integer> deleteUniQueryByIds(Long[] ids) {
|
|
||||||
try {
|
|
||||||
Integer renewal = uniQueryDao.deleteUniQueryByIds(ids);
|
|
||||||
for (Long id : ids) {
|
|
||||||
uniQueryDao.deleteUniQueryByUqId(id);
|
|
||||||
}
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
||||||
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除万能查询信息
|
|
||||||
*
|
|
||||||
* @param id 万能查询ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public ServerResult<Integer> deleteUniQueryById(Long id) {
|
|
||||||
try {
|
|
||||||
Integer renewal = uniQueryDao.deleteUniQueryById(id);
|
|
||||||
uniQueryDao.deleteUniQueryByUqId(id);
|
|
||||||
if (renewal > 0) {
|
|
||||||
return new ServerResult<>(true, renewal);
|
|
||||||
} else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import com.ebts.generator.dto.InterTableDto;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
|
|
||||||
public class GenInterApiUtils {
|
|
||||||
|
|
||||||
|
|
||||||
public static VelocityContext prepareContext(InterTableDto interTableDto) {
|
|
||||||
return new VelocityContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,222 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.utils.constant.GenConstants;
|
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
|
||||||
import com.ebts.generator.config.GenConfig;
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成器 工具类
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class GenUtils {
|
|
||||||
/**
|
|
||||||
* 初始化表信息
|
|
||||||
*/
|
|
||||||
public static void initTable(GenTable genTable, Long operName) {
|
|
||||||
genTable.setClassName(convertClassName(genTable.getTableName()));
|
|
||||||
genTable.setPackageName(GenConfig.getPackageName());
|
|
||||||
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
|
||||||
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
|
||||||
genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
|
||||||
genTable.setFunctionAuthor(GenConfig.getAuthor());
|
|
||||||
genTable.setCreateBy(operName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化列属性字段
|
|
||||||
*/
|
|
||||||
public static void initColumnField(GenTableColumn column, GenTable table) {
|
|
||||||
String dataType = getDbType(column.getColumnType());
|
|
||||||
String columnName = column.getColumnName();
|
|
||||||
column.setTableId(table.getTableId());
|
|
||||||
column.setCreateBy(table.getCreateBy());
|
|
||||||
// 设置java字段名
|
|
||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
|
||||||
// 设置默认类型
|
|
||||||
column.setJavaType(GenConstants.TYPE_STRING);
|
|
||||||
|
|
||||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
|
|
||||||
// 字符串长度超过500设置为文本域
|
|
||||||
Integer columnLength = getColumnLength(column.getColumnType());
|
|
||||||
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
|
||||||
column.setHtmlType(htmlType);
|
|
||||||
} else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
|
|
||||||
column.setJavaType(GenConstants.TYPE_DATE);
|
|
||||||
column.setHtmlType(GenConstants.HTML_DATETIME);
|
|
||||||
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
|
||||||
|
|
||||||
// 如果是浮点型 统一用BigDecimal
|
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
|
||||||
}
|
|
||||||
// 如果是整形
|
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
|
||||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
|
||||||
}
|
|
||||||
// 长整形
|
|
||||||
else {
|
|
||||||
column.setJavaType(GenConstants.TYPE_LONG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 插入字段(默认所有字段都需要插入)
|
|
||||||
column.setIsInsert(GenConstants.REQUIRE);
|
|
||||||
|
|
||||||
// 编辑字段
|
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
|
|
||||||
column.setIsEdit(GenConstants.REQUIRE);
|
|
||||||
}
|
|
||||||
// 列表字段
|
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
|
|
||||||
column.setIsList(GenConstants.REQUIRE);
|
|
||||||
}
|
|
||||||
// 查询字段
|
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
|
|
||||||
column.setIsQuery(GenConstants.REQUIRE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询字段类型
|
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
|
|
||||||
column.setQueryType(GenConstants.QUERY_LIKE);
|
|
||||||
}
|
|
||||||
// 状态字段设置单选框
|
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_RADIO);
|
|
||||||
}
|
|
||||||
// 类型&性别字段设置下拉框
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
|
||||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
|
||||||
}
|
|
||||||
// 图片字段设置图片上传控件
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
|
||||||
}
|
|
||||||
// 文件字段设置文件上传控件
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "file")) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
|
||||||
}
|
|
||||||
// 内容字段设置富文本控件
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
|
|
||||||
column.setHtmlType(GenConstants.HTML_EDITOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验数组是否包含指定值
|
|
||||||
*
|
|
||||||
* @param arr 数组
|
|
||||||
* @param targetValue 值
|
|
||||||
* @return 是否包含
|
|
||||||
*/
|
|
||||||
public static boolean arraysContains(String[] arr, String targetValue) {
|
|
||||||
return Arrays.asList(arr).contains(targetValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取模块名
|
|
||||||
*
|
|
||||||
* @param packageName 包名
|
|
||||||
* @return 模块名
|
|
||||||
*/
|
|
||||||
public static String getModuleName(String packageName) {
|
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
|
||||||
int nameLength = packageName.length();
|
|
||||||
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
|
||||||
return moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取业务名
|
|
||||||
*
|
|
||||||
* @param tableName 表名
|
|
||||||
* @return 业务名
|
|
||||||
*/
|
|
||||||
public static String getBusinessName(String tableName) {
|
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
|
||||||
int nameLength = tableName.length();
|
|
||||||
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
|
||||||
return businessName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表名转换成Java类名
|
|
||||||
*
|
|
||||||
* @param tableName 表名称
|
|
||||||
* @return 类名
|
|
||||||
*/
|
|
||||||
public static String convertClassName(String tableName) {
|
|
||||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
|
||||||
String tablePrefix = GenConfig.getTablePrefix();
|
|
||||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
|
|
||||||
String[] searchList = StringUtils.split(tablePrefix, ",");
|
|
||||||
tableName = replaceFirst(tableName, searchList);
|
|
||||||
}
|
|
||||||
return StringUtils.convertToCamelCase(tableName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量替换前缀
|
|
||||||
*
|
|
||||||
* @param replacementm 替换值
|
|
||||||
* @param searchList 替换列表
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String replaceFirst(String replacementm, String[] searchList) {
|
|
||||||
String text = replacementm;
|
|
||||||
for (String searchString : searchList) {
|
|
||||||
if (replacementm.startsWith(searchString)) {
|
|
||||||
text = replacementm.replaceFirst(searchString, "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关键字替换
|
|
||||||
*
|
|
||||||
* @param text 需要被替换的名字
|
|
||||||
* @return 替换后的名字
|
|
||||||
*/
|
|
||||||
public static String replaceText(String text) {
|
|
||||||
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据库类型字段
|
|
||||||
*
|
|
||||||
* @param columnType 列类型
|
|
||||||
* @return 截取后的列类型
|
|
||||||
*/
|
|
||||||
public static String getDbType(String columnType) {
|
|
||||||
if (StringUtils.indexOf(columnType, "(") > 0) {
|
|
||||||
return StringUtils.substringBefore(columnType, "(");
|
|
||||||
} else {
|
|
||||||
return columnType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字段长度
|
|
||||||
*
|
|
||||||
* @param columnType 列类型
|
|
||||||
* @return 截取后的列类型
|
|
||||||
*/
|
|
||||||
public static Integer getColumnLength(String columnType) {
|
|
||||||
if (StringUtils.indexOf(columnType, "(") > 0) {
|
|
||||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
|
||||||
return Integer.valueOf(length);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.DateUtils;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.generator.entity.ApiClass;
|
|
||||||
import com.ebts.generator.entity.InterTable;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 18209
|
|
||||||
*/
|
|
||||||
public class InterTableUtils {
|
|
||||||
public static List<VelocityContext> prepareMoudleContext(List<InterTable> interTableList) {
|
|
||||||
List<ApiClass> apiClassList = new ArrayList<ApiClass>();
|
|
||||||
for (int i = 0; i < interTableList.size(); i++) {
|
|
||||||
InterTable interTable = interTableList.get(i);
|
|
||||||
if (apiClassList.size() == 0) {
|
|
||||||
ApiClass apiclass = interTable.getApiclass();
|
|
||||||
List<InterTable> interTables = new ArrayList<InterTable>();
|
|
||||||
interTable.setApiclass(null);
|
|
||||||
interTables.add(interTable);
|
|
||||||
apiclass.setInterTables(interTables);
|
|
||||||
apiClassList.add(apiclass);
|
|
||||||
} else {
|
|
||||||
boolean start = true;
|
|
||||||
for (int j = 0; j < apiClassList.size(); j++) {
|
|
||||||
ApiClass api = apiClassList.get(j);
|
|
||||||
if (interTable.getcId() == api.getId()) {
|
|
||||||
List<InterTable> interTableList1 = api.getInterTables();
|
|
||||||
interTable.setApiclass(null);
|
|
||||||
interTableList1.add(interTable);
|
|
||||||
api.setInterTables(interTableList1);
|
|
||||||
apiClassList.set(j, api);
|
|
||||||
start = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (start) {
|
|
||||||
ApiClass apiclass = interTable.getApiclass();
|
|
||||||
List<InterTable> interTables = new ArrayList<InterTable>();
|
|
||||||
interTable.setApiclass(null);
|
|
||||||
interTables.add(interTable);
|
|
||||||
apiclass.setInterTables(interTables);
|
|
||||||
apiClassList.add(apiclass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<VelocityContext> contextList = new ArrayList<VelocityContext>();
|
|
||||||
for (int i = 0; i < apiClassList.size(); i++) {
|
|
||||||
ApiClass apiclass = apiClassList.get(i);
|
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
|
||||||
String module = apiclass.getInterTables().get(0).getmName();
|
|
||||||
String className = apiclass.getcName();
|
|
||||||
boolean permission = false;
|
|
||||||
for (InterTable interTable : apiclass.getInterTables()) {
|
|
||||||
if (interTable.getIsPermission().equals("1")) {
|
|
||||||
permission = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
velocityContext.put("createBy", SecurityUtils.getUserId());
|
|
||||||
velocityContext.put("Permission", permission);
|
|
||||||
velocityContext.put("packageName", "com.huhyun." + module);
|
|
||||||
velocityContext.put("prefix", module + ":" + getLowerCase(className));
|
|
||||||
velocityContext.put("ClassName", getUpperCase(className));
|
|
||||||
velocityContext.put("columns", apiclass.getInterTables());
|
|
||||||
velocityContext.put("reqMapping", "/" + module + "/" + getLowerCase(className));
|
|
||||||
velocityContext.put("functionName", apiclass.getcDescribe());
|
|
||||||
velocityContext.put("author", apiclass.getAuthor());
|
|
||||||
velocityContext.put("emali", apiclass.getEmail());
|
|
||||||
velocityContext.put("time", DateUtils.getTime());
|
|
||||||
contextList.add(velocityContext);
|
|
||||||
|
|
||||||
}
|
|
||||||
return contextList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VelocityContext prepareClassContext(ApiClass apiclass) {
|
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
|
||||||
boolean permission = false;
|
|
||||||
for (InterTable interTable : apiclass.getInterTables()) {
|
|
||||||
if (interTable.getIsPermission().equals("1")) {
|
|
||||||
permission = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
velocityContext.put("createBy", SecurityUtils.getUserId());
|
|
||||||
velocityContext.put("Permission", permission);
|
|
||||||
velocityContext.put("packageName", apiclass.getPackageName());
|
|
||||||
velocityContext.put("ClassName", getUpperCase(apiclass.getcName()));
|
|
||||||
velocityContext.put("columns", apiclass.getInterTables());
|
|
||||||
velocityContext.put("prefix", apiclass.getPrefix());
|
|
||||||
velocityContext.put("reqMapping", getClassUrl(apiclass.getcName(), apiclass.getModule().getmName()));
|
|
||||||
velocityContext.put("functionName", apiclass.getcDescribe());
|
|
||||||
velocityContext.put("author", apiclass.getAuthor());
|
|
||||||
velocityContext.put("emali", apiclass.getEmail());
|
|
||||||
velocityContext.put("time", DateUtils.getTime());
|
|
||||||
return velocityContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getClassUrl(String cname, String mname) {
|
|
||||||
return "/" + getLowerCase(mname) + "/" + getLowerCase(cname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, String> getTemplateList(Integer type) {
|
|
||||||
Map<String, String> templates = new HashMap<String, String>();
|
|
||||||
templates.put("java", "vm/java/class.java.vm");
|
|
||||||
templates.put("sql", "vm/sql/class.sql.vm");
|
|
||||||
return templates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUpperCase(String str) {
|
|
||||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLowerCase(String str) {
|
|
||||||
return str.toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.entity.RelColumn;
|
|
||||||
import com.ebts.generator.utils.constant.GenConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 18209
|
|
||||||
* @Date 2021/2/24 22:46
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
public class RelUtil {
|
|
||||||
|
|
||||||
|
|
||||||
public static void initRelColumn(RelColumn relColumn, Long relId) {
|
|
||||||
//获取数据库数据类型
|
|
||||||
String dataType = GenUtils.getDbType(relColumn.getColumnType());
|
|
||||||
//获取字段名称
|
|
||||||
String columnName = relColumn.getColumnName();
|
|
||||||
//设置tableid
|
|
||||||
relColumn.setRelId(relId);
|
|
||||||
//设置创建者id
|
|
||||||
relColumn.setCreateBy(1);
|
|
||||||
//转为设置java字段名称
|
|
||||||
relColumn.setJavaField(StringUtils.toCamelCase(columnName));
|
|
||||||
//默认类型
|
|
||||||
relColumn.setJavaType(GenConstants.TYPE_STRING);
|
|
||||||
//默认查询条件 精确查询
|
|
||||||
relColumn.setQueryType(GenConstants.QUERY_EQ);
|
|
||||||
|
|
||||||
if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || GenUtils.arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
|
|
||||||
//字符串长度超500设置htmlType为文本域
|
|
||||||
Integer columnLength = GenUtils.getColumnLength(relColumn.getColumnType());
|
|
||||||
String htmlType = columnLength >= 500 || GenUtils.arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
|
||||||
relColumn.setHtmlType(htmlType);
|
|
||||||
} else if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
|
|
||||||
relColumn.setJavaType(GenConstants.TYPE_DATE);
|
|
||||||
relColumn.setHtmlType(GenConstants.HTML_DATETIME);
|
|
||||||
} else if (GenUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
|
||||||
relColumn.setHtmlType(GenConstants.HTML_INPUT);
|
|
||||||
|
|
||||||
// 如果是浮点型 统一用BigDecimal
|
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(relColumn.getColumnType(), "(", ")"), ",");
|
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
|
||||||
relColumn.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
|
||||||
}
|
|
||||||
// 如果是整形
|
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
|
||||||
relColumn.setJavaType(GenConstants.TYPE_INTEGER);
|
|
||||||
}
|
|
||||||
// 长整形
|
|
||||||
else {
|
|
||||||
relColumn.setJavaType(GenConstants.TYPE_LONG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 列表字段
|
|
||||||
relColumn.setIsList(GenConstants.REQUIRE);
|
|
||||||
// 查询字段
|
|
||||||
relColumn.setIsQuery(GenConstants.NO_REQUIRE);
|
|
||||||
//初始化字典
|
|
||||||
relColumn.setDictType("");
|
|
||||||
// 查询字段类型
|
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
|
|
||||||
relColumn.setQueryType(GenConstants.QUERY_LIKE);
|
|
||||||
}
|
|
||||||
// 状态字段设置单选框
|
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
|
|
||||||
relColumn.setHtmlType(GenConstants.HTML_RADIO);
|
|
||||||
}
|
|
||||||
// 类型&性别字段设置下拉框
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
|
||||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
|
|
||||||
relColumn.setHtmlType(GenConstants.HTML_SELECT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.Constants;
|
|
||||||
import org.apache.velocity.app.Velocity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* VelocityEngine工厂
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class VelocityInitializer {
|
|
||||||
/**
|
|
||||||
* 初始化vm方法
|
|
||||||
*/
|
|
||||||
public static void initVelocity() {
|
|
||||||
Properties p = new Properties();
|
|
||||||
try {
|
|
||||||
// 加载classpath目录下的vm文件
|
|
||||||
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
|
||||||
// 定义字符集
|
|
||||||
p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8);
|
|
||||||
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
|
|
||||||
// 初始化Velocity引擎,指定配置Properties
|
|
||||||
Velocity.init(p);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,374 +0,0 @@
|
||||||
package com.ebts.generator.utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.DateUtils;
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import com.ebts.generator.entity.RelTable;
|
|
||||||
import com.ebts.generator.utils.constant.GenConstants;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ebts.generator.entity.GenTable;
|
|
||||||
import com.ebts.generator.entity.GenTableColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模板处理工具类
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class VelocityUtils {
|
|
||||||
/**
|
|
||||||
* 项目空间路径
|
|
||||||
*/
|
|
||||||
private static final String PROJECT_PATH = "main/java";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mybatis空间路径
|
|
||||||
*/
|
|
||||||
private static final String MYBATIS_PATH = "main/resources/mapper";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认上级菜单,系统工具
|
|
||||||
*/
|
|
||||||
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置模板变量信息
|
|
||||||
*
|
|
||||||
* @return 模板列表
|
|
||||||
*/
|
|
||||||
public static VelocityContext prepareContext(GenTable genTable) {
|
|
||||||
String moduleName = genTable.getModuleName();
|
|
||||||
String businessName = genTable.getBusinessName();
|
|
||||||
String packageName = genTable.getPackageName();
|
|
||||||
String tplCategory = genTable.getTplCategory();
|
|
||||||
String functionName = genTable.getFunctionName();
|
|
||||||
|
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
|
||||||
velocityContext.put("tplCategory", genTable.getTplCategory());
|
|
||||||
velocityContext.put("tableName", genTable.getTableName());
|
|
||||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
|
||||||
velocityContext.put("ClassName", genTable.getClassName());
|
|
||||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
|
||||||
velocityContext.put("moduleName", genTable.getModuleName());
|
|
||||||
velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
|
|
||||||
velocityContext.put("businessName", genTable.getBusinessName());
|
|
||||||
velocityContext.put("basePackage", getPackagePrefix(packageName));
|
|
||||||
velocityContext.put("packageName", packageName);
|
|
||||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
|
||||||
velocityContext.put("datetime", DateUtils.getDate());
|
|
||||||
velocityContext.put("createBy", SecurityUtils.getUserId());
|
|
||||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
|
||||||
velocityContext.put("importList", getImportList(genTable));
|
|
||||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
|
||||||
velocityContext.put("columns", genTable.getColumns());
|
|
||||||
velocityContext.put("table", genTable);
|
|
||||||
setMenuVelocityContext(velocityContext, genTable);
|
|
||||||
if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
|
||||||
setTreeVelocityContext(velocityContext, genTable);
|
|
||||||
}
|
|
||||||
if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
|
||||||
setSubVelocityContext(velocityContext, genTable);
|
|
||||||
}
|
|
||||||
if (GenConstants.TPL_REL.equals(tplCategory)) {
|
|
||||||
setRelVelocityContext(velocityContext, genTable);
|
|
||||||
}
|
|
||||||
return velocityContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setRelVelocityContext(VelocityContext context, GenTable genTable) {
|
|
||||||
context.put("relTables", genTable.getRelTables());
|
|
||||||
context.put("tableMapping", StringUtils.sqlFormat(genTable.getTableName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
|
|
||||||
String options = genTable.getOptions();
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
|
||||||
String parentMenuId = getParentMenuId(paramsObj);
|
|
||||||
context.put("parentMenuId", parentMenuId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
|
|
||||||
String options = genTable.getOptions();
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
|
||||||
String treeCode = getTreecode(paramsObj);
|
|
||||||
String treeParentCode = getTreeParentCode(paramsObj);
|
|
||||||
String treeName = getTreeName(paramsObj);
|
|
||||||
|
|
||||||
context.put("treeCode", treeCode);
|
|
||||||
context.put("treeParentCode", treeParentCode);
|
|
||||||
context.put("treeName", treeName);
|
|
||||||
context.put("expandColumn", getExpandColumn(genTable));
|
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
|
|
||||||
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
|
||||||
}
|
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
|
|
||||||
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
|
|
||||||
GenTable subTable = genTable.getSubTable();
|
|
||||||
String subTableName = genTable.getSubTableName();
|
|
||||||
String subTableFkName = genTable.getSubTableFkName();
|
|
||||||
String subClassName = genTable.getSubTable().getClassName();
|
|
||||||
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
|
||||||
|
|
||||||
context.put("tableMapping", StringUtils.sqlFormat(genTable.getTableName()));
|
|
||||||
context.put("subMapping", StringUtils.sqlFormat(subTable.getTableName()));
|
|
||||||
context.put("subTable", subTable);
|
|
||||||
context.put("subTableName", subTableName);
|
|
||||||
context.put("subTableFkName", subTableFkName);
|
|
||||||
context.put("subTableFkClassName", subTableFkClassName);
|
|
||||||
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
|
||||||
context.put("subClassName", subClassName);
|
|
||||||
context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
|
||||||
context.put("subImportList", getImportList(genTable.getSubTable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取模板信息
|
|
||||||
*
|
|
||||||
* @return 模板列表
|
|
||||||
*/
|
|
||||||
public static List<String> getTemplateList(String tplCategory) {
|
|
||||||
List<String> templates = new ArrayList<String>();
|
|
||||||
templates.add("vm/java/entity.java.vm");
|
|
||||||
templates.add("vm/java/dao.java.vm");
|
|
||||||
templates.add("vm/java/service.java.vm");
|
|
||||||
templates.add("vm/java/serviceImpl.java.vm");
|
|
||||||
templates.add("vm/java/controller.java.vm");
|
|
||||||
templates.add("vm/xml/mapper.xml.vm");
|
|
||||||
templates.add("vm/sql/table.sql.vm");
|
|
||||||
templates.add("vm/js/api.js.vm");
|
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
|
||||||
templates.add("vm/vue/index.vue.vm");
|
|
||||||
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
|
||||||
templates.add("vm/vue/index-tree.vue.vm");
|
|
||||||
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
|
||||||
templates.add("vm/vue/index.vue.vm");
|
|
||||||
templates.add("vm/java/sub-entity.java.vm");
|
|
||||||
} else if (GenConstants.TPL_REL.equals(tplCategory)) {
|
|
||||||
templates.add("vm/vue/index.vue.vm");
|
|
||||||
templates.add("vm/java/rel-entity.java.vm");
|
|
||||||
}
|
|
||||||
return templates;
|
|
||||||
}
|
|
||||||
public static String getRelFileName(String template, GenTable genTable, RelTable relTable){
|
|
||||||
|
|
||||||
// 文件名称
|
|
||||||
String fileName = "";
|
|
||||||
// 包路径
|
|
||||||
String packageName = genTable.getPackageName();
|
|
||||||
// 模块名
|
|
||||||
String moduleName = genTable.getModuleName();
|
|
||||||
|
|
||||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
|
||||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, relTable.getRelClass());
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPreviewName(String template, String ClassName) {
|
|
||||||
String fileName = "";
|
|
||||||
if (template.contains("entity.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}.java", ClassName);
|
|
||||||
}
|
|
||||||
if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, ClassName)) {
|
|
||||||
fileName = StringUtils.format("{}.java", ClassName);
|
|
||||||
} else if (template.contains("rel-entity.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}.java", ClassName);
|
|
||||||
} else if (template.contains("dao.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}Dao.java", ClassName);
|
|
||||||
} else if (template.contains("service.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}Service.java", ClassName);
|
|
||||||
} else if (template.contains("serviceImpl.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}ServiceImpl.java", ClassName);
|
|
||||||
} else if (template.contains("controller.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}Controller.java",ClassName);
|
|
||||||
} else if (template.contains("mapper.xml.vm")) {
|
|
||||||
fileName = StringUtils.format("{}Mapper.xml",ClassName);
|
|
||||||
} else if (template.contains("table.sql.vm")) {
|
|
||||||
fileName = ClassName + "menu.sql";
|
|
||||||
} else if (template.contains("api.js.vm")) {
|
|
||||||
fileName = StringUtils.format("{}.js", StringUtils.toLoad(ClassName));
|
|
||||||
} else if (template.contains("index.vue.vm")) {
|
|
||||||
fileName = "index.vue";
|
|
||||||
} else if (template.contains("index-tree.vue.vm")) {
|
|
||||||
fileName = "index.vue";
|
|
||||||
}
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件名
|
|
||||||
*/
|
|
||||||
public static String getFileName(String template, GenTable genTable) {
|
|
||||||
// 文件名称
|
|
||||||
String fileName = "";
|
|
||||||
// 包路径
|
|
||||||
String packageName = genTable.getPackageName();
|
|
||||||
// 模块名
|
|
||||||
String moduleName = genTable.getModuleName();
|
|
||||||
// 大写类名
|
|
||||||
String className = genTable.getClassName();
|
|
||||||
// 业务名称
|
|
||||||
String businessName = genTable.getBusinessName();
|
|
||||||
|
|
||||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
|
||||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
|
||||||
String vuePath = "vue";
|
|
||||||
|
|
||||||
if (template.contains("entity.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, className);
|
|
||||||
}
|
|
||||||
if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
|
|
||||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName());
|
|
||||||
} else if (template.contains("ass-entity.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, GenUtils.convertClassName(genTable.getAssTableName()));
|
|
||||||
} else if (template.contains("dao.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className);
|
|
||||||
} else if (template.contains("service.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className);
|
|
||||||
} else if (template.contains("serviceImpl.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
|
||||||
} else if (template.contains("controller.java.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
|
||||||
} else if (template.contains("mapper.xml.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
|
||||||
} else if (template.contains("table.sql.vm")) {
|
|
||||||
fileName = businessName + "menu.sql";
|
|
||||||
} else if (template.contains("api.js.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
|
||||||
} else if (template.contains("index.vue.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
|
||||||
} else if (template.contains("index-tree.vue.vm")) {
|
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
|
||||||
}
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取包前缀
|
|
||||||
*
|
|
||||||
* @param packageName 包名称
|
|
||||||
* @return 包前缀名称
|
|
||||||
*/
|
|
||||||
public static String getPackagePrefix(String packageName) {
|
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
|
||||||
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
|
||||||
return basePackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据列类型获取导入包
|
|
||||||
*
|
|
||||||
* @param genTable 业务表对象
|
|
||||||
* @return 返回需要导入的包列表
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getImportList(GenTable genTable) {
|
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
|
||||||
GenTable subGenTable = genTable.getSubTable();
|
|
||||||
HashSet<String> importList = new HashSet<String>();
|
|
||||||
if (StringUtils.isNotNull(subGenTable)) {
|
|
||||||
importList.add("java.util.List");
|
|
||||||
}
|
|
||||||
for (GenTableColumn column : columns) {
|
|
||||||
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
|
|
||||||
importList.add("java.util.Date");
|
|
||||||
importList.add("com.fasterxml.jackson.annotation.JsonFormat");
|
|
||||||
} else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
|
|
||||||
importList.add("java.math.BigDecimal");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return importList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取权限前缀
|
|
||||||
*
|
|
||||||
* @param moduleName 模块名称
|
|
||||||
* @param businessName 业务名称
|
|
||||||
* @return 返回权限前缀
|
|
||||||
*/
|
|
||||||
public static String getPermissionPrefix(String moduleName, String businessName) {
|
|
||||||
return StringUtils.format("{}:{}", moduleName, businessName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取上级菜单ID字段
|
|
||||||
*
|
|
||||||
* @param paramsObj 生成其他选项
|
|
||||||
* @return 上级菜单ID字段
|
|
||||||
*/
|
|
||||||
public static String getParentMenuId(JSONObject paramsObj) {
|
|
||||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
|
|
||||||
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
|
||||||
}
|
|
||||||
return DEFAULT_PARENT_MENU_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取树编码
|
|
||||||
*
|
|
||||||
* @param paramsObj 生成其他选项
|
|
||||||
* @return 树编码
|
|
||||||
*/
|
|
||||||
public static String getTreecode(JSONObject paramsObj) {
|
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
|
||||||
}
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取树父编码
|
|
||||||
*
|
|
||||||
* @param paramsObj 生成其他选项
|
|
||||||
* @return 树父编码
|
|
||||||
*/
|
|
||||||
public static String getTreeParentCode(JSONObject paramsObj) {
|
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
|
||||||
}
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取树名称
|
|
||||||
*
|
|
||||||
* @param paramsObj 生成其他选项
|
|
||||||
* @return 树名称
|
|
||||||
*/
|
|
||||||
public static String getTreeName(JSONObject paramsObj) {
|
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
|
||||||
}
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取需要在哪一列上面显示展开按钮
|
|
||||||
*
|
|
||||||
* @param genTable 业务表对象
|
|
||||||
* @return 展开按钮列序号
|
|
||||||
*/
|
|
||||||
public static int getExpandColumn(GenTable genTable) {
|
|
||||||
String options = genTable.getOptions();
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
|
||||||
int num = 0;
|
|
||||||
for (GenTableColumn column : genTable.getColumns()) {
|
|
||||||
if (column.isList()) {
|
|
||||||
num++;
|
|
||||||
String columnName = column.getColumnName();
|
|
||||||
if (columnName.equals(treeName)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,199 +0,0 @@
|
||||||
package com.ebts.generator.utils.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成通用常量
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class GenConstants {
|
|
||||||
/**
|
|
||||||
* 单表(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_CRUD = "crud";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树表(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_TREE = "tree";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主子表(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_SUB = "sub";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联查询(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_ASS = "ass";
|
|
||||||
/**
|
|
||||||
* 多表关联查询(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_REL = "rel";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树编码字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_CODE = "treeCode";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树父编码字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树名称字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_NAME = "treeName";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单ID字段
|
|
||||||
*/
|
|
||||||
public static final String PARENT_MENU_ID = "parentMenuId";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单名称字段
|
|
||||||
*/
|
|
||||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库字符串类型
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2", "tinytext", "text",
|
|
||||||
"mediumtext", "longtext"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库文本类型
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库时间类型
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库数字类型
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
|
|
||||||
"bit", "bigint", "float", "float", "double", "decimal"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面不需要编辑字段
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面不需要显示的列表字段
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by",
|
|
||||||
"update_time"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面不需要查询字段
|
|
||||||
*/
|
|
||||||
public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
|
|
||||||
"update_time", "remark"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entity基类字段
|
|
||||||
*/
|
|
||||||
public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tree基类字段
|
|
||||||
*/
|
|
||||||
public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文本框
|
|
||||||
*/
|
|
||||||
public static final String HTML_INPUT = "input";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文本域
|
|
||||||
*/
|
|
||||||
public static final String HTML_TEXTAREA = "textarea";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下拉框
|
|
||||||
*/
|
|
||||||
public static final String HTML_SELECT = "select";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单选框
|
|
||||||
*/
|
|
||||||
public static final String HTML_RADIO = "radio";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复选框
|
|
||||||
*/
|
|
||||||
public static final String HTML_CHECKBOX = "checkbox";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_DATETIME = "datetime";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 图片上传控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 富文本控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_EDITOR = "editor";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_STRING = "String";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 整型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_INTEGER = "Integer";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 长整型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_LONG = "Long";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 浮点型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_DOUBLE = "Double";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高精度计算类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 时间类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_DATE = "Date";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模糊查询
|
|
||||||
*/
|
|
||||||
public static final String QUERY_LIKE = "LIKE";
|
|
||||||
/**
|
|
||||||
* 精确查询
|
|
||||||
*/
|
|
||||||
public static final String QUERY_EQ = "EQ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要
|
|
||||||
*/
|
|
||||||
public static final String REQUIRE = "1";
|
|
||||||
/**
|
|
||||||
* 不需要
|
|
||||||
*/
|
|
||||||
public static final String NO_REQUIRE = "0";
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package com.ebts.generator.utils.sql;
|
|
||||||
|
|
||||||
import com.ebts.common.exception.BaseException;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sql操作工具类
|
|
||||||
*
|
|
||||||
* @author binlin
|
|
||||||
*/
|
|
||||||
public class GenSqlUtil {
|
|
||||||
/**
|
|
||||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
|
||||||
*/
|
|
||||||
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查字符,防止注入绕过
|
|
||||||
*/
|
|
||||||
public static String escapeOrderBySql(String value) {
|
|
||||||
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) {
|
|
||||||
throw new BaseException("参数不符合规范,不能进行查询");
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证 order by 语法是否符合规范
|
|
||||||
*/
|
|
||||||
public static boolean isValidOrderBySql(String value) {
|
|
||||||
return value.matches(SQL_PATTERN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.ApiClassDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.ApiClass" id="ApiclassResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mId" column="m_id" />
|
|
||||||
<result property="cName" column="c_name" />
|
|
||||||
<result property="cDescribe" column="c_describe" />
|
|
||||||
<result property="packageName" column="package_name" />
|
|
||||||
<result property="author" column="author" />
|
|
||||||
<result property="email" column="email" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<result property="prefix" column="prefix" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="ApiclassModuleResult" type="com.ebts.generator.entity.ApiClass" extends="ApiclassResult">
|
|
||||||
<collection property="module" notNullColumn="id" javaType="com.ebts.generator.entity.Module" resultMap="ModuleResult" />
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.Module" id="ModuleResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mName" column="m_name" />
|
|
||||||
<result property="mDescribe" column="m_describe" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectApiclassVo">
|
|
||||||
select id, m_id, c_name, c_describe, package_name, author, email, remark,prefix, create_time, create_by, update_time, update_by from gen_api_class
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectApiclassList" parameterType="Apiclass" resultMap="ApiclassModuleResult">
|
|
||||||
select a.id,a.m_id,a.c_name,a.c_describe,a.package_name,a.author,a.email,a.prefix,a.remark,a.create_by,a.create_time,
|
|
||||||
a.update_time,a.update_by,m.id,m.m_name,m.m_describe
|
|
||||||
from gen_api_class a
|
|
||||||
left join gen_module m on a.m_id = m.id
|
|
||||||
<where>
|
|
||||||
<if test="mId != null "> and a.m_id = #{mId}</if>
|
|
||||||
<if test="cName != null and cName != ''"> and a.c_name like concat('%', #{cName}, '%')</if>
|
|
||||||
<if test="author != null and author != ''"> and a.author like concat('%', #{author}, '%')</if>
|
|
||||||
<if test="email != null and email != ''"> and a.email like concat('%', #{email}, '%')</if>
|
|
||||||
<if test="cDescribe != null and cDescribe != ''"> and a.c_describe like concat('%', #{cDescribe}, '%')</if>
|
|
||||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and a.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectApiclassById" parameterType="Long" resultMap="ApiclassResult">
|
|
||||||
<include refid="selectApiclassVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertApiclass" parameterType="Apiclass" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_api_class
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mId != null">m_id,</if>
|
|
||||||
<if test="cName != null and cName != ''">c_name,</if>
|
|
||||||
<if test="cDescribe != null and cDescribe != ''">c_describe,</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name,</if>
|
|
||||||
<if test="author != null and author != ''">author,</if>
|
|
||||||
<if test="email != null and email != ''">email,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="prefix != null and prefix != ''">prefix,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mId != null">#{mId},</if>
|
|
||||||
<if test="cName != null and cName != ''">#{cName},</if>
|
|
||||||
<if test="cDescribe != null and cDescribe != ''">#{cDescribe},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
|
||||||
<if test="author != null and author != ''">#{author},</if>
|
|
||||||
<if test="email != null and email != ''">#{email},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="prefix != null and prefix != ''">#{prefix},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateApiclass" parameterType="Apiclass">
|
|
||||||
update gen_api_class
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="mId != null">m_id = #{mId},</if>
|
|
||||||
<if test="cName != null and cName != ''">c_name = #{cName},</if>
|
|
||||||
<if test="cDescribe != null and cDescribe != ''">c_describe = #{cDescribe},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
|
||||||
<if test="author != null and author != ''">author = #{author},</if>
|
|
||||||
<if test="email != null and email != ''">email = #{email},</if>
|
|
||||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
|
||||||
<if test="prefix != null and prefix != ''">prefix = #{prefix},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteApiclassById" parameterType="Long">
|
|
||||||
delete from gen_api_class where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteApiclassByIds" parameterType="String">
|
|
||||||
delete from gen_api_class where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.GenTableColumnDao">
|
|
||||||
|
|
||||||
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
|
||||||
<id property="columnId" column="column_id" />
|
|
||||||
<result property="tableId" column="table_id" />
|
|
||||||
<result property="columnName" column="column_name" />
|
|
||||||
<result property="columnComment" column="column_comment" />
|
|
||||||
<result property="columnType" column="column_type" />
|
|
||||||
<result property="javaType" column="java_type" />
|
|
||||||
<result property="javaField" column="java_field" />
|
|
||||||
<result property="isPk" column="is_pk" />
|
|
||||||
<result property="isIncrement" column="is_increment" />
|
|
||||||
<result property="isInsert" column="is_insert" />
|
|
||||||
<result property="isEdit" column="is_edit" />
|
|
||||||
<result property="isList" column="is_list" />
|
|
||||||
<result property="isQuery" column="is_query" />
|
|
||||||
<result property="isRegular" column="is_regular" />
|
|
||||||
<result property="queryType" column="query_type" />
|
|
||||||
<result property="htmlType" column="html_type" />
|
|
||||||
<result property="dictType" column="dict_type" />
|
|
||||||
<result property="sort" column="sort" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectGenTableColumnVo">
|
|
||||||
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time,is_regular from gen_table_column
|
|
||||||
</sql>
|
|
||||||
<!--todo 获取数据库每行的配置信息-->
|
|
||||||
<select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
|
|
||||||
<include refid="selectGenTableColumnVo"/>
|
|
||||||
where table_id = #{tableId}
|
|
||||||
order by sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
|
||||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
|
||||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
|
||||||
order by ordinal_position
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
|
||||||
insert into gen_table_column (
|
|
||||||
<if test="tableId != null and tableId != ''">table_id,</if>
|
|
||||||
<if test="columnName != null and columnName != ''">column_name,</if>
|
|
||||||
<if test="columnComment != null and columnComment != ''">column_comment,</if>
|
|
||||||
<if test="columnType != null and columnType != ''">column_type,</if>
|
|
||||||
<if test="javaType != null and javaType != ''">java_type,</if>
|
|
||||||
<if test="javaField != null and javaField != ''">java_field,</if>
|
|
||||||
<if test="isPk != null and isPk != ''">is_pk,</if>
|
|
||||||
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
|
|
||||||
<if test="isRequired != null and isRequired != ''">is_required,</if>
|
|
||||||
<if test="isInsert != null and isInsert != ''">is_insert,</if>
|
|
||||||
<if test="isEdit != null and isEdit != ''">is_edit,</if>
|
|
||||||
<if test="isList != null and isList != ''">is_list,</if>
|
|
||||||
<if test="isQuery != null and isQuery != ''">is_query,</if>
|
|
||||||
<if test="queryType != null and queryType != ''">query_type,</if>
|
|
||||||
<if test="htmlType != null and htmlType != ''">html_type,</if>
|
|
||||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
|
||||||
<if test="sort != null">sort,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="tableId != null and tableId != ''">#{tableId},</if>
|
|
||||||
<if test="columnName != null and columnName != ''">#{columnName},</if>
|
|
||||||
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
|
|
||||||
<if test="columnType != null and columnType != ''">#{columnType},</if>
|
|
||||||
<if test="javaType != null and javaType != ''">#{javaType},</if>
|
|
||||||
<if test="javaField != null and javaField != ''">#{javaField},</if>
|
|
||||||
<if test="isPk != null and isPk != ''">#{isPk},</if>
|
|
||||||
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
|
|
||||||
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
|
|
||||||
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
|
|
||||||
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
|
|
||||||
<if test="isList != null and isList != ''">#{isList},</if>
|
|
||||||
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
|
|
||||||
<if test="queryType != null and queryType != ''">#{queryType},</if>
|
|
||||||
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
|
|
||||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
|
||||||
<if test="sort != null">#{sort},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!--todo x修改行配置信息-->
|
|
||||||
<update id="updateGenTableColumn" parameterType="GenTableColumn">
|
|
||||||
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
|
||||||
update gen_table_column
|
|
||||||
<set>
|
|
||||||
column_comment = #{item.columnComment},
|
|
||||||
java_type = #{item.javaType},
|
|
||||||
java_field = #{item.javaField},
|
|
||||||
is_insert = #{item.isInsert},
|
|
||||||
is_edit = #{item.isEdit},
|
|
||||||
is_list = #{item.isList},
|
|
||||||
is_query = #{item.isQuery},
|
|
||||||
is_required = #{item.isRequired},
|
|
||||||
is_regular = #{item.isRegular},
|
|
||||||
query_type = #{item.queryType},
|
|
||||||
html_type = #{item.htmlType},
|
|
||||||
dict_type = #{item.dictType},
|
|
||||||
sort = #{item.sort},
|
|
||||||
update_by = #{item.updateBy},
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where column_id = #{item.columnId}
|
|
||||||
</foreach>
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
|
||||||
delete from gen_table_column where table_id in
|
|
||||||
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
|
||||||
#{tableId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteGenTableColumns">
|
|
||||||
delete from gen_table_column where column_id in
|
|
||||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
|
||||||
#{item.columnId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,226 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.GenTableDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.GenTable" id="GenTableResult">
|
|
||||||
<id property="tableId" column="table_id" />
|
|
||||||
<result property="tableName" column="table_name" />
|
|
||||||
<result property="tableComment" column="table_comment" />
|
|
||||||
<result property="subTableName" column="sub_table_name" />
|
|
||||||
<result property="subTableFkName" column="sub_table_fk_name" />
|
|
||||||
<result property="className" column="class_name" />
|
|
||||||
<result property="tplCategory" column="tpl_category" />
|
|
||||||
<result property="packageName" column="package_name" />
|
|
||||||
<result property="moduleName" column="module_name" />
|
|
||||||
<result property="businessName" column="business_name" />
|
|
||||||
<result property="functionName" column="function_name" />
|
|
||||||
<result property="functionAuthor" column="function_author" />
|
|
||||||
<result property="genType" column="gen_type" />
|
|
||||||
<result property="genPath" column="gen_path" />
|
|
||||||
<result property="options" column="options" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.GenTableColumn" id="GenTableColumnResult">
|
|
||||||
<id property="columnId" column="column_id" />
|
|
||||||
<result property="tableId" column="table_id" />
|
|
||||||
<result property="columnName" column="column_name" />
|
|
||||||
<result property="columnComment" column="column_comment" />
|
|
||||||
<result property="columnType" column="column_type" />
|
|
||||||
<result property="javaType" column="java_type" />
|
|
||||||
<result property="javaField" column="java_field" />
|
|
||||||
<result property="isPk" column="is_pk" />
|
|
||||||
<result property="isIncrement" column="is_increment" />
|
|
||||||
<result property="isRequired" column="is_required" />
|
|
||||||
<result property="isInsert" column="is_insert" />
|
|
||||||
<result property="isEdit" column="is_edit" />
|
|
||||||
<result property="isList" column="is_list" />
|
|
||||||
<result property="isQuery" column="is_query" />
|
|
||||||
<result property="isRegular" column="is_regular" />
|
|
||||||
<result property="regular" column="regular" />
|
|
||||||
<result property="queryType" column="query_type" />
|
|
||||||
<result property="htmlType" column="html_type" />
|
|
||||||
<result property="dictType" column="dict_type" />
|
|
||||||
<result property="sort" column="sort" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertMenu">
|
|
||||||
${paramSQL}
|
|
||||||
</insert>
|
|
||||||
<sql id="selectGenTableVo">
|
|
||||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category,
|
|
||||||
package_name, module_name, business_name, function_name, function_author, gen_type, gen_path,
|
|
||||||
options, create_by, create_time, update_by, update_time, remark from gen_table
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
|
||||||
<include refid="selectGenTableVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="tableName != null and tableName != ''">
|
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">
|
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
<!--AND table_name NOT LIKE 'gen_%'-->
|
|
||||||
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
|
||||||
where table_schema = (select database())
|
|
||||||
AND table_name NOT LIKE 'qrtz_%'
|
|
||||||
AND table_name NOT LIKE 'gen_%'
|
|
||||||
AND table_name NOT IN (select table_name from gen_table)
|
|
||||||
<if test="tableName != null and tableName != ''">
|
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">
|
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
<!-- AND table_name NOT LIKE 'gen_%' -->
|
|
||||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
|
||||||
where table_name NOT LIKE 'qrtz_%'
|
|
||||||
AND table_name NOT LIKE 'gen_%'
|
|
||||||
AND table_schema = (select database())
|
|
||||||
AND table_name in
|
|
||||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
|
||||||
where table_comment <![CDATA[ <> ]]> '' AND table_schema = (select database())
|
|
||||||
AND table_name = #{tableName}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!--todo 获取表信息 预览代码使用-->
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
|
||||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name, gt.class_name, gt.tpl_category, gt.package_name,
|
|
||||||
gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.gen_type, gt.gen_path, gt.options, gt.remark,
|
|
||||||
gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type, gtc.java_field, gtc.is_pk, gtc.is_increment, gtc.is_required,
|
|
||||||
gtc.is_insert, gtc.is_edit, gtc.is_list, gtc.is_query, gtc.query_type, gtc.html_type, gtc.dict_type, gtc.sort, gtc.is_regular, gr.regular
|
|
||||||
FROM gen_table gt
|
|
||||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
|
||||||
LEFT JOIN gen_regular gr ON gtc.is_regular = gr.id
|
|
||||||
where gt.table_id = #{tableId} order by gtc.sort
|
|
||||||
</select>
|
|
||||||
<!--todo 获取表信息 生成代码使用-->
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
|
||||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name,gt.class_name, gt.tpl_category,
|
|
||||||
gt.package_name, gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.gen_type, gt.gen_path,
|
|
||||||
gt.options, gt.remark, gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type,
|
|
||||||
gtc.java_field, gtc.is_pk, gtc.is_increment, gtc.is_required, gtc.is_insert, gtc.is_edit, gtc.is_list,
|
|
||||||
gtc.is_query, gtc.query_type, gtc.html_type, gtc.dict_type, gtc.sort, gtc.is_regular, gr.regular
|
|
||||||
FROM gen_table gt
|
|
||||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
|
||||||
LEFT JOIN gen_regular gr ON gtc.is_regular = gr.id
|
|
||||||
where gt.table_name = #{tableName} order by gtc.sort
|
|
||||||
</select>
|
|
||||||
<!-- todo 查询数据库行配置信息-->
|
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
|
||||||
SELECT gt.table_id, gt.table_name, gt.table_comment, gt.sub_table_name, gt.sub_table_fk_name, gt.class_name, gt.tpl_category,
|
|
||||||
gt.package_name, gt.module_name, gt.business_name, gt.function_name, gt.function_author, gt.options, gt.remark,
|
|
||||||
gtc.column_id, gtc.column_name, gtc.column_comment, gtc.column_type, gtc.java_type, gtc.java_field, gtc.is_pk,
|
|
||||||
gtc.is_increment, gtc.is_required, gtc.is_insert,gtc.is_edit, gtc.is_list, gtc.is_query, gtc.query_type,
|
|
||||||
gtc.html_type, gtc.dict_type, gtc.sort
|
|
||||||
FROM gen_table gt
|
|
||||||
LEFT JOIN gen_table_column gtc ON gt.table_id = gtc.table_id
|
|
||||||
order by gtc.sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
|
||||||
insert into gen_table (
|
|
||||||
<if test="tableName != null">table_name,</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
|
||||||
<if test="className != null and className != ''">class_name,</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name,</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
|
||||||
<if test="businessName != null and businessName != ''">business_name,</if>
|
|
||||||
<if test="functionName != null and functionName != ''">function_name,</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
|
|
||||||
<if test="genType != null and genType != ''">gen_type,</if>
|
|
||||||
<if test="genPath != null and genPath != ''">gen_path,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="tableName != null">#{tableName},</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
|
||||||
<if test="className != null and className != ''">#{className},</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
|
||||||
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
|
||||||
<if test="functionName != null and functionName != ''">#{functionName},</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
|
|
||||||
<if test="genType != null and genType != ''">#{genType},</if>
|
|
||||||
<if test="genPath != null and genPath != ''">#{genPath},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateGenTable" parameterType="GenTable">
|
|
||||||
update gen_table
|
|
||||||
<set>
|
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
|
||||||
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
|
||||||
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
|
||||||
<if test="assTableName != null and assTableName !=''">ass_table_name = #{assTableName},</if>
|
|
||||||
<if test="assTableColumn != null and assTableColumn !=''">ass_table_column = #{assTableColumn},</if>
|
|
||||||
<if test="assTableFkColumn != null and assTableFkColumn !=''">ass_table_fk_column = #{assTableFkColumn},</if>
|
|
||||||
<if test="assQueryType != null and assQueryType !=''">ass_query_type = #{assQueryType},</if>
|
|
||||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
|
||||||
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
|
||||||
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
|
||||||
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
|
|
||||||
<if test="options != null and options != ''">options = #{options},</if>
|
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where table_id = #{tableId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteGenTableByIds" parameterType="Long">
|
|
||||||
delete from gen_table where table_id in
|
|
||||||
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
|
||||||
#{tableId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,183 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.InterTableDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.InterTable" id="InterTableResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mId" column="m_id" />
|
|
||||||
<result property="cId" column="c_id" />
|
|
||||||
<result property="itName" column="it_name" />
|
|
||||||
<result property="itDescribe" column="it_describe" />
|
|
||||||
<result property="isPermission" column="is_permission" />
|
|
||||||
<result property="requrl" column="requrl" />
|
|
||||||
<result property="method" column="method" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
<result property="mName" column="m_name" />
|
|
||||||
<result property="isGenerate" column="is_generate" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<collection property="apiclass" javaType="com.ebts.generator.entity.ApiClass" resultMap="ModuleApiclassResult" notNullColumn="c_id"/>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.ApiClass" id="ModuleApiclassResult">
|
|
||||||
<result property="id" column="class_id" />
|
|
||||||
<result property="mId" column="m_id" />
|
|
||||||
<result property="cName" column="c_name" />
|
|
||||||
<result property="cDescribe" column="c_describe" />
|
|
||||||
<result property="packageName" column="package_name" />
|
|
||||||
<result property="author" column="author" />
|
|
||||||
<result property="email" column="email" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<result property="prefix" column="prefix" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.Module" id="ModuleResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mName" column="m_name" />
|
|
||||||
<result property="mDescribe" column="m_describe" />
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.ApiClass" id="ApiclassResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mId" column="m_id" />
|
|
||||||
<result property="cName" column="c_name" />
|
|
||||||
<result property="cDescribe" column="c_describe" />
|
|
||||||
<result property="packageName" column="package_name" />
|
|
||||||
<result property="author" column="author" />
|
|
||||||
<result property="email" column="email" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<result property="prefix" column="prefix" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<collection property="interTables" javaType="java.util.List" notNullColumn="id" resultMap="InterTableClassResult"/>
|
|
||||||
<collection property="module" javaType="com.ebts.generator.entity.Module" notNullColumn="m_id" resultMap="ModuleResult"/>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.InterTable" id="InterTableClassResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mId" column="m_id" />
|
|
||||||
<result property="cId" column="c_id" />
|
|
||||||
<result property="itName" column="it_name" />
|
|
||||||
<result property="itDescribe" column="it_describe" />
|
|
||||||
<result property="isPermission" column="is_permission" />
|
|
||||||
<result property="requrl" column="requrl" />
|
|
||||||
<result property="method" column="method" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
<result property="mName" column="m_name" />
|
|
||||||
<result property="isGenerate" column="is_generate" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectInterTableVo">
|
|
||||||
select id, m_id, c_id, it_name, it_describe, is_permission, requrl, method, is_generate, type, create_time, create_by from gen_inter_table
|
|
||||||
</sql>
|
|
||||||
<select id="selectInterTableClass" resultMap="ApiclassResult" parameterType="Long">
|
|
||||||
select sa.*, sit.*, sm.*
|
|
||||||
from gen_api_class sa
|
|
||||||
left join gen_inter_table sit on sit.c_id = sa.id
|
|
||||||
left join gen_module sm on sm.id = sa.m_id
|
|
||||||
where sa.id = #{id} and sit.type = 2
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectInterTableModule" resultMap="InterTableResult" parameterType="Long">
|
|
||||||
SELECT (select m_name from gen_module sm WHERE sm.id=sit.m_id) AS m_name, sit.*,
|
|
||||||
sa.id as class_id, sa.m_id, sa.c_name, sa.c_describe, sa.package_name, sa.author, sa.email, sa.prefix, sa.remark, sa.create_time, sa.create_by, sa.update_time, sa.update_by
|
|
||||||
from gen_inter_table sit
|
|
||||||
LEFT JOIN gen_api_class sa ON sa.id = sit.c_id
|
|
||||||
WHERE sit.m_id=#{id} AND sit.type = 1;
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectInterTableList" parameterType="InterTable" resultMap="InterTableResult">
|
|
||||||
<include refid="selectInterTableVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="mId != null "> and m_id = #{mId}</if>
|
|
||||||
<if test="cId != null "> and c_id = #{cId}</if>
|
|
||||||
<if test="itName != null and itName != ''"> and it_name like concat('%', #{itName}, '%')</if>
|
|
||||||
<if test="itDescribe != null and itDescribe != ''"> and it_describe like concat('%', #{itDescribe}, '%')</if>
|
|
||||||
<if test="isPermission != null "> and is_permission = #{isPermission}</if>
|
|
||||||
<if test="type != null "> and type = #{type}</if>
|
|
||||||
<if test="requrl != null and requrl != ''"> and requrl like concat('%', #{requrl}, '%')</if>
|
|
||||||
<if test="method != null and method != ''"> and method = #{method}</if>
|
|
||||||
<if test="isGenerate != null "> and is_generate = #{isGenerate}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectInterTableById" parameterType="Long" resultMap="InterTableResult">
|
|
||||||
<include refid="selectInterTableVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertInterTables" parameterType="java.util.List">
|
|
||||||
insert into gen_inter_table (m_id, c_id, it_name, it_describe, is_permission, requrl, method, is_generate, type, create_by) VALUES
|
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
|
||||||
(#{item.mId},#{item.cId},#{item.itName},#{item.itDescribe},#{item.isPermission},#{item.requrl},#{item.method},#{item.isGenerate},#{item.type},#{item.createBy})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
<delete id="deleteInterTableByClassId" parameterType="Long">
|
|
||||||
delete from gen_inter_table where c_id = #{cId} and type = 2
|
|
||||||
</delete>
|
|
||||||
<delete id="deleteInterTableByModuleId" parameterType="Long">
|
|
||||||
delete from gen_inter_table where c_id = #{cId} and type = 1
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="insertInterTable" parameterType="InterTable" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_inter_table
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mId != null">m_id,</if>
|
|
||||||
<if test="cId != null">c_id,</if>
|
|
||||||
<if test="itName != null">it_name,</if>
|
|
||||||
<if test="itDescribe != null">it_describe,</if>
|
|
||||||
<if test="isPermission != null">is_permission,</if>
|
|
||||||
<if test="requrl != null">requrl,</if>
|
|
||||||
<if test="method != null">method,</if>
|
|
||||||
<if test="type != null">type,</if>
|
|
||||||
<if test="isGenerate != null">is_generate,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mId != null">#{mId},</if>
|
|
||||||
<if test="cId != null">#{cId},</if>
|
|
||||||
<if test="itName != null">#{itName},</if>
|
|
||||||
<if test="itDescribe != null">#{itDescribe},</if>
|
|
||||||
<if test="isPermission != null">#{isPermission},</if>
|
|
||||||
<if test="requrl != null">#{requrl},</if>
|
|
||||||
<if test="method != null">#{method},</if>
|
|
||||||
<if test="type != null">#{type},</if>
|
|
||||||
<if test="isGenerate != null">#{isGenerate},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateInterTable" parameterType="InterTable">
|
|
||||||
update gen_inter_table
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="mId != null">m_id = #{mId},</if>
|
|
||||||
<if test="cId != null">c_id = #{cId},</if>
|
|
||||||
<if test="itName != null">it_name = #{itName},</if>
|
|
||||||
<if test="itDescribe != null">it_describe = #{itDescribe},</if>
|
|
||||||
<if test="isPermission != null">is_permission = #{isPermission},</if>
|
|
||||||
<if test="requrl != null">requrl = #{requrl},</if>
|
|
||||||
<if test="method != null">method = #{method},</if>
|
|
||||||
<if test="type != null">type = #{type},</if>
|
|
||||||
<if test="isGenerate != null">is_generate = #{isGenerate},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteInterTableById" parameterType="Long">
|
|
||||||
delete from gen_inter_table where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteInterTableByIds" parameterType="String">
|
|
||||||
delete from gen_inter_table where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.ModuleDao">
|
|
||||||
|
|
||||||
<resultMap type="Module" id="ModuleResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="mName" column="m_name" />
|
|
||||||
<result property="mDescribe" column="m_describe" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectModuleVo">
|
|
||||||
select id, m_name, m_describe, remark, create_time, create_by, update_time, update_by from gen_module
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectModuleList" parameterType="Module" resultMap="ModuleResult">
|
|
||||||
<include refid="selectModuleVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="mName != null and mName != ''"> and m_name like concat('%', #{mName}, '%')</if>
|
|
||||||
<if test="mDescribe != null and mDescribe != ''"> and m_describe like concat('%', #{mDescribe}, '%')</if>
|
|
||||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectModuleById" parameterType="Long" resultMap="ModuleResult">
|
|
||||||
<include refid="selectModuleVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertModule" parameterType="Module" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_module
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mName != null and mName != ''">m_name,</if>
|
|
||||||
<if test="mDescribe != null and mDescribe != ''">m_describe,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mName != null and mName != ''">#{mName},</if>
|
|
||||||
<if test="mDescribe != null and mDescribe != ''">#{mDescribe},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateModule" parameterType="Module">
|
|
||||||
update gen_module
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="mName != null and mName != ''">m_name = #{mName},</if>
|
|
||||||
<if test="mDescribe != null and mDescribe != ''">m_describe = #{mDescribe},</if>
|
|
||||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteModuleById" parameterType="Long">
|
|
||||||
delete from gen_module where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteModuleByIds" parameterType="String">
|
|
||||||
delete from gen_module where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
|
|
||||||
<mapper namespace="com.ebts.generator.dao.QueryDao">
|
|
||||||
<resultMap type="com.ebts.generator.entity.UniQuery" id="QueryResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="uqName" column="uq_name" />
|
|
||||||
<result property="uqSql" column="uq_sql" />
|
|
||||||
<result property="uqDescribe" column="uq_describe" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="isRelease" column="is_release" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<collection property="uniCons" javaType="java.util.List" notNullColumn="id" resultMap="UniConResult"/>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap type="com.ebts.generator.entity.UniCon" id="UniConResult">
|
|
||||||
<result property="id" column="uc_id" />
|
|
||||||
<result property="uqId" column="uq_id" />
|
|
||||||
<result property="ucName" column="uc_name" />
|
|
||||||
<result property="ucKey" column="uc_key" />
|
|
||||||
<result property="ucCon" column="uc_con" />
|
|
||||||
<result property="ucMock" column="uc_mock" />
|
|
||||||
<result property="ucDescribe" column="uc_describe" />
|
|
||||||
<result property="ucType" column="uc_type" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
</resultMap>
|
|
||||||
<select id="UniQuery" resultType="java.util.Map">
|
|
||||||
${paramSQL}
|
|
||||||
</select>
|
|
||||||
<delete id="deleteMenu">
|
|
||||||
delete from sys_menu where path = #{path}
|
|
||||||
</delete>
|
|
||||||
<insert id="insertMenu" parameterType="Menu">
|
|
||||||
insert into sys_menu(
|
|
||||||
<if test="menuId != null and menuId != 0">menu_id,</if>
|
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
|
||||||
<if test="menuName != null and menuName != ''">menu_name,</if>
|
|
||||||
<if test="orderNum != null and orderNum != ''">order_num,</if>
|
|
||||||
<if test="path != null and path != ''">path,</if>
|
|
||||||
<if test="component != null and component != ''">component,</if>
|
|
||||||
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
|
||||||
<if test="isCache != null and isCache != ''">is_cache,</if>
|
|
||||||
<if test="menuType != null and menuType != ''">menu_type,</if>
|
|
||||||
<if test="visible != null">visible,</if>
|
|
||||||
<if test="status != null">status,</if>
|
|
||||||
<if test="perms !=null and perms != ''">perms,</if>
|
|
||||||
<if test="icon != null and icon != ''">icon,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="menuId != null and menuId != 0">#{menuId},</if>
|
|
||||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
|
||||||
<if test="menuName != null and menuName != ''">#{menuName},</if>
|
|
||||||
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
|
|
||||||
<if test="path != null and path != ''">#{path},</if>
|
|
||||||
<if test="component != null and component != ''">#{component},</if>
|
|
||||||
<if test="isFrame != null and isFrame != ''">#{isFrame},</if>
|
|
||||||
<if test="isCache != null and isCache != ''">#{isCache},</if>
|
|
||||||
<if test="menuType != null and menuType != ''">#{menuType},</if>
|
|
||||||
<if test="visible != null">#{visible},</if>
|
|
||||||
<if test="status != null">#{status},</if>
|
|
||||||
<if test="perms !=null and perms != ''">#{perms},</if>
|
|
||||||
<if test="icon != null and icon != ''">#{icon},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
<select id="Release" resultType="Integer" parameterType="Long">
|
|
||||||
select is_release from gen_uni_query where id = #{id}
|
|
||||||
</select>
|
|
||||||
<update id="changeRelease" parameterType="com.ebts.generator.entity.UniQuery">
|
|
||||||
update gen_uni_query set is_release = #{isRelease} where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<select id="selectQueryInfo" parameterType="Long" resultMap="QueryResult">
|
|
||||||
select uq.id, uq.uq_name, uq.uq_sql, uq.uq_describe, uq.create_by, uq.is_release, uq.create_time, uq.update_by, uq.update_time,
|
|
||||||
uc.id as uc_id, uc.uq_id, uc.uc_name, uc.uc_key, uc.uc_con, uc.uc_mock, uc.uc_describe ,uc.uc_type,uc.type
|
|
||||||
from gen_uni_query uq
|
|
||||||
left join gen_uni_con uc on uc.uq_id = uq.id
|
|
||||||
where uq.id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<delete id="deleteUniCon">
|
|
||||||
delete from gen_uni_con where uq_id = #{uqId}
|
|
||||||
</delete>
|
|
||||||
<insert id="insertUniCon">
|
|
||||||
insert into gen_uni_con(uq_id,uc_name,uc_key,uc_con,uc_mock,uc_describe,uc_type,type) values
|
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
|
||||||
(#{item.uqId},#{item.ucName},#{item.ucKey},#{item.ucCon},#{item.ucMock},#{item.ucDescribe},#{item.ucType},#{item.type})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.RegularDao">
|
|
||||||
|
|
||||||
<resultMap type="Regular" id="RegularResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="name" column="name" />
|
|
||||||
<result property="regular" column="regular" />
|
|
||||||
<result property="validation" column="validation" />
|
|
||||||
<result property="enable" column="enable" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectRegularVo">
|
|
||||||
select id, name, regular, validation, enable, create_by, create_time, update_by, update_time from gen_regular
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectRegularList" parameterType="Regular" resultMap="RegularResult">
|
|
||||||
<include refid="selectRegularVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="1=1">and id != 1</if>
|
|
||||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
||||||
<if test="regular != null and regular != ''"> and regular like concat('%', #{regular}, '%')</if>
|
|
||||||
<if test="validation != null and validation != ''"> and validation like concat('%', #{validation}, '%')</if>
|
|
||||||
<if test="enable != null "> and enable = #{enable}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
<select id="selectRegularOption" parameterType="Regular" resultMap="RegularResult">
|
|
||||||
select id ,name from gen_regular where enable = 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectRegularById" parameterType="Long" resultMap="RegularResult">
|
|
||||||
<include refid="selectRegularVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertRegular" parameterType="Regular" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_regular
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="name != null and name != ''">name,</if>
|
|
||||||
<if test="regular != null and regular != ''">regular,</if>
|
|
||||||
<if test="validation != null">validation,</if>
|
|
||||||
<if test="enable != null">enable,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="createTime != null">create_time,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
<if test="updateTime != null">update_time,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="name != null and name != ''">#{name},</if>
|
|
||||||
<if test="regular != null and regular != ''">#{regular},</if>
|
|
||||||
<if test="validation != null">#{validation},</if>
|
|
||||||
<if test="enable != null">#{enable},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="createTime != null">#{createTime},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateRegular" parameterType="Regular">
|
|
||||||
update gen_regular
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="name != null and name != ''">name = #{name},</if>
|
|
||||||
<if test="regular != null and regular != ''">regular = #{regular},</if>
|
|
||||||
<if test="validation != null">validation = #{validation},</if>
|
|
||||||
<if test="enable != null">enable = #{enable},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteRegularById" parameterType="Long">
|
|
||||||
delete from gen_regular where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteRegularByIds" parameterType="String">
|
|
||||||
delete from gen_regular where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.RelDao">
|
|
||||||
|
|
||||||
<resultMap id="RelTableResult" type="com.ebts.generator.entity.RelTable">
|
|
||||||
<result property="id" column="id"/>
|
|
||||||
<result property="tableId" column="table_id"/>
|
|
||||||
<result property="relName" column="rel_name"/>
|
|
||||||
<result property="relAs" column="rel_as"/>
|
|
||||||
<result property="tableName" column="table_name"/>
|
|
||||||
<result property="tableAs" column="table_as"/>
|
|
||||||
<result property="relComment" column="rel_comment"/>
|
|
||||||
<result property="relColumn" column="rel_column"/>
|
|
||||||
<result property="tableColumn" column="table_column"/>
|
|
||||||
<result property="relClass" column="rel_class"/>
|
|
||||||
<result property="relclass" column="relclass"/>
|
|
||||||
<result property="queryType" column="query_type"/>
|
|
||||||
<result property="sort" column="sort"/>
|
|
||||||
<result property="createBy" column="create_by"/>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap id="RelTableColumnResult" type="com.ebts.generator.entity.RelTable" extends="RelTableResult">
|
|
||||||
<collection property="relColumns" notNullColumn="id" javaType="java.util.List" resultMap="RelColumnResult" />
|
|
||||||
</resultMap>
|
|
||||||
<resultMap id="RelColumnResult" type="com.ebts.generator.entity.RelColumn">
|
|
||||||
<result property="relId" column="rel_id"/>
|
|
||||||
<result property="columnName" column="column_name"/>
|
|
||||||
<result property="columnComment" column="column_comment"/>
|
|
||||||
<result property="columnType" column="column_type"/>
|
|
||||||
<result property="javaType" column="java_type"/>
|
|
||||||
<result property="javaField" column="java_field"/>
|
|
||||||
<result property="isList" column="is_list"/>
|
|
||||||
<result property="isQuery" column="is_query"/>
|
|
||||||
<result property="queryType" column="col_query_type"/>
|
|
||||||
<result property="htmlType" column="html_type"/>
|
|
||||||
<result property="dictType" column="dict_type"/>
|
|
||||||
<result property="sort" column="sorts"/>
|
|
||||||
<result property="createBy" column="create_by"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="tableInfos" resultType="java.util.Map">
|
|
||||||
select table_name, table_comment
|
|
||||||
from information_schema.tables
|
|
||||||
where table_schema = (select database())
|
|
||||||
AND table_name NOT LIKE 'qrtz_%'
|
|
||||||
AND table_name NOT LIKE 'gen_%'
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTableColumn" resultType="com.ebts.generator.entity.RelColumn" parameterType="String">
|
|
||||||
select column_name, ordinal_position as sort, column_comment, column_type
|
|
||||||
from information_schema.columns
|
|
||||||
where table_schema = (select database())
|
|
||||||
and table_name = (#{tableName})
|
|
||||||
order by sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertRelTables" parameterType="java.util.List">
|
|
||||||
insert into gen_rel_table(id, table_id, rel_name,rel_as,table_name,table_as, rel_comment,
|
|
||||||
rel_column, table_column, rel_class, relclass, query_type, sort, create_by)
|
|
||||||
values
|
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
|
||||||
(#{item.id},#{item.tableId},#{item.relName},#{item.relAs},#{item.tableName},
|
|
||||||
#{item.tableAs},#{item.relComment},#{item.relColumn},#{item.tableColumn},#{item.relClass},
|
|
||||||
#{item.relclass},#{item.queryType},#{item.sort},#{item.createBy})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<insert id="insertRelColumns" parameterType="java.util.List">
|
|
||||||
insert into gen_rel_column(rel_id, column_name, column_comment, column_type, java_type, java_field, is_list,
|
|
||||||
is_query, query_type, html_type, dict_type, sort, create_by)
|
|
||||||
values
|
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
|
||||||
(#{item.relId},#{item.columnName},#{item.columnComment},#{item.columnType},
|
|
||||||
#{item.javaType},#{item.javaField},#{item.isList},#{item.isQuery},
|
|
||||||
#{item.queryType},#{item.htmlType},#{item.dictType},#{item.sort},
|
|
||||||
#{item.createBy})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
<select id="tableColumns" resultType="java.util.Map">
|
|
||||||
select column_name, column_comment
|
|
||||||
from information_schema.columns
|
|
||||||
where table_schema = (select database())
|
|
||||||
and table_name = (#{tableName})
|
|
||||||
order by ordinal_position
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="relTableByTableId" resultMap="RelTableColumnResult" parameterType="Long">
|
|
||||||
select grt.id, grt.table_id, grt.rel_name, grt.rel_as, grt.table_name, grt.table_as, grt.rel_comment, grt.rel_column, grt.table_column, grt.rel_class, grt.relclass, grt.query_type, grt.sort, grt.create_by,
|
|
||||||
grc.rel_id, grc.column_name, grc.column_comment, grc.column_type, grc.java_type, grc.java_field, grc.is_list, grc.is_query, grc.query_type as col_query_type, grc.html_type, grc.dict_type, grc.sort as sorts, grc.create_by
|
|
||||||
from gen_rel_table grt
|
|
||||||
left join gen_rel_column grc on grt.id = grc.rel_id
|
|
||||||
where grt.table_id = #{tableId}
|
|
||||||
order by grt.sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<delete id="deleteRelColumnByRelId">
|
|
||||||
delete from gen_rel_column where rel_id = #{relId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteRelTableByTableId">
|
|
||||||
delete from gen_rel_table where table_id = #{tableId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.RelationalMapDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.RelationalMap" id="RelationalMapResult">
|
|
||||||
<result property="mainId" column="main_id" />
|
|
||||||
<result property="childId" column="child_id" />
|
|
||||||
<result property="mainKey" column="main_key" />
|
|
||||||
<result property="childKey" column="child_key" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
</resultMap>
|
|
||||||
<sql id="selectRelationalMapVo">
|
|
||||||
select main_id, child_id, main_key, child_key, type from gen_relational_mapping
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectRelationalMapList" parameterType="RelationalMap" resultMap="RelationalMapResult">
|
|
||||||
<include refid="selectRelationalMapVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="mainId != null "> and main_id = #{mainId}</if>
|
|
||||||
<if test="childId != null "> and child_id = #{childId}</if>
|
|
||||||
<if test="mainKey != null and mainKey != ''"> and main_key like concat('%', #{mainKey}, '%')</if>
|
|
||||||
<if test="childKey != null and childKey != ''"> and child_key like concat('%', #{childKey}, '%')</if>
|
|
||||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectRelationalMapById" parameterType="Long" resultMap="RelationalMapResult">
|
|
||||||
<include refid="selectRelationalMapVo"/>
|
|
||||||
where main_id = #{mainId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertRelationalMap" parameterType="RelationalMap">
|
|
||||||
insert into gen_relational_mapping
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mainId != null">main_id,</if>
|
|
||||||
<if test="childId != null">child_id,</if>
|
|
||||||
<if test="mainKey != null">main_key,</if>
|
|
||||||
<if test="childKey != null">child_key,</if>
|
|
||||||
<if test="type != null">type,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="mainId != null">#{mainId},</if>
|
|
||||||
<if test="childId != null">#{childId},</if>
|
|
||||||
<if test="mainKey != null">#{mainKey},</if>
|
|
||||||
<if test="childKey != null">#{childKey},</if>
|
|
||||||
<if test="type != null">#{type},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateRelationalMap" parameterType="RelationalMap">
|
|
||||||
update gen_relational_mapping
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="childId != null">child_id = #{childId},</if>
|
|
||||||
<if test="mainKey != null">main_key = #{mainKey},</if>
|
|
||||||
<if test="childKey != null">child_key = #{childKey},</if>
|
|
||||||
<if test="type != null">type = #{type},</if>
|
|
||||||
</trim>
|
|
||||||
where main_id = #{mainId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteRelationalMapById" parameterType="Long">
|
|
||||||
delete from gen_relational_mapping where main_id = #{mainId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteRelationalMapByIds" parameterType="String">
|
|
||||||
delete from gen_relational_mapping where main_id in
|
|
||||||
<foreach item="mainId" collection="array" open="(" separator="," close=")">
|
|
||||||
#{mainId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="batchRelationalMap">
|
|
||||||
insert into gen_relational_mapping(main_id, child_id, main_key, child_key, type) values
|
|
||||||
<foreach collection="list" index="index" item="item" separator=",">
|
|
||||||
(#{item.mainId},#{item.childId},#{item.mainKey},#{item.childKey},#{item.type})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.SearchTableRoleDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.SearchTableRole" id="SearchTableRoleResult">
|
|
||||||
<result property="searchTableId" column="search_table_id" />
|
|
||||||
<result property="roleId" column="role_id" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="selectSearchTableRoleList" parameterType="SearchTableRole" resultMap="SearchTableRoleResult">
|
|
||||||
select search_table_id, role_id from gen_search_table_role
|
|
||||||
<where>
|
|
||||||
<if test="searchTableId != null "> and search_table_id = #{searchTableId}</if>
|
|
||||||
<if test="roleId != null "> and role_id = #{roleId}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<delete id="deleteSearchTableRoleById" parameterType="Long">
|
|
||||||
delete from gen_search_table_role where search_table_id = #{searchTableId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteSearchTableRoleByIds" parameterType="String">
|
|
||||||
delete from gen_search_table_role where search_table_id in
|
|
||||||
<foreach item="searchTableId" collection="array" open="(" separator="," close=")">
|
|
||||||
#{searchTableId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
<insert id="batchSearchTableRole">
|
|
||||||
insert into gen_search_table_role (search_table_id, role_id) values
|
|
||||||
<foreach collection="list" separator="," item="item" index="index">
|
|
||||||
(#{item.searchTableId},#{item.roleId})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.TopSearchTableDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.TopSearchTable" id="TopSearchTableResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="tableName" column="table_name" />
|
|
||||||
<result property="tableComment" column="table_comment" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="TopSearchTableTopSearchColumnResult" type="com.ebts.generator.entity.TopSearchTable" extends="TopSearchTableResult">
|
|
||||||
<collection property="topSearchColumnList" notNullColumn="id" javaType="java.util.List" resultMap="TopSearchColumnResult" />
|
|
||||||
<collection property="relationalMapList" notNullColumn="id" javaType="java.util.List" resultMap="RelationalMappingResult" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.TopSearchColumn" id="TopSearchColumnResult">
|
|
||||||
<result property="id" column="column_id" />
|
|
||||||
<result property="searchTableId" column="search_table_id" />
|
|
||||||
<result property="columnName" column="column_name" />
|
|
||||||
<result property="columnComment" column="column_comment" />
|
|
||||||
<result property="columnType" column="column_type" />
|
|
||||||
<result property="isPk" column="is_pk" />
|
|
||||||
<result property="isUse" column="is_use_column" />
|
|
||||||
<result property="sort" column="sort" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.RelationalMap" id="RelationalMappingResult">
|
|
||||||
<result property="mainId" column="main_id" />
|
|
||||||
<result property="childId" column="child_id" />
|
|
||||||
<result property="mainKey" column="main_key" />
|
|
||||||
<result property="childKey" column="child_key" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sql id="selectTopSearchTableVo">
|
|
||||||
select id, table_name, table_comment, remark, create_by, create_time, update_by, update_time from gen_top_search_table
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectTopSearchTableInfo" resultMap="TopSearchTableResult">
|
|
||||||
select id, table_name ,table_comment from gen_top_search_table where 1=1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTableColumns" resultMap="TopSearchColumnResult" parameterType="Long">
|
|
||||||
select column_name ,column_comment from gen_top_search_column where search_table_id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectTopSearchTableList" parameterType="TopSearchTable" resultMap="TopSearchTableResult">
|
|
||||||
<include refid="selectTopSearchTableVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''"> and table_comment like concat('%', #{tableComment}, '%')</if>
|
|
||||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
|
||||||
<if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''"> and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTopSearchTableById" parameterType="Long" resultMap="TopSearchTableTopSearchColumnResult">
|
|
||||||
select gtst.id, gtst.table_name, gtst.table_comment, gtst.remark, gtst.create_by, gtst.create_time, gtst.update_by, gtst.update_time,
|
|
||||||
gtsc.id as column_id, gtsc.search_table_id, gtsc.column_name, gtsc.column_comment, gtsc.column_type, gtsc.is_use as is_use_column, gtsc.create_by, gtsc.create_time, gtsc.update_by, gtsc.update_time,
|
|
||||||
grm.main_id, grm.child_id, grm.main_key, grm.child_key, grm.type
|
|
||||||
from gen_top_search_table gtst
|
|
||||||
left join gen_top_search_column gtsc on gtsc.search_table_id = gtst.id
|
|
||||||
left join gen_relational_mapping grm on grm.main_id = gtst.id
|
|
||||||
where gtst.id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTopSearchTables" resultMap="TopSearchTableTopSearchColumnResult" parameterType="String">
|
|
||||||
select gtst.id, gtst.table_name, gtst.table_comment, gtst.remark, gtst.create_by, gtst.create_time, gtst.update_by, gtst.update_time,
|
|
||||||
gtsc.id as column_id, gtsc.search_table_id, gtsc.column_name, gtsc.column_comment, gtsc.column_type, gtsc.is_use as is_use_column, gtsc.create_by, gtsc.create_time, gtsc.update_by, gtsc.update_time,
|
|
||||||
grm.main_id, grm.child_id, grm.main_key, grm.child_key, grm.type
|
|
||||||
from gen_top_search_table gtst
|
|
||||||
left join gen_top_search_column gtsc on gtsc.search_table_id = gtst.id
|
|
||||||
left join gen_relational_mapping grm on grm.main_id = gtst.id
|
|
||||||
where gtsc.is_use = 1 and gtst.id IN (SELECT search_table_id FROM gen_search_table_role WHERE role_id IN
|
|
||||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
|
||||||
#{roleId}
|
|
||||||
</foreach>)
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDbTableList" resultType="java.util.Map">
|
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
|
||||||
where table_schema = (select database())
|
|
||||||
AND table_name NOT LIKE 'qrtz_%'
|
|
||||||
AND table_name NOT LIKE 'gen_%'
|
|
||||||
AND table_name NOT IN (select table_name from gen_top_search_table)
|
|
||||||
<if test="tableName != null and tableName != ''">
|
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">
|
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDbTableListByNames" resultMap="TopSearchTableResult">
|
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
|
||||||
where table_name NOT LIKE 'qrtz_%'
|
|
||||||
and table_name NOT LIKE 'gen_%'
|
|
||||||
and table_schema = (select database())
|
|
||||||
and table_name in
|
|
||||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="TopSearchColumnResult">
|
|
||||||
select column_name, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, column_type
|
|
||||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
|
||||||
order by ordinal_position
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertTopSearchTable" parameterType="TopSearchTable" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_top_search_table
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="tableName != null">table_name,</if>
|
|
||||||
<if test="tableComment != null">table_comment,</if>
|
|
||||||
<if test="remark != null">remark,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="tableName != null">#{tableName},</if>
|
|
||||||
<if test="tableComment != null">#{tableComment},</if>
|
|
||||||
<if test="remark != null">#{remark},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateTopSearchTable" parameterType="TopSearchTable">
|
|
||||||
update gen_top_search_table
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
|
||||||
<if test="tableComment != null">table_comment = #{tableComment},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteTopSearchTableById" parameterType="Long">
|
|
||||||
delete from gen_top_search_table where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteTopSearchTableByIds" parameterType="String">
|
|
||||||
delete from gen_top_search_table where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteTopSearchColumnBySearchTableIds" parameterType="String">
|
|
||||||
delete from gen_top_search_column where search_table_id in
|
|
||||||
<foreach item="searchTableId" collection="array" open="(" separator="," close=")">
|
|
||||||
#{searchTableId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteTopSearchColumnBySearchTableId" parameterType="Long">
|
|
||||||
delete from gen_top_search_column where search_table_id = #{searchTableId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="batchTopSearchColumn">
|
|
||||||
insert into gen_top_search_column(search_table_id,column_name,column_comment,column_type,is_use,create_by,create_time) values
|
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
|
||||||
(#{item.searchTableId},#{item.columnName},#{item.columnComment},#{item.columnType},#{item.isUse},#{item.createBy},#{item.createTime})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ebts.generator.dao.UniQueryDao">
|
|
||||||
|
|
||||||
<resultMap type="com.ebts.generator.entity.UniQuery" id="UniQueryResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="uqName" column="uq_name" />
|
|
||||||
<result property="uqSql" column="uq_sql" />
|
|
||||||
<result property="uqDescribe" column="uq_describe" />
|
|
||||||
<result property="isRelease" column="is_release" />
|
|
||||||
<result property="topJson" column="top_json" />
|
|
||||||
<result property="type" column="type" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<sql id="selectUniQueryVo">
|
|
||||||
select id, uq_name, uq_sql, uq_describe, type, is_release, create_by, create_time, update_by, update_time from gen_uni_query
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectUniQueryList" parameterType="UniQuery" resultMap="UniQueryResult">
|
|
||||||
<include refid="selectUniQueryVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="uqName != null and uqName != ''"> and uq_name like concat('%', #{uqName}, '%')</if>
|
|
||||||
<if test="uqDescribe != null and uqDescribe != ''"> and uq_describe like concat('%', #{uqDescribe}, '%')</if>
|
|
||||||
<if test="type != null and type != ''"> and type = #{type} </if>
|
|
||||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectUniQueryById" parameterType="Long" resultMap="UniQueryResult">
|
|
||||||
select * from gen_uni_query where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertUniQuery" parameterType="UniQuery" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into gen_uni_query
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="uqName != null and uqName != ''">uq_name,</if>
|
|
||||||
<if test="uqSql != null">uq_sql,</if>
|
|
||||||
<if test="uqDescribe != null and uqDescribe != ''">uq_describe,</if>
|
|
||||||
<if test="type != null and type != ''">type,</if>
|
|
||||||
<if test="topJson != null and topJson != ''">top_json,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="uqName != null and uqName != ''">#{uqName},</if>
|
|
||||||
<if test="uqSql != null">#{uqSql},</if>
|
|
||||||
<if test="uqDescribe != null and uqDescribe != ''">#{uqDescribe},</if>
|
|
||||||
<if test="type != null and type != ''">#{type},</if>
|
|
||||||
<if test="topJson != null and topJson != ''">#{topJson},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateUniQuery" parameterType="UniQuery">
|
|
||||||
update gen_uni_query
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="uqName != null and uqName != ''">uq_name = #{uqName},</if>
|
|
||||||
<if test="uqSql != null">uq_sql = #{uqSql},</if>
|
|
||||||
<if test="isPreview != null">is_preview = #{isPreview},</if>
|
|
||||||
<if test="uqDescribe != null and uqDescribe != ''">uq_describe = #{uqDescribe},</if>
|
|
||||||
<if test="type != null and type != ''">type = #{type},</if>
|
|
||||||
<if test="topJson != null and topJson != ''">top_json = #{topJson},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteUniQueryById" parameterType="Long">
|
|
||||||
delete from gen_uni_query where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteUniQueryByUqId" parameterType="Long">
|
|
||||||
delete from gen_uni_con where uq_id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteUniQueryByIds" parameterType="String">
|
|
||||||
delete from gen_uni_query where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
package ${packageName}.controller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${ClassName} ${functionName}
|
|
||||||
*
|
|
||||||
* Author ${author}
|
|
||||||
* Email ${emali}
|
|
||||||
* Date ${time}
|
|
||||||
*/
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.controller.BaseController;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if($Permission)
|
|
||||||
@Api(value = "${functionName}",tags = "${functionName}")
|
|
||||||
#end
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("${reqMapping}")
|
|
||||||
public class ${ClassName}Controller extends BaseController{
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(${ClassName}Controller.class);
|
|
||||||
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.isGenerate.equals("1"))
|
|
||||||
#set($InterName = $column.itName.substring(0,1).toUpperCase() + ${column.itName.substring(1)})
|
|
||||||
/**
|
|
||||||
* ${column.itDescribe}
|
|
||||||
*/
|
|
||||||
@ApiOperation("${column.itDescribe}")
|
|
||||||
#if($column.isPermission.equals("1"))
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${prefix}:${column.requrl}')")
|
|
||||||
@Log(title = "${column.itDescribe}", businessType = BusinessType.OTHER)
|
|
||||||
#end
|
|
||||||
@${column.method}Mapping("/${column.requrl}")
|
|
||||||
#if($column.method.equals("Get"))
|
|
||||||
public AjaxResult ${InterName} ( Map<String,String> parms){
|
|
||||||
#else
|
|
||||||
public AjaxResult ${InterName} (@RequestBody Map<String,String> parms){
|
|
||||||
#end
|
|
||||||
try {
|
|
||||||
return AjaxResult.success("${column.itDescribe}测试!");
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EBTSException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
package ${packageName}.controller;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.core.controller.EBTSController;
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ebts.common.annotation.Log;
|
|
||||||
import com.ebts.common.core.entity.AjaxResult;
|
|
||||||
import com.ebts.common.enums.BusinessType;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
import ${packageName}.entity.${ClassName};
|
|
||||||
import ${packageName}.service.${ClassName}Service;
|
|
||||||
import com.ebts.common.utils.poi.ExcelUtil;
|
|
||||||
#if($table.crud || $table.sub)
|
|
||||||
import com.ebts.common.core.page.TableDataInfo;
|
|
||||||
#elseif($table.tree)
|
|
||||||
#elseif($table.tplCategory.equals("rel"))
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}Controller
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Api(value = "${functionName}管理",tags = "${functionName}管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/${moduleName}/${businessName}")
|
|
||||||
public class ${ClassName}Controller extends EBTSController {
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(${ClassName}Controller.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ${ClassName}Service ${className}Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*/
|
|
||||||
@ApiOperation("查询${functionName}列表")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:list')")
|
|
||||||
@PostMapping("/list")
|
|
||||||
public Serializable list(@Validated @RequestBody ${ClassName} ${className}) {
|
|
||||||
startPage(${className}.getPageInfo());
|
|
||||||
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
#if($table.crud || $table.sub || $tplCategory.equals("rel"))
|
|
||||||
return getDataTable(genServerResult.getData());
|
|
||||||
#elseif($table.tree)
|
|
||||||
return AjaxResult.success(genServerResult.getData());
|
|
||||||
#end
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出${functionName}列表
|
|
||||||
*/
|
|
||||||
@ApiOperation("导出${functionName}列表")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:export')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
|
||||||
@PostMapping("/export")
|
|
||||||
public AjaxResult export(@Validated @RequestBody ${ClassName} ${className}) {
|
|
||||||
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
|
||||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return util.exportExcel(genServerResult.getData(), "${businessName}");
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取${functionName}详细信息
|
|
||||||
*/
|
|
||||||
@ApiOperation("获取${functionName}详细信息")
|
|
||||||
@ApiImplicitParam(name = "${pkColumn.javaField}" , value = "${functionName}${pkColumn.javaField}" , required = true, dataType = "${pkColumn.javaType}" , paramType = "path")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:query')")
|
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
|
|
||||||
ServerResult<${ClassName}> genServerResult = ${className}Service.select${ClassName}ById(${pkColumn.javaField});
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success(genServerResult.getData());
|
|
||||||
} else {
|
|
||||||
return AjaxResult.info(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*/
|
|
||||||
@ApiOperation("新增${functionName}")
|
|
||||||
@ApiImplicitParam(name = "${className}" , value = "新增${functionName}信息" , dataType = "${ClassName}")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:add')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@Validated @RequestBody ${ClassName} ${className}) {
|
|
||||||
ServerResult<Integer> genServerResult = ${className}Service.insert${ClassName}(${className});
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*/
|
|
||||||
@ApiOperation("修改${functionName}")
|
|
||||||
@ApiImplicitParam(name = "${className}" , value = "修改${functionName}信息" , dataType = "${ClassName}")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:edit')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody ${ClassName} ${className}) {
|
|
||||||
ServerResult<Integer> genServerResult = ${className}Service.update${ClassName}(${className});
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}
|
|
||||||
*/
|
|
||||||
@ApiOperation("删除${functionName}")
|
|
||||||
@ApiImplicitParam(name = "${pkColumn.javaField}s" , value = "${functionName}${pkColumn.javaField}s" , required = true, dataType = "${pkColumn.javaType}" , paramType = "path")
|
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:remove')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
|
||||||
if (${pkColumn.javaField}s.length<0){
|
|
||||||
return AjaxResult.error("id不能为空!");
|
|
||||||
}
|
|
||||||
ServerResult<Integer> genServerResult = ${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
|
||||||
if (genServerResult.isStart()) {
|
|
||||||
return AjaxResult.success();
|
|
||||||
} else {
|
|
||||||
return AjaxResult.error(genServerResult.getMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
package ${packageName}.dao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import ${packageName}.entity.${ClassName};
|
|
||||||
#if($table.sub)
|
|
||||||
import ${packageName}.entity.${subClassName};
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}Mapper接口
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
public interface ${ClassName}Dao {
|
|
||||||
/**
|
|
||||||
* 查询${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return ${functionName}
|
|
||||||
*/
|
|
||||||
${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return ${functionName}集合
|
|
||||||
*/
|
|
||||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insert${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int update${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${subTable.functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增${subTable.functionName}
|
|
||||||
*
|
|
||||||
* @param ${subclassName}List ${subTable.functionName}列表
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过${functionName}ID删除${subTable.functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
@ -1,162 +0,0 @@
|
||||||
package ${packageName}.entity;
|
|
||||||
|
|
||||||
#foreach ($import in $importList)
|
|
||||||
import ${import};
|
|
||||||
#end
|
|
||||||
#if($table.crud || $table.sub || $tplCategory.equals("rel"))
|
|
||||||
#set($Entity="BaseEntity")
|
|
||||||
#elseif($table.tree)
|
|
||||||
#set($Entity="TreeEntity")
|
|
||||||
#end
|
|
||||||
#if($table.tplCategory.equals("rel"))
|
|
||||||
import com.ebts.common.annotation.Excels;
|
|
||||||
#elseif($table.tplCategory.equals("sub"))
|
|
||||||
import ${packageName}.entity.${subClassName};
|
|
||||||
#end
|
|
||||||
import com.ebts.common.core.entity.${Entity};
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}对象 ${tableName}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
#if($table.crud || $table.sub)
|
|
||||||
#set($Entity="BaseEntity")
|
|
||||||
#elseif($table.tree)
|
|
||||||
#set($Entity="TreeEntity")
|
|
||||||
#end
|
|
||||||
@ApiModel("${functionName}")
|
|
||||||
public class ${ClassName} extends ${Entity}{
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
#if($column.list)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
|
||||||
#elseif($column.javaType == 'Date')
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
#else
|
|
||||||
@Excel(name = "${comment}")
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($column.isRequired == 1)
|
|
||||||
@NotNull(message = "${column.columnComment}不能为空!")
|
|
||||||
#end
|
|
||||||
#if($column.isRegular != 1)
|
|
||||||
@Pattern(regexp = "${column.regular}",message = "${column.columnComment}格式错误!")
|
|
||||||
#end
|
|
||||||
@ApiModelProperty("${column.columnComment}")
|
|
||||||
private $column.javaType $column.javaField;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#if($table.sub)
|
|
||||||
/** $table.subTable.functionName信息 */
|
|
||||||
@ApiModelProperty("${table.subTable.functionName}信息")
|
|
||||||
private List<${subClassName}> ${subclassName}List;
|
|
||||||
|
|
||||||
#elseif($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isList.equals("1"))
|
|
||||||
#set($count = $count + 1)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#set($targetName = "")
|
|
||||||
#set($indexs = 0)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isList.equals("1"))
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#set($indexs = $indexs + 1)
|
|
||||||
#set($targetName = $targetName + '@Excel(name = "'+$comment+'",targetAttr = "'+$column.javaField+'")')
|
|
||||||
#if($indexs != $count)
|
|
||||||
#set($targetName = $targetName + ",")
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/** ${table.relComment}信息 */
|
|
||||||
@Excels({${targetName}})
|
|
||||||
private ${table.relClass} ${table.relclass};
|
|
||||||
#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
|
||||||
#set($AttrName=$column.javaField)
|
|
||||||
#else
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#end
|
|
||||||
public void set${AttrName}($column.javaType $column.javaField){
|
|
||||||
this.$column.javaField = $column.javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $column.javaType get${AttrName}(){
|
|
||||||
return $column.javaField;
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#if($table.sub)
|
|
||||||
public List<${subClassName}> get${subClassName}List(){
|
|
||||||
return ${subclassName}List;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List){
|
|
||||||
this.${subclassName}List = ${subclassName}List;
|
|
||||||
}
|
|
||||||
#elseif($table.tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
public ${table.relClass} get${table.relClass}(){
|
|
||||||
return ${table.relclass};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set${table.relClass}(${table.relClass} ${table.relclass}){
|
|
||||||
this.${table.relclass} = ${table.relclass};
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
|
||||||
#set($AttrName=$column.javaField)
|
|
||||||
#else
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#end
|
|
||||||
.append("${column.javaField}", get${AttrName}())
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
.append("${subclassName}List", get${subClassName}List())
|
|
||||||
#elseif($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
.append("${table.relclass}",get${table.relClass}())
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
package ${packageName}.entity;
|
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ${relTable.relClass} extends BaseEntity{
|
|
||||||
|
|
||||||
#foreach($column in $relTable.relColumns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
/** $column.columnComment */
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
|
||||||
#elseif($column.javaType == 'Date')
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
#else
|
|
||||||
@Excel(name = "${comment}")
|
|
||||||
#end
|
|
||||||
private $column.javaType $column.javaField;
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#foreach ($column in $relTable.relColumns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
|
||||||
#set($AttrName=$column.javaField)
|
|
||||||
#else
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#end
|
|
||||||
public void set${AttrName}($column.javaType $column.javaField){
|
|
||||||
this.$column.javaField = $column.javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $column.javaType get${AttrName}(){
|
|
||||||
return $column.javaField;
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package ${packageName}.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import ${packageName}.entity.${ClassName};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}Service接口
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
public interface ${ClassName}Service
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return ${functionName}
|
|
||||||
*/
|
|
||||||
ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return ${functionName}集合
|
|
||||||
*/
|
|
||||||
ServerResult<List<${ClassName}>> select${ClassName}List(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> insert${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> update${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
ServerResult<Integer> delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
}
|
|
||||||
|
|
@ -1,234 +0,0 @@
|
||||||
package ${packageName}.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.ebts.common.constant.ReturnConstants;
|
|
||||||
import com.ebts.common.exception.EbtsException;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
|
||||||
import com.ebts.common.utils.DateUtils;
|
|
||||||
#end
|
|
||||||
#if($column.javaField == 'updateBy' || $column.javaField == 'createBy')
|
|
||||||
import com.ebts.common.utils.SecurityUtils;
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
import com.ebts.common.utils.ServerResult;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
#if($table.sub)
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import com.ebts.common.utils.StringUtils;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${packageName}.entity.${subClassName};
|
|
||||||
#end
|
|
||||||
import ${packageName}.dao.${ClassName}Dao;
|
|
||||||
import ${packageName}.entity.${ClassName};
|
|
||||||
import ${packageName}.service.${ClassName}Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}Service业务层处理
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(${ClassName}ServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ${ClassName}Dao ${className}Dao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return ${functionName}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
|
||||||
try {
|
|
||||||
${ClassName} ${className} = ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
|
||||||
if (${className} != null){
|
|
||||||
return new ServerResult<>(true,${className});
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return ${functionName}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<List<${ClassName}>> select${ClassName}List(${ClassName} ${className}) {
|
|
||||||
try {
|
|
||||||
List<${ClassName}> ${className}List = ${className}Dao.select${ClassName}List(${className});
|
|
||||||
if (${className}List.size()>0){
|
|
||||||
return new ServerResult<>(true,${className}List);
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false,ReturnConstants.RESULT_EMPTY);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
#if($table.sub)
|
|
||||||
@Transactional
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> insert${ClassName}(${ClassName} ${className}) {
|
|
||||||
try {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField == 'createBy')
|
|
||||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
int renewal = ${className}Dao.insert${ClassName}(${className});
|
|
||||||
if (insert${subClassName}(${className})){
|
|
||||||
return new ServerResult<>(false,ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Integer renewal = ${className}Dao.insert${ClassName}(${className});
|
|
||||||
#end
|
|
||||||
if (renewal >0){
|
|
||||||
return new ServerResult<>(true,renewal);
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
#if($table.sub)
|
|
||||||
@Transactional
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> update${ClassName}(${ClassName} ${className}) {
|
|
||||||
try {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField == 'updateBy')
|
|
||||||
${className}.setUpdateBy(SecurityUtils.getUserId());
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
${className}Dao.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
|
||||||
if (insert${subClassName}(${className})){
|
|
||||||
return new ServerResult<>(false,ReturnConstants.DB_EX);
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
Integer renewal = ${className}Dao.update${ClassName}(${className});
|
|
||||||
if (renewal >0){
|
|
||||||
return new ServerResult<>(true,renewal);
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
#if($table.sub)
|
|
||||||
@Transactional
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
|
||||||
try {
|
|
||||||
#if($table.sub)
|
|
||||||
//批量删除子表数据
|
|
||||||
${className}Dao.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
|
||||||
#end
|
|
||||||
Integer renewal = ${className}Dao.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
|
||||||
if (renewal >0){
|
|
||||||
return new ServerResult<>(true,renewal);
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ServerResult<Integer> delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
|
||||||
try {
|
|
||||||
#if($table.sub)
|
|
||||||
//删除子表数据
|
|
||||||
${className}Dao.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
|
||||||
#end
|
|
||||||
Integer renewal = ${className}Dao.delete${ClassName}ById(${pkColumn.javaField});
|
|
||||||
if (renewal >0){
|
|
||||||
return new ServerResult<>(true,renewal);
|
|
||||||
}else {
|
|
||||||
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
throw new EbtsException(ReturnConstants.OP_ERROR,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${subTable.functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}对象
|
|
||||||
*/
|
|
||||||
public boolean insert${subClassName}(${ClassName} ${className}) {
|
|
||||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
|
||||||
Long ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
|
||||||
if (StringUtils.isNotNull(${subclassName}List)) {
|
|
||||||
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
|
||||||
for (${subClassName} ${subclassName} : ${subclassName}List){
|
|
||||||
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
|
||||||
list.add(${subclassName});
|
|
||||||
}
|
|
||||||
if (list.size() > 0) {
|
|
||||||
Integer renewal = ${className}Dao.batch${subClassName}(list);
|
|
||||||
if (renewal>0){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package ${packageName}.entity;
|
|
||||||
|
|
||||||
#foreach ($import in $subImportList)
|
|
||||||
import ${import};
|
|
||||||
#end
|
|
||||||
import com.ebts.common.annotation.Excel;
|
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${subTable.functionName}对象 ${subTableName}
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
public class ${subClassName} extends BaseEntity{
|
|
||||||
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
/** $column.columnComment */
|
|
||||||
#if($column.list)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
|
||||||
#elseif($column.javaType == 'Date')
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
#else
|
|
||||||
@Excel(name = "${comment}")
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
private $column.javaType $column.javaField;
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
|
||||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
|
||||||
#set($AttrName=$column.javaField)
|
|
||||||
#else
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#end
|
|
||||||
public void set${AttrName}($column.javaType $column.javaField){
|
|
||||||
this.$column.javaField = $column.javaField;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $column.javaType get${AttrName}(){
|
|
||||||
return $column.javaField;
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
|
||||||
#set($AttrName=$column.javaField)
|
|
||||||
#else
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#end
|
|
||||||
.append("${column.javaField}", get${AttrName}())
|
|
||||||
#end
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
|
|
||||||
// 查询${functionName}列表
|
|
||||||
export function list${BusinessName}(data) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}/list',
|
|
||||||
method: 'post',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出${functionName}
|
|
||||||
export function export${BusinessName}(data) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}/export',
|
|
||||||
method: 'post',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询${functionName}详细
|
|
||||||
export function get${BusinessName}(${pkColumn.javaField}) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增${functionName}
|
|
||||||
export function add${BusinessName}(data) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}',
|
|
||||||
method: 'post',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改${functionName}
|
|
||||||
export function update${BusinessName}(data) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}',
|
|
||||||
method: 'put',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除${functionName}
|
|
||||||
export function del${BusinessName}(${pkColumn.javaField}) {
|
|
||||||
return request({
|
|
||||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
-- ${functionName}Controller
|
|
||||||
|
|
||||||
delete from sys_menu where perms= '${prefix}';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}', 5, '1', '#','' ,1, 0, 'F', '0', '0', '${prefix}','#', ${createBy}, sysdate(), 0, null, '${functionName}接口管理');
|
|
||||||
|
|
||||||
SELECT @parentId := LAST_INSERT_ID();
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.isGenerate.equals("1"))
|
|
||||||
|
|
||||||
delete from sys_menu where perms= '${prefix}:${column.requrl}';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${column.itDescribe}', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${prefix}:${column.requrl}', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
-- 菜单 SQL
|
|
||||||
|
|
||||||
delete from sys_menu where perms= '${permissionPrefix}:list';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', ${createBy}, sysdate(), 0, null, '${functionName}菜单');
|
|
||||||
|
|
||||||
-- 按钮父菜单ID
|
|
||||||
SELECT @parentId := LAST_INSERT_ID();
|
|
||||||
|
|
||||||
delete from sys_menu where perms= '${permissionPrefix}:query';
|
|
||||||
|
|
||||||
-- 按钮 SQL
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
|
|
||||||
delete from sys_menu where perms = '${permissionPrefix}:add';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
|
|
||||||
delete from sys_menu where perms = '${permissionPrefix}:edit';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
|
|
||||||
delete from sys_menu where perms = '${permissionPrefix}:remove';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
|
|
||||||
delete from sys_menu where perms = '${permissionPrefix}:export';
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', ${createBy}, sysdate(), 0, null, '');
|
|
||||||
|
|
@ -1,526 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.query)
|
|
||||||
#set($dictType=$column.dictType)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.htmlType == "input")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.${column.javaField}"
|
|
||||||
placeholder="请输入${comment}"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${column.javaField}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
:value="dict.dictValue"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-date-picker clearable size="small"
|
|
||||||
v-model="queryParams.${column.javaField}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="daterange${AttrName}"
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="${businessName}List"
|
|
||||||
row-key="${treeCode}"
|
|
||||||
default-expand-all
|
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
||||||
>
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.pk)
|
|
||||||
#elseif($column.list && $column.htmlType == "datetime")
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
#elseif($column.list && "" != $column.dictType)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
|
||||||
#elseif($column.list && "" != $javaField)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-edit"
|
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($field=$column.javaField)
|
|
||||||
#if($column.insert && !$column.pk)
|
|
||||||
#if(($column.usableColumn) || (!$column.superColumn))
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#set($dictType=$column.dictType)
|
|
||||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
|
||||||
<el-form-item label="${comment}" prop="${treeParentCode}">
|
|
||||||
<treeselect v-model="form.${treeParentCode}" :options="${businessName}Options" :normalizer="normalizer" placeholder="请选择${comment}" />
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "input")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "imageUpload")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<imageUpload v-model="form.${field}"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "fileUpload")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<fileUpload v-model="form.${field}"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "editor")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<editor v-model="form.${field}" :min-height="192"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
|
||||||
|
|
||||||
></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "select" && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictValue">
|
|
||||||
{{dict.dictLabel}}
|
|
||||||
</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
|
||||||
|
|
||||||
>{{dict.dictLabel}}</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-date-picker clearable size="small"
|
|
||||||
v-model="form.${field}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "textarea")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
|
||||||
import ImageUpload from '@/components/ImageUpload';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
|
||||||
import FileUpload from '@/components/FileUpload';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
|
||||||
import Editor from '@/components/Editor';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "${BusinessName}",
|
|
||||||
components: {
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
|
||||||
ImageUpload,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
|
||||||
FileUpload,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
|
||||||
Editor,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
Treeselect
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// 遮罩层
|
|
||||||
loading: true,
|
|
||||||
// 显示搜索条件
|
|
||||||
showSearch: true,
|
|
||||||
// ${functionName}表格数据
|
|
||||||
${businessName}List: [],
|
|
||||||
// ${functionName}树选项
|
|
||||||
${businessName}Options: [],
|
|
||||||
// 弹出层标题
|
|
||||||
title: "",
|
|
||||||
// 是否显示弹出层
|
|
||||||
open: false,
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if(${column.dictType} != '')
|
|
||||||
// $comment字典
|
|
||||||
${column.javaField}Options: [],
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
// $comment时间范围
|
|
||||||
daterange${AttrName}: [],
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
// 查询参数
|
|
||||||
queryParams: {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.query)
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
// 表单参数
|
|
||||||
form: {},
|
|
||||||
// 表单校验
|
|
||||||
rules: {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.required)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
$column.javaField: [
|
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
|
||||||
#if($column.isRegular != 1)
|
|
||||||
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
|
||||||
#end
|
|
||||||
]#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getList();
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(${column.dictType} != '')
|
|
||||||
this.getDicts("${column.dictType}").then(response => {
|
|
||||||
this.${column.javaField}Options = response.data;
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/** 查询${functionName}列表 */
|
|
||||||
getList() {
|
|
||||||
this.loading = true;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
this.queryParams.params = {};
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
|
||||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
|
||||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
|
||||||
this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 转换${functionName}数据结构 */
|
|
||||||
normalizer(node) {
|
|
||||||
if (node.children && !node.children.length) {
|
|
||||||
delete node.children;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
id: node.${treeCode},
|
|
||||||
label: node.${treeName},
|
|
||||||
children: node.children
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/** 查询部门下拉树结构 */
|
|
||||||
getTreeselect() {
|
|
||||||
list${BusinessName}().then(response => {
|
|
||||||
this.${businessName}Options = [];
|
|
||||||
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
|
||||||
data.children = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
|
||||||
this.${businessName}Options.push(data);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(${column.dictType} != '')
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
// $comment字典翻译
|
|
||||||
${column.javaField}Format(row, column) {
|
|
||||||
return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
// 取消按钮
|
|
||||||
cancel() {
|
|
||||||
this.open = false;
|
|
||||||
this.reset();
|
|
||||||
},
|
|
||||||
// 表单重置
|
|
||||||
reset() {
|
|
||||||
this.form = {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "radio")
|
|
||||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#elseif($column.htmlType == "checkbox")
|
|
||||||
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#else
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
this.resetForm("form");
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
|
||||||
handleQuery() {
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
/** 重置按钮操作 */
|
|
||||||
resetQuery() {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
this.daterange${AttrName} = [];
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
this.resetForm("queryForm");
|
|
||||||
this.handleQuery();
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd() {
|
|
||||||
this.reset();
|
|
||||||
this.getTreeselect();
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加${functionName}";
|
|
||||||
},
|
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
this.getTreeselect();
|
|
||||||
if (row != null) {
|
|
||||||
this.form.${treeParentCode} = row.${treeCode};
|
|
||||||
}
|
|
||||||
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
|
|
||||||
this.form = response.data;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改${functionName}";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm() {
|
|
||||||
this.#[[$]]#refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
if (this.form.${pkColumn.javaField} != null) {
|
|
||||||
update${BusinessName}(this.form).then(response => {
|
|
||||||
this.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
add${BusinessName}(this.form).then(response => {
|
|
||||||
this.msgSuccess("新增成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
handleDelete(row) {
|
|
||||||
this.$confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning"
|
|
||||||
}).then(function() {
|
|
||||||
return del${BusinessName}(row.${pkColumn.javaField});
|
|
||||||
}).then(() => {
|
|
||||||
this.getList();
|
|
||||||
this.msgSuccess("删除成功");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,810 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.query)
|
|
||||||
#set($dictType=$column.dictType)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.htmlType == "input")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.${column.javaField}"
|
|
||||||
placeholder="请输入${comment}"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${column.javaField}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
:value="dict.dictValue"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-date-picker clearable size="small"
|
|
||||||
v-model="queryParams.${column.javaField}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="daterange${AttrName}"
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isQuery == '1')
|
|
||||||
#set($dictType=$column.dictType)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.htmlType == "input")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.${table.relclass}.${column.javaField}"
|
|
||||||
placeholder="请输入${comment}"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${table.relclass}.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${table.relclass}${column.javaField}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
:value="dict.dictValue"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${table.relclass}.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-date-picker clearable size="small"
|
|
||||||
v-model="queryParams.${table.relclass}.${column.javaField}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="${table.relclass}${AttrName}"
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
plain
|
|
||||||
icon="el-icon-edit"
|
|
||||||
size="mini"
|
|
||||||
:disabled="single"
|
|
||||||
@click="handleUpdate"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
plain
|
|
||||||
icon="el-icon-delete"
|
|
||||||
size="mini"
|
|
||||||
:disabled="multiple"
|
|
||||||
@click="handleDelete"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="warning"
|
|
||||||
plain
|
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
|
||||||
<el-table-column label="序号" type="index" align="center">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
##todo 请将scope.$ index 中间的空格去掉
|
|
||||||
<span>{{ ((queryParams.pageInfo.pageNum - 1) * queryParams.pageInfo.pageSize + scope.$ index + 1)}}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.pk && "" != $column.pk)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
|
||||||
#elseif($column.list && $column.htmlType == "datetime")
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
#elseif($column.list && "" != $column.dictType)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
|
||||||
#elseif($column.list && "" != $javaField)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.isList == "1" && $column.htmlType == "datetime")
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${table.relclass}.${javaField}" width="180">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.${table.relclass}.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
#elseif($column.isList == "1" && "" != $column.dictType)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${table.relclass}.${javaField}" :formatter="${javaField}Format" />
|
|
||||||
#elseif($column.isList == "1" && "" != $javaField)
|
|
||||||
<el-table-column label="${comment}" align="center" prop="${table.relclass}.${javaField}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-edit"
|
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<pagination
|
|
||||||
v-show="total>0"
|
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageInfo.pageNum"
|
|
||||||
:limit.sync="queryParams.pageInfo.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($field=$column.javaField)
|
|
||||||
#if($column.insert && !$column.pk)
|
|
||||||
#if(($column.usableColumn) || (!$column.superColumn))
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#set($dictType=$column.dictType)
|
|
||||||
#if($column.htmlType == "input")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "imageUpload")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<imageUpload v-model="form.${field}"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "fileUpload")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<fileUpload v-model="form.${field}"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "editor")
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<editor v-model="form.${field}" :min-height="192"/>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
|
||||||
|
|
||||||
></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "select" && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictValue">
|
|
||||||
{{dict.dictLabel}}
|
|
||||||
</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
|
||||||
|
|
||||||
>{{dict.dictLabel}}</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-date-picker clearable size="small"
|
|
||||||
v-model="form.${field}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "textarea")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
|
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
|
||||||
<el-table-column type="selection" width="50" align="center" />
|
|
||||||
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
|
||||||
#foreach($column in $subTable.columns)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
|
||||||
#elseif($column.list && "" != $javaField)
|
|
||||||
<el-table-column label="$comment" prop="${javaField}">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</el-table>
|
|
||||||
#end
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
|
||||||
import ImageUpload from '@/components/ImageUpload';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
|
||||||
import FileUpload from '@/components/FileUpload';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
|
||||||
import Editor from '@/components/Editor';
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "${BusinessName}",
|
|
||||||
components: {
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
|
||||||
ImageUpload,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
|
||||||
FileUpload,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
|
||||||
Editor,
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// 遮罩层
|
|
||||||
loading: true,
|
|
||||||
// 选中数组
|
|
||||||
ids: [],
|
|
||||||
#if($table.sub)
|
|
||||||
// 子表选中数据
|
|
||||||
checked${subClassName}: [],
|
|
||||||
#end
|
|
||||||
// 非单个禁用
|
|
||||||
single: true,
|
|
||||||
// 非多个禁用
|
|
||||||
multiple: true,
|
|
||||||
// 显示搜索条件
|
|
||||||
showSearch: true,
|
|
||||||
// 总条数
|
|
||||||
total: 0,
|
|
||||||
// ${functionName}表格数据
|
|
||||||
${businessName}List: [],
|
|
||||||
#if($table.sub)
|
|
||||||
// ${subTable.functionName}表格数据
|
|
||||||
${subclassName}List: [],
|
|
||||||
#end
|
|
||||||
// 弹出层标题
|
|
||||||
title: "",
|
|
||||||
// 是否显示弹出层
|
|
||||||
open: false,
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if(${column.dictType}!='')
|
|
||||||
// $comment字典
|
|
||||||
${column.javaField}Options: [],
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
// $comment时间范围
|
|
||||||
daterange${AttrName}: [],
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
#if(${column.dictType}!="")
|
|
||||||
// $comment字典
|
|
||||||
${table.relclass}${column.javaField}Options: [],
|
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
// $comment时间范围
|
|
||||||
${table.relclass}${AttrName}: [],
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
// 查询参数
|
|
||||||
queryParams: {
|
|
||||||
pageInfo:{
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
},
|
|
||||||
params:{},
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.query && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
${table.relclass}: {
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isQuery == '1' && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
|
||||||
${column.javaField}: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
params:{},
|
|
||||||
},
|
|
||||||
#if($velocityCount != $relTables.size()),#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
},
|
|
||||||
// 表单参数
|
|
||||||
form: {},
|
|
||||||
// 表单校验
|
|
||||||
rules: {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.required)
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
$column.javaField: [
|
|
||||||
{ required: true, message: "${comment}不能为空}", trigger: #if($column.htmlType == "select")"change"#else"blur"#end },
|
|
||||||
#if($column.isRegular != 1)
|
|
||||||
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
|
||||||
#end
|
|
||||||
]#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getList();
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(${column.dictType}!='')
|
|
||||||
this.getDicts("${column.dictType}").then(response => {
|
|
||||||
this.${column.javaField}Options = response.data;
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.tplCategory.equals("rel"))
|
|
||||||
#foreach ($table in $relTables)
|
|
||||||
#foreach ($column in $table.relColumns)
|
|
||||||
#if(${column.dictType}!='')
|
|
||||||
this.getDicts("${column.dictType}").then(response => {
|
|
||||||
this.${table.relclass}${column.javaField}Options = response.data;
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/** 查询${functionName}列表 */
|
|
||||||
getList() {
|
|
||||||
this.loading = true;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
this.queryParams.params={}
|
|
||||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
|
||||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
|
||||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end#if($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
this.queryParams.${table.relclass}.params={}
|
|
||||||
if (null != this.ass${AttrName} && '' != this.ass${AttrName}) {
|
|
||||||
this.queryParams.${table.relclass}.params["begin${AttrName}"] = this.ass${AttrName}[0];
|
|
||||||
this.queryParams.${table.relclass}.params["end${AttrName}"] = this.ass${AttrName}[1];
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
|
||||||
this.${businessName}List = response.rows;
|
|
||||||
this.total = response.total;
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if(${column.dictType} != '')
|
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
|
||||||
#if($parentheseIndex != -1)
|
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
|
||||||
#else
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
#end
|
|
||||||
// $comment字典翻译
|
|
||||||
${column.javaField}Format(row, column) {
|
|
||||||
return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
// 取消按钮
|
|
||||||
cancel() {
|
|
||||||
this.open = false;
|
|
||||||
this.reset();
|
|
||||||
},
|
|
||||||
// 表单重置
|
|
||||||
reset() {
|
|
||||||
this.form = {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType != "datetime" && $column.queryType != "BETWEEN" && $column.javaField != 'createBy' && $column.javaField != 'updateBy')
|
|
||||||
#if($column.htmlType == "radio")
|
|
||||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#elseif($column.htmlType == "checkbox")
|
|
||||||
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#else
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
#if($table.sub)
|
|
||||||
this.${subclassName}List = [];
|
|
||||||
#end
|
|
||||||
this.resetForm("form");
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
|
||||||
handleQuery() {
|
|
||||||
this.queryParams.pageNum = 1;
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
/** 重置按钮操作 */
|
|
||||||
resetQuery() {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
this.daterange${AttrName} = [];
|
|
||||||
this.queryParams.params={}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($tplCategory.equals("rel"))
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
this.${table.relclass}${AttrName} = [];
|
|
||||||
this.queryParams.${table.relclass}.params={}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
this.resetForm("queryForm");
|
|
||||||
this.handleQuery();
|
|
||||||
},
|
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map(item => item.${pkColumn.javaField})
|
|
||||||
this.single = selection.length!==1
|
|
||||||
this.multiple = !selection.length
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd() {
|
|
||||||
this.reset();
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加${functionName}";
|
|
||||||
},
|
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
|
||||||
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
|
||||||
this.form = response.data;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
this.${subclassName}List = response.data.${subclassName}List;
|
|
||||||
#end
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改${functionName}";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm() {
|
|
||||||
this.#[[$]]#refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
this.form.${subclassName}List = this.${subclassName}List;
|
|
||||||
#end
|
|
||||||
if (this.form.${pkColumn.javaField} != null) {
|
|
||||||
update${BusinessName}(this.form).then(response => {
|
|
||||||
this.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
add${BusinessName}(this.form).then(response => {
|
|
||||||
this.msgSuccess("新增成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
handleDelete(row) {
|
|
||||||
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
|
|
||||||
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning"
|
|
||||||
}).then(function() {
|
|
||||||
return del${BusinessName}(${pkColumn.javaField}s);
|
|
||||||
}).then(() => {
|
|
||||||
this.getList();
|
|
||||||
this.msgSuccess("删除成功");
|
|
||||||
})
|
|
||||||
},
|
|
||||||
#if($table.sub)
|
|
||||||
/** ${subTable.functionName}序号 */
|
|
||||||
row${subClassName}Index({ row, rowIndex }) {
|
|
||||||
row.index = rowIndex + 1;
|
|
||||||
},
|
|
||||||
/** ${subTable.functionName}添加按钮操作 */
|
|
||||||
handleAdd${subClassName}() {
|
|
||||||
let obj = {};
|
|
||||||
#foreach($column in $subTable.columns)
|
|
||||||
#if($column.pk || $column.javaField == ${subTableFkclassName})
|
|
||||||
#elseif($column.list && "" != $javaField)
|
|
||||||
obj.$column.javaField = "";
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
this.${subclassName}List.push(obj);
|
|
||||||
},
|
|
||||||
/** ${subTable.functionName}删除按钮操作 */
|
|
||||||
handleDelete${subClassName}() {
|
|
||||||
if (this.checked${subClassName}.length == 0) {
|
|
||||||
this.$alert("请先选择要删除的${subTable.functionName}数据", "提示", { confirmButtonText: "确定", });
|
|
||||||
} else {
|
|
||||||
this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/** 单选框选中数据 */
|
|
||||||
handle${subClassName}SelectionChange(selection) {
|
|
||||||
if (selection.length > 1) {
|
|
||||||
this.$refs.${subclassName}.clearSelection();
|
|
||||||
this.$refs.${subclassName}.toggleRowSelection(selection.pop());
|
|
||||||
} else {
|
|
||||||
this.checked${subClassName} = selection;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
/** 导出按钮操作 */
|
|
||||||
handleExport() {
|
|
||||||
const queryParams = this.queryParams;
|
|
||||||
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning"
|
|
||||||
}).then(function() {
|
|
||||||
return export${BusinessName}(queryParams);
|
|
||||||
}).then(response => {
|
|
||||||
this.download(response.msg);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,247 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="${packageName}.dao.${ClassName}Dao">
|
|
||||||
|
|
||||||
<resultMap type="${packageName}.entity.${ClassName}" id="${ClassName}Result">
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<resultMap id="${ClassName}${subClassName}Result" type="${packageName}.entity.${ClassName}" extends="${ClassName}Result">
|
|
||||||
<collection property="${subclassName}List" notNullColumn="${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="${packageName}.entity.${subClassName}" id="${subClassName}Result">
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#end
|
|
||||||
#if($table.tplCategory.equals("rel"))
|
|
||||||
<resultMap id="${ClassName}AllResult" type="${packageName}.entity.${ClassName}" extends="${ClassName}Result">
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
<collection property="${table.relclass}" notNullColumn="${table.relColumn}" javaType="${packageName}.entity.${table.relClass}" resultMap="${table.relClass}Result" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
<resultMap id="${table.relClass}Result" type="${packageName}.entity.${table.relClass}">
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
<sql id="select${ClassName}Vo">
|
|
||||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
|
|
||||||
#if($tplCategory.equals("rel"))
|
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}AllResult">
|
|
||||||
select #foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#set($count = 0)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isList == "1")
|
|
||||||
#set($count = $count + 1)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#set($indexs = 0)
|
|
||||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $relTables.size()),
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
from ${tableName} ${tableMapping}
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
${table.queryType} join ${table.relName} ${table.relAs} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
|
||||||
#end
|
|
||||||
<where>
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($queryType=$column.queryType)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($javaType=$column.javaType)
|
|
||||||
#set($columnName=$tableMapping+'.'+$column.columnName)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#if($column.query)
|
|
||||||
#if($column.queryType == "EQ")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
|
||||||
#elseif($queryType == "NE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LIKE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
|
||||||
#elseif($queryType == "BETWEEN")
|
|
||||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#set($queryType=$column.queryType)
|
|
||||||
#set($javaField=$table.relclass + "." + $column.javaField)
|
|
||||||
#set($javaType=$column.javaType)
|
|
||||||
#set($columnName=$table.relAs+'.'+$column.columnName)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#if($column.isQuery.equals("1"))
|
|
||||||
#if($column.queryType == "EQ")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
|
||||||
#elseif($queryType == "NE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LIKE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
|
||||||
#elseif($queryType == "BETWEEN")
|
|
||||||
<if test="${table.relclass}.params.begin$AttrName != null and ${table.relclass}.params.begin$AttrName != '' and ${table.relclass}.params.end$AttrName != null and ${table.relclass}.params.end$AttrName != ''"> and $columnName between #{${table.relclass}.params.begin$AttrName} and #{${table.relclass}.params.end$AttrName}</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
|
||||||
<include refid="select${ClassName}Vo"/>
|
|
||||||
<where>
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($queryType=$column.queryType)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($javaType=$column.javaType)
|
|
||||||
#set($columnName=$column.columnName)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#if($column.isQuery.equals("1"))
|
|
||||||
#if($column.queryType == "EQ")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
|
||||||
#elseif($queryType == "NE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LIKE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
|
||||||
#elseif($queryType == "BETWEEN")
|
|
||||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
|
||||||
#if($table.crud || $table.tree || $tplCategory.equals("rel"))
|
|
||||||
<include refid="select${ClassName}Vo"/>
|
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
#elseif($table.sub)
|
|
||||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
|
||||||
#foreach($column in $subTable.columns) ${subMapping}.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
|
||||||
from ${tableName} ${tableMapping}
|
|
||||||
left join ${subTableName} ${subMapping} on ${subMapping}.${subTableFkName} = ${tableMapping}.${pkColumn.columnName}
|
|
||||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
#end
|
|
||||||
</select>
|
|
||||||
#if($tplCategory.equals("rel"))
|
|
||||||
<select id="select${ClassName}AllById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}AllResult">
|
|
||||||
select #foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
#set($count = 0)
|
|
||||||
#foreach($column in $table.relColumns)
|
|
||||||
#if($column.isList == "1")
|
|
||||||
#set($count = $count + 1)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#set($indexs = 0)
|
|
||||||
#foreach($column in $table.relColumns) #if($column.isList == "1")#set($indexs = $indexs + 1)${table.relAs}.$column.columnName#if($indexs != $count),#end#end#end#if($velocityCount != $relTables.size()),
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
from ${tableName} ${tableMapping}
|
|
||||||
#foreach($table in $relTables)
|
|
||||||
${table.queryType} join ${table.relName} ${table.relAs} on ${table.tableAs}.${table.tableColumn} = ${table.relAs}.${table.relColumn}
|
|
||||||
#end
|
|
||||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
</select>
|
|
||||||
#end
|
|
||||||
|
|
||||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
|
||||||
insert into ${tableName}
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if(($column.columnName != $pkColumn.columnName || !$pkColumn.increment) && $column.isInsert == 1)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if(($column.columnName != $pkColumn.columnName || !$pkColumn.increment) && $column.isInsert == 1)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="update${ClassName}" parameterType="${ClassName}">
|
|
||||||
update ${tableName}
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.columnName != $pkColumn.columnName && $column.isInsert == 1)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="delete${ClassName}ById" parameterType="${pkColumn.javaType}">
|
|
||||||
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="delete${ClassName}ByIds" parameterType="String">
|
|
||||||
delete from ${tableName} where ${pkColumn.columnName} in
|
|
||||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
|
||||||
#{${pkColumn.javaField}}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} in
|
|
||||||
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
|
||||||
#{${subTableFkclassName}}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="Long">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="batch${subClassName}">
|
|
||||||
insert into ${subTableName}(#set($index = 0)#foreach($column in $subTable.columns)#if($column.isPk.equals("1"))#set($insex = 1)#else$column.columnName#if($velocityCount != ($subTable.columns.size()-$index)),#end#end#end) values
|
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
|
||||||
(#foreach($column in $subTable.columns)#if($column.isPk.equals("1"))#set($index = 1)#else#{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end#end)
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
#end
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in New Issue