<?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.slodon.b2b2c.dao.write.goods.GoodsSearchWordsWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.goods.pojo.GoodsSearchWords">
    <id column="words_id" property="wordsId" />
    <result column="web_site" property="webSite" />
    <result column="words_content" property="wordsContent" />
    <result column="full_py" property="fullPy" />
    <result column="simple_py" property="simplePy" />
    <result column="resource" property="resource" />
    <result column="create_time" property="createTime" />
    <result column="search_goods_num" property="searchGoodsNum" />
    <result column="search_frequency" property="searchFrequency" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="webSite != null">
        `web_site`,
      </if>
      <if test="wordsContent != null">
        `words_content`,
      </if>
      <if test="fullPy != null">
        `full_py`,
      </if>
      <if test="simplePy != null">
        `simple_py`,
      </if>
      <if test="resource != null">
        `resource`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="searchGoodsNum != null">
        `search_goods_num`,
      </if>
      <if test="searchFrequency != null">
        `search_frequency`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `words_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.wordsIdNotEquals != null">
          AND `words_id` != #{example.wordsIdNotEquals}
        </if>
        <if test="example.wordsIdIn != null">
          AND `words_id` in (${example.wordsIdIn})
        </if>
        <if test="example.webSite != null">
          AND `web_site` = #{example.webSite}
        </if>
        <if test="example.wordsContent != null">
          AND `words_content` = #{example.wordsContent}
        </if>
        <if test="example.wordsContentLike != null">
          AND `words_content` like concat('%',#{example.wordsContentLike},'%')
        </if>
        <if test="example.fullPy != null">
          AND `full_py` = #{example.fullPy}
        </if>
        <if test="example.simplePy != null">
          AND `simple_py` = #{example.simplePy}
        </if>
        <if test="example.resource != null">
          AND `resource` = #{example.resource}
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.searchGoodsNum != null">
          AND `search_goods_num` = #{example.searchGoodsNum}
        </if>
        <if test="example.searchGoodsNumLike != null">
          AND `search_goods_num` like concat('%',#{example.searchGoodsNumLike},'%')
        </if>
        <if test="example.searchFrequency != null">
          AND `search_frequency` = #{example.searchFrequency}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `words_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.goods.example.GoodsSearchWordsExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `goods_search_words`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `goods_search_words`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `goods_search_words`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `goods_search_words`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `goods_search_words`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `goods_search_words`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `goods_search_words`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `goods_search_words`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="words_id" keyProperty="wordsId" parameterType="com.slodon.b2b2c.goods.pojo.GoodsSearchWords" useGeneratedKeys="true">
    INSERT INTO `goods_search_words`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="webSite != null">
        #{webSite},
      </if>
      <if test="wordsContent != null">
        #{wordsContent},
      </if>
      <if test="fullPy != null">
        #{fullPy},
      </if>
      <if test="simplePy != null">
        #{simplePy},
      </if>
      <if test="resource != null">
        #{resource},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="searchGoodsNum != null">
        #{searchGoodsNum},
      </if>
      <if test="searchFrequency != null">
        #{searchFrequency},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `goods_search_words`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.webSite != null">
        `web_site` = #{record.webSite},
      </if>
      <if test="record.wordsContent != null">
        `words_content` = #{record.wordsContent},
      </if>
      <if test="record.fullPy != null">
        `full_py` = #{record.fullPy},
      </if>
      <if test="record.simplePy != null">
        `simple_py` = #{record.simplePy},
      </if>
      <if test="record.resource != null">
        `resource` = #{record.resource},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.searchGoodsNum != null">
        `search_goods_num` = #{record.searchGoodsNum},
      </if>
      <if test="record.searchFrequency != null">
        `search_frequency` = #{record.searchFrequency},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `goods_search_words`
    <trim prefix="SET" suffixOverrides=",">
      <if test="webSite != null">
        `web_site` = #{webSite},
      </if>
      <if test="wordsContent != null">
        `words_content` = #{wordsContent},
      </if>
      <if test="fullPy != null">
        `full_py` = #{fullPy},
      </if>
      <if test="simplePy != null">
        `simple_py` = #{simplePy},
      </if>
      <if test="resource != null">
        `resource` = #{resource},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="searchGoodsNum != null">
        `search_goods_num` = #{searchGoodsNum},
      </if>
      <if test="searchFrequency != null">
        `search_frequency` = #{searchFrequency},
      </if>
    </trim>
    WHERE `words_id` = #{wordsId}
  </update>
</mapper>