<?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="com.matrix.system.shopXcx.dao.ShopDeliveryDetailDao">
|
<!-- 定义ShopDeliveryDetail 的复杂关联map -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopDeliveryDetail" id="ShopDeliveryDetailMap">
|
<id property="id" column="id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="deliveryId" column="delivery_id" />
|
<result property="orderDetailId" column="order_detail_id" />
|
<result property="stockId" column="stock_id" />
|
<result property="stockName" column="stock_name" />
|
<result property="batch" column="batch" />
|
<result property="num" column="num" />
|
<result property="stockCode" column="stock_code" />
|
</resultMap>
|
|
|
<!-- 定义ShopDeliveryDetail 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopDeliveryDetail" id="ShopDeliveryDetailSimpleMap">
|
<id property="id" column="id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="deliveryId" column="delivery_id" />
|
<result property="orderDetailId" column="order_detail_id" />
|
<result property="stockId" column="stock_id" />
|
<result property="stockName" column="stock_name" />
|
<result property="batch" column="batch" />
|
<result property="num" column="num" />
|
<result property="stockCode" column="stock_code" />
|
</resultMap>
|
|
<!-- 字段sql -->
|
<sql id="columns">
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
id,
|
delivery_id,
|
order_detail_id,
|
stock_id,
|
stock_name,
|
batch,
|
num,
|
stock_code
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.createBy},
|
now(),
|
#{item.updateBy},
|
now(),
|
#{item.id},
|
#{item.deliveryId},
|
#{item.orderDetailId},
|
#{item.stockId},
|
#{item.stockName},
|
#{item.batch},
|
#{item.num},
|
#{item.stockCode}
|
</sql>
|
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.id!=null and record.id!='') or (record.id!='' and record.id==0) ">
|
and id = #{record.id}
|
</if>
|
<if test="(record.deliveryId!=null and record.deliveryId!='') or (record.deliveryId!='' and record.deliveryId==0) ">
|
and delivery_id = #{record.deliveryId}
|
</if>
|
<if test="(record.orderDetailId!=null and record.orderDetailId!='') or (record.orderDetailId!='' and record.orderDetailId==0) ">
|
and order_detail_id = #{record.orderDetailId}
|
</if>
|
<if test="(record.stockId!=null and record.stockId!='') or (record.stockId!='' and record.stockId==0) ">
|
and stock_id = #{record.stockId}
|
</if>
|
<if test="(record.stockName!=null and record.stockName!='') or (record.stockName!='' and record.stockName==0) ">
|
and stock_name = #{record.stockName}
|
</if>
|
<if test="(record.batch!=null and record.batch!='') or (record.batch!='' and record.batch==0) ">
|
and batch = #{record.batch}
|
</if>
|
<if test="(record.num!=null and record.num!='') or (record.num!='' and record.num==0) ">
|
and num = #{record.num}
|
</if>
|
<if test="(record.stockCode!=null and record.stockCode!='') or (record.stockCode!='' and record.stockCode==0) ">
|
and stock_code = #{record.stockCode}
|
</if>
|
</if>
|
|
</sql>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopDeliveryDetail"
|
useGeneratedKeys="true" keyProperty="item.id">
|
INSERT INTO shop_delivery_detail (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shop_delivery_detail (
|
<include refid="columns"></include>
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
<include refid="propertys"></include>
|
)</foreach>
|
</insert>
|
|
|
|
|
|
<!-- 根据Map更新 部分更新 -->
|
<update id="updateByMap" parameterType="java.util.HashMap" >
|
UPDATE shop_delivery_detail
|
<set>
|
<if test="_parameter.containsKey('deliveryId')">
|
delivery_id = #{deliveryId},
|
</if>
|
<if test="_parameter.containsKey('orderDetailId')">
|
order_detail_id = #{orderDetailId},
|
</if>
|
<if test="_parameter.containsKey('stockId')">
|
stock_id = #{stockId},
|
</if>
|
<if test="_parameter.containsKey('stockName')">
|
stock_name = #{stockName},
|
</if>
|
<if test="_parameter.containsKey('batch')">
|
batch = #{batch},
|
</if>
|
<if test="_parameter.containsKey('num')">
|
num = #{num},
|
</if>
|
<if test="_parameter.containsKey('stockCode')">
|
stock_code = #{stockCode},
|
</if>
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
<!-- 根据对象更新 部分更新 -->
|
<update id="updateByModel" parameterType="Integer">
|
UPDATE shop_delivery_detail
|
<set>
|
<if test="record.deliveryId != null ">
|
delivery_id = #{record.deliveryId},
|
</if>
|
<if test="record.orderDetailId != null ">
|
order_detail_id = #{record.orderDetailId},
|
</if>
|
<if test="record.stockId != null ">
|
stock_id = #{record.stockId},
|
</if>
|
<if test="record.stockName != null and record.stockName != '' ">
|
stock_name = #{record.stockName},
|
</if>
|
<if test="record.batch != null and record.batch != '' ">
|
batch = #{record.batch},
|
</if>
|
<if test="record.num != null ">
|
num = #{record.num},
|
</if>
|
<if test="record.stockCode != null and record.stockCode != '' ">
|
stock_code = #{record.stockCode},
|
</if>
|
</set>
|
WHERE id=#{record.id}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shop_delivery_detail where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" parameterType="Integer">
|
DELETE FROM shop_delivery_detail
|
where id=#{id}
|
</delete>
|
|
<!-- 根据对象删除-->
|
<delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopDeliveryDetail">
|
DELETE FROM shop_delivery_detail
|
<where>
|
<include refid="where_sql" ></include>
|
</where>
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShopDeliveryDetailMap">
|
select
|
<include refid="columns" ></include>
|
from shop_delivery_detail
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer">
|
select count(*)
|
from shop_delivery_detail
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="ShopDeliveryDetailMap">
|
select
|
<include refid="columns" ></include>
|
from shop_delivery_detail
|
where id=#{id}
|
</select>
|
|
|
<!-- 根据id 锁表查询-->
|
<select id="selectForUpdate" resultMap="ShopDeliveryDetailMap">
|
select
|
<include refid="columns" ></include>
|
from shop_delivery_detail
|
where id=#{id}
|
for update
|
</select>
|
|
|
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="ShopDeliveryDetailMap">
|
select
|
<include refid="columns" ></include>
|
from shop_delivery_detail
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
</mapper>
|