<?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.StrategyOverviewUserSetMapper">

    <sql id="Base_Column_List">
        id,user_id,is_original,permission_id
    </sql>

    <insert id="insertUserHabit" parameterType="com.ho.business.entity.StrategyOverviewUserSet">
        insert into strategy_overview_user_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="isOriginal != null">is_original,</if>
            <if test="permissionId != null">permission_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">  #{userId},</if>
            <if test="isOriginal != null">#{isOriginal},</if>
            <if test="permissionId != null">#{permissionId},</if>
        </trim>
    </insert>

    <update id="updateById" parameterType="com.ho.business.entity.StrategyOverviewUserSet">
        update strategy_overview_user_set
        <set>
            <if test="isOriginal != null">
                is_original = #{isOriginal},
            </if>
            <if test="permissionId != null">
                permissionId = #{permissionId},
            </if>
        </set>
        where id = #{id}
    </update>

    <select id="selectByUserId" resultType="com.ho.business.entity.StrategyOverviewUserSet">
        SELECT <include refid="Base_Column_List"/>
        FROM strategy_overview_user_set
        WHERE user_id = #{userId}
        limit 1
    </select>

</mapper>
