| <?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.ShopArticleTypeDao"> | 
|   | 
|     <!-- 定义ShopArticleType 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopArticleType" id="ShopArticleTypeMap"> | 
|         <id property="artypeId" column="artype_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="artypeParentid" column="artype_parentid" /> | 
|             <result property="artypeName" column="artype_name" /> | 
|             <result property="artypeSort" column="artype_sort" /> | 
|             <result property="artypeDescribe" column="artype_describe" /> | 
|             <result property="artypeCode" column="artype_code" /> | 
|             <result property="artypeImgurl" column="artype_imgurl" /> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义ShopArticleType 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopArticleType" id="ShopArticleTypeSimpleMap"> | 
|         <id property="artypeId" column="artype_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="artypeParentid" column="artype_parentid" /> | 
|             <result property="artypeName" column="artype_name" /> | 
|             <result property="artypeSort" column="artype_sort" /> | 
|             <result property="artypeDescribe" column="artype_describe" /> | 
|             <result property="artypeCode" column="artype_code" /> | 
|             <result property="artypeImgurl" column="artype_imgurl" /> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             artype_id, | 
|             artype_parentid, | 
|             artype_name, | 
|             artype_sort, | 
|             artype_describe, | 
|             artype_code, | 
|             artype_imgurl, | 
|             company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.artypeId}, | 
|             #{item.artypeParentid}, | 
|             #{item.artypeName}, | 
|             #{item.artypeSort}, | 
|             #{item.artypeDescribe}, | 
|             #{item.artypeCode}, | 
|             #{item.artypeImgurl}, | 
|         #{item.companyId} | 
|     </sql> | 
|      | 
|     <!-- where sql --> | 
|     <sql id="where_sql"> | 
|           | 
|          <if test="record!=null"> | 
|             <if test="(record.artypeId!=null and record.artypeId!='') or  (record.artypeId!='' and record.artypeId==0)  "> | 
|                 and artype_id  = #{record.artypeId}  | 
|             </if> | 
|             <if test="(record.artypeParentid!=null and record.artypeParentid!='') or  (record.artypeParentid!='' and record.artypeParentid==0)  "> | 
|                 and artype_parentid  = #{record.artypeParentid}  | 
|             </if> | 
|             <if test="(record.artypeName!=null and record.artypeName!='') or  (record.artypeName!='' and record.artypeName==0)  "> | 
|                 and artype_name  = #{record.artypeName}  | 
|             </if> | 
|             <if test="(record.artypeSort!=null and record.artypeSort!='') or  (record.artypeSort!='' and record.artypeSort==0)  "> | 
|                 and artype_sort  = #{record.artypeSort}  | 
|             </if> | 
|             <if test="(record.artypeDescribe!=null and record.artypeDescribe!='') or  (record.artypeDescribe!='' and record.artypeDescribe==0)  "> | 
|                 and artype_describe  = #{record.artypeDescribe}  | 
|             </if> | 
|             <if test="(record.artypeCode!=null and record.artypeCode!='') or  (record.artypeCode!='' and record.artypeCode==0)  "> | 
|                 and artype_code  = #{record.artypeCode}  | 
|             </if> | 
|             <if test="(record.artypeImgurl!=null and record.artypeImgurl!='') or  (record.artypeImgurl!='' and record.artypeImgurl==0)  "> | 
|                 and artype_imgurl  = #{record.artypeImgurl}  | 
|             </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.ShopArticleType" | 
|         useGeneratedKeys="true" keyProperty="item.artypeId"> | 
|         INSERT INTO shop_article_type ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_article_type ( | 
|         <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_article_type | 
|         <set> | 
|             <if test="_parameter.containsKey('artypeParentid')"> | 
|                     artype_parentid = #{artypeParentid}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('artypeName')"> | 
|                     artype_name = #{artypeName}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('artypeSort')"> | 
|                     artype_sort = #{artypeSort}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('artypeDescribe')"> | 
|                     artype_describe = #{artypeDescribe}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('artypeCode')"> | 
|                     artype_code = #{artypeCode}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('artypeImgurl')"> | 
|                     artype_imgurl = #{artypeImgurl}, | 
|                 </if>         | 
|         </set> | 
|         WHERE artype_id=#{artypeId}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Integer"> | 
|         UPDATE shop_article_type | 
|         <set> | 
|             <if test="record.artypeParentid != null "> | 
|                 artype_parentid  = #{record.artypeParentid},  | 
|             </if> | 
|             <if test="record.artypeName != null and record.artypeName != '' "> | 
|                 artype_name  = #{record.artypeName},  | 
|             </if> | 
|             <if test="record.artypeSort != null "> | 
|                 artype_sort  = #{record.artypeSort},  | 
|             </if> | 
|             <if test="record.artypeDescribe != null and record.artypeDescribe != '' "> | 
|                 artype_describe  = #{record.artypeDescribe},  | 
|             </if> | 
|             <if test="record.artypeCode != null and record.artypeCode != '' "> | 
|                 artype_code  = #{record.artypeCode},  | 
|             </if> | 
|             <if test="record.artypeImgurl != null and record.artypeImgurl != '' "> | 
|                 artype_imgurl  = #{record.artypeImgurl},  | 
|             </if> | 
|         </set> | 
|         WHERE artype_id=#{record.artypeId}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_article_type where  artype_id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" parameterType="Integer"> | 
|         DELETE FROM shop_article_type | 
|         where  artype_id=#{artypeId}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopArticleType"> | 
|         DELETE FROM shop_article_type | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShopArticleTypeMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_article_type | 
|         <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_article_type | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopArticleTypeMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_article_type | 
|         where  artype_id=#{artypeId}  | 
|     </select> | 
|   | 
|     <!-- 提供常见问题文章接口--> | 
|     <select id="selectByTypeCode" resultMap="ShopArticleTypeMap"> | 
|         <!--SELECT | 
|         <include refid="columns" ></include> | 
|         FROM shop_article_type p | 
|         WHERE p.artype_parentid IN ( SELECT t.artype_id FROM shop_article_type t WHERE t.artype_code = 'cjwt' )--> | 
|         select | 
|         <include refid="columns" ></include> | 
|         from shop_article_type p where p.artype_code = 'cjwt' | 
|     </select> | 
|   | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopArticleTypeMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_article_type | 
|         where  artype_id=#{artype_id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopArticleTypeMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_article_type | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
| </mapper> |