Skip to content

Commit

Permalink
1.修复bejson安全防护策略拦截问题(感谢@liangbintao@1808083642的反馈) 2.优化字段名含date字符串的处…
Browse files Browse the repository at this point in the history
…理(感谢@smilexzh的反馈) 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交)
  • Loading branch information
moshowgame committed Dec 29, 2019
1 parent 8b37443 commit 03152e5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 63 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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节点处理,子节点缺失'{'头处理|
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand All @@ -37,7 +38,7 @@ public String index() {

@PostMapping("/genCode")
@ResponseBody
public ReturnT<Map<String, String>> codeGenerate( ParamInfo paramInfo ) {
public ReturnT<Map<String, String>> codeGenerate(@RequestBody ParamInfo paramInfo ) {

try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
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")) {
Expand Down
2 changes: 1 addition & 1 deletion generator-web/src/main/resources/static/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "20191128"}
{"version": "20191229"}
42 changes: 30 additions & 12 deletions generator-web/src/main/resources/templates/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -72,6 +89,7 @@
}
}
});
return false;
});
/**
* 按钮事件组
Expand Down

0 comments on commit 03152e5

Please sign in to comment.