| <?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.ShoppingGoodsCategoryDao"> | 
|      | 
|     <resultMap type="ShoppingGoodsCategory" id="ShoppingGoodsCategoryMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="name" column="name" /> | 
|             <result property="parentId" column="parent_id" /> | 
|             <result property="sequence" column="sequence" /> | 
|             <result property="salePlatform" column="sale_platform" /> | 
|   | 
|         <result property="shopId" column="shop_id"/> | 
|         <result property="companyId" column="company_id"/> | 
|     </resultMap> | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="ShoppingGoodsCategory" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO shopping_goods_category ( | 
|             id, | 
|             name, | 
|             parent_id, | 
|             sequence, | 
|             sale_platform, | 
|             shop_id, | 
|             company_id | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{name}, | 
|             #{parentId}, | 
|             #{sequence}, | 
|             #{salePlatform}, | 
|             #{shopId}, | 
|             #{companyId} | 
|     ) | 
|     </insert> | 
|   | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shopping_goods_category ( | 
|         name, | 
|         parent_id, | 
|         sequence, | 
|         sale_platform, | 
|         shop_id, | 
|         company_id | 
|         ) | 
|         VALUES | 
|         <foreach collection="list" item="item" index="index" separator=",">( | 
|   | 
|             #{item.name}, | 
|             #{item.parentId}, | 
|             #{item.sequence}, | 
|             #{item.salePlatform}, | 
|             #{item.shopId}, | 
|             #{item.companyId} | 
|             )</foreach> | 
|     </insert> | 
|   | 
|   | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE shopping_goods_category | 
|         <set> | 
|                 <if test="name != null and name !='' "> | 
|                     name = #{name}, | 
|                 </if>         | 
|                 <if test="parentId != null and parentId !='' "> | 
|                     parent_id = #{parentId}, | 
|                 </if>         | 
|                 <if test="sequence != null and sequence !='' "> | 
|                     sequence = #{sequence}, | 
|                 </if>     | 
|                 <if test="salePlatform != null and salePlatform !='' "> | 
|                     sale_platform = #{salePlatform}, | 
|                 </if> | 
|             <if test="companyId != null and companyId !='' "> | 
|                 company_id = #{companyId}, | 
|             </if> | 
|             <if test="shopId != null and shopId !='' "> | 
|                 shop_id = #{shopId}, | 
|             </if> | 
|   | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shopping_goods_category where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM shopping_goods_category | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShoppingGoodsCategoryMap"> | 
|         select * | 
|         from shopping_goods_category | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id  = #{record.id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and name  = #{record.name} | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|                 and parent_id = #{record.parentId} | 
|             </if> | 
|             <if test="record.sequence != null and record.sequence !='' "> | 
|                 and sequence  = #{record.sequence} | 
|             </if> | 
|   | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and shop_id = #{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and company_id = #{record.companyId} | 
|             </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 shopping_goods_category | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|             and id  id  = #{record.id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|             and name id  = #{record.name} | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|             and parent_id  id  = #{record.parentId} | 
|             </if> | 
|             <if test="record.sequence != null and record.sequence !='' "> | 
|             and sequence  id  = #{record.sequence} | 
|             </if> | 
|   | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and shop_id = #{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and company_id = #{record.companyId} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShoppingGoodsCategoryMap"> | 
|         select * | 
|         from shopping_goods_category | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShoppingGoodsCategoryMap"> | 
|         select * | 
|         from shopping_goods_category | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id  = #{record.id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and name = #{record.name} | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|                 and parent_id  = #{record.parentId} | 
|             </if> | 
|             <if test="record.sequence != null and record.sequence !='' "> | 
|                 and sequence = #{record.sequence} | 
|             </if> | 
|   | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and shop_id = #{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and company_id = #{record.companyId} | 
|             </if> | 
|         </if> | 
|         ORDER BY sequence | 
|     </select> | 
|   | 
|     <select id="selectChildNodesByName" resultMap="ShoppingGoodsCategoryMap"> | 
|         select * from shopping_goods_category a | 
|         inner join shopping_goods_category b on a.parent_id=b.id and b.parent_id=0 | 
|         <if test="record.name != null and record.name != ''"> | 
|             and b.name=#{record.name} | 
|         </if> | 
|         <where> | 
|             <if test="record.shopId != null"> | 
|                 and a.shop_id=#{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null"> | 
|                 and a.company_id=#{record.companyId} | 
|             </if> | 
|         </where> | 
|     </select> | 
| </mapper> |