<?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.ArticleDao"> 
 | 
     
 | 
    <resultMap type="Article" id="ArticleMap"> 
 | 
            <id property="id" column="id" /> 
 | 
            <result property="typeId" column="type_id" /> 
 | 
            <result property="articleAuthor" column="article_author" /> 
 | 
            <result property="title" column="title" /> 
 | 
            <result property="isPublish" column="is_publish" /> 
 | 
            <result property="articleAbstract" column="article_abstract" /> 
 | 
            <result property="content" column="content" /> 
 | 
            <result property="image" column="image" /> 
 | 
            <result property="sort" column="sort" /> 
 | 
            <result property="createtiem" column="createtiem" /> 
 | 
            <result property="url" column="url" /> 
 | 
        <result property="companyId" column="company_id"/> 
 | 
             
 | 
             
 | 
            <result property="articleTypeName" column="article_type_name" /> 
 | 
            <result property="type" column="type" /> 
 | 
            <result property="likeNumber" column="like_number" /> 
 | 
            <result property="classify" column="classify" /> 
 | 
            <result property="commentNum" column="commentNum" /> 
 | 
             
 | 
    </resultMap> 
 | 
    <!--  插入方法   --> 
 | 
    <insert id="insert" parameterType="Article" 
 | 
        useGeneratedKeys="true" keyProperty="id"> 
 | 
        INSERT INTO article ( 
 | 
            id, 
 | 
            type_id, 
 | 
            article_author, 
 | 
            title, 
 | 
            is_publish, 
 | 
            article_abstract, 
 | 
            content, 
 | 
            image, 
 | 
            sort, 
 | 
            createtiem, 
 | 
            url, 
 | 
            like_number, 
 | 
            classify, 
 | 
            company_id 
 | 
        ) 
 | 
    VALUES ( 
 | 
            #{id}, 
 | 
            #{typeId}, 
 | 
            #{articleAuthor}, 
 | 
            #{title}, 
 | 
            #{isPublish}, 
 | 
            #{articleAbstract}, 
 | 
            #{content}, 
 | 
            #{image}, 
 | 
            #{sort}, 
 | 
            #{createtiem}, 
 | 
            #{url}, 
 | 
            #{likeNumber}, 
 | 
            #{classify}, 
 | 
            #{companyId} 
 | 
    ) 
 | 
    </insert> 
 | 
     
 | 
     
 | 
    <!--  根据id更新 部分更新   --> 
 | 
    <update id="update" > 
 | 
        UPDATE article 
 | 
        <set> 
 | 
                <if test="typeId != null and typeId !='' "> 
 | 
                    type_id = #{typeId}, 
 | 
                </if>         
 | 
                <if test="articleAuthor != null and articleAuthor !='' "> 
 | 
                    article_author = #{articleAuthor}, 
 | 
                </if>         
 | 
                <if test="title != null and title !='' "> 
 | 
                    title = #{title}, 
 | 
                </if>         
 | 
                <if test="isPublish != null and isPublish !='' "> 
 | 
                    is_publish = #{isPublish}, 
 | 
                </if>         
 | 
                <if test="articleAbstract != null and articleAbstract !='' "> 
 | 
                    article_abstract = #{articleAbstract}, 
 | 
                </if>         
 | 
                <if test="content != null and content !='' "> 
 | 
                    content = #{content}, 
 | 
                </if>         
 | 
                <if test="image != null and image !='' "> 
 | 
                    image = #{image}, 
 | 
                </if>         
 | 
                <if test="sort != null and sort !='' "> 
 | 
                    sort = #{sort}, 
 | 
                </if>         
 | 
                <if test="createtiem != null   "> 
 | 
                    createtiem = #{createtiem}, 
 | 
                </if>         
 | 
                <if test="url != null and url !='' "> 
 | 
                    url = #{url}, 
 | 
                </if>         
 | 
                <if test="likeNumber != null and likeNumber !='' "> 
 | 
                    like_number = #{likeNumber}, 
 | 
                </if> 
 | 
                <if test="classify != null and classify !='' "> 
 | 
                    classify = #{classify}, 
 | 
                </if> 
 | 
        </set> 
 | 
        WHERE id=#{id}  
 | 
    </update> 
 | 
     
 | 
     
 | 
     
 | 
    <!-- 批量删除 --> 
 | 
    <delete id="deleteByIds" parameterType="java.util.List"> 
 | 
        delete from article where  id in 
 | 
        <foreach collection="list" index="index" item="item" open="(" 
 | 
            separator="," close=")"> 
 | 
            #{item} 
 | 
        </foreach> 
 | 
    </delete> 
 | 
         
 | 
    <!-- 根据id删除--> 
 | 
    <delete id="deleteById" > 
 | 
        DELETE FROM article 
 | 
        where  id=#{id}  
 | 
    </delete> 
 | 
     
 | 
     
 | 
     
 | 
    <!-- 分页查询 --> 
 | 
    <select id="selectInPage" resultMap="ArticleMap"> 
 | 
        select  
 | 
            id, 
 | 
            type_id, 
 | 
            article_author, 
 | 
            title, 
 | 
            is_publish, 
 | 
            article_abstract, 
 | 
            content, 
 | 
            image, 
 | 
            sort, 
 | 
            createtiem, 
 | 
            url, 
 | 
            classify, 
 | 
            like_number, 
 | 
            company_id, 
 | 
            (select article_type_name from article_type c where type_id = c.id) articleTypeName, 
 | 
            (select type from article_type c where type_id = c.id) type 
 | 
        from article 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.typeId != null and record.typeId !='' "> 
 | 
                and type_id = #{record.typeId} 
 | 
            </if> 
 | 
            <if test="record.articleAuthor != null and record.articleAuthor !='' "> 
 | 
                and article_author = #{record.articleAuthor} 
 | 
            </if> 
 | 
            <if test="record.title != null and record.title !='' "> 
 | 
                and title like CONCAT('%',#{record.title},'%') 
 | 
            </if> 
 | 
            <if test="record.isPublish != null and record.isPublish !='' "> 
 | 
                and is_publish = #{record.isPublish} 
 | 
            </if> 
 | 
            <if test="record.articleAbstract != null and record.articleAbstract !='' "> 
 | 
                and article_abstract like CONCAT('%',#{ecord.articleAbstract},'%') 
 | 
            </if> 
 | 
            <if test="record.content != null and record.content !='' "> 
 | 
                and content like CONCAT('%',#{record.content},'%') 
 | 
            </if> 
 | 
            <if test="record.image != null and record.image !='' "> 
 | 
                and image = #{record.image} 
 | 
            </if> 
 | 
            <if test="record.sort != null and record.sort !='' "> 
 | 
                and sort = #{record.sort} 
 | 
            </if> 
 | 
            <if test="record.createtiem != null   "> 
 | 
                and createtiem = #{record.createtiem} 
 | 
            </if> 
 | 
            <if test="record.url != null and record.url !='' "> 
 | 
                and url = #{record.url} 
 | 
            </if> 
 | 
            <if test="record.classify != null and record.classify !='' "> 
 | 
                and classify = #{record.classify} 
 | 
            </if> 
 | 
            <if test="record.likeNumber != null and record.likeNumber !='' "> 
 | 
                and like_number = #{record.likeNumber} 
 | 
            </if> 
 | 
            <if test="record.companyId != null and record.companyId !='' "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
            <if test="record.type != null and record.type !='' "> 
 | 
                and (select type from article_type c where type_id = c.id) = #{record.type} 
 | 
            </if> 
 | 
            <if test="record.articleTypeName != null and record.url !='' "> 
 | 
                and (select article_type_name from article_type c where type_id = c.id) = #{record.articleTypeName} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by type_id,sort 
 | 
        <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="selectInPag" resultMap="ArticleMap"> 
 | 
        select  
 | 
            id, 
 | 
            type_id, 
 | 
            article_author, 
 | 
            title, 
 | 
            is_publish, 
 | 
            article_abstract, 
 | 
            content, 
 | 
            image, 
 | 
            sort, 
 | 
            createtiem, 
 | 
            url, 
 | 
            classify, 
 | 
            like_number, 
 | 
            company_id, 
 | 
            (select article_type_name from article_type c where type_id = c.id) articleTypeName, 
 | 
            (select type from article_type c where type_id = c.id) type 
 | 
        from article 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.typeId != null and record.typeId !='' "> 
 | 
                and type_id = #{record.typeId} 
 | 
            </if> 
 | 
            <if test="record.articleAuthor != null and record.articleAuthor !='' "> 
 | 
                and article_author = #{record.articleAuthor} 
 | 
            </if> 
 | 
            <if test="record.title != null and record.title !='' "> 
 | 
                and title like CONCAT('%',#{record.title},'%') 
 | 
            </if> 
 | 
            <if test="record.isPublish != null and record.isPublish !='' "> 
 | 
                and is_publish = #{record.isPublish} 
 | 
            </if> 
 | 
            <if test="record.articleAbstract != null and record.articleAbstract !='' "> 
 | 
                and article_abstract like CONCAT('%',#{ecord.articleAbstract},'%') 
 | 
            </if> 
 | 
            <if test="record.content != null and record.content !='' "> 
 | 
                and content like CONCAT('%',#{record.content},'%') 
 | 
            </if> 
 | 
            <if test="record.image != null and record.image !='' "> 
 | 
                and image = #{record.image} 
 | 
            </if> 
 | 
            <if test="record.sort != null and record.sort !='' "> 
 | 
                and sort = #{record.sort} 
 | 
            </if> 
 | 
            <if test="record.createtiem != null  "> 
 | 
                and createtiem = #{record.createtiem} 
 | 
            </if> 
 | 
            <if test="record.url != null and record.url !='' "> 
 | 
                and url = #{record.url} 
 | 
            </if> 
 | 
            <if test="record.classify != null and record.classify !='' "> 
 | 
                and classify = #{record.classify} 
 | 
            </if> 
 | 
            <if test="record.likeNumber != null and record.likeNumber !='' "> 
 | 
                and like_number = #{record.likeNumber} 
 | 
            </if> 
 | 
            <if test="record.type != null and record.type !='' "> 
 | 
                and (select type from article_type c where type_id = c.id) = #{record.type} 
 | 
            </if> 
 | 
            <if test="record.articleTypeName != null and record.url !='' "> 
 | 
                and (select article_type_name from article_type c where type_id = c.id) = #{record.articleTypeName} 
 | 
            </if> 
 | 
            <if test="record.companyId != null and record.companyId !='' "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by type_id,sort,createtiem desc 
 | 
        limit #{staPage},#{endPage} 
 | 
    </select> 
 | 
     
 | 
    <!-- 查询总条数 --> 
 | 
    <select id="selectTotalRecord"    resultType="java.lang.Integer"> 
 | 
    select count(*) 
 | 
    from article 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.typeId != null and record.typeId !='' "> 
 | 
                and type_id = #{record.typeId} 
 | 
            </if> 
 | 
            <if test="record.articleAuthor != null and record.articleAuthor !='' "> 
 | 
                and article_author = #{record.articleAuthor} 
 | 
            </if> 
 | 
            <if test="record.title != null and record.title !='' "> 
 | 
                and title like CONCAT('%',#{record.title},'%') 
 | 
            </if> 
 | 
            <if test="record.isPublish != null and record.isPublish !='' "> 
 | 
                and is_publish = #{record.isPublish} 
 | 
            </if> 
 | 
            <if test="record.articleAbstract != null and record.articleAbstract !='' "> 
 | 
                and article_abstract like CONCAT('%',#{ecord.articleAbstract},'%') 
 | 
            </if> 
 | 
            <if test="record.content != null and record.content !='' "> 
 | 
                and content like CONCAT('%',#{record.content},'%') 
 | 
            </if> 
 | 
            <if test="record.image != null and record.image !='' "> 
 | 
                and image = #{record.image} 
 | 
            </if> 
 | 
            <if test="record.sort != null and record.sort !='' "> 
 | 
                and sort = #{record.sort} 
 | 
            </if> 
 | 
            <if test="record.createtiem != null  "> 
 | 
                and createtiem = #{record.createtiem} 
 | 
            </if> 
 | 
            <if test="record.url != null and record.url !='' "> 
 | 
                and url = #{record.url} 
 | 
            </if> 
 | 
            <if test="record.classify != null and record.classify !='' "> 
 | 
                and classify = #{record.classify} 
 | 
            </if> 
 | 
            <if test="record.likeNumber != null and record.likeNumber !='' "> 
 | 
                and like_number = #{record.likeNumber} 
 | 
            </if> 
 | 
            <if test="record.type != null and record.type !='' "> 
 | 
                and (select type from article_type c where type_id = c.id) = #{record.type} 
 | 
            </if> 
 | 
            <if test="record.articleTypeName != null and record.url !='' "> 
 | 
                and (select article_type_name from article_type c where type_id = c.id) = #{record.articleTypeName} 
 | 
            </if> 
 | 
            <if test="record.companyId != null and record.companyId !='' "> 
 | 
                and company_id = #{record.companyId} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <!-- 根据id查询--> 
 | 
    <select id="selectById" resultMap="ArticleMap"> 
 | 
        select  
 | 
            id, 
 | 
            type_id, 
 | 
            article_author, 
 | 
            title, 
 | 
            is_publish, 
 | 
            article_abstract, 
 | 
            content, 
 | 
            image, 
 | 
            sort, 
 | 
            createtiem, 
 | 
            url, 
 | 
            like_number, 
 | 
            classify, 
 | 
            company_id, 
 | 
           (select article_type_name from article_type c where type_id = c.id) articleTypeName<!-- 所属门店名称 --> 
 | 
        from article 
 | 
        where  id=#{id}  
 | 
    </select> 
 | 
  
 | 
  
 | 
  
 | 
     
 | 
    <!-- 根据对象查询--> 
 | 
    <select id="selectByModel" resultMap="ArticleMap"> 
 | 
        select  
 | 
            a.id, 
 | 
            a.type_id, 
 | 
            a.article_author, 
 | 
            a.title, 
 | 
            a.is_publish, 
 | 
            a.article_abstract, 
 | 
            a.content, 
 | 
            a.image, 
 | 
            a.sort, 
 | 
            a.createtiem, 
 | 
            a.url, 
 | 
            a.classify, 
 | 
            a.like_number, 
 | 
            a.company_id, 
 | 
           (select article_type_name from article_type c where a.type_id = c.id) articleTypeName,<!-- 所属门店名称 --> 
 | 
           (select count(*) from article_comment ac where ac.article_id=a.id) commentNum 
 | 
        from article a 
 | 
        where 1=1 
 | 
        <if test="record!=null"> 
 | 
            <if test="record.id != null and record.id !='' "> 
 | 
                and a.id = #{record.id} 
 | 
            </if> 
 | 
            <if test="record.typeId != null and record.typeId !='' "> 
 | 
                and a.type_id = #{record.typeId} 
 | 
            </if> 
 | 
            <if test="record.articleAuthor != null and record.articleAuthor !='' "> 
 | 
                and a.article_author = #{record.articleAuthor} 
 | 
            </if> 
 | 
            <if test="record.title != null and record.title !='' "> 
 | 
                and a.title like CONCAT('%',#{record.title},'%') 
 | 
            </if> 
 | 
            <if test="record.isPublish != null and record.isPublish !='' "> 
 | 
                and a.is_publish = #{record.isPublish} 
 | 
            </if> 
 | 
            <if test="record.articleAbstract != null and record.articleAbstract !='' "> 
 | 
                and a.article_abstract like CONCAT('%',#{ecord.articleAbstract},'%') 
 | 
            </if> 
 | 
            <if test="record.content != null and record.content !='' "> 
 | 
                and a.content like CONCAT('%',#{record.content},'%') 
 | 
            </if> 
 | 
            <if test="record.image != null and record.image !='' "> 
 | 
                and a.image = #{record.image} 
 | 
            </if> 
 | 
            <if test="record.sort != null and record.sort !='' "> 
 | 
                and a.sort = #{record.sort} 
 | 
            </if> 
 | 
            <if test="record.createtiem != null  "> 
 | 
                and a.createtiem = #{record.createtiem} 
 | 
            </if> 
 | 
            <if test="record.url != null and record.url !='' "> 
 | 
                and a.url = #{record.url} 
 | 
            </if> 
 | 
            <if test="record.classify != null and record.classify !='' "> 
 | 
                and a.classify = #{record.classify} 
 | 
            </if> 
 | 
            <if test="record.likeNumber != null and record.likeNumber !='' "> 
 | 
                and a.like_number = #{record.likeNumber} 
 | 
            </if> 
 | 
            <if test="record.articleTypeName != null and record.url !='' "> 
 | 
                and (select article_type_name from article_type c where a.type_id = c.id) = #{record.articleTypeName} 
 | 
            </if> 
 | 
            <if test="record.companyId != null and record.companyId !='' "> 
 | 
                and a.company_id = #{record.companyId} 
 | 
            </if> 
 | 
        </if> 
 | 
        order by type_id,sort,createtiem desc 
 | 
    </select> 
 | 
  
 | 
    <select id="selectApiArticleListInPage" resultMap="ArticleMap"> 
 | 
        select * from article a 
 | 
        inner join article_type b on a.type_id=b.id 
 | 
        where a.company_id=#{record.companyId} and  (a.type_id=#{record.typeId} or find_in_set(#{record.typeId}, b.parent_ids)) 
 | 
        order by a.createtiem desc 
 | 
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> 
 | 
            <if test="pageVo.offset >=0  and pageVo.limit >0"> 
 | 
                limit 
 | 
                #{pageVo.offset},#{pageVo.limit} 
 | 
            </if> 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
  
 | 
</mapper> 
 |