<?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.FsFamousPrescribeMapper">

    <resultMap type="FsFamousPrescribe" id="FsFamousPrescribeResult">
        <result property="id"    column="id"    />
        <result property="prescribeName"    column="prescribe_name"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="sort"    column="sort"    />
        <result property="prescribeType"    column="prescribe_type"    />
        <result property="indication"    column="indication"    />
        <result property="belongBook"    column="belong_book"    />
        <result property="descs"    column="descs"    />
        <result property="action"    column="action"    />
        <result property="usageMethod"    column="usage_method"    />
        <result property="msg"    column="msg"    />
        <result property="createTime"    column="create_time"    />
        <result property="status"    column="status"    />
        <result property="pinyin"    column="pinyin"    />
        <result property="actionTitle"    column="action_title"    />
    </resultMap>

    <sql id="selectFsFamousPrescribeVo">
        select id, prescribe_name,action_title, img_url,pinyin, sort, prescribe_type, indication, belong_book, descs, action, usage_method, msg, create_time, status from fs_famous_prescribe
    </sql>

    <select id="selectFsFamousPrescribeList" parameterType="FsFamousPrescribe" resultMap="FsFamousPrescribeResult">
        <include refid="selectFsFamousPrescribeVo"/>
        <where>
            <if test="prescribeName != null  and prescribeName != ''"> and prescribe_name like concat('%', #{prescribeName}, '%')</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="prescribeType != null  and prescribeType != ''"> and prescribe_type = #{prescribeType}</if>
            <if test="indication != null  and indication != ''"> and indication = #{indication}</if>
            <if test="belongBook != null  and belongBook != ''"> and belong_book = #{belongBook}</if>
            <if test="descs != null  and descs != ''"> and descs = #{descs}</if>
            <if test="action != null  and action != ''"> and action = #{action}</if>
            <if test="usageMethod  != null  and usageMethod  != ''"> and usage_method = #{usageMethod }</if>
            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by sort,id desc
    </select>

    <select id="selectFsFamousPrescribeById" parameterType="Long" resultMap="FsFamousPrescribeResult">
        <include refid="selectFsFamousPrescribeVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsFamousPrescribe" parameterType="FsFamousPrescribe" useGeneratedKeys="true" keyProperty="id">
        insert into fs_famous_prescribe
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="prescribeName != null and prescribeName != ''">prescribe_name,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="sort != null">sort,</if>
            <if test="prescribeType != null">prescribe_type,</if>
            <if test="indication != null">indication,</if>
            <if test="belongBook != null">belong_book,</if>
            <if test="descs != null">descs,</if>
            <if test="action != null">action,</if>
            <if test="usageMethod  != null">usage_method,</if>
            <if test="msg != null">msg,</if>
            <if test="createTime != null">create_time,</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="prescribeName != null and prescribeName != ''">#{prescribeName},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="sort != null">#{sort},</if>
            <if test="prescribeType != null">#{prescribeType},</if>
            <if test="indication != null">#{indication},</if>
            <if test="belongBook != null">#{belongBook},</if>
            <if test="descs != null">#{descs},</if>
            <if test="action != null">#{action},</if>
            <if test="usageMethod  != null">#{usageMethod },</if>
            <if test="msg != null">#{msg},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="status != null">#{status},</if>
            <if test="pinyin != null">#{pinyin},</if>
            <if test="actionTitle != null">#{actionTitle},</if>
         </trim>
    </insert>

    <update id="updateFsFamousPrescribe" parameterType="FsFamousPrescribe">
        update fs_famous_prescribe
        <trim prefix="SET" suffixOverrides=",">
            <if test="prescribeName != null and prescribeName != ''">prescribe_name = #{prescribeName},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="prescribeType != null">prescribe_type = #{prescribeType},</if>
            <if test="indication != null">indication = #{indication},</if>
            <if test="belongBook != null">belong_book = #{belongBook},</if>
            <if test="descs != null">descs = #{descs},</if>
            <if test="action != null">action = #{action},</if>
            <if test="usageMethod  != null">usage_method = #{usageMethod },</if>
            <if test="msg != null">msg = #{msg},</if>
            <if test="createTime != null">create_time = #{createTime},</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="deleteFsFamousPrescribeById" parameterType="Long">
        delete from fs_famous_prescribe where id = #{id}
    </delete>

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