<?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.fidms.web.mapper.FlowFieldInputMapper">
    
    <resultMap type="FlowFieldInput" id="FlowFieldInputResult">
        <result property="id"    column="id"    />
        <result property="model3dId"    column="model_3d_id"    />
        <result property="machNumberX"    column="mach_number_x"    />
        <result property="machNumberY"    column="mach_number_y"    />
        <result property="machNumberZ"    column="mach_number_z"    />
        <result property="flightHeight"    column="flight_height"    />
        <result property="oxCoordinate"    column="ox_coordinate"    />
        <result property="oyCoordinate"    column="oy_coordinate"    />
        <result property="ozCoordinate"    column="oz_coordinate"    />
        <result property="pressure"    column="pressure"    />
        <result property="flowVelocityX"    column="flow_velocity_x"    />
        <result property="flowVelocityY"    column="flow_velocity_y"    />
        <result property="flowVelocityZ"    column="flow_velocity_z"    />
        <result property="density"    column="density"    />
        <result property="co2MassFraction"    column="co2_mass_fraction"    />
        <result property="coMassFraction"    column="co_mass_fraction"    />
        <result property="h2oMassFraction"    column="h2o_mass_fraction"    />
        <result property="temperature"    column="temperature"    />
        <result property="fluentGridFile"    column="fluent_grid_file"    />
        <result property="fluentGridFilePath"    column="fluent_grid_file_path"    />
        <result property="fluentCasFile"    column="fluent_cas_file"    />
        <result property="fluentCasFilePath"    column="fluent_cas_file_path"    />
        <result property="fluentDatFile"    column="fluent_dat_file"    />
        <result property="fluentDatFilePath"    column="fluent_dat_file_path"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFlowFieldInputVo">
        SELECT
            ffi.id,
            ffi.model_3d_id,
            m3.`name` model3dName,
            ffi.mach_number_x,
            ffi.mach_number_y,
            ffi.mach_number_z,
            ffi.flight_height,
            ffi.ox_coordinate,
            ffi.oy_coordinate,
            ffi.oz_coordinate,
            ffi.pressure,
            ffi.flow_velocity_x,
            ffi.flow_velocity_y,
            ffi.flow_velocity_z,
            ffi.density,
            ffi.co2_mass_fraction,
            ffi.co_mass_fraction,
            ffi.h2o_mass_fraction,
            ffi.temperature,
            ffi.fluent_grid_file,
            ffi.fluent_grid_file_path,
            ffi.fluent_cas_file,
            ffi.fluent_cas_file_path,
            ffi.fluent_dat_file,
            ffi.fluent_dat_file_path,
            ffi.create_by,
            ffi.create_time,
            ffi.update_by,
            ffi.update_time
        FROM
            bz_flow_field_input_t ffi
            LEFT JOIN bz_model_3d_t m3 ON ffi.model_3d_id = m3.id
    </sql>

    <select id="selectFlowFieldInputList" parameterType="FlowFieldInput" resultMap="FlowFieldInputResult">
        <include refid="selectFlowFieldInputVo"/>
        <where>  
            <if test="model3dId != null "> and model_3d_id = #{model3dId}</if>
            <if test="machNumberX != null "> and mach_number_x = #{machNumberX}</if>
            <if test="machNumberY != null "> and mach_number_y = #{machNumberY}</if>
            <if test="machNumberZ != null "> and mach_number_z = #{machNumberZ}</if>
            <if test="flightHeight != null "> and flight_height = #{flightHeight}</if>
            <if test="oxCoordinate != null "> and ox_coordinate = #{oxCoordinate}</if>
            <if test="oyCoordinate != null "> and oy_coordinate = #{oyCoordinate}</if>
            <if test="ozCoordinate != null "> and oz_coordinate = #{ozCoordinate}</if>
            <if test="pressure != null "> and pressure = #{pressure}</if>
            <if test="flowVelocityX != null "> and flow_velocity_x = #{flowVelocityX}</if>
            <if test="flowVelocityY != null "> and flow_velocity_y = #{flowVelocityY}</if>
            <if test="flowVelocityZ != null "> and flow_velocity_z = #{flowVelocityZ}</if>
            <if test="density != null "> and density = #{density}</if>
            <if test="co2MassFraction != null "> and co2_mass_fraction = #{co2MassFraction}</if>
            <if test="coMassFraction != null "> and co_mass_fraction = #{coMassFraction}</if>
            <if test="h2oMassFraction != null "> and h2o_mass_fraction = #{h2oMassFraction}</if>
            <if test="temperature != null "> and temperature = #{temperature}</if>
            <if test="fluentGridFile != null  and fluentGridFile != ''"> and fluent_grid_file = #{fluentGridFile}</if>
            <if test="fluentGridFilePath != null  and fluentGridFilePath != ''"> and fluent_grid_file_path = #{fluentGridFilePath}</if>
            <if test="fluentCasFile != null  and fluentCasFile != ''"> and fluent_cas_file = #{fluentCasFile}</if>
            <if test="fluentCasFilePath != null  and fluentCasFilePath != ''"> and fluent_cas_file_path = #{fluentCasFilePath}</if>
            <if test="fluentDatFile != null  and fluentDatFile != ''"> and fluent_dat_file = #{fluentDatFile}</if>
            <if test="fluentDatFilePath != null  and fluentDatFilePath != ''"> and fluent_dat_file_path = #{fluentDatFilePath}</if>
        </where>
    </select>
    
    <select id="selectFlowFieldInputById" parameterType="Long" resultMap="FlowFieldInputResult">
        <include refid="selectFlowFieldInputVo"/>
        where ffi.id = #{id}
    </select>
        
    <insert id="insertFlowFieldInput" parameterType="FlowFieldInput" useGeneratedKeys="true" keyProperty="id">
        insert into bz_flow_field_input_t
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="model3dId != null">model_3d_id,</if>
            <if test="machNumberX != null">mach_number_x,</if>
            <if test="machNumberY != null">mach_number_y,</if>
            <if test="machNumberZ != null">mach_number_z,</if>
            <if test="flightHeight != null">flight_height,</if>
            <if test="oxCoordinate != null">ox_coordinate,</if>
            <if test="oyCoordinate != null">oy_coordinate,</if>
            <if test="ozCoordinate != null">oz_coordinate,</if>
            <if test="pressure != null">pressure,</if>
            <if test="flowVelocityX != null">flow_velocity_x,</if>
            <if test="flowVelocityY != null">flow_velocity_y,</if>
            <if test="flowVelocityZ != null">flow_velocity_z,</if>
            <if test="density != null">density,</if>
            <if test="co2MassFraction != null">co2_mass_fraction,</if>
            <if test="coMassFraction != null">co_mass_fraction,</if>
            <if test="h2oMassFraction != null">h2o_mass_fraction,</if>
            <if test="temperature != null">temperature,</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">fluent_grid_file,</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">fluent_grid_file_path,</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">fluent_cas_file,</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">fluent_cas_file_path,</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">fluent_dat_file,</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">fluent_dat_file_path,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="model3dId != null">#{model3dId},</if>
            <if test="machNumberX != null">#{machNumberX},</if>
            <if test="machNumberY != null">#{machNumberY},</if>
            <if test="machNumberZ != null">#{machNumberZ},</if>
            <if test="flightHeight != null">#{flightHeight},</if>
            <if test="oxCoordinate != null">#{oxCoordinate},</if>
            <if test="oyCoordinate != null">#{oyCoordinate},</if>
            <if test="ozCoordinate != null">#{ozCoordinate},</if>
            <if test="pressure != null">#{pressure},</if>
            <if test="flowVelocityX != null">#{flowVelocityX},</if>
            <if test="flowVelocityY != null">#{flowVelocityY},</if>
            <if test="flowVelocityZ != null">#{flowVelocityZ},</if>
            <if test="density != null">#{density},</if>
            <if test="co2MassFraction != null">#{co2MassFraction},</if>
            <if test="coMassFraction != null">#{coMassFraction},</if>
            <if test="h2oMassFraction != null">#{h2oMassFraction},</if>
            <if test="temperature != null">#{temperature},</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">#{fluentGridFile},</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">#{fluentGridFilePath},</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">#{fluentCasFile},</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">#{fluentCasFilePath},</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">#{fluentDatFile},</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">#{fluentDatFilePath},</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>
         </trim>
    </insert>

    <update id="updateFlowFieldInput" parameterType="FlowFieldInput">
        update bz_flow_field_input_t
        <trim prefix="SET" suffixOverrides=",">
            <if test="model3dId != null">model_3d_id = #{model3dId},</if>
            <if test="machNumberX != null">mach_number_x = #{machNumberX},</if>
            <if test="machNumberY != null">mach_number_y = #{machNumberY},</if>
            <if test="machNumberZ != null">mach_number_z = #{machNumberZ},</if>
            <if test="flightHeight != null">flight_height = #{flightHeight},</if>
            <if test="oxCoordinate != null">ox_coordinate = #{oxCoordinate},</if>
            <if test="oyCoordinate != null">oy_coordinate = #{oyCoordinate},</if>
            <if test="ozCoordinate != null">oz_coordinate = #{ozCoordinate},</if>
            <if test="pressure != null">pressure = #{pressure},</if>
            <if test="flowVelocityX != null">flow_velocity_x = #{flowVelocityX},</if>
            <if test="flowVelocityY != null">flow_velocity_y = #{flowVelocityY},</if>
            <if test="flowVelocityZ != null">flow_velocity_z = #{flowVelocityZ},</if>
            <if test="density != null">density = #{density},</if>
            <if test="co2MassFraction != null">co2_mass_fraction = #{co2MassFraction},</if>
            <if test="coMassFraction != null">co_mass_fraction = #{coMassFraction},</if>
            <if test="h2oMassFraction != null">h2o_mass_fraction = #{h2oMassFraction},</if>
            <if test="temperature != null">temperature = #{temperature},</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">fluent_grid_file = #{fluentGridFile},</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">fluent_grid_file_path = #{fluentGridFilePath},</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">fluent_cas_file = #{fluentCasFile},</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">fluent_cas_file_path = #{fluentCasFilePath},</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">fluent_dat_file = #{fluentDatFile},</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">fluent_dat_file_path = #{fluentDatFilePath},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFlowFieldInputById" parameterType="Long">
        delete from bz_flow_field_input_t where id = #{id}
    </delete>

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