<?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.mcwl.resource.mapper.ModelVersionMapper">
    <insert id="addModelVersion" useGeneratedKeys="true" keyProperty="id">
                    INSERT INTO model_version (
                    model_id,version_name,version_description,model_version_type, file_path,file_name, trigger_words, sampling, high, vae, cfg,
                    is_free, is_public, is_encrypt, is_online_use, allow_download_image,
                    allow_software_use, allow_fusion, allow_commercial_use, allow_usage,
                    is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size,file_hash
                    )
                    VALUES
                        (
                        #{modelId},#{versionName}, #{versionDescription},#{modelVersionType}, #{filePath},
                        #{fileName},#{triggerWords},#{sampling}, #{high}, #{vae}, #{cfg},
                        #{isFree}, #{isPublic}, #{isEncrypt}, #{isOnlineUse},
                        #{allowDownloadImage}, #{allowSoftwareUse}, #{allowFusion},
                        #{allowCommercialUse}, #{allowUsage}, #{isExclusiveModel},
                        #{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize},#{fileHash}
                        )
    </insert>


<!--        <insert id="addModelVersion" useGeneratedKeys="true" keyProperty="item.id">-->
<!--            INSERT INTO model_version (-->
<!--            model_id,version_name,version_description,model_version_type, file_path,file_name, trigger_words, sampling, high, vae, cfg,-->
<!--            is_free, is_public, is_encrypt, is_online_use, allow_download_image,-->
<!--            allow_software_use, allow_fusion, allow_commercial_use, allow_usage,-->
<!--            is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag-->
<!--            )-->
<!--            VALUES-->
<!--            <foreach collection="modelVersionList" item="item" separator=",">-->
<!--                (-->
<!--                #{modelProduct.id},#{item.versionName}, #{item.versionDescription},#{item.modelVersionType}, #{item.filePath},-->
<!--                #{item.fileName},#{item.triggerWords},#{item.sampling}, #{item.high}, #{item.vae}, #{item.cfg},-->
<!--                #{item.isFree}, #{item.isPublic}, #{item.isEncrypt}, #{item.isOnlineUse},-->
<!--                #{item.allowDownloadImage}, #{item.allowSoftwareUse}, #{item.allowFusion},-->
<!--                #{item.allowCommercialUse}, #{item.allowUsage}, #{item.isExclusiveModel},-->
<!--                #{item.sampleImagePaths}, #{item.hideImageGenInfo},'0'-->
<!--                )-->
<!--            </foreach>-->
<!--    </insert>-->

    <update id="updateByName">
        update model_version set audit_status = #{auditStatus},
                                     audit_text = #{auditText}
        where version_name = #{versionName} and model_id = #{modelId}
    </update>

    <select id="selectByFileName" resultType="com.mcwl.resource.domain.ModelVersion">
        select key_rate,is_encrypt from model_version where file_name = #{name}
    </select>
    <select id="selectByHash" resultType="com.mcwl.resource.domain.ModelVersion">
        select * from model_version where file_hash = #{hashCode}
    </select>

</mapper>
