mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 13:52:39 +08:00
新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议)
This commit is contained in:
parent
e90f9f77e4
commit
b30ce868ff
12
README.md
12
README.md
@ -7,10 +7,16 @@
|
|||||||
|
|
||||||
# Description
|
# Description
|
||||||
- √ 基于SpringBoot2+Freemarker+Bootstrap
|
- √ 基于SpringBoot2+Freemarker+Bootstrap
|
||||||
- √ 以释放双手为目的
|
- √ 以解放双手为目的,减少大量重复的CRUD工作
|
||||||
- √ 支持mysql/oracle/pgsql三大数据库
|
- √ 支持mysql/oracle/pgsql三大数据库
|
||||||
- √ 用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码.
|
- √ 用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码.
|
||||||
|
|
||||||
|
# Advantage
|
||||||
|
- 自动记忆最近生成的内容,最多保留9个
|
||||||
|
- 支持特殊字符模板(`#`请用`井`代替;`$`请用`¥`代替)
|
||||||
|
- 提供众多通用模板,易于使用,复制粘贴加简单修改即可完成CRUD操作
|
||||||
|
- 支持JSON逆向生成(只支持简单的一级树)
|
||||||
|
|
||||||
|
|
||||||
# Url
|
# Url
|
||||||
|
|
||||||
@ -20,14 +26,14 @@
|
|||||||
|CSDN博客|http://zhengkai.blog.csdn.net|
|
|CSDN博客|http://zhengkai.blog.csdn.net|
|
||||||
|最新Jar包|https://github.com/moshowgame/SpringBootCodeGenerator/releases|
|
|最新Jar包|https://github.com/moshowgame/SpringBootCodeGenerator/releases|
|
||||||
|
|
||||||
感谢bejson三叔将他部署在[BEJSON](www.bejson.com)上,目前是besjon专供工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).
|
感谢bejson三叔将他部署在[BEJSON](www.bejson.com)上,目前是besjon专供的金牌工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).
|
||||||
|
|
||||||
|
|
||||||
# Update
|
# Update
|
||||||
|
|
||||||
|更新日期|更新内容|
|
|更新日期|更新内容|
|
||||||
|-|-|
|
|-|-|
|
||||||
|20200517|1.代码重构!异常处理优化,Freemarker相关工具类优化,简化模板生成部分,通过template.json来配置需要生成的模板,不需要配置java文件。 2.修复包含comment关键字时注释无法识别的问题。(感谢@1nchaos的反馈) 3.赞赏优化,感谢大家的赞赏|
|
|20200517|1.代码重构!异常处理优化,Freemarker相关工具类优化,简化模板生成部分,通过template.json来配置需要生成的模板,不需要配置java文件。 2.修复包含comment关键字时注释无法识别的问题。(感谢@1nchaos的反馈) 3.赞赏优化,感谢大家的赞赏 4.新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议)。|
|
||||||
|20200503|1.优化对特殊字符的处理,对于包含#和$等特殊字符的,在模板使用井和¥代替便可,escapeString方法会自动处理<br> 2.优化mybatisplus实体类相关(感谢@chunchengmeigui的反馈) 3.修优化对所有类型的判断(感谢@cnlw的反馈) 4.移除swagger-entity,该功能已经包含在‘swagger-ui’的下拉选项中 5.升级hutool和lombok版本|
|
|20200503|1.优化对特殊字符的处理,对于包含#和$等特殊字符的,在模板使用井和¥代替便可,escapeString方法会自动处理<br> 2.优化mybatisplus实体类相关(感谢@chunchengmeigui的反馈) 3.修优化对所有类型的判断(感谢@cnlw的反馈) 4.移除swagger-entity,该功能已经包含在‘swagger-ui’的下拉选项中 5.升级hutool和lombok版本|
|
||||||
|20200306|1.提交一套layuimini+mybatisplus的模板. 2.修复mybatisplus一些相关问题. |
|
|20200306|1.提交一套layuimini+mybatisplus的模板. 2.修复mybatisplus一些相关问题. |
|
||||||
|20200206|1.新增历史记录功能,自动保存最近生成的对象 2.新增swagger开关选项和修复@Column带name参数(感谢@liuyu-struggle的建议) 3.去除mybatis模板中的方括号[]和修改模板里的类注释样式(感谢@gaohanghang的PR)|
|
|20200206|1.新增历史记录功能,自动保存最近生成的对象 2.新增swagger开关选项和修复@Column带name参数(感谢@liuyu-struggle的建议) 3.去除mybatis模板中的方括号[]和修改模板里的类注释样式(感谢@gaohanghang的PR)|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class FreemarkerUtil {
|
|||||||
* 传入需要转义的字符串进行转义
|
* 传入需要转义的字符串进行转义
|
||||||
* 20200503 zhengkai.blog.csdn.net
|
* 20200503 zhengkai.blog.csdn.net
|
||||||
* */
|
* */
|
||||||
public String escapeString(String originStr){
|
public static String escapeString(String originStr){
|
||||||
return originStr.replaceAll("井","\\#").replaceAll("¥","\\$");
|
return originStr.replaceAll("井","\\#").replaceAll("¥","\\$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public class FreemarkerUtil {
|
|||||||
throws IOException, TemplateException {
|
throws IOException, TemplateException {
|
||||||
|
|
||||||
Template template = freemarkerConfig.getTemplate(templateName);
|
Template template = freemarkerConfig.getTemplate(templateName);
|
||||||
String htmlText = processTemplateIntoString(template, params);
|
String htmlText = escapeString(processTemplateIntoString(template, params));
|
||||||
return htmlText;
|
return htmlText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,12 @@
|
|||||||
"group": "mybatis",
|
"group": "mybatis",
|
||||||
"description": "model"
|
"description": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "26",
|
||||||
|
"name": "mapper2",
|
||||||
|
"group": "mybatis",
|
||||||
|
"description": "mapper annotation"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "30",
|
"id": "30",
|
||||||
"name": "entity",
|
"name": "entity",
|
||||||
|
|||||||
@ -12,8 +12,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data<#if swagger?exists && swagger==true>
|
||||||
<#if swagger?exists && swagger==true>@ApiModel("${classInfo.classComment}")</#if>
|
@ApiModel("${classInfo.classComment}")</#if>
|
||||||
public class ${classInfo.className} implements Serializable {
|
public class ${classInfo.className} implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
package ${packageName}.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.*;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description ${classInfo.classComment}Mapper
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface ${classInfo.className}Mapper {
|
||||||
|
|
||||||
|
@Select("select * from ${classInfo.tableName} where ${classInfo.tableName}_id=井{id}")
|
||||||
|
public ${classInfo.className} getById(Integer id);
|
||||||
|
|
||||||
|
@Options(useGeneratedKeys=true,keyProperty="${classInfo.className?uncap_first}Id")
|
||||||
|
@Insert("insert into ${classInfo.tableName}"
|
||||||
|
"(<#list classInfo.fieldList as fieldItem >${fieldItem.columnName}<#if fieldItem_has_next>,</#if></#list>)"
|
||||||
|
"values(<#list classInfo.fieldList as fieldItem >${fieldItem.fieldName}<#if fieldItem_has_next>,</#if>)</#list>")
|
||||||
|
public Integer insert(${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
|
@Delete(value = "delete from ${classInfo.tableName} where ${classInfo.tableName}_id=井{${classInfo.className?uncap_first}Id}")
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
@Update(value = "update ${classInfo.tableName} set "
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
<#if fieldItem.columnName != "id">+" ${fieldItem.columnName}=井{${fieldItem.fieldName}}<#if fieldItem_has_next>,</#if>"</#if>
|
||||||
|
</#list>
|
||||||
|
+" where ${classInfo.tableName}_id=井{${classInfo.className?uncap_first}Id} ")
|
||||||
|
boolean update(${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
|
|
||||||
|
@Results(value = {
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
@Result(property = "${fieldItem.fieldName}", column = "${fieldItem.columnName}")<#if fieldItem_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
})
|
||||||
|
@Select(value = "select * from ${classInfo.tableName} where ${classInfo.tableName}_id=井{queryParam}")
|
||||||
|
${classInfo.className} selectOne(String queryParam);
|
||||||
|
|
||||||
|
@Results(value = {
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
@Result(property = "${fieldItem.fieldName}", column = "${fieldItem.columnName}")<#if fieldItem_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
})
|
||||||
|
@Select(value = "select * from ${classInfo.tableName} where "
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
+" ${fieldItem.columnName}=井{${fieldItem.fieldName}}<#if fieldItem_has_next> or </#if>"
|
||||||
|
</#list>
|
||||||
|
)
|
||||||
|
List<${classInfo.className}> selectList(${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
|
}
|
||||||
@ -217,7 +217,9 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Spring Boot Code Generator!</h2>
|
<h2>Spring Boot Code Generator!</h2>
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
√基于SpringBoot2+Freemarker的<a class="lead" href="https://github.com/moshowgame/SpringBootCodeGenerator">代码生成器</a>,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br>
|
√基于SpringBoot2+Freemarker的<a class="lead" href="https://github.com/moshowgame/SpringBootCodeGenerator">代码生成器</a><br>
|
||||||
|
√以解放双手为目的,减少大量重复的CRUD工作<br>
|
||||||
|
√支持mysql/oracle/pgsql三大数据库<br>
|
||||||
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br>
|
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br>
|
||||||
如果发现有SQL语句不能识别,请<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues">留言</a>,同时欢迎大家提<a href="https://github.com/moshowgame/SpringBootCodeGenerator/pulls">PR</a>和<a href="#" id="donate1">赞赏</a>,谢谢!<a id="version" href="#">查看版本</a>
|
如果发现有SQL语句不能识别,请<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues">留言</a>,同时欢迎大家提<a href="https://github.com/moshowgame/SpringBootCodeGenerator/pulls">PR</a>和<a href="#" id="donate1">赞赏</a>,谢谢!<a id="version" href="#">查看版本</a>
|
||||||
</p>
|
</p>
|
||||||
@ -279,7 +281,7 @@
|
|||||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||||
CREATE TABLE 'userinfo' (
|
CREATE TABLE 'userinfo' (
|
||||||
'user_id' int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
'user_id' int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
'username' varchar(255) NOT NULL COMMENT '用户名',
|
'user_name' varchar(255) NOT NULL COMMENT '用户名',
|
||||||
'addtime' datetime NOT NULL COMMENT '创建时间',
|
'addtime' datetime NOT NULL COMMENT '创建时间',
|
||||||
PRIMARY KEY ('user_id')
|
PRIMARY KEY ('user_id')
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
||||||
@ -307,10 +309,11 @@ CREATE TABLE 'userinfo' (
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
<button type="button" class="btn btn-default generator" id="mybatis">ibatisXml</button>
|
||||||
<button type="button" class="btn btn-default generator" id="mapper">mapper</button>
|
<button type="button" class="btn btn-default generator" id="mapper">mapper</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="mapper2">mapper2</button>
|
||||||
<button type="button" class="btn btn-default generator" id="service">service</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="service_impl">serviceImpl</button>
|
||||||
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user