<?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.gxwebsoft.shop.mapper.ShopArticleMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM shop_article a
        <where>
            <if test="param.articleId != null">
                AND a.article_id = #{param.articleId}
            </if>
            <if test="param.title != null">
                AND a.title LIKE CONCAT('%', #{param.title}, '%')
            </if>
            <if test="param.type != null">
                AND a.type = #{param.type}
            </if>
            <if test="param.model != null">
                AND a.model LIKE CONCAT('%', #{param.model}, '%')
            </if>
            <if test="param.detail != null">
                AND a.detail LIKE CONCAT('%', #{param.detail}, '%')
            </if>
            <if test="param.categoryId != null">
                AND a.category_id = #{param.categoryId}
            </if>
            <if test="param.parentId != null">
                AND a.parent_id = #{param.parentId}
            </if>
            <if test="param.topic != null">
                AND a.topic LIKE CONCAT('%', #{param.topic}, '%')
            </if>
            <if test="param.tags != null">
                AND a.tags LIKE CONCAT('%', #{param.tags}, '%')
            </if>
            <if test="param.image != null">
                AND a.image LIKE CONCAT('%', #{param.image}, '%')
            </if>
            <if test="param.imageWidth != null">
                AND a.image_width = #{param.imageWidth}
            </if>
            <if test="param.imageHeight != null">
                AND a.image_height = #{param.imageHeight}
            </if>
            <if test="param.price != null">
                AND a.price = #{param.price}
            </if>
            <if test="param.startTime != null">
                AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
            </if>
            <if test="param.endTime != null">
                AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
            </if>
            <if test="param.source != null">
                AND a.source LIKE CONCAT('%', #{param.source}, '%')
            </if>
            <if test="param.overview != null">
                AND a.overview LIKE CONCAT('%', #{param.overview}, '%')
            </if>
            <if test="param.virtualViews != null">
                AND a.virtual_views = #{param.virtualViews}
            </if>
            <if test="param.actualViews != null">
                AND a.actual_views = #{param.actualViews}
            </if>
            <if test="param.rate != null">
                AND a.rate = #{param.rate}
            </if>
            <if test="param.showType != null">
                AND a.show_type = #{param.showType}
            </if>
            <if test="param.password != null">
                AND a.password LIKE CONCAT('%', #{param.password}, '%')
            </if>
            <if test="param.permission != null">
                AND a.permission = #{param.permission}
            </if>
            <if test="param.platform != null">
                AND a.platform LIKE CONCAT('%', #{param.platform}, '%')
            </if>
            <if test="param.files != null">
                AND a.files LIKE CONCAT('%', #{param.files}, '%')
            </if>
            <if test="param.video != null">
                AND a.video LIKE CONCAT('%', #{param.video}, '%')
            </if>
            <if test="param.accept != null">
                AND a.accept LIKE CONCAT('%', #{param.accept}, '%')
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.province != null">
                AND a.province LIKE CONCAT('%', #{param.province}, '%')
            </if>
            <if test="param.city != null">
                AND a.city LIKE CONCAT('%', #{param.city}, '%')
            </if>
            <if test="param.region != null">
                AND a.region LIKE CONCAT('%', #{param.region}, '%')
            </if>
            <if test="param.address != null">
                AND a.address LIKE CONCAT('%', #{param.address}, '%')
            </if>
            <if test="param.likes != null">
                AND a.likes = #{param.likes}
            </if>
            <if test="param.commentNumbers != null">
                AND a.comment_numbers = #{param.commentNumbers}
            </if>
            <if test="param.toUsers != null">
                AND a.to_users LIKE CONCAT('%', #{param.toUsers}, '%')
            </if>
            <if test="param.author != null">
                AND a.author LIKE CONCAT('%', #{param.author}, '%')
            </if>
            <if test="param.recommend != null">
                AND a.recommend = #{param.recommend}
            </if>
            <if test="param.bmUsers != null">
                AND a.bm_users = #{param.bmUsers}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.projectId != null">
                AND a.project_id = #{param.projectId}
            </if>
            <if test="param.lang != null">
                AND a.lang LIKE CONCAT('%', #{param.lang}, '%')
            </if>
            <if test="param.langArticleId != null">
                AND a.lang_article_id = #{param.langArticleId}
            </if>
            <if test="param.translation != null">
                AND a.translation = #{param.translation}
            </if>
            <if test="param.editor != null">
                AND a.editor = #{param.editor}
            </if>
            <if test="param.pdfUrl != null">
                AND a.pdf_url LIKE CONCAT('%', #{param.pdfUrl}, '%')
            </if>
            <if test="param.version != null">
                AND a.version = #{param.version}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
            <if test="param.keywords != null">
                AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
                )
              </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopArticle">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopArticle">
        <include refid="selectSql"></include>
    </select>

</mapper>
