| <?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.hive.dao.MoneyCardAssembleDao"> | 
|     <!-- 定义MoneyCardAssemble 的复杂关联map --> | 
|     <resultMap type="MoneyCardAssemble" id="MoneyCardAssembleMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="type" column="type" /> | 
|             <result property="goodsId" column="goods_id" /> | 
|             <result property="cateId" column="cate_id" /> | 
|             <result property="cardId" column="card_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义MoneyCardAssemble 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="MoneyCardAssemble" id="MoneyCardAssembleSimpleMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="type" column="type" /> | 
|             <result property="goodsId" column="goods_id" /> | 
|             <result property="cateId" column="cate_id" /> | 
|             <result property="cardId" column="card_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="MoneyCardAssemble" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO money_card_assemble ( | 
|             id, | 
|             type, | 
|             goods_id, | 
|             cate_id, | 
|             card_id | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{type}, | 
|             #{goodsId}, | 
|             #{cateId}, | 
|             #{cardId} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|     INSERT INTO money_card_assemble ( | 
|     id, | 
|     type, | 
|     goods_id, | 
|     cate_id, | 
|     card_id | 
|     ) | 
|     VALUES  | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|             #{item.id}, | 
|             #{item.type}, | 
|             #{item.goodsId}, | 
|             #{item.cateId}, | 
|             #{item.cardId} | 
|     )</foreach> | 
|     </insert> | 
|      | 
|      | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE money_card_assemble | 
|         <set> | 
|                 <if test="type != null and type !='' "> | 
|                     type = #{type}, | 
|                 </if>         | 
|                 <if test="goodsId != null and goodsId !='' "> | 
|                     goods_id = #{goodsId}, | 
|                 </if>         | 
|                 <if test="cateId != null and cateId !='' "> | 
|                     cate_id = #{cateId}, | 
|                 </if>         | 
|                 <if test="cardId != null and cardId !='' "> | 
|                     card_id = #{cardId}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from money_card_assemble where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM money_card_assemble | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|      | 
|     <!-- 根据充值卡id删除--> | 
|     <delete id="deleteByCardId" > | 
|         DELETE FROM money_card_assemble | 
|         where  card_id=#{id}  | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="MoneyCardAssembleMap"> | 
|         select  | 
|             id, | 
|             type, | 
|             goods_id, | 
|             cate_id, | 
|             card_id | 
|         from money_card_assemble | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id  = #{record.id}  | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and type  = #{record.type}  | 
|             </if> | 
|             <if test="record.goodsId != null and record.goodsId !='' "> | 
|                 and goods_id  = #{record.goodsId}  | 
|             </if> | 
|             <if test="record.cateId != null and record.cateId !='' "> | 
|                 and cate_id  = #{record.cateId}  | 
|             </if> | 
|             <if test="record.cardId != null and record.cardId !='' "> | 
|                 and card_id  = #{record.cardId}  | 
|             </if> | 
|         </if> | 
|         <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"    resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from money_card_assemble | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|             and id = #{record.id}  | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|             and type = #{record.type}  | 
|             </if> | 
|             <if test="record.goodsId != null and record.goodsId !='' "> | 
|             and goods_id = #{record.goodsId}  | 
|             </if> | 
|             <if test="record.cateId != null and record.cateId !='' "> | 
|             and cate_id = #{record.cateId}  | 
|             </if> | 
|             <if test="record.cardId != null and record.cardId !='' "> | 
|             and card_id = #{record.cardId}  | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="MoneyCardAssembleMap"> | 
|         select  | 
|             id, | 
|             type, | 
|             goods_id, | 
|             cate_id, | 
|             card_id | 
|         from money_card_assemble | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="MoneyCardAssembleMap"> | 
|         select  | 
|             id, | 
|             type, | 
|             goods_id, | 
|             cate_id, | 
|             card_id | 
|         from money_card_assemble | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id = #{record.id}  | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and type = #{record.type}  | 
|             </if> | 
|             <if test="record.goodsId != null and record.goodsId !='' "> | 
|                 and goods_id = #{record.goodsId}  | 
|             </if> | 
|             <if test="record.cateId != null and record.cateId !='' "> | 
|                 and cate_id = #{record.cateId}  | 
|             </if> | 
|             <if test="record.cardId != null and record.cardId !='' "> | 
|                 and card_id = #{record.cardId}  | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="selectByCardId" resultMap="MoneyCardAssembleMap"> | 
|         select | 
|             id, | 
|             type, | 
|             goods_id, | 
|             cate_id, | 
|             card_id | 
|         from money_card_assemble where card_id=#{cardId} | 
|     </select> | 
|   | 
|     <select id="selectCardRelationGoods" resultType="com.matrix.system.app.vo.ShoppingGoodsDetailVo"> | 
|         select | 
|             b.name goodsName, | 
|             b.measure measure, | 
|             b.volume volume | 
|         from money_card_assemble a | 
|         inner join shopping_goods b on a.goods_id=b.id | 
|         where a.card_id=#{cardId} | 
|     </select> | 
|   | 
|     <select id="selectCardRelationCategory" resultType="com.matrix.system.hive.bean.ShoppingGoodsCategory"> | 
|         select | 
|             a.id id, | 
|             a.name name, | 
|             a.parent_id parentId | 
|         from shopping_goods_category a | 
|         inner join money_card_assemble b on a.id=b.cate_id | 
|         where b.card_id=#{cardId}; | 
|     </select> | 
| </mapper> |