<?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.ruoyi.system.mapper.SysPointTierMapper">

    <resultMap type="SysPointTier" id="SysPointTierResult">
        <result property="id"    column="id"    />
        <result property="points"    column="points"    />
        <result property="orderCondition"    column="order_condition"    />
        <result property="isEnabled"    column="is_enabled"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSysPointTierVo">
        select id, points, order_condition, is_enabled, is_deleted, create_time, update_time from sys_point_tier
    </sql>

    <select id="selectSysPointTierList" parameterType="SysPointTier" resultMap="SysPointTierResult">
        <include refid="selectSysPointTierVo"/>
        <where>
            <if test="points != null "> and points = #{points}</if>
            <if test="orderCondition != null "> and order_condition = #{orderCondition}</if>
            <if test="isEnabled != null "> and is_enabled = #{isEnabled}</if>
            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
        </where>
    </select>

    <select id="selectSysPointTierById" parameterType="Long" resultMap="SysPointTierResult">
        <include refid="selectSysPointTierVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysPointTier" parameterType="SysPointTier" useGeneratedKeys="true" keyProperty="id">
        insert into sys_point_tier
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="points != null">points,</if>
            <if test="orderCondition != null">order_condition,</if>
            <if test="isEnabled != null">is_enabled,</if>
            <if test="isDeleted != null">is_deleted,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="points != null">#{points},</if>
            <if test="orderCondition != null">#{orderCondition},</if>
            <if test="isEnabled != null">#{isEnabled},</if>
            <if test="isDeleted != null">#{isDeleted},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateSysPointTier" parameterType="SysPointTier">
        update sys_point_tier
        <trim prefix="SET" suffixOverrides=",">
            <if test="points != null">points = #{points},</if>
            <if test="orderCondition != null">order_condition = #{orderCondition},</if>
            <if test="isEnabled != null">is_enabled = #{isEnabled},</if>
            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysPointTierById" parameterType="Long">
        update sys_point_tier set isDeleted = '1' where id = #{id}
    </delete>

    <delete id="deleteSysPointTierByIds" parameterType="String">
        update sys_point_tier set isDeleted = '1' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
