<?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.mxjb.mapper.MxjbMultipleWayFormMapper">
    
    <resultMap type="MxjbMultipleWayForm" id="MxjbMultipleWayFormResult">
        <result property="formId"    column="form_id"    />
        <result property="userId"    column="user_id"    />
        <result property="name"    column="name"    />
        <result property="content"    column="content"  typeHandler="com.ruoyi.mxjb.handlers.MultipleWayDataHandler"  />
        <result property="conclusion"    column="conclusion"  typeHandler="com.ruoyi.mxjb.handlers.MultipleWayDataHandler"   />
        <result property="createdTime"    column="created_time"    />
    </resultMap>

    <sql id="selectMxjbMultipleWayFormVo">
        select form_id, user_id, name, content, conclusion, created_time from mxjb_multiple_way_form
    </sql>

    <select id="selectMxjbMultipleWayFormSimpleList" parameterType="MxjbMultipleWayForm" resultMap="MxjbMultipleWayFormResult">
        select form_id, user_id, name, created_time from mxjb_multiple_way_form
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
        </where>
        order by created_time desc
    </select>

    <select id="selectMxjbMultipleWayFormList" parameterType="MxjbMultipleWayForm" resultMap="MxjbMultipleWayFormResult">
        <include refid="selectMxjbMultipleWayFormVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
        </where>
        order by created_time desc
    </select>
    
    <select id="selectMxjbMultipleWayFormByFormId" parameterType="Long" resultMap="MxjbMultipleWayFormResult">
        <include refid="selectMxjbMultipleWayFormVo"/>
        where form_id = #{formId}
    </select>
        
    <insert id="insertMxjbMultipleWayForm" parameterType="MxjbMultipleWayForm" useGeneratedKeys="true" keyProperty="formId">
        insert into mxjb_multiple_way_form
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="name != null">name,</if>
            <if test="content != null">content,</if>
            <if test="conclusion != null">conclusion,</if>
            <if test="createdTime != null">created_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="name != null">#{name},</if>
            <if test="content != null">#{content, typeHandler=com.ruoyi.mxjb.handlers.MultipleWayDataHandler},</if>
            <if test="conclusion != null">#{conclusion, typeHandler=com.ruoyi.mxjb.handlers.MultipleWayDataHandler},</if>
            <if test="createdTime != null">#{createdTime},</if>
         </trim>
    </insert>

    <update id="updateMxjbMultipleWayForm" parameterType="MxjbMultipleWayForm">
        update mxjb_multiple_way_form
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="content != null">content = #{content, typeHandler=com.ruoyi.mxjb.handlers.MultipleWayDataHandler},</if>
            <if test="conclusion != null">conclusion = #{conclusion, typeHandler=com.ruoyi.mxjb.handlers.MultipleWayDataHandler},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
        </trim>
        where form_id = #{formId}
    </update>

    <delete id="deleteMxjbMultipleWayFormByFormId" parameterType="Long">
        delete from mxjb_multiple_way_form where form_id = #{formId}
    </delete>

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