| <?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.ShopAdvertisDao"> | 
|   | 
|     <!-- 定义ShopAdvertis 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopAdvertis" id="ShopAdvertisMap"> | 
|         <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="title" column="title" /> | 
|             <result property="imgUrl" column="img_url" /> | 
|             <result property="jumpPath" column="jump_path" /> | 
|             <result property="typeId" column="type_id" /> | 
|             <result property="sort" column="sort" /> | 
|             <result property="remarks" column="remarks" /> | 
|         <result property="linkType" column="link_type"/> | 
|         <result property="linkUrl" column="link_url"/> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义ShopAdvertis 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopAdvertis" id="ShopAdvertisSimpleMap"> | 
|         <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="title" column="title" /> | 
|             <result property="imgUrl" column="img_url" /> | 
|             <result property="jumpPath" column="jump_path" /> | 
|             <result property="typeId" column="type_id" /> | 
|             <result property="sort" column="sort" /> | 
|             <result property="remarks" column="remarks" /> | 
|         <result property="linkType" column="link_type"/> | 
|         <result property="linkUrl" column="link_url"/> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             title, | 
|             img_url, | 
|             jump_path, | 
|             type_id, | 
|             sort, | 
|             remarks, | 
| link_type, | 
| link_url, | 
|             company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.title}, | 
|             #{item.imgUrl}, | 
|             #{item.jumpPath}, | 
|             #{item.typeId}, | 
|             #{item.sort}, | 
|             #{item.remarks}, | 
|             #{item.linkType}, | 
|             #{item.linkUrl}, | 
|         #{item.companyId} | 
|     </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.title!=null and record.title!='') or  (record.title!='' and record.title==0)  "> | 
|                 and title  = #{record.title}  | 
|             </if> | 
|             <if test="(record.imgUrl!=null and record.imgUrl!='') or  (record.imgUrl!='' and record.imgUrl==0)  "> | 
|                 and img_url  = #{record.imgUrl}  | 
|             </if> | 
|             <if test="(record.jumpPath!=null and record.jumpPath!='') or  (record.jumpPath!='' and record.jumpPath==0)  "> | 
|                 and jump_path  = #{record.jumpPath}  | 
|             </if> | 
|             <if test="(record.typeId!=null and record.typeId!='') or  (record.typeId!='' and record.typeId==0)  "> | 
|                 and type_id  = #{record.typeId}  | 
|             </if> | 
|             <if test="(record.sort!=null and record.sort!='') or  (record.sort!='' and record.sort==0)  "> | 
|                 and sort  = #{record.sort}  | 
|             </if> | 
|             <if test="(record.remarks!=null and record.remarks!='') or  (record.remarks!='' and record.remarks==0)  "> | 
|                 and remarks  = #{record.remarks}  | 
|             </if> | 
|              <if test="record.companyId != null and record.companyId !='' "> | 
|                  and company_id = #{record.companyId} | 
|              </if> | 
|   | 
|          </if> | 
|           | 
|     </sql> | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopAdvertis" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO shop_advertis ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_advertis ( | 
|         <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_advertis | 
|         <set> | 
|             <if test="_parameter.containsKey('title')"> | 
|                     title = #{title}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('imgUrl')"> | 
|                     img_url = #{imgUrl}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('jumpPath')"> | 
|                     jump_path = #{jumpPath}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('typeId')"> | 
|                     type_id = #{typeId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('sort')"> | 
|                     sort = #{sort}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('remarks')"> | 
|                     remarks = #{remarks}, | 
|                 </if> | 
|             <if test="_parameter.containsKey('linkUrl')"> | 
|                 link_url = #{linkUrl}, | 
|             </if> | 
|             <if test="_parameter.containsKey('linkType')"> | 
|                 link_type = #{linkType}, | 
|             </if> | 
|   | 
|   | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Integer"> | 
|         UPDATE shop_advertis | 
|         <set> | 
|             <if test="record.title != null and record.title != '' "> | 
|                 title  = #{record.title},  | 
|             </if> | 
|             <if test="record.imgUrl != null and record.imgUrl != '' "> | 
|                 img_url  = #{record.imgUrl},  | 
|             </if> | 
|             <if test="record.jumpPath != null and record.jumpPath != '' "> | 
|                 jump_path  = #{record.jumpPath},  | 
|             </if> | 
|             <if test="record.typeId != null "> | 
|                 type_id  = #{record.typeId},  | 
|             </if> | 
|             <if test="record.sort != null "> | 
|                 sort  = #{record.sort},  | 
|             </if> | 
|             <if test="record.remarks != null and record.remarks != '' "> | 
|                 remarks  = #{record.remarks},  | 
|             </if> | 
|             <if test="record.linkType != null and record.linkType != '' "> | 
|                 link_type = #{linkType}, | 
|             </if> | 
|             <if test="record.linkUrl != null and record.linkUrl != '' "> | 
|                 link_url = #{linkUrl}, | 
|             </if> | 
|   | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                  company_id = #{record.companyId} | 
|             </if> | 
|   | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_advertis 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_advertis | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopAdvertis"> | 
|         DELETE FROM shop_advertis | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultType="com.matrix.system.shopXcx.bean.ShopAdvertis"> | 
|         select | 
|         ad.create_by createBy, | 
|         ad.create_time createTime, | 
|         ad.update_by updateBy, | 
|         ad.update_time updateTime, | 
|         ad.id, | 
|         ad.title, | 
|         ad.img_url imgUrl, | 
|         ad.jump_path jumpPath, | 
|         ad.type_id typeId, | 
|         ad.sort, | 
|         ad.remarks, | 
|         IFNULL(adType.adt_name ,'无分类') adtName | 
|         from shop_advertis ad | 
|         left join shop_advertis_type adType | 
|         on ad.type_id = adType.adt_id | 
|         <where> | 
|             <if test="record!=null"> | 
|   | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and ad.company_id = #{record.companyId} | 
|                 </if> | 
|   | 
|                 <if test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                     and ad.id  = #{record.id} | 
|                 </if> | 
|                 <if test="(record.title!=null and record.title!='') or  (record.title!='' and record.title==0)  "> | 
|                     and ad.title like concat('%', #{record.title}, '%') | 
|                 </if> | 
|                 <if test="(record.imgUrl!=null and record.imgUrl!='') or  (record.imgUrl!='' and record.imgUrl==0)  "> | 
|                     and ad.img_url  = #{record.imgUrl} | 
|                 </if> | 
|                 <if test="(record.jumpPath!=null and record.jumpPath!='') or  (record.jumpPath!='' and record.jumpPath==0)  "> | 
|                     and ad.jump_path  = #{record.jumpPath} | 
|                 </if> | 
|                 <if test="(record.typeId!=null and record.typeId!='') or  (record.typeId!='' and record.typeId==0)  "> | 
|                     and ad.type_id  = #{record.typeId} | 
|                 </if> | 
|                 <if test="(record.sort!=null and record.sort!='') or  (record.sort!='' and record.sort==0)  "> | 
|                     and ad.sort  = #{record.sort} | 
|                 </if> | 
|                 <if test="(record.remarks!=null and record.remarks!='') or  (record.remarks!='' and record.remarks==0)  "> | 
|                     and ad.remarks  = #{record.remarks} | 
|                 </if> | 
|                 <if test="(record.adtName!=null and record.adtName!='') or  (record.adtName!='' and record.adtName==0)  "> | 
|                     and adType.adt_name like concat('%', #{record.adtName}, '%') | 
|                 </if> | 
|   | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and ad.company_id = #{record.companyId} | 
|                 </if> | 
|             </if> | 
|         </where> | 
|         order by type_id desc, sort | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <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_advertis ad | 
|         left join shop_advertis_type adType | 
|         on ad.type_id = adType.adt_id | 
|         <where> | 
|             <if test="record!=null"> | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and ad.company_id = #{record.companyId} | 
|                 </if> | 
|                 <if test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                     and ad.id  = #{record.id} | 
|                 </if> | 
|                 <if test="(record.title!=null and record.title!='') or  (record.title!='' and record.title==0)  "> | 
|                     and ad.title like concat('%', #{record.title}, '%') | 
|                 </if> | 
|                 <if test="(record.imgUrl!=null and record.imgUrl!='') or  (record.imgUrl!='' and record.imgUrl==0)  "> | 
|                     and ad.img_url  = #{record.imgUrl} | 
|                 </if> | 
|                 <if test="(record.jumpPath!=null and record.jumpPath!='') or  (record.jumpPath!='' and record.jumpPath==0)  "> | 
|                     and ad.jump_path  = #{record.jumpPath} | 
|                 </if> | 
|                 <if test="(record.typeId!=null and record.typeId!='') or  (record.typeId!='' and record.typeId==0)  "> | 
|                     and ad.type_id  = #{record.typeId} | 
|                 </if> | 
|                 <if test="(record.sort!=null and record.sort!='') or  (record.sort!='' and record.sort==0)  "> | 
|                     and ad.sort  = #{record.sort} | 
|                 </if> | 
|                 <if test="(record.remarks!=null and record.remarks!='') or  (record.remarks!='' and record.remarks==0)  "> | 
|                     and ad.remarks  = #{record.remarks} | 
|                 </if> | 
|                 <if test="(record.adtName!=null and record.adtName!='') or  (record.adtName!='' and record.adtName==0)  "> | 
|                     and adType.adt_name like concat('%', #{record.adtName}, '%') | 
|                 </if> | 
|   | 
|                 <if test="record.companyId != null and record.companyId !='' "> | 
|                     and ad.company_id = #{record.companyId} | 
|                 </if> | 
|             </if> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopAdvertisMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_advertis | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopAdvertisMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_advertis | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopAdvertisMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_advertis | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
|   | 
|     <select id="selectListByType" resultMap="ShopAdvertisMap"> | 
|         select ad.* | 
|         from shop_advertis ad, shop_advertis_type adType | 
|         where ad.type_id = adType.adt_id and adType.adt_code = #{type} | 
|         order by ad.sort | 
|         <if test="capacity!=null"> | 
|             limit #{capacity} | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="selectListByTypeId" resultMap="ShopAdvertisMap"> | 
|         select ad.* | 
|         from shop_advertis ad, shop_advertis_type adType | 
|         where ad.type_id = adType.adt_id and adType.adt_id = #{adtId} | 
|         order by ad.sort | 
|         <if test="capacity!=null"> | 
|             limit #{capacity} | 
|         </if> | 
|   | 
|     </select> | 
|   | 
|   | 
| </mapper> |