<?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.basic.mapper.HwLanguageMapper">
    
    <resultMap type="HwLanguage" id="HwLanguageResult">
        <result property="languageId"    column="language_id"    />
        <result property="languageCode"    column="language_code"    />
        <result property="languageName"    column="language_name"    />
        <result property="languageLang"    column="language_lang"    />
        <result property="languageCountry"    column="language_country"    />
        <result property="defaultFlag"    column="default_flag"    />
    </resultMap>

    <sql id="selectHwLanguageVo">
        select language_id, language_code, language_name, language_lang, language_country, default_flag from hw_language
    </sql>

    <select id="selectHwLanguageList" parameterType="HwLanguage" resultMap="HwLanguageResult">
        <include refid="selectHwLanguageVo"/>
        <where>  
            <if test="languageCode != null  and languageCode != ''"> and language_code = #{languageCode}</if>
            <if test="languageName != null  and languageName != ''"> and language_name like concat('%', #{languageName}, '%')</if>
            <if test="languageLang != null  and languageLang != ''"> and language_lang = #{languageLang}</if>
            <if test="languageCountry != null  and languageCountry != ''"> and language_country = #{languageCountry}</if>
            <if test="defaultFlag != null  and defaultFlag != ''"> and default_flag = #{defaultFlag}</if>
        </where>
    </select>
    
    <select id="selectHwLanguageByLanguageId" parameterType="Long" resultMap="HwLanguageResult">
        <include refid="selectHwLanguageVo"/>
        where language_id = #{languageId}
    </select>
        
    <insert id="insertHwLanguage" parameterType="HwLanguage" useGeneratedKeys="true" keyProperty="languageId">
        insert into hw_language
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="languageCode != null and languageCode != ''">language_code,</if>
            <if test="languageName != null and languageName != ''">language_name,</if>
            <if test="languageLang != null">language_lang,</if>
            <if test="languageCountry != null">language_country,</if>
            <if test="defaultFlag != null and defaultFlag != ''">default_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="languageCode != null and languageCode != ''">#{languageCode},</if>
            <if test="languageName != null and languageName != ''">#{languageName},</if>
            <if test="languageLang != null">#{languageLang},</if>
            <if test="languageCountry != null">#{languageCountry},</if>
            <if test="defaultFlag != null and defaultFlag != ''">#{defaultFlag},</if>
         </trim>
    </insert>

    <update id="updateHwLanguage" parameterType="HwLanguage">
        update hw_language
        <trim prefix="SET" suffixOverrides=",">
            <if test="languageCode != null and languageCode != ''">language_code = #{languageCode},</if>
            <if test="languageName != null and languageName != ''">language_name = #{languageName},</if>
            <if test="languageLang != null">language_lang = #{languageLang},</if>
            <if test="languageCountry != null">language_country = #{languageCountry},</if>
            <if test="defaultFlag != null and defaultFlag != ''">default_flag = #{defaultFlag},</if>
        </trim>
        where language_id = #{languageId}
    </update>

    <delete id="deleteHwLanguageByLanguageId" parameterType="Long">
        delete from hw_language where language_id = #{languageId}
    </delete>

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