<?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.xinyilu.system.mapper.heightWeightInfo.HeightWeightInfoMapper">

    <resultMap type="HeightWeightInfo" id="HeightWeightInfoResult">
        <result property="id" column="id"/>
        <result property="age" column="age"/>
        <result property="sex" column="sex"/>
        <result property="monthAgeFlag" column="month_age_flag"/>
        <result property="itemFlag" column="item_flag"/>
        <result property="minValue" column="min_value"/>
        <result property="maxValue" column="max_value"/>
        <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="selectHeightWeightInfoVo">
        select id, age, sex, month_age_flag, item_flag, min_value, max_value, create_by, create_time, update_by, update_time from height_weight_info
    </sql>

    <select id="selectHeightWeightInfoList" parameterType="HeightWeightInfo" resultMap="HeightWeightInfoResult">
        <include refid="selectHeightWeightInfoVo"/>
        <where>
            <if test="age != null ">
                and age = #{age}
            </if>
            <if test="sex != null  and sex != ''">
                and sex = #{sex}
            </if>
            <if test="monthAgeFlag != null  and monthAgeFlag != ''">
                and month_age_flag = #{monthAgeFlag}
            </if>
            <if test="itemFlag != null  and itemFlag != ''">
                and item_flag = #{itemFlag}
            </if>
            <if test="minValue != null ">
                and min_value = #{minValue}
            </if>
            <if test="maxValue != null ">
                and max_value = #{maxValue}
            </if>
        </where>
    </select>

    <select id="selectHeightWeightInfoById" parameterType="Long"
            resultMap="HeightWeightInfoResult">
        <include refid="selectHeightWeightInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertHeightWeightInfo" parameterType="HeightWeightInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into height_weight_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="age != null">age,
            </if>
            <if test="sex != null">sex,
            </if>
            <if test="monthAgeFlag != null">month_age_flag,
            </if>
            <if test="itemFlag != null">item_flag,
            </if>
            <if test="minValue != null">min_value,
            </if>
            <if test="maxValue != null">max_value,
            </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="age != null">#{age},
            </if>
            <if test="sex != null">#{sex},
            </if>
            <if test="monthAgeFlag != null">#{monthAgeFlag},
            </if>
            <if test="itemFlag != null">#{itemFlag},
            </if>
            <if test="minValue != null">#{minValue},
            </if>
            <if test="maxValue != null">#{maxValue},
            </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="updateHeightWeightInfo" parameterType="HeightWeightInfo">
        update height_weight_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="age != null">age =
                #{age},
            </if>
            <if test="sex != null">sex =
                #{sex},
            </if>
            <if test="monthAgeFlag != null">month_age_flag =
                #{monthAgeFlag},
            </if>
            <if test="itemFlag != null">item_flag =
                #{itemFlag},
            </if>
            <if test="minValue != null">min_value =
                #{minValue},
            </if>
            <if test="maxValue != null">max_value =
                #{maxValue},
            </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="deleteHeightWeightInfoById" parameterType="Long">
        delete from height_weight_info where id = #{id}
    </delete>

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