<?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.interfaces.mapper.TbModelsMapper">

    <resultMap type="com.ruoyi.interfaces.domain.TbModels" id="TbModelsResult">
        <result property="modelId"    column="MODEL_ID"    />
        <result property="modelName"    column="MODEL_NAME"    />
        <result property="modelShortname"    column="MODEL_SHORTNAME"    />
        <result property="modelGroup"    column="MODEL_GROUP"    />
        <result property="modelDescription"    column="MODEL_DESCRIPTION"    />
        <result property="version"    column="VERSION"    />
        <result property="modelType"    column="MODEL_TYPE"    />
        <result property="executionType"    column="EXECUTION_TYPE"    />
        <result property="taskType"    column="TASK_TYPE"    />
        <result property="providerUnit"    column="PROVIDER_UNIT"    />
        <result property="dllPath"    column="DLL_PATH"    />
        <result property="isCalibratable"    column="IS_CALIBRATABLE"    />
        <result property="status"    column="STATUS"    />
        <result property="createdBy"    column="CREATED_BY"    />
        <result property="createdTime"    column="CREATED_TIME"    />
        <result property="updatedBy"    column="UPDATED_BY"    />
        <result property="updatedTime"    column="UPDATED_TIME"    />
        <result property="modelLanguafe"    column="MODEL_LANGUAFE"    />
        <result property="modelVersion"    column="MODEL_VERSION"    />
        <result property="cpuNum"    column="CPU_NUM"    />
        <result property="memo"    column="MEMO"    />
        <result property="isGpu"    column="IS_GPU"    />
        <result property="platform"    column="PLATFORM"    />
        <result property="runModel"    column="RUN_MODEL"    />
        <result property="modelExample"    column="MODEL_EXAMPLE"    />
    </resultMap>

    <sql id="selectTbModelsVo">
        select MODEL_ID, MODEL_NAME, MODEL_SHORTNAME, MODEL_GROUP, MODEL_DESCRIPTION, VERSION, MODEL_TYPE, EXECUTION_TYPE, TASK_TYPE, PROVIDER_UNIT, DLL_PATH, IS_CALIBRATABLE, STATUS, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, MODEL_LANGUAFE, MODEL_VERSION, CPU_NUM, MEMO, IS_GPU, PLATFORM, RUN_MODEL, MODEL_EXAMPLE from sh_model.tb_models
    </sql>

    <select id="selectTbModelsList" parameterType="com.ruoyi.interfaces.domain.TbModels" resultMap="TbModelsResult">
        <include refid="selectTbModelsVo"/>
        <where>
            <if test="modelName != null  and modelName != ''"> and MODEL_NAME like concat('%', #{modelName}, '%')</if>
            <if test="modelShortname != null  and modelShortname != ''"> and MODEL_SHORTNAME like concat('%', #{modelShortname}, '%')</if>
            <if test="modelGroup != null  and modelGroup != ''"> and MODEL_GROUP = #{modelGroup}</if>
            <if test="modelDescription != null  and modelDescription != ''"> and MODEL_DESCRIPTION = #{modelDescription}</if>
            <if test="version != null  and version != ''"> and VERSION = #{version}</if>
            <if test="modelType != null  and modelType != ''"> and MODEL_TYPE = #{modelType}</if>
            <if test="executionType != null  and executionType != ''"> and EXECUTION_TYPE = #{executionType}</if>
            <if test="taskType != null  and taskType != ''"> and TASK_TYPE = #{taskType}</if>
            <if test="providerUnit != null  and providerUnit != ''"> and PROVIDER_UNIT = #{providerUnit}</if>
            <if test="dllPath != null  and dllPath != ''"> and DLL_PATH = #{dllPath}</if>
            <if test="isCalibratable != null  and isCalibratable != ''"> and IS_CALIBRATABLE = #{isCalibratable}</if>
            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
            <if test="createdBy != null  and createdBy != ''"> and CREATED_BY = #{createdBy}</if>
            <if test="createdTime != null "> and CREATED_TIME = #{createdTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and UPDATED_BY = #{updatedBy}</if>
            <if test="updatedTime != null "> and UPDATED_TIME = #{updatedTime}</if>
            <if test="modelLanguafe != null  and modelLanguafe != ''"> and MODEL_LANGUAFE = #{modelLanguafe}</if>
            <if test="modelVersion != null  and modelVersion != ''"> and MODEL_VERSION = #{modelVersion}</if>
            <if test="cpuNum != null  and cpuNum != ''"> and CPU_NUM = #{cpuNum}</if>
            <if test="memo != null  and memo != ''"> and MEMO = #{memo}</if>
            <if test="isGpu != null  and isGpu != ''"> and IS_GPU = #{isGpu}</if>
            <if test="platform != null  and platform != ''"> and PLATFORM = #{platform}</if>
            <if test="runModel != null  and runModel != ''"> and RUN_MODEL = #{runModel}</if>
            <if test="modelExample != null  and modelExample != ''"> and modelExample = #{MODEL_EXAMPLE}</if>
        </where>
    </select>

    <select id="selectTbModelsByModelId" parameterType="Long" resultMap="TbModelsResult">
        <include refid="selectTbModelsVo"/>
        where MODEL_ID = #{modelId}
    </select>

    <insert id="insertTbModels" parameterType="com.ruoyi.interfaces.domain.TbModels" useGeneratedKeys="true" keyProperty="modelId">
        insert into sh_model.tb_models
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="modelName != null">MODEL_NAME,</if>
            <if test="modelShortname != null">MODEL_SHORTNAME,</if>
            <if test="modelGroup != null">MODEL_GROUP,</if>
            <if test="modelDescription != null">MODEL_DESCRIPTION,</if>
            <if test="version != null">VERSION,</if>
            <if test="modelType != null">MODEL_TYPE,</if>
            <if test="executionType != null">EXECUTION_TYPE,</if>
            <if test="taskType != null">TASK_TYPE,</if>
            <if test="providerUnit != null">PROVIDER_UNIT,</if>
            <if test="dllPath != null">DLL_PATH,</if>
            <if test="isCalibratable != null">IS_CALIBRATABLE,</if>
            <if test="status != null">STATUS,</if>
            <if test="createdBy != null">CREATED_BY,</if>
            <if test="createdTime != null">CREATED_TIME,</if>
            <if test="updatedBy != null">UPDATED_BY,</if>
            <if test="updatedTime != null">UPDATED_TIME,</if>
            <if test="modelLanguafe != null">MODEL_LANGUAFE,</if>
            <if test="modelVersion != null">MODEL_VERSION,</if>
            <if test="cpuNum != null">CPU_NUM,</if>
            <if test="memo != null">MEMO,</if>
            <if test="isGpu != null">IS_GPU,</if>
            <if test="platform != null">PLATFORM,</if>
            <if test="runModel != null">RUN_MODEL,</if>
            <if test="modelExample != null">MODEL_EXAMPLE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="modelName != null">#{modelName},</if>
            <if test="modelShortname != null">#{modelShortname},</if>
            <if test="modelGroup != null">#{modelGroup},</if>
            <if test="modelDescription != null">#{modelDescription},</if>
            <if test="version != null">#{version},</if>
            <if test="modelType != null">#{modelType},</if>
            <if test="executionType != null">#{executionType},</if>
            <if test="taskType != null">#{taskType},</if>
            <if test="providerUnit != null">#{providerUnit},</if>
            <if test="dllPath != null">#{dllPath},</if>
            <if test="isCalibratable != null">#{isCalibratable},</if>
            <if test="status != null">#{status},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
            <if test="modelLanguafe != null">#{modelLanguafe},</if>
            <if test="modelVersion != null">#{modelVersion},</if>
            <if test="cpuNum != null">#{cpuNum},</if>
            <if test="memo != null">#{memo},</if>
            <if test="isGpu != null">#{isGpu},</if>
            <if test="platform != null">#{platform},</if>
            <if test="runModel != null">#{runModel},</if>
            <if test="modelExample != null">#{modelExample},</if>
        </trim>
    </insert>

    <update id="updateTbModels" parameterType="com.ruoyi.interfaces.domain.TbModels">
        update sh_model.tb_models
        <trim prefix="SET" suffixOverrides=",">
            <if test="modelName != null">MODEL_NAME = #{modelName},</if>
            <if test="modelShortname != null">MODEL_SHORTNAME = #{modelShortname},</if>
            <if test="modelGroup != null">MODEL_GROUP = #{modelGroup},</if>
            <if test="modelDescription != null">MODEL_DESCRIPTION = #{modelDescription},</if>
            <if test="version != null">VERSION = #{version},</if>
            <if test="modelType != null">MODEL_TYPE = #{modelType},</if>
            <if test="executionType != null">EXECUTION_TYPE = #{executionType},</if>
            <if test="taskType != null">TASK_TYPE = #{taskType},</if>
            <if test="providerUnit != null">PROVIDER_UNIT = #{providerUnit},</if>
            <if test="dllPath != null">DLL_PATH = #{dllPath},</if>
            <if test="isCalibratable != null">IS_CALIBRATABLE = #{isCalibratable},</if>
            <if test="status != null">STATUS = #{status},</if>
            <if test="createdBy != null">CREATED_BY = #{createdBy},</if>
            <if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
            <if test="updatedBy != null">UPDATED_BY = #{updatedBy},</if>
            <if test="updatedTime != null">UPDATED_TIME = #{updatedTime},</if>
            <if test="modelLanguafe != null">MODEL_LANGUAFE = #{modelLanguafe},</if>
            <if test="modelVersion != null">MODEL_VERSION = #{modelVersion},</if>
            <if test="cpuNum != null">CPU_NUM = #{cpuNum},</if>
            <if test="memo != null">MEMO = #{memo},</if>
            <if test="isGpu != null">IS_GPU = #{isGpu},</if>
            <if test="platform != null">PLATFORM = #{platform},</if>
            <if test="runModel != null">RUN_MODEL = #{runModel},</if>
            <if test="modelExample != null">MODEL_EXAMPLE = #{modelExample},</if>
        </trim>
        where MODEL_ID = #{modelId}
    </update>

    <delete id="deleteTbModelsByModelId" parameterType="Long">
        delete from sh_model.tb_models where MODEL_ID = #{modelId}
    </delete>

    <delete id="deleteTbModelsByModelIds" parameterType="String">
        delete from sh_model.tb_models where MODEL_ID in
        <foreach item="modelId" collection="array" open="(" separator="," close=")">
            #{modelId}
        </foreach>
    </delete>
</mapper>