mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-03-22 07:28:25 +08:00
修改日期 : 2021-10-01
背景 : 当使用 mybatis组件生成代码时,各个组件之间对于实体类使用名称不一致,需要手动修改部分代码
修改 :
1 mybatis.ftl 统一使用 不带 Entity 的 实体类,保证 mybatis所有组件功能保持一致,避免手动修改
This commit is contained in:
@@ -1,89 +1,89 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="${packageName}.dao.${classInfo.className}Dao">
|
<mapper namespace="${packageName}.dao.${classInfo.className}Dao">
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="${packageName}.entity.${classInfo.className}Entity" >
|
<resultMap id="BaseResultMap" type="${packageName}.entity.${classInfo.className}" >
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
<#list classInfo.fieldList as fieldItem >
|
<#list classInfo.fieldList as fieldItem >
|
||||||
<result column="${fieldItem.columnName}" property="${fieldItem.fieldName}" />
|
<result column="${fieldItem.columnName}" property="${fieldItem.fieldName}" />
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
<#list classInfo.fieldList as fieldItem >
|
<#list classInfo.fieldList as fieldItem >
|
||||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="${packageName}.entity.${classInfo.className}">
|
||||||
INSERT INTO ${classInfo.tableName}
|
INSERT INTO ${classInfo.tableName}
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
<#list classInfo.fieldList as fieldItem >
|
<#list classInfo.fieldList as fieldItem >
|
||||||
<#if fieldItem.columnName != "id" >
|
<#if fieldItem.columnName != "id" >
|
||||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
||||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||||
${r"</if>"}
|
${r"</if>"}
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
<#list classInfo.fieldList as fieldItem >
|
<#list classInfo.fieldList as fieldItem >
|
||||||
<#if fieldItem.columnName != "id" >
|
<#if fieldItem.columnName != "id" >
|
||||||
<#--<#if fieldItem.columnName="addtime" || fieldItem.columnName="updatetime" >
|
<#--<#if fieldItem.columnName="addtime" || fieldItem.columnName="updatetime" >
|
||||||
${r"<if test ='null != "}${fieldItem.fieldName}${r"'>"}
|
${r"<if test ='null != "}${fieldItem.fieldName}${r"'>"}
|
||||||
NOW()<#if fieldItem_has_next>,</#if>
|
NOW()<#if fieldItem_has_next>,</#if>
|
||||||
${r"</if>"}
|
${r"</if>"}
|
||||||
<#else>-->
|
<#else>-->
|
||||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
||||||
${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>
|
${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>
|
||||||
${r"</if>"}
|
${r"</if>"}
|
||||||
<#--</#if>-->
|
<#--</#if>-->
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<delete id="delete" >
|
<delete id="delete" >
|
||||||
DELETE FROM ${classInfo.tableName}
|
DELETE FROM ${classInfo.tableName}
|
||||||
WHERE id = ${r"#{id}"}
|
WHERE id = ${r"#{id}"}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<update id="update" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
<update id="update" parameterType="${packageName}.entity.${classInfo.className}">
|
||||||
UPDATE ${classInfo.tableName}
|
UPDATE ${classInfo.tableName}
|
||||||
<set>
|
<set>
|
||||||
<#list classInfo.fieldList as fieldItem >
|
<#list classInfo.fieldList as fieldItem >
|
||||||
<#if fieldItem.columnName != "id" && fieldItem.columnName != "AddTime" && fieldItem.columnName != "UpdateTime" >
|
<#if fieldItem.columnName != "id" && fieldItem.columnName != "AddTime" && fieldItem.columnName != "UpdateTime" >
|
||||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">${fieldItem.columnName} = ${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>${r"</if>"}
|
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">${fieldItem.columnName} = ${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>${r"</if>"}
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = ${r"#{"}id${r"}"}
|
WHERE id = ${r"#{"}id${r"}"}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<select id="load" resultMap="BaseResultMap">
|
<select id="load" resultMap="BaseResultMap">
|
||||||
SELECT <include refid="Base_Column_List" />
|
SELECT <include refid="Base_Column_List" />
|
||||||
FROM ${classInfo.tableName}
|
FROM ${classInfo.tableName}
|
||||||
WHERE id = ${r"#{id}"}
|
WHERE id = ${r"#{id}"}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="pageList" resultMap="BaseResultMap">
|
<select id="pageList" resultMap="BaseResultMap">
|
||||||
SELECT <include refid="Base_Column_List" />
|
SELECT <include refid="Base_Column_List" />
|
||||||
FROM ${classInfo.tableName}
|
FROM ${classInfo.tableName}
|
||||||
LIMIT ${r"#{offset}"}, ${r"#{pageSize}"}
|
LIMIT ${r"#{offset}"}, ${r"#{pageSize}"}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="pageListCount" resultType="java.lang.Integer">
|
<select id="pageListCount" resultType="java.lang.Integer">
|
||||||
SELECT count(1)
|
SELECT count(1)
|
||||||
FROM ${classInfo.tableName}
|
FROM ${classInfo.tableName}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user