<?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.xjs.aword.mapper.ApiAWordMapper">

    <resultMap type="com.xjs.aword.domain.ApiAWord" id="ApiAWordResult">
        <result property="id" column="id"/>
        <result property="dataId" column="data_id"/>
        <result property="content" column="content"/>
        <result property="source" column="source"/>
        <result property="note" column="note"/>
        <result property="tts" column="tts"/>
        <result property="imgurl" column="imgurl"/>
        <result property="date" column="date"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectApiAWordVo">
        select id, data_id, content, source, note, tts, imgurl, date, create_time
        from api_a_word
    </sql>

    <select id="selectApiAWordList" parameterType="com.xjs.aword.domain.ApiAWord" resultMap="ApiAWordResult">
        <include refid="selectApiAWordVo"/>
        <where>
            <if test="content != null  and content != ''">and content like "%"#{content}"%"</if>
            <if test="source != null  and source != ''">and source like "%"#{source}"%"</if>
            <if test="note != null  and note != ''">and note like "%"#{note}"%"</if>
        </where>
        order by date desc
    </select>

    <select id="selectApiAWordById" parameterType="Long" resultMap="ApiAWordResult">
        <include refid="selectApiAWordVo"/>
        where id = #{id}
    </select>

    <delete id="deleteApiAWordById" parameterType="Long">
        delete
        from api_a_word
        where id = #{id}
    </delete>

    <delete id="deleteApiAWordByIds" parameterType="String">
        delete from api_a_word where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>