码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis的接口映射语法

时间:2018-02-03 16:02:59      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:1.0   getc   lan   public   util   factory   close   status   data   

<?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="cn.eeka.productwms.dao.biz.ProductInBoundDao" >
<resultMap id="BaseResultMap" type="cn.eeka.productwms.entity.biz.ProductInBound" >
<id column="productInBoundId" property="productInBoundId" jdbcType="VARCHAR" />
<result column="productInBoundCode" property="productInBoundCode" jdbcType="VARCHAR" />
<result column="factoryCode" property="factoryCode" jdbcType="VARCHAR" />
<result column="factoryName" property="factoryName" jdbcType="VARCHAR" />
<result column="customerCode" property="customerCode" jdbcType="VARCHAR" />
<result column="customerName" property="customerName" jdbcType="VARCHAR" />
<result column="storageAreaId" property="storageAreaId" jdbcType="VARCHAR" />
<result column="documentDate" property="documentDate" jdbcType="TIMESTAMP" />
<result column="originDocCode" property="originDocCode" jdbcType="VARCHAR" />
<result column="referenceCode" property="referenceCode" jdbcType="VARCHAR" />
<result column="orderTotal" property="orderTotal" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="createUserId" property="createUserId" jdbcType="VARCHAR" />
<result column="createUserId" property="createUserId" jdbcType="VARCHAR" />
<result column="createDate" property="createDate" jdbcType="TIMESTAMP" />
<result column="updateDate" property="updateDate" jdbcType="TIMESTAMP" />
<result column="postDate" property="postDate" jdbcType="TIMESTAMP" />
<result column="version" property="version" jdbcType="INTEGER" />
</resultMap>

<sql id="Base_Column_List" >
productInBoundId, productInBoundCode, factoryCode, factoryName, customerCode, customerName,
storageAreaId, documentDate, originDocCode, referenceCode, orderTotal,
status, createUserId, updateUserId, createDate, updateDate, version
</sql>

<insert id="insert" parameterType="cn.eeka.productwms.entity.biz.ProductInBound" >
insert into PM_ProductInBound (productInBoundId, productInBoundCode,
factoryCode, factoryName, customerCode,
customerName, storageAreaId, documentDate,
originDocCode, referenceCode, orderTotal, status,
createUserId, updateUserId, createDate,
updateDate, postDate, version)
values (#{productInBoundId,jdbcType=VARCHAR}, #{productInBoundCode,jdbcType=VARCHAR},
#{factoryCode,jdbcType=VARCHAR}, #{factoryName,jdbcType=VARCHAR}, #{customerCode,jdbcType=VARCHAR},
#{customerName,jdbcType=VARCHAR}, #{storageAreaId}, #{documentDate,jdbcType=TIMESTAMP}, #{originDocCode,jdbcType=VARCHAR},
#{referenceCode,jdbcType=VARCHAR}, #{orderTotal,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER},
#{createUserId,jdbcType=VARCHAR}, #{updateUserId,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
#{updateDate,jdbcType=TIMESTAMP}, #{postDate}, #{version,jdbcType=INTEGER})
</insert>

<update id="updateByPrimaryKey" parameterType="cn.eeka.productwms.entity.biz.ProductInBound" >
update PM_ProductInBound
<set >
<if test="productInBoundCode != null" >
productInBoundCode = #{productInBoundCode,jdbcType=VARCHAR},
</if>
<if test="factoryCode != null" >
factoryCode = #{factoryCode,jdbcType=VARCHAR},
</if>
<if test="factoryName != null" >
factoryName = #{factoryName,jdbcType=VARCHAR},
</if>
</set>
where productInBoundId = #{productInBoundId,jdbcType=VARCHAR}
</update>

<update id="updateById" parameterType="java.util.HashMap">
update PM_ProductInBound
<set >
<if test="status != null" >
status = #{status},
</if>
<if test="updateUserId != null" >
updateUserId = #{updateUserId},
</if>
<if test="updateDate != null" >
updateDate = #{updateDate},
</if>
<if test="version != null" >
version = #{version} + 1
</if>
</set>
where productInBoundId = #{productInBoundId}
and version = #{version}
</update>

<select id="listByPagePC" parameterType="java.util.HashMap" resultMap="BaseResultMap" >
SELECT pro.* FROM PM_ProductInBound pro
<where>
<include refid="condition_where_clause" />
</where>

<!--这里是后台动态排序(排序的字段不固定)-->
<if test="orderByCondition != null and orderByCondition != ‘‘">
        ORDER BY ${orderByCondition} DESC
</if>

<if test="offset != null">
  limit #{offset},#{limit}
</if>

</select>

<select id="getCountByCondition" parameterType="java.util.HashMap" resultType="java.lang.Integer">
SELECT count(1) FROM PM_ProductInBound pro
<where>
<include refid="condition_where_clause" />
</where>
</select>

<sql id="condition_where_clause">
<if test="productInBoundCode != null and productInBoundCode != ‘‘">
<bind name="productInBoundCodeCon" value="‘%‘ + productInBoundCode + ‘%‘" />
and pro.productInBoundCode LIKE #{productInBoundCodeCon}
</if>

<if test="referenceCode != null and referenceCode != ‘‘">
  <bind name="referenceCodeCon" value="‘%‘ + referenceCode + ‘%‘" />
  and pro.referenceCode  LIKE #{referenceCodeCon}
</if>

<if test="storageAreaIds != null and storageAreaIds.size > 0">
  AND pro.storageAreaId IN
  <foreach collection="storageAreaIds" item="storageAreaId" index="index" open="("  separator="," close=")">
    #{storageAreaId}
  </foreach>
</if>

<if test="startDate != null and startDate != ‘‘">
  <![CDATA[AND pro.documentDate >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ‘‘">
  <![CDATA[AND pro.documentDate <= #{endDate}]]>
</if>

</sql>

</mapper>

mybatis的接口映射语法

标签:1.0   getc   lan   public   util   factory   close   status   data   

原文地址:http://blog.51cto.com/9381188/2068469

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!