<?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.ibs.dashboard.mapper.LscjAmountRulesMapper">
    
    <resultMap type="LscjAmountRules" id="LscjAmountRulesResult">
        <result property="orgId"    column="org_id"    />
        <result property="id"    column="id"    />
        <result property="level"    column="level"    />
        <result property="transType"    column="trans_type"    />
        <result property="amount"    column="amount"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectLscjAmountRulesVo">
        select id,org_id, level, trans_type, amount, create_time from lscj_amount_rules
    </sql>

    <select id="selectLscjAmountRulesList" parameterType="LscjAmountRules" resultMap="LscjAmountRulesResult">
        <include refid="selectLscjAmountRulesVo"/>
        <where>
            <if test="id != null and id != ''"> and id = #{id}</if>
            <if test="orgId != null and orgId!= ''" > and org_id = #{orgId}</if>
            <if test=" amount != null "> and amount = #{amount}</if>
            <if test=" transType != null and transType != '' "> and trans_type = #{transType}</if>
            <if test="level != null and level != '' "> and level = #{level}</if>
            <if test="userId != null and userId!=''"> and user_id = #{userId}</if>
            <if test="startTime !=null  ">and create_time &gt;= #{startTime}</if>
            <if test="endTime !=null ">and create_time &lt;= #{endTime}</if>
        </where>
        order by id desc
        limit #{size}  offset #{num}
    </select>
    <select id="selectLscjAmountRulesListCount" parameterType="LscjAmountRules" resultType="Integer">
     select   count(0) from lscj_amount_rules
        <where>
            <if test="id != null and id != ''"> and id = #{id}</if>
            <if test="orgId != null and orgId!= ''" > and org_id = #{orgId}</if>
            <if test=" amount != null "> and amount = #{amount}</if>
            <if test=" transType != null and transType != '' "> and trans_type = #{transType}</if>
            <if test="level != null and level != '' "> and level = #{level}</if>
            <if test="userId != null and userId!=''"> and user_id = #{userId}</if>
            <if test="startTime !=null  ">and create_time &gt;= #{startTime}</if>
            <if test="endTime !=null ">and create_time &lt;= #{endTime}</if>
        </where>

    </select>
    <select id="selectLscjAmountRulesById" parameterType="String" resultMap="LscjAmountRulesResult">
        <include refid="selectLscjAmountRulesVo"/>
        where id =  #{id}
    </select>

    <insert id="insertLscjAmountRules" parameterType="LscjAmountRules">
        insert into lscj_amount_rules
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orgId != null">org_id,</if>
            <if test="level != null">level,</if>
            <if test="transType != null">trans_type,</if>
            <if test="amount != null">amount,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="orgId != null">#{orgId},</if>
            <if test="level != null">#{level},</if>
            <if test="transType != null">#{transType},</if>
            <if test="amount != null">#{amount},</if>
            <if test="createTime !=null">#{createTime}</if>
         </trim>
    </insert>

    <update id="updateLscjAmountRules" parameterType="LscjAmountRules">
        update lscj_amount_rules
        <trim prefix="SET" suffixOverrides=",">
            <if test="level != null">level = #{level},</if>
            <if test="transType != null">trans_type = #{transType},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
        order by id
        limit #{pageSize}  offset #{pageNum}
    </update>

    <delete id="deleteLscjAmountRulesByOrgId" parameterType="String">
        delete from lscj_amount_rules where id = #{orgId}
    </delete>

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