mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-06-11 11:23:10 +08:00
Compare commits
4 Commits
r20191128.
...
r20191229.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03152e54ef | ||
|
|
8b37443018 | ||
|
|
eb7760ac18 | ||
|
|
ae7815105f |
@@ -27,6 +27,7 @@
|
||||
|
||||
|更新日期|更新内容|
|
||||
|-|-|
|
||||
|20191229|1.修复bejson安全防护策略拦截问题(感谢@liangbintao和@1808083642的反馈) 2.优化字段名含date字符串的处理(感谢@smilexzh的反馈) 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交)|
|
||||
|20191128|1.修复支持string-copy导致的以n结尾的字母不显示问题 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|
||||
|20191126|1.springboot2内置tomcat更换为性能更强大的undertow 2.修复tinyintTransType参数丢失问题 |
|
||||
|20191124|1.java代码结构优化. 2.新增简单的json生成模式 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献) 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理,JSONObject和JSONArray节点处理,子节点缺失'{'头处理|
|
||||
|
||||
@@ -5,10 +5,8 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@Slf4j
|
||||
public class GeneratorWebApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GeneratorWebApplication.class,args);
|
||||
log.info("项目启动启动成功!访问地址: http://localhost:1234/generator");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description 动态获取tomcat启动端口,控制台打印项目访问地址
|
||||
* @Author Gao Hang Hang
|
||||
* @Date 2019-12-27 14:37
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ServerConfig implements ApplicationListener<WebServerInitializedEvent> {
|
||||
|
||||
private int serverPort;
|
||||
|
||||
public int getPort() {
|
||||
return this.serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(WebServerInitializedEvent event) {
|
||||
this.serverPort = event.getWebServer().getPort();
|
||||
//log.info("Get WebServer port {}", serverPort);
|
||||
log.info("项目启动启动成功!访问地址: http://localhost:{}/generator", serverPort);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +1,49 @@
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 2019-2-11 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/* @Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedHeaders("x-requested-with")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
|
||||
.maxAge(3600);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
//FastJsonHttpMessageConverter
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
|
||||
List<MediaType> fastMediaTypes = new ArrayList<>();
|
||||
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
fastJsonConfig.setCharset(Charset.forName("UTF-8"));
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
|
||||
//StringHttpMessageConverter
|
||||
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
||||
stringConverter.setDefaultCharset(Charset.forName("UTF-8"));
|
||||
stringConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
converters.add(stringConverter);
|
||||
converters.add(fastConverter);
|
||||
}
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 2019-2-11 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/* @Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedHeaders("x-requested-with")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
|
||||
.maxAge(3600);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
//FastJsonHttpMessageConverter
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
|
||||
List<MediaType> fastMediaTypes = new ArrayList<>();
|
||||
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
fastJsonConfig.setCharset(StandardCharsets.UTF_8);
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
|
||||
//StringHttpMessageConverter
|
||||
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
||||
stringConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
stringConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
converters.add(stringConverter);
|
||||
converters.add(fastConverter);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -37,7 +38,7 @@ public class IndexController {
|
||||
|
||||
@PostMapping("/genCode")
|
||||
@ResponseBody
|
||||
public ReturnT<Map<String, String>> codeGenerate( ParamInfo paramInfo ) {
|
||||
public ReturnT<Map<String, String>> codeGenerate(@RequestBody ParamInfo paramInfo ) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class TableParseUtil {
|
||||
fieldClass = Float.class.getSimpleName();
|
||||
} else if (columnLine.contains("double")) {
|
||||
fieldClass = Double.class.getSimpleName();
|
||||
} else if (columnLine.contains("time") || columnLine.contains("date") || columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
||||
} else if (columnLine.contains("time") || columnLine.contains(" date") || columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
||||
fieldClass = Date.class.getSimpleName();
|
||||
} else if (columnLine.contains("varchar") || columnLine.contains(" text")|| columnLine.contains("char")
|
||||
|| columnLine.contains("clob")||columnLine.contains("blob")||columnLine.contains("json")) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version": "20191128"}
|
||||
{"version": "20191229"}
|
||||
@@ -42,27 +42,44 @@
|
||||
genCodeArea.setSize('auto','auto');
|
||||
|
||||
var codeData;
|
||||
|
||||
// 使用:var jsonObj = $("#formId").serializeObject();
|
||||
$.fn.serializeObject = function()
|
||||
{
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
$.each(a, function() {
|
||||
if (o[this.name]) {
|
||||
if (!o[this.name].push) {
|
||||
o[this.name] = [o[this.name]];
|
||||
}
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
o[this.name] = this.value || '';
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
$('#btnGenCode').click(function () {
|
||||
var tableSql = ddlSqlArea.getValue();
|
||||
var jsonData = {
|
||||
"tableSql": ddlSqlArea.getValue(),
|
||||
"packageName":$("#packageName").val(),
|
||||
"returnUtil":$("#returnUtil").val(),
|
||||
"authorName":$("#authorName").val(),
|
||||
"dataType":$("#dataType").val(),
|
||||
"tinyintTransType":$("#tinyintTransType").val(),
|
||||
"nameCaseType":$("#nameCaseType").val()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: base_url + "/genCode",
|
||||
data: {
|
||||
"tableSql": tableSql,
|
||||
"packageName":$("#packageName").val(),
|
||||
"returnUtil":$("#returnUtil").val(),
|
||||
"authorName":$("#authorName").val(),
|
||||
"dataType":$("#dataType").val(),
|
||||
"tinyintTransType":$("#tinyintTransType").val(),
|
||||
"nameCaseType":$("#nameCaseType").val()
|
||||
},
|
||||
data:(JSON.stringify(jsonData)),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
if (data.code === 200) {
|
||||
codeData = data.data;
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
@@ -72,6 +89,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
/**
|
||||
* 按钮事件组
|
||||
|
||||
Reference in New Issue
Block a user