<?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.ruoyi.kaohe.mapper.KhVoteItemsMapper">

    <resultMap type="KhVoteItems" id="KhVoteItemsResult">
        <result property="id"    column="id"    />
        <result property="vitemName"    column="vitem_name"    />
        <result property="score"    column="score"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectKhVoteItemsVo">
        select id, vitem_name, score, create_by, create_time, update_by, update_time, remark from kh_vote_items
    </sql>

    <select id="selectKhVoteItemsList" parameterType="KhVoteItems" resultMap="KhVoteItemsResult">
        <include refid="selectKhVoteItemsVo"/>
        <where>
            <if test="vitemName != null  and vitemName != ''"> and vitem_name like concat('%', #{vitemName}, '%')</if>
            <if test="score != null "> and score = #{score}</if>
        </where>
    </select>

    <select id="selectKhVoteItemsById" parameterType="Long" resultMap="KhVoteItemsResult">
        <include refid="selectKhVoteItemsVo"/>
        where id = #{id}
    </select>

    <insert id="insertKhVoteItems" parameterType="KhVoteItems" useGeneratedKeys="true" keyProperty="id">
        insert into kh_vote_items
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="vitemName != null">vitem_name,</if>
            <if test="score != null">score,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="vitemName != null">#{vitemName},</if>
            <if test="score != null">#{score},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateKhVoteItems" parameterType="KhVoteItems">
        update kh_vote_items
        <trim prefix="SET" suffixOverrides=",">
            <if test="vitemName != null">vitem_name = #{vitemName},</if>
            <if test="score != null">score = #{score},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKhVoteItemsById" parameterType="Long">
        delete from kh_vote_items where id = #{id}
    </delete>

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