<?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.xinelu.manage.mapper.basesportinfo.BaseSportInfoMapper">

    <resultMap type="BaseSportInfo" id="BaseSportInfoResult">
            <result property="id" column="id"/>
            <result property="sportName" column="sport_name"/>
            <result property="sportTypeId" column="sport_type_id"/>
            <result property="sportTypeName" column="sport_type_name"/>
            <result property="sportWay" column="sport_way"/>
            <result property="sportFrequency" column="sport_frequency"/>
            <result property="sportDuration" column="sport_duration"/>
            <result property="sportTime" column="sport_time"/>
            <result property="sportIntensity" column="sport_intensity"/>
            <result property="sportAttention" column="sport_attention"/>
            <result property="sportRemark" column="sport_remark"/>
            <result property="createTime" column="create_time"/>
            <result property="createBy" column="create_by"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectBaseSportInfoVo">
        select id, sport_name, sport_type_id, sport_type_name, sport_way, sport_frequency, sport_duration, sport_time, sport_intensity, sport_attention, sport_remark, create_time, create_by, update_by, update_time from base_sport_info
    </sql>

    <select id="selectBaseSportInfoList" parameterType="BaseSportInfo" resultMap="BaseSportInfoResult">
        <include refid="selectBaseSportInfoVo"/>
        <where>
            <if test="sportName != null  and sportName != ''">
                and sport_name like concat('%', #{sportName}, '%')
            </if>
            <if test="sportTypeId != null ">
                and sport_type_id = #{sportTypeId}
            </if>
            <if test="sportTypeName != null  and sportTypeName != ''">
                and sport_type_name like concat('%', #{sportTypeName}, '%')
            </if>
            <if test="sportWay != null  and sportWay != ''">
                and sport_way = #{sportWay}
            </if>
            <if test="sportFrequency != null  and sportFrequency != ''">
                and sport_frequency = #{sportFrequency}
            </if>
            <if test="sportDuration != null  and sportDuration != ''">
                and sport_duration = #{sportDuration}
            </if>
            <if test="sportTime != null  and sportTime != ''">
                and sport_time = #{sportTime}
            </if>
            <if test="sportIntensity != null  and sportIntensity != ''">
                and sport_intensity = #{sportIntensity}
            </if>
            <if test="sportAttention != null  and sportAttention != ''">
                and sport_attention = #{sportAttention}
            </if>
            <if test="sportRemark != null  and sportRemark != ''">
                and sport_remark = #{sportRemark}
            </if>
        </where>
    </select>

    <select id="selectBaseSportInfoById" parameterType="Long"
            resultMap="BaseSportInfoResult">
            <include refid="selectBaseSportInfoVo"/>
            where id = #{id}
    </select>

    <insert id="insertBaseSportInfo" parameterType="BaseSportInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into base_sport_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="sportName != null">sport_name,
                    </if>
                    <if test="sportTypeId != null">sport_type_id,
                    </if>
                    <if test="sportTypeName != null">sport_type_name,
                    </if>
                    <if test="sportWay != null">sport_way,
                    </if>
                    <if test="sportFrequency != null">sport_frequency,
                    </if>
                    <if test="sportDuration != null">sport_duration,
                    </if>
                    <if test="sportTime != null">sport_time,
                    </if>
                    <if test="sportIntensity != null">sport_intensity,
                    </if>
                    <if test="sportAttention != null">sport_attention,
                    </if>
                    <if test="sportRemark != null">sport_remark,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="createBy != null">create_by,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="sportName != null">#{sportName},
                    </if>
                    <if test="sportTypeId != null">#{sportTypeId},
                    </if>
                    <if test="sportTypeName != null">#{sportTypeName},
                    </if>
                    <if test="sportWay != null">#{sportWay},
                    </if>
                    <if test="sportFrequency != null">#{sportFrequency},
                    </if>
                    <if test="sportDuration != null">#{sportDuration},
                    </if>
                    <if test="sportTime != null">#{sportTime},
                    </if>
                    <if test="sportIntensity != null">#{sportIntensity},
                    </if>
                    <if test="sportAttention != null">#{sportAttention},
                    </if>
                    <if test="sportRemark != null">#{sportRemark},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="createBy != null">#{createBy},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
        </trim>
    </insert>

    <update id="updateBaseSportInfo" parameterType="BaseSportInfo">
        update base_sport_info
        <trim prefix="SET" suffixOverrides=",">
                    <if test="sportName != null">sport_name =
                        #{sportName},
                    </if>
                    <if test="sportTypeId != null">sport_type_id =
                        #{sportTypeId},
                    </if>
                    <if test="sportTypeName != null">sport_type_name =
                        #{sportTypeName},
                    </if>
                    <if test="sportWay != null">sport_way =
                        #{sportWay},
                    </if>
                    <if test="sportFrequency != null">sport_frequency =
                        #{sportFrequency},
                    </if>
                    <if test="sportDuration != null">sport_duration =
                        #{sportDuration},
                    </if>
                    <if test="sportTime != null">sport_time =
                        #{sportTime},
                    </if>
                    <if test="sportIntensity != null">sport_intensity =
                        #{sportIntensity},
                    </if>
                    <if test="sportAttention != null">sport_attention =
                        #{sportAttention},
                    </if>
                    <if test="sportRemark != null">sport_remark =
                        #{sportRemark},
                    </if>
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="createBy != null">create_by =
                        #{createBy},
                    </if>
                    <if test="updateBy != null">update_by =
                        #{updateBy},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBaseSportInfoById" parameterType="Long">
        delete from base_sport_info where id = #{id}
    </delete>

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