<?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.mirs.biz.mapper.BrdfDataMapper">
    
    <resultMap type="BrdfData" id="BrdfDataResult">
        <result property="id"    column="id"    />
        <result property="sampleModel"    column="sample_model"    />
        <result property="temperatureK"    column="temperature_k"    />
        <result property="wavelengthUm"    column="wavelength_um"    />
        <result property="thetaIncident"    column="theta_incident"    />
        <result property="phiIncident"    column="phi_incident"    />
        <result property="thetaReflected"    column="theta_reflected"    />
        <result property="phiReflected"    column="phi_reflected"    />
        <result property="measurement1"    column="measurement_1"    />
        <result property="measurement2"    column="measurement_2"    />
        <result property="measurement3"    column="measurement_3"    />
        <result property="measurement4"    column="measurement_4"    />
        <result property="measurement5"    column="measurement_5"    />
        <result property="meanValue"    column="mean_value"    />
        <result property="repeatabilityPct"    column="repeatability_pct"    />
        <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="selectBrdfDataVo">
        select id, sample_model, temperature_k, wavelength_um, theta_incident, phi_incident, theta_reflected, phi_reflected, measurement_1, measurement_2, measurement_3, measurement_4, measurement_5, mean_value, repeatability_pct, create_by, create_time, update_by, update_time from biz_brdf_data_t
    </sql>

    <select id="selectBrdfDataList" parameterType="BrdfData" resultMap="BrdfDataResult">
        <include refid="selectBrdfDataVo"/>
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
            <if test="temperatureK != null "> and temperature_k = #{temperatureK}</if>
            <if test="wavelengthUm != null  and wavelengthUm != ''"> and wavelength_um = #{wavelengthUm}</if>
            <if test="thetaIncident != null "> and theta_incident = #{thetaIncident}</if>
            <if test="phiIncident != null "> and phi_incident = #{phiIncident}</if>
            <if test="thetaReflected != null "> and theta_reflected = #{thetaReflected}</if>
            <if test="phiReflected != null "> and phi_reflected = #{phiReflected}</if>
        </where>
    </select>
    
    <select id="selectBrdfDataById" parameterType="Long" resultMap="BrdfDataResult">
        <include refid="selectBrdfDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertBrdfData" parameterType="BrdfData" useGeneratedKeys="true" keyProperty="id">
        insert into biz_brdf_data_t
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sampleModel != null">sample_model,</if>
            <if test="temperatureK != null">temperature_k,</if>
            <if test="wavelengthUm != null">wavelength_um,</if>
            <if test="thetaIncident != null">theta_incident,</if>
            <if test="phiIncident != null">phi_incident,</if>
            <if test="thetaReflected != null">theta_reflected,</if>
            <if test="phiReflected != null">phi_reflected,</if>
            <if test="measurement1 != null">measurement_1,</if>
            <if test="measurement2 != null">measurement_2,</if>
            <if test="measurement3 != null">measurement_3,</if>
            <if test="measurement4 != null">measurement_4,</if>
            <if test="measurement5 != null">measurement_5,</if>
            <if test="meanValue != null">mean_value,</if>
            <if test="repeatabilityPct != null">repeatability_pct,</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="sampleModel != null">#{sampleModel},</if>
            <if test="temperatureK != null">#{temperatureK},</if>
            <if test="wavelengthUm != null">#{wavelengthUm},</if>
            <if test="thetaIncident != null">#{thetaIncident},</if>
            <if test="phiIncident != null">#{phiIncident},</if>
            <if test="thetaReflected != null">#{thetaReflected},</if>
            <if test="phiReflected != null">#{phiReflected},</if>
            <if test="measurement1 != null">#{measurement1},</if>
            <if test="measurement2 != null">#{measurement2},</if>
            <if test="measurement3 != null">#{measurement3},</if>
            <if test="measurement4 != null">#{measurement4},</if>
            <if test="measurement5 != null">#{measurement5},</if>
            <if test="meanValue != null">#{meanValue},</if>
            <if test="repeatabilityPct != null">#{repeatabilityPct},</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>

    <insert id="batchInsertBrdfData" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
        insert into biz_brdf_data_t (
        sample_model,
        temperature_k,
        wavelength_um,
        theta_incident,
        phi_incident,
        theta_reflected,
        phi_reflected,
        measurement_1,
        measurement_2,
        measurement_3,
        measurement_4,
        measurement_5,
        mean_value,
        repeatability_pct,
        create_by,
        create_time,
        update_by,
        update_time
        ) values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.sampleModel},
            #{item.temperatureK},
            #{item.wavelengthUm},
            #{item.thetaIncident},
            #{item.phiIncident},
            #{item.thetaReflected},
            #{item.phiReflected},
            #{item.measurement1},
            #{item.measurement2},
            #{item.measurement3},
            #{item.measurement4},
            #{item.measurement5},
            #{item.meanValue},
            #{item.repeatabilityPct},
            #{item.createBy},
            #{item.createTime},
            #{item.updateBy},
            #{item.updateTime}
            )
        </foreach>
    </insert>

    <update id="updateBrdfData" parameterType="BrdfData">
        update biz_brdf_data_t
        <trim prefix="SET" suffixOverrides=",">
            <if test="sampleModel != null">sample_model = #{sampleModel},</if>
            <if test="temperatureK != null">temperature_k = #{temperatureK},</if>
            <if test="wavelengthUm != null">wavelength_um = #{wavelengthUm},</if>
            <if test="thetaIncident != null">theta_incident = #{thetaIncident},</if>
            <if test="phiIncident != null">phi_incident = #{phiIncident},</if>
            <if test="thetaReflected != null">theta_reflected = #{thetaReflected},</if>
            <if test="phiReflected != null">phi_reflected = #{phiReflected},</if>
            <if test="measurement1 != null">measurement_1 = #{measurement1},</if>
            <if test="measurement2 != null">measurement_2 = #{measurement2},</if>
            <if test="measurement3 != null">measurement_3 = #{measurement3},</if>
            <if test="measurement4 != null">measurement_4 = #{measurement4},</if>
            <if test="measurement5 != null">measurement_5 = #{measurement5},</if>
            <if test="meanValue != null">mean_value = #{meanValue},</if>
            <if test="repeatabilityPct != null">repeatability_pct = #{repeatabilityPct},</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="deleteBrdfDataById" parameterType="Long">
        delete from biz_brdf_data_t where id = #{id}
    </delete>

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

    <select id="getTemperatureK" parameterType="String" resultType="HashMap">
        select distinct temperature_k name, temperature_k value from biz_brdf_data_t
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
        </where>
        ORDER BY temperature_k asc
    </select>

    <select id="getThetaIncident" resultType="HashMap">
        select distinct theta_incident name, theta_incident value from biz_brdf_data_t
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
        </where>
        order by theta_incident asc
    </select>

    <select id="getPhiIncident" resultType="HashMap">
        select distinct phi_incident name, phi_incident value from biz_brdf_data_t
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
        </where>
        order by phi_incident asc
    </select>

    <select id="getThetaReflected" resultType="HashMap">
        select distinct theta_reflected name, theta_reflected value from biz_brdf_data_t
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
        </where>
        order by theta_reflected asc
    </select>

    <select id="getPhiReflected" resultType="HashMap">
        select distinct phi_reflected name, phi_reflected value from biz_brdf_data_t
        <where>
            <if test="sampleModel != null  and sampleModel != ''"> and sample_model = #{sampleModel}</if>
        </where>
        order by phi_reflected asc
    </select>
</mapper>