<?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.ho.business.mapper.HomeConfigMapper">

    <resultMap id="BaseResultMap" type="com.ho.business.entity.HomeConfig">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="stationId" column="station_id" jdbcType="INTEGER"/>
        <result property="topLeft" column="topLeft" jdbcType="VARCHAR"/>
        <result property="leftBottom" column="leftBottom" jdbcType="VARCHAR"/>
        <result property="topCenter" column="topCenter" jdbcType="VARCHAR"/>
        <result property="rightCenter" column="rightCenter" jdbcType="VARCHAR"/>
        <result property="bottom" column="bottom" jdbcType="VARCHAR"/>
        <result property="rightTop" column="rightTop" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,station_id,topLeft,leftBottom,topCenter,rightCenter,bottom,rightTop
    </sql>



    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.vo.req.HomeConfigAddReqVO"
             useGeneratedKeys="true">
         insert into `home_config`
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="stationId != null">station_id,</if>
             <if test="topLeft != null">topLeft,</if>
             <if test="leftBottom != null">leftBottom,</if>
             <if test="topCenter != null">topCenter,</if>
             <if test="rightCenter != null">rightCenter,</if>
             <if test="bottom != null">bottom,</if>
             <if test="rightTop != null">rightTop,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="stationId != null">#{stationId},</if>
             <if test="topLeft != null">#{topLeft},</if>
             <if test="leftBottom != null">#{leftBottom},</if>
             <if test="topCenter != null">#{topCenter},</if>
             <if test="rightCenter != null">#{rightCenter},</if>
             <if test="bottom != null">#{bottom},</if>
             <if test="rightTop != null">#{rightTop},</if>
         </trim>
     </insert>

     <delete id="delete">
         delete
         from `home_config`
         where station_id = #{id,jdbcType=INTEGER}
     </delete>

    <select id="selectByStationId" resultType="com.ho.business.entity.HomeConfig">
        SELECT
        <include refid="Base_Column_List"/>
        from `home_config`
        <where>
            <if test="stationId != null ">
                station_id = #{stationId}
            </if>
        </where>
    </select>



</mapper>
