<?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.reptileclient.jlifeapp.dao.jz.HmRightsSuppliersMapper">
    <resultMap id="BaseResultMap" type="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers">
        <!--@mbg.generated-->
        <!--@Table hm_rights_suppliers-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="supply_code" jdbcType="VARCHAR" property="supplyCode"/>
        <result column="supply_name" jdbcType="VARCHAR" property="supplyName"/>
        <result column="is_use" jdbcType="BOOLEAN" property="isUse"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, supply_code, supply_name, is_use
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from hm_rights_suppliers
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete
        from hm_rights_suppliers
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id"
            parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into hm_rights_suppliers (supply_code, supply_name, is_use)
        values (#{supplyCode,jdbcType=VARCHAR}, #{supplyName,jdbcType=VARCHAR}, #{isUse,jdbcType=BOOLEAN})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into hm_rights_suppliers
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="supplyCode != null and supplyCode != ''">
                supply_code,
            </if>
            <if test="supplyName != null and supplyName != ''">
                supply_name,
            </if>
            <if test="isUse != null">
                is_use,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="supplyCode != null and supplyCode != ''">
                #{supplyCode,jdbcType=VARCHAR},
            </if>
            <if test="supplyName != null and supplyName != ''">
                #{supplyName,jdbcType=VARCHAR},
            </if>
            <if test="isUse != null">
                #{isUse,jdbcType=BOOLEAN},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers">
        <!--@mbg.generated-->
        update hm_rights_suppliers
        <set>
            <if test="supplyCode != null and supplyCode != ''">
                supply_code = #{supplyCode,jdbcType=VARCHAR},
            </if>
            <if test="supplyName != null and supplyName != ''">
                supply_name = #{supplyName,jdbcType=VARCHAR},
            </if>
            <if test="isUse != null">
                is_use = #{isUse,jdbcType=BOOLEAN},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers">
        <!--@mbg.generated-->
        update hm_rights_suppliers
        set supply_code = #{supplyCode,jdbcType=VARCHAR},
            supply_name = #{supplyName,jdbcType=VARCHAR},
            is_use      = #{isUse,jdbcType=BOOLEAN}
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update hm_rights_suppliers
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="supply_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.supplyCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="supply_name = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.supplyName,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="is_use = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.isUse,jdbcType=BOOLEAN}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update hm_rights_suppliers
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="supply_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.supplyCode != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.supplyCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="supply_name = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.supplyName != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.supplyName,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="is_use = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.isUse != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.isUse,jdbcType=BOOLEAN}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into hm_rights_suppliers
                (supply_code, supply_name, is_use)
                values
        <foreach collection="list" item="item" separator=",">
            (#{item.supplyCode,jdbcType=VARCHAR}, #{item.supplyName,jdbcType=VARCHAR}, #{item.isUse,jdbcType=BOOLEAN})
        </foreach>
    </insert>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into hm_rights_suppliers
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            supply_code,
            supply_name,
            is_use,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            #{supplyCode,jdbcType=VARCHAR},
            #{supplyName,jdbcType=VARCHAR},
            #{isUse,jdbcType=BOOLEAN},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            supply_code = #{supplyCode,jdbcType=VARCHAR},
            supply_name = #{supplyName,jdbcType=VARCHAR},
            is_use      = #{isUse,jdbcType=BOOLEAN},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsSuppliers" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into hm_rights_suppliers
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="supplyCode != null and supplyCode != ''">
                supply_code,
            </if>
            <if test="supplyName != null and supplyName != ''">
                supply_name,
            </if>
            <if test="isUse != null">
                is_use,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="supplyCode != null and supplyCode != ''">
                #{supplyCode,jdbcType=VARCHAR},
            </if>
            <if test="supplyName != null and supplyName != ''">
                #{supplyName,jdbcType=VARCHAR},
            </if>
            <if test="isUse != null">
                #{isUse,jdbcType=BOOLEAN},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            <if test="supplyCode != null and supplyCode != ''">
                supply_code = #{supplyCode,jdbcType=VARCHAR},
            </if>
            <if test="supplyName != null and supplyName != ''">
                supply_name = #{supplyName,jdbcType=VARCHAR},
            </if>
            <if test="isUse != null">
                is_use = #{isUse,jdbcType=BOOLEAN},
            </if>
        </trim>
    </insert>

    <select id="selectAll" resultMap="BaseResultMap">
        select *
        from hm_rights_suppliers
        where is_use = true
    </select>
</mapper>
