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

    <resultMap type="FsVessel" id="FsVesselResult">
        <result property="id"    column="id"    />
        <result property="vesselName"    column="vessel_name"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="sort"    column="sort"    />
        <result property="vessel"    column="vessel"    />
        <result property="region"    column="region"    />
        <result property="descs"    column="descs"    />
        <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="selectFsVesselVo">
        select id, vessel_name, action_title,img_url, pinyin,sort, vessel, region, descs, create_time, status from fs_vessel
    </sql>

    <select id="selectFsVesselList" parameterType="FsVessel" resultMap="FsVesselResult">
        <include refid="selectFsVesselVo"/>
        <where>
            <if test="vesselName != null  and vesselName != ''"> and vessel_name like concat('%', #{vesselName}, '%')</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="vessel != null  and vessel != ''"> and vessel = #{vessel}</if>
            <if test="region != null  and region != ''"> and region = #{region}</if>
            <if test="descs != null  and descs != ''"> and descs like concat('%', #{descs}, '%')</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="selectFsVesselById" parameterType="Long" resultMap="FsVesselResult">
        <include refid="selectFsVesselVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsVessel" parameterType="FsVessel">
        insert into fs_vessel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="vesselName != null and vesselName != ''">vessel_name,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="sort != null">sort,</if>
            <if test="vessel != null">vessel,</if>
            <if test="region != null">region,</if>
            <if test="descs != null and descs != ''">descs,</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="id != null">#{id},</if>
            <if test="vesselName != null and vesselName != ''">#{vesselName},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="sort != null">#{sort},</if>
            <if test="vessel != null">#{vessel},</if>
            <if test="region != null">#{region},</if>
            <if test="descs != null and descs != ''">#{descs},</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="updateFsVessel" parameterType="FsVessel">
        update fs_vessel
        <trim prefix="SET" suffixOverrides=",">
            <if test="vesselName != null and vesselName != ''">vessel_name = #{vesselName},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="vessel != null">vessel = #{vessel},</if>
            <if test="region != null">region = #{region},</if>
            <if test="descs != null and descs != ''">descs = #{descs},</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="deleteFsVesselById" parameterType="Long">
        delete from fs_vessel where id = #{id}
    </delete>

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