查询
<select id="selectOption" resultType="Map" parameterType="com.model.Option"> select * from system_option <where> <if test="uuid != null and uuid != ''"> uuid=#{uuid} </if> <if test="name != null and name != ''"> and name=#{name} </if> <if test="description != null and description != ''"> and description=#{description} </if> <if test="url != null and url != ''"> and url=#{url} </if> <if test="parentID != null and parentID != ''"> and parentID=#{parentID} </if> </where> </select>
修改
<update id="updateOption" parameterType="com.model.Option"> update system_option set <if test="url != null and url !=''"> url = #{url}, </if> <if test="description != null and description !=''"> description = #{description}, </if> <if test="name != null and name !=''"> name = #{name }, </if> <if test="parentID != null and parentID !=''"> parentID = #{parentID }, </if> <if test="sequence != null and sequence !=''"> sequence = #{sequence }, </if> uuid=#{uuid} where uuid = #{uuid} </update>
插入
<insert id="insertOption" parameterType="com.model.Option"> insert into system_option <trim prefix="(" suffix=")" suffixOverrides="," > <if test="name != null" > name, </if> <if test="url != null" > url, </if> <if test="uuid != null" > uuid, </if> <if test="description != null" > description, </if> <if test="parentID != null" > parentID </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="name != null" > #{name}, </if> <if test="url != null" > #{url}, </if> <if test="uuid != null" > #{uuid}, </if> <if test="description != null" > #{description}, </if> <if test="parentID != null" > #{parentID} </if> </trim> </insert>