mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-03-22 15:39:04 +08:00
新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议)
This commit is contained in:
@@ -31,7 +31,7 @@ public class FreemarkerUtil {
|
||||
* 传入需要转义的字符串进行转义
|
||||
* 20200503 zhengkai.blog.csdn.net
|
||||
* */
|
||||
public String escapeString(String originStr){
|
||||
public static String escapeString(String originStr){
|
||||
return originStr.replaceAll("井","\\#").replaceAll("¥","\\$");
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class FreemarkerUtil {
|
||||
throws IOException, TemplateException {
|
||||
|
||||
Template template = freemarkerConfig.getTemplate(templateName);
|
||||
String htmlText = processTemplateIntoString(template, params);
|
||||
String htmlText = escapeString(processTemplateIntoString(template, params));
|
||||
return htmlText;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,12 @@
|
||||
"group": "mybatis",
|
||||
"description": "model"
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"name": "mapper2",
|
||||
"group": "mybatis",
|
||||
"description": "mapper annotation"
|
||||
},
|
||||
{
|
||||
"id": "30",
|
||||
"name": "entity",
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
*/
|
||||
@Data
|
||||
<#if swagger?exists && swagger==true>@ApiModel("${classInfo.classComment}")</#if>
|
||||
@Data<#if swagger?exists && swagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
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">
|
||||
<h2>Spring Boot Code Generator!</h2>
|
||||
<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>
|
||||
如果发现有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>
|
||||
@@ -279,7 +281,7 @@
|
||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||
CREATE TABLE 'userinfo' (
|
||||
'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 '创建时间',
|
||||
PRIMARY KEY ('user_id')
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
||||
@@ -307,10 +309,11 @@ CREATE TABLE 'userinfo' (
|
||||
</div>
|
||||
</div>
|
||||
<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="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_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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user