<?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.model.mapper.LicenseMapper">
    
    <resultMap type="License" id="LicenseResult">
        <result property="licenseId"    column="license_id"    />
        <result property="licenseName"    column="license_name"    />
        <result property="reamk"    column="reamk"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectLicenseVo">
        select license_id, license_name, reamk, create_by, create_time, del_flag, update_by, update_time from license
    </sql>

    <select id="selectLicenseList" parameterType="License" resultMap="LicenseResult">
        <include refid="selectLicenseVo"/>
        <where>  
            <if test="licenseName != null  and licenseName != ''"> and license_name like concat('%', #{licenseName}, '%')</if>
            <if test="reamk != null  and reamk != ''"> and reamk = #{reamk}</if>
        </where>
    </select>
    
    <select id="selectLicenseByLicenseId" parameterType="Long" resultMap="LicenseResult">
        <include refid="selectLicenseVo"/>
        where license_id = #{licenseId}
    </select>
    <select id="getLicenseList" resultType="com.ruoyi.model.domain.License">
        <include refid="selectLicenseVo"/>
    </select>

    <insert id="insertLicense" parameterType="License">
        insert into license
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="licenseId != null">license_id,</if>
            <if test="licenseName != null">license_name,</if>
            <if test="reamk != null">reamk,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="licenseId != null">#{licenseId},</if>
            <if test="licenseName != null">#{licenseName},</if>
            <if test="reamk != null">#{reamk},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateLicense" parameterType="License">
        update license
        <trim prefix="SET" suffixOverrides=",">
            <if test="licenseName != null">license_name = #{licenseName},</if>
            <if test="reamk != null">reamk = #{reamk},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where license_id = #{licenseId}
    </update>

    <delete id="deleteLicenseByLicenseId" parameterType="Long">
        delete from license where license_id = #{licenseId}
    </delete>

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