<?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.MxjbMultipleWayCondMapper">
    
    <resultMap type="MxjbMultipleWayCond" id="MxjbMultipleWayCondResult">
        <result property="id"    column="id"    />
        <result property="direction"    column="direction"    />
        <result property="sort"    column="sort"    />
        <result property="condId"    column="condId"    />
        <result property="type"    column="type"    />
        <result property="sex"    column="sex"    />
        <result property="age"    column="age"    />
        <result property="location"    column="location"    />
        <result property="reverse"    column="reverse"    />
        <result property="optionValues"    column="optionValues"    />
        <result property="message"    column="message"    />
    </resultMap>

    <sql id="selectMxjbMultipleWayCondVo">
        select id, direction, sort, condId, type, sex, age, location, reverse, optionValues, message from mxjb_multiple_way_cond
    </sql>

    <select id="selectMxjbMultipleWayCondList" parameterType="MxjbMultipleWayCond" resultMap="MxjbMultipleWayCondResult">
        <include refid="selectMxjbMultipleWayCondVo"/>
        <where>  
            <if test="direction != null  and direction != ''"> and direction = #{direction}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="condId != null "> and condId = #{condId}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="age != null  and sex != ''"> and age = #{age}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="reverse != null "> and reverse = #{reverse}</if>
            <if test="optionValues != null  and optionValues != ''"> and optionValues = #{optionValues}</if>
            <if test="message != null  and message != ''"> and message = #{message}</if>
        </where>
        order by direction, sort
    </select>
    
    <select id="selectMxjbMultipleWayCondById" parameterType="Integer" resultMap="MxjbMultipleWayCondResult">
        <include refid="selectMxjbMultipleWayCondVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMxjbMultipleWayCond" parameterType="MxjbMultipleWayCond" useGeneratedKeys="true" keyProperty="id">
        insert into mxjb_multiple_way_cond
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="direction != null">direction,</if>
            <if test="sort != null">sort,</if>
            <if test="condId != null">condId,</if>
            <if test="type != null">type,</if>
            <if test="sex != null">sex,</if>
            <if test="age != null">age,</if>
            <if test="location != null">location,</if>
            <if test="reverse != null">reverse,</if>
            <if test="optionValues != null">optionValues,</if>
            <if test="message != null">message,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="direction != null">#{direction},</if>
            <if test="sort != null">#{sort},</if>
            <if test="condId != null">#{condId},</if>
            <if test="type != null">#{type},</if>
            <if test="sex != null">#{sex},</if>
            <if test="age != null">#{age},</if>
            <if test="location != null">#{location},</if>
            <if test="reverse != null">#{reverse},</if>
            <if test="optionValues != null">#{optionValues},</if>
            <if test="message != null">#{message},</if>
         </trim>
    </insert>

    <update id="updateMxjbMultipleWayCond" parameterType="MxjbMultipleWayCond">
        update mxjb_multiple_way_cond
        <trim prefix="SET" suffixOverrides=",">
            <if test="direction != null">direction = #{direction},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="condId != null">condId = #{condId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="age != null">age = #{age},</if>
            <if test="location != null">location = #{location},</if>
            <if test="reverse != null">reverse = #{reverse},</if>
            <if test="optionValues != null">optionValues = #{optionValues},</if>
            <if test="message != null">message = #{message},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMxjbMultipleWayCondById" parameterType="Integer">
        delete from mxjb_multiple_way_cond where id = #{id}
    </delete>

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