为了账号安全,请及时绑定邮箱和手机立即绑定

mybatis的接口映射语法

标签:
SQL Server

<?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>

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消