mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 05:48:33 +08:00
提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request)
This commit is contained in:
parent
6fb2cbae63
commit
256d93d88d
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/.idea
|
||||
/target/*
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
@ -16,6 +16,8 @@ SpringBootCodeGenerator
|
||||
<tr><td>CSDN博客</td> <td>http://blog.csdn.net/moshowgame</td></tr>
|
||||
<tr><td></td> <td></td></tr>
|
||||
<tr><td>更新日期</td> <td>更新内容</td></tr>
|
||||
<tr><td>20190211<td>提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request)。</td></tr>
|
||||
<tr><td>20190210<td>实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request)。</td></tr>
|
||||
<tr><td>20190106<td>修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈),修复JdbcTemplates模板两处错误(感谢@everflourish的反馈)。</td></tr>
|
||||
<tr><td>20181212<td>首页UI优化,新增MybatisPlus模块(感谢@三叔同事的建议),修复作者名和包名获取失败问题(感谢@Yanch1994的反馈)。</td></tr>
|
||||
<tr><td>20181122<td>优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导)。</td></tr>
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CorsFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
/*String curOrigin = request.getHeader("Origin");
|
||||
System.out.println("###跨域过滤器->当前访问来源->"+curOrigin+"###"); */
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT, GET");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {}
|
||||
|
||||
@Override
|
||||
public void destroy() {}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
/**
|
||||
* 添加fastjson的转换
|
||||
*/
|
||||
@Configuration
|
||||
public class FastjsonConverter {
|
||||
|
||||
@Bean
|
||||
public HttpMessageConverters customConverters() {
|
||||
// 定义一个转换消息的对象
|
||||
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
|
||||
// 添加fastjson的配置信息 比如 :是否要格式化返回的json数据
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
//fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
|
||||
|
||||
List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
|
||||
|
||||
// 处理中文乱码问题1
|
||||
// 处理中文乱码问题2
|
||||
fastJsonConfig.setCharset(Charset.forName("UTF-8"));
|
||||
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
//fastMediaTypes.add(MediaType.valueOf("text/plain;charset=UTF-8"));
|
||||
//fastMediaTypes.add(MediaType.valueOf("text/html;charset=UTF-8"));
|
||||
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
// 在转换器中添加配置信息
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
|
||||
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
||||
stringConverter.setDefaultCharset(Charset.forName("UTF-8"));
|
||||
stringConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||
|
||||
// 将转换器添加到converters中
|
||||
return new HttpMessageConverters(stringConverter,fastConverter);
|
||||
}
|
||||
}
|
||||
@ -0,0 +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);
|
||||
}
|
||||
}
|
||||
@ -5,12 +5,12 @@ import com.softdev.system.generator.entity.ReturnT;
|
||||
import com.softdev.system.generator.util.CodeGeneratorTool;
|
||||
import com.softdev.system.generator.util.FreemarkerTool;
|
||||
import freemarker.template.TemplateException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -22,8 +22,8 @@ import java.util.Map;
|
||||
* @author zhengk/moshow
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
public class IndexController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
|
||||
|
||||
@Autowired
|
||||
private FreemarkerTool freemarkerTool;
|
||||
@ -35,16 +35,17 @@ public class IndexController {
|
||||
|
||||
@RequestMapping("/genCode")
|
||||
@ResponseBody
|
||||
public ReturnT<Map<String, String>> codeGenerate(String tableSql,String authorName,String packageName) {
|
||||
public ReturnT<Map<String, String>> codeGenerate(String tableSql,
|
||||
//2019-2-10 liutf 修改为@RequestParam参数校验
|
||||
@RequestParam(required = false, defaultValue = "大狼狗") String authorName,
|
||||
@RequestParam(required = false, defaultValue = "com.softdev.system")String packageName
|
||||
) {
|
||||
|
||||
if(StringUtils.isBlank(authorName)) authorName="大狼狗";
|
||||
|
||||
if(StringUtils.isBlank(packageName)) packageName="com.softdev.system";
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isBlank(tableSql)) {
|
||||
return new ReturnT<Map<String, String>>(ReturnT.FAIL_CODE, "表结构信息不可为空");
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE, "表结构信息不可为空");
|
||||
}
|
||||
|
||||
// parse table
|
||||
@ -60,31 +61,30 @@ public class IndexController {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
|
||||
//UI
|
||||
result.put("swaggerui", freemarkerTool.processString("xxl-code-generator/swagger-ui.ftl", params));
|
||||
result.put("elementui", freemarkerTool.processString("xxl-code-generator/element-ui.ftl", params));
|
||||
result.put("bootstrap", freemarkerTool.processString("xxl-code-generator/bootstrap.ftl", params));
|
||||
|
||||
result.put("swagger-ui", freemarkerTool.processString("code-generator/ui/swagger-ui.ftl", params));
|
||||
result.put("element-ui", freemarkerTool.processString("code-generator/ui/element-ui.ftl", params));
|
||||
result.put("bootstrap-ui", freemarkerTool.processString("code-generator/ui/bootstrap-ui.ftl", params));
|
||||
//mybatis old
|
||||
result.put("controller", freemarkerTool.processString("xxl-code-generator/controller.ftl", params));
|
||||
result.put("service", freemarkerTool.processString("xxl-code-generator/service.ftl", params));
|
||||
result.put("service_impl", freemarkerTool.processString("xxl-code-generator/service_impl.ftl", params));
|
||||
result.put("dao", freemarkerTool.processString("xxl-code-generator/dao.ftl", params));
|
||||
result.put("mybatis", freemarkerTool.processString("xxl-code-generator/mybatis.ftl", params));
|
||||
result.put("model", freemarkerTool.processString("xxl-code-generator/model.ftl", params));
|
||||
result.put("controller", freemarkerTool.processString("code-generator/mybatis/controller.ftl", params));
|
||||
result.put("service", freemarkerTool.processString("code-generator/mybatis/service.ftl", params));
|
||||
result.put("service_impl", freemarkerTool.processString("code-generator/mybatis/service_impl.ftl", params));
|
||||
result.put("dao", freemarkerTool.processString("code-generator/mybatis/dao.ftl", params));
|
||||
result.put("mybatis", freemarkerTool.processString("code-generator/mybatis/mybatis.ftl", params));
|
||||
result.put("model", freemarkerTool.processString("code-generator/mybatis/model.ftl", params));
|
||||
//jpa
|
||||
result.put("entity", freemarkerTool.processString("xxl-code-generator/entity.ftl", params));
|
||||
result.put("repository", freemarkerTool.processString("xxl-code-generator/repository.ftl", params));
|
||||
result.put("jpacontroller", freemarkerTool.processString("xxl-code-generator/jpacontroller.ftl", params));
|
||||
result.put("entity", freemarkerTool.processString("code-generator/jpa/entity.ftl", params));
|
||||
result.put("repository", freemarkerTool.processString("code-generator/jpa/repository.ftl", params));
|
||||
result.put("jpacontroller", freemarkerTool.processString("code-generator/jpa/jpacontroller.ftl", params));
|
||||
//jdbc template
|
||||
result.put("jtdao", freemarkerTool.processString("xxl-code-generator/jtdao.ftl", params));
|
||||
result.put("jtdaoimpl", freemarkerTool.processString("xxl-code-generator/jtdaoimpl.ftl", params));
|
||||
result.put("jtdao", freemarkerTool.processString("code-generator/jdbc-template/jtdao.ftl", params));
|
||||
result.put("jtdaoimpl", freemarkerTool.processString("code-generator/jdbc-template/jtdaoimpl.ftl", params));
|
||||
//beetsql
|
||||
result.put("beetlmd", freemarkerTool.processString("xxl-code-generator/beetlmd.ftl", params));
|
||||
result.put("beetlentity", freemarkerTool.processString("xxl-code-generator/beetlentity.ftl", params));
|
||||
result.put("beetlcontroller", freemarkerTool.processString("xxl-code-generator/beetlcontroller.ftl", params));
|
||||
result.put("beetlmd", freemarkerTool.processString("code-generator/beetlsql/beetlmd.ftl", params));
|
||||
result.put("beetlentity", freemarkerTool.processString("code-generator/beetlsql/beetlentity.ftl", params));
|
||||
result.put("beetlcontroller", freemarkerTool.processString("code-generator/beetlsql/beetlcontroller.ftl", params));
|
||||
//mybatis plus
|
||||
result.put("pluscontroller", freemarkerTool.processString("xxl-code-generator/pluscontroller.ftl", params));
|
||||
result.put("plusmapper", freemarkerTool.processString("xxl-code-generator/plusmapper.ftl", params));
|
||||
result.put("pluscontroller", freemarkerTool.processString("code-generator/mybatis-plus/pluscontroller.ftl", params));
|
||||
result.put("plusmapper", freemarkerTool.processString("code-generator/mybatis-plus/plusmapper.ftl", params));
|
||||
|
||||
// 计算,生成代码行数
|
||||
int lineNum = 0;
|
||||
@ -93,13 +93,13 @@ public class IndexController {
|
||||
lineNum += StringUtils.countMatches(item.getValue(), "\n");
|
||||
}
|
||||
}
|
||||
logger.info("生成代码行数:{}", lineNum);
|
||||
log.info("生成代码行数:{}", lineNum);
|
||||
//测试环境可自行开启
|
||||
//logger.info("生成代码数据:{}", result);
|
||||
return new ReturnT<Map<String, String>>(result);
|
||||
//log.info("生成代码数据:{}", result);
|
||||
return new ReturnT<>(result);
|
||||
} catch (IOException | TemplateException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new ReturnT<Map<String, String>>(ReturnT.FAIL_CODE, "表结构解析失败"+e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE, "表结构解析失败"+e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.softdev.system.generator.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -7,44 +9,12 @@ import java.util.List;
|
||||
*
|
||||
* @author xuxueli 2018-05-02 20:02:34
|
||||
*/
|
||||
@Data
|
||||
public class ClassInfo {
|
||||
|
||||
private String tableName;
|
||||
private String className;
|
||||
private String classComment;
|
||||
|
||||
private List<FieldInfo> fieldList;
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getClassComment() {
|
||||
return classComment;
|
||||
}
|
||||
|
||||
public void setClassComment(String classComment) {
|
||||
this.classComment = classComment;
|
||||
}
|
||||
|
||||
public List<FieldInfo> getFieldList() {
|
||||
return fieldList;
|
||||
}
|
||||
|
||||
public void setFieldList(List<FieldInfo> fieldList) {
|
||||
this.fieldList = fieldList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +1,13 @@
|
||||
package com.softdev.system.generator.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* field info
|
||||
*
|
||||
* @author xuxueli 2018-05-02 20:11:05
|
||||
*/
|
||||
@Data
|
||||
public class FieldInfo {
|
||||
|
||||
private String columnName;
|
||||
@ -12,36 +15,4 @@ public class FieldInfo {
|
||||
private String fieldClass;
|
||||
private String fieldComment;
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getFieldClass() {
|
||||
return fieldClass;
|
||||
}
|
||||
|
||||
public void setFieldClass(String fieldClass) {
|
||||
this.fieldClass = fieldClass;
|
||||
}
|
||||
|
||||
public String getFieldComment() {
|
||||
return fieldComment;
|
||||
}
|
||||
|
||||
public void setFieldComment(String fieldComment) {
|
||||
this.fieldComment = fieldComment;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.softdev.system.generator.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* common return
|
||||
* @author xuxueli 2015-12-4 16:32:31
|
||||
*/
|
||||
@Data
|
||||
public class ReturnT<T> implements Serializable {
|
||||
public static final long serialVersionUID = 42L;
|
||||
|
||||
@ -27,23 +30,4 @@ public class ReturnT<T> implements Serializable {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@ package com.softdev.system.generator.util;
|
||||
*/
|
||||
public class CodeGenerateException extends RuntimeException {
|
||||
private static final long serialVersionUID = 42L;
|
||||
public CodeGenerateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CodeGenerateException(String msg) {
|
||||
super(msg);
|
||||
@ -18,4 +21,9 @@ public class CodeGenerateException extends RuntimeException {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CodeGenerateException(String message, Throwable cause,
|
||||
boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@ package com.softdev.system.generator.util;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -19,7 +17,6 @@ import java.util.Map;
|
||||
*/
|
||||
@Component
|
||||
public class FreemarkerTool {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CodeGeneratorTool.class);
|
||||
|
||||
@Autowired
|
||||
private Configuration configuration;
|
||||
|
||||
@ -1,13 +1,5 @@
|
||||
package com.softdev.system.generator.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.softdev.system.generator.entity.ClassInfo;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* string tool
|
||||
*
|
||||
@ -32,7 +24,8 @@ public class StringUtils {
|
||||
* @return
|
||||
*/
|
||||
public static String lowerCaseFirst(String str) {
|
||||
return (str!=null&str.length()>1)?str.substring(0, 1).toLowerCase() + str.substring(1):"";
|
||||
//2019-2-10 解决StringUtils.lowerCaseFirst潜在的NPE异常@liutf
|
||||
return (str!=null&&str.length()>1)?str.substring(0, 1).toLowerCase() + str.substring(1):"";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,25 +56,6 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*String tableSql="comment on column check_info is `体检信息` ,comment on column check_xxxxx is `体检信息xx` ";
|
||||
String fieldName="check_info";
|
||||
String fieldComment="aaa";
|
||||
Matcher columnCommentMatcher = Pattern.compile(fieldName+" is `").matcher(tableSql); // "\\{(.*?)\\}"
|
||||
while(columnCommentMatcher.find()){
|
||||
String columnCommentTmp = columnCommentMatcher.group();
|
||||
System.out.println(columnCommentTmp);
|
||||
fieldComment = tableSql.substring(tableSql.indexOf(columnCommentTmp)+columnCommentTmp.length()).trim();
|
||||
fieldComment = fieldComment.substring(0,fieldComment.indexOf("`")).trim();
|
||||
}
|
||||
System.out.println(fieldComment);*/
|
||||
/*ClassInfo classInfo=new ClassInfo();
|
||||
classInfo.setClassComment("xxxx");
|
||||
classInfo.setTableName("2b");
|
||||
ClassInfo newInfo=new ClassInfo();
|
||||
classInfo.setClassName("bbbb");
|
||||
classInfo.setTableName("3b");
|
||||
//以new为主
|
||||
BeanUtil.copyProperties(classInfo,newInfo,true, CopyOptions.create());
|
||||
System.out.println(JSON.toJSONString(newInfo));*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,10 @@ tomcat:
|
||||
background-processor-delay: 30
|
||||
basedir: ${user.home}/tomcat/
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
banner:
|
||||
charset: UTF-8
|
||||
http:
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${classInfo.classComment}
|
||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
public interface I${classInfo.className}DAO {
|
||||
|
||||
int add(${classInfo.className} ${classInfo.className?uncap_first});
|
||||
|
||||
int update(${classInfo.className} ${classInfo.className?uncap_first});
|
||||
|
||||
int delete(int id);
|
||||
|
||||
${classInfo.className} findById(int id);
|
||||
|
||||
List<${classInfo.className}> findAllList(Map<String,Object> param);
|
||||
|
||||
}
|
||||
@ -60,11 +60,9 @@
|
||||
icon: '1',
|
||||
content: "代码生成成功",
|
||||
end: function () {
|
||||
|
||||
codeData = data.data;
|
||||
genCodeArea.setValue(codeData.swaggerui);
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -79,117 +77,10 @@
|
||||
/**
|
||||
* 按钮事件组
|
||||
*/
|
||||
$('#swaggerui').click(function () {
|
||||
if(!$.isEmptyObject(codeData)){
|
||||
genCodeArea.setValue(codeData.swaggerui);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#entity').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.entity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#repository').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.repository);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#jpacontroller').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.jpacontroller);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#model').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.model);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#mybatis').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.mybatis);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#dao').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.dao);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#service').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.service);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#service_impl').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.service_impl);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#controller').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.controller);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#jtdao').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.jtdao);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#jtdaoimpl').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.jtdaoimpl);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#beetlcontroller').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.beetlcontroller);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#beetlmd').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.beetlmd);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#beetlentity').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#bootstrap').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.bootstrap);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#element-ui').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.elementui);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#pluscontroller').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.pluscontroller);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
$('#plusmapper').click(function () {
|
||||
if(!$.isEmptyObject(codeData)) {
|
||||
genCodeArea.setValue(codeData.plusmapper);
|
||||
$('.generator').bind('click', function () {
|
||||
if (!$.isEmptyObject(codeData)) {
|
||||
var id = this.id;
|
||||
genCodeArea.setValue(codeData[id]);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
@ -246,8 +137,8 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="model">entity(set/get)</button>
|
||||
<button type="button" class="btn btn-default" id="beetlentity">entity(lombok)</button>
|
||||
<button type="button" class="btn btn-default generator" id="model">entity(set/get)</button>
|
||||
<button type="button" class="btn btn-default generator" id="beetlentity">entity(lombok)</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar col-md-7" role="toolbar" aria-label="Toolbar with button groups">
|
||||
@ -257,11 +148,11 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="mybatis">mybatis</button>
|
||||
<button type="button" class="btn btn-default" id="dao">dao</button>
|
||||
<button type="button" class="btn btn-default" id="service">service</button>
|
||||
<button type="button" class="btn btn-default" id="service_impl">service_impl</button>
|
||||
<button type="button" class="btn btn-default" id="controller">controller</button>
|
||||
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
||||
<button type="button" class="btn btn-default generator" id="dao">dao</button>
|
||||
<button type="button" class="btn btn-default generator" id="service">service</button>
|
||||
<button type="button" class="btn btn-default generator" id="service_impl">service_impl</button>
|
||||
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -274,8 +165,8 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="plusmapper">mapper</button>
|
||||
<button type="button" class="btn btn-default" id="pluscontroller">controller</button>
|
||||
<button type="button" class="btn btn-default generator" id="plusmapper">mapper</button>
|
||||
<button type="button" class="btn btn-default generator" id="pluscontroller">controller</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -286,9 +177,9 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="swaggerui">swagger-ui</button>
|
||||
<button type="button" class="btn btn-default" id="element-ui">element-ui</button>
|
||||
<button type="button" class="btn btn-default" id="bootstrap">bootstrap-ui</button>
|
||||
<button type="button" class="btn btn-default generator" id="swagger-ui">swagger-ui</button>
|
||||
<button type="button" class="btn btn-default generator" id="element-ui">element-ui</button>
|
||||
<button type="button" class="btn btn-default generator" id="bootstrap-ui">bootstrap-ui</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -301,8 +192,8 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="beetlmd">beetlmd</button>
|
||||
<button type="button" class="btn btn-default" id="beetlcontroller">beetlcontroller</button>
|
||||
<button type="button" class="btn btn-default generator" id="beetlmd">beetlmd</button>
|
||||
<button type="button" class="btn btn-default generator" id="beetlcontroller">beetlcontroller</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||
@ -312,9 +203,9 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="entity">jpa-entity</button>
|
||||
<button type="button" class="btn btn-default" id="repository">repository</button>
|
||||
<button type="button" class="btn btn-default" id="jpacontroller">controller</button>
|
||||
<button type="button" class="btn btn-default generator" id="entity">jpa-entity</button>
|
||||
<button type="button" class="btn btn-default generator" id="repository">repository</button>
|
||||
<button type="button" class="btn btn-default generator" id="jpacontroller">controller</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -326,8 +217,8 @@ CREATE TABLE `userinfo` (
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-default" id="jtdaoimpl">daoimpl</button>
|
||||
<button type="button" class="btn btn-default" id="jtdao">dao</button>
|
||||
<button type="button" class="btn btn-default generator" id="jtdaoimpl">daoimpl</button>
|
||||
<button type="button" class="btn btn-default generator" id="jtdao">dao</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${classInfo.classComment}
|
||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
public interface I${classInfo.className}DAO {
|
||||
|
||||
int add(${classInfo.classComment} ${classInfo.className?uncap_first});
|
||||
|
||||
int update(${classInfo.classComment} ${classInfo.className?uncap_first});
|
||||
|
||||
int delete(int id);
|
||||
|
||||
${classInfo.classComment} findById(int id);
|
||||
|
||||
List<${classInfo.classComment}> findAllList(Map<String,Object> param);
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user