<?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.fs.store.mapper.FsChineseMedicineMapper">

    <resultMap type="FsChineseMedicine" id="FsChineseMedicineResult">
        <result property="id"    column="id"    />
        <result property="medicineName"    column="medicine_name"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="sort"    column="sort"    />
        <result property="isUsual"    column="is_usual"    />
        <result property="indication"    column="indication"    />
        <result property="action"    column="action"    />
        <result property="usageMethod"    column="usage_method"    />
        <result property="descs"    column="descs"    />
        <result property="msg"    column="msg"    />
        <result property="vessel"    column="vessel"    />
        <result property="flavor"    column="flavor"    />
        <result property="status"    column="status"    />
        <result property="pinyin"    column="pinyin"    />
        <result property="actionTitle"    column="action_title"    />
    </resultMap>

    <sql id="selectFsChineseMedicineVo">
        select id, medicine_name, img_url,action_title, sort, is_usual, indication, action, usage_method, descs, msg, vessel, flavor, status, pinyin from fs_chinese_medicine
    </sql>

    <select id="selectFsChineseMedicineList" parameterType="FsChineseMedicine" resultMap="FsChineseMedicineResult">
        <include refid="selectFsChineseMedicineVo"/>
        <where>
            <if test="medicineName != null  and medicineName != ''"> and medicine_name like concat('%', #{medicineName}, '%')</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="isUsual != null "> and is_usual = #{isUsual}</if>
            <if test="indication != null  and indication != ''"> and indication = #{indication}</if>
            <if test="action != null  and action != ''"> and action = #{action}</if>
            <if test="usageMethod != null  and usageMethod != ''"> and usage_method = #{usageMethod}</if>
            <if test="descs != null  and descs != ''"> and descs = #{descs}</if>
            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
            <if test="vessel != null  and vessel != ''"> and vessel = #{vessel}</if>
            <if test="flavor != null  and flavor != ''"> and flavor = #{flavor}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="pinyin != null  and pinyin != ''"> and pinyin = #{pinyin}</if>
        </where>
    </select>

    <select id="selectFsChineseMedicineById" parameterType="Long" resultMap="FsChineseMedicineResult">
        <include refid="selectFsChineseMedicineVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsChineseMedicine" parameterType="FsChineseMedicine" useGeneratedKeys="true" keyProperty="id">
        insert into fs_chinese_medicine
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="medicineName != null and medicineName != ''">medicine_name,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="sort != null">sort,</if>
            <if test="isUsual != null">is_usual,</if>
            <if test="indication != null">indication,</if>
            <if test="action != null">action,</if>
            <if test="usageMethod != null">usage_method,</if>
            <if test="descs != null">descs,</if>
            <if test="msg != null">msg,</if>
            <if test="vessel != null">vessel,</if>
            <if test="flavor != null">flavor,</if>
            <if test="status != null">status,</if>
            <if test="pinyin != null">pinyin,</if>
            <if test="actionTitle != null">action_title,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="medicineName != null and medicineName != ''">#{medicineName},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="sort != null">#{sort},</if>
            <if test="isUsual != null">#{isUsual},</if>
            <if test="indication != null">#{indication},</if>
            <if test="action != null">#{action},</if>
            <if test="usageMethod != null">#{usageMethod},</if>
            <if test="descs != null">#{descs},</if>
            <if test="msg != null">#{msg},</if>
            <if test="vessel != null">#{vessel},</if>
            <if test="flavor != null">#{flavor},</if>
            <if test="status != null">#{status},</if>
            <if test="pinyin != null">#{pinyin},</if>
            <if test="actionTitle != null">#{actionTitle},</if>
         </trim>
    </insert>

    <update id="updateFsChineseMedicine" parameterType="FsChineseMedicine">
        update fs_chinese_medicine
        <trim prefix="SET" suffixOverrides=",">
            <if test="medicineName != null and medicineName != ''">medicine_name = #{medicineName},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="isUsual != null">is_usual = #{isUsual},</if>
            <if test="indication != null">indication = #{indication},</if>
            <if test="action != null">action = #{action},</if>
            <if test="usageMethod != null">usage_method = #{usageMethod},</if>
            <if test="descs != null">descs = #{descs},</if>
            <if test="msg != null">msg = #{msg},</if>
            <if test="vessel != null">vessel = #{vessel},</if>
            <if test="flavor != null">flavor = #{flavor},</if>
            <if test="status != null">status = #{status},</if>
            <if test="pinyin != null">pinyin = #{pinyin},</if>
            <if test="actionTitle != null">action_title = #{actionTitle},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsChineseMedicineById" parameterType="Long">
        delete from fs_chinese_medicine where id = #{id}
    </delete>

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