1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| ##引入mybatis支持 $!{mybatisSupport.vm}
##设置保存名称与保存位置 $!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml")) $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper">
<resultMap type="$!{tableInfo.savePackageName}.model.entity.$!{tableInfo.name}" id="$!{tableInfo.name}Map"> #foreach($column in $tableInfo.fullColumn) <result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/> #end </resultMap> <sql id="Base_Column_List"> #foreach($column in $tableInfo.fullColumn) $column.obj.name#if($foreach.hasNext),#end #end </sql> <insert id="addOne"> insert into $!{tableInfo.obj.name} ( #foreach($column in $tableInfo.otherColumn) #if(!$column.name.equals("id") && !$column.name.equals("delFlag")) <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end#if($column.type.equals("java.lang.Integer")) and $!column.name != 0#end#if($column.type.equals("java.lang.Long")) and $!column.name != 0L#end">$!column.obj.name,</if> #end #end #foreach($column in $tableInfo.otherColumn) #if($column.name.equals("createTime")) create_time, #end #if($column.name.equals("delFlag")) del_flag, #end #end ) values ( #foreach($column in $tableInfo.otherColumn) #if(!$column.name.equals("id") && !$column.name.equals("delFlag")) <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end#if($column.type.equals("java.lang.Integer")) and $!column.name != 0#end#if($column.type.equals("java.lang.Long")) and $!column.name != 0L#end">$!column.obj.name,</if> #end #end #foreach($column in $tableInfo.otherColumn) #if($column.name.equals("createTime")) sysdate(), #end #if($column.name.equals("delFlag")) '0', #end #end ) </insert> <update id="updateOne"> update $!{tableInfo.obj.name} set #foreach($column in $tableInfo.otherColumn) <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end#if($column.type.equals("java.lang.Integer")) and $!column.name != 0#end#if($column.type.equals("java.lang.Long")) and $!column.name != 0L#end">$!column.obj.name = #{$!column.name},</if> #end where 1 = 0 </update> </mapper>
|