<?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.yfd.platform.modules.storage.mapper.StorageSourceMapper">
    <resultMap id="BaseResultMap" type="com.yfd.platform.modules.storage.model.entity.StorageSource">
        <!--@mbg.generated-->
        <!--@Table "fi_storage_source"-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="enable" jdbcType="BIT" property="enable"/>
        <result column="enable_cache" jdbcType="BIT" property="enableCache"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="auto_refresh_cache" jdbcType="BIT" property="autoRefreshCache"/>
        <result column="type" jdbcType="VARCHAR" property="type"/>
        <result column="search_enable" jdbcType="BIT" property="searchEnable"/>
        <result column="search_ignore_case" jdbcType="BIT" property="searchIgnoreCase"/>
        <result column="order_num" jdbcType="INTEGER" property="orderNum"/>
        <result column="default_switch_to_img_mode" jdbcType="BIT" property="defaultSwitchToImgMode"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="key" jdbcType="VARCHAR" property="key"/>
        <result column="enable_file_operator" jdbcType="VARCHAR" property="enableFileOperator"/>
        <result column="search_mode" jdbcType="VARCHAR" property="searchMode"/>
        <result column="enable_file_anno_operator" jdbcType="BIT" property="enableFileAnnoOperator"/>
        <result column="compatibility_readme" jdbcType="BIT" property="compatibilityReadme"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        `id`, `enable`, `enable_cache`, `name`, `auto_refresh_cache`, `type`, `search_enable`,
        `search_ignore_case`, `order_num`, `default_switch_to_img_mode`,
        `remark`, `key`, `enable_file_operator`, `search_mode`, `enable_file_anno_operator`, `compatibility_readme`
    </sql>

    <select id="findListByEnableOrderByOrderNum" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from fi_storage_source where enable = true order by ifnull(order_num, -1), id desc
    </select>

    <!--auto generated by MybatisCodeHelper on 2021-07-15-->
    <select id="findAllOrderByOrderNum" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from fi_storage_source order by ifnull(order_num, -1), id desc
    </select>

    <select id="selectMaxId" resultType="java.lang.Integer">
        select max(id) max from fi_storage_source
    </select>

    <!--auto generated by MybatisCodeHelper on 2021-07-15-->
    <select id="findByType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from fi_storage_source
        where `type`=#{type,jdbcType=VARCHAR}
    </select>

    <update id="updateSetOrderNumById">
        update fi_storage_source set order_num = #{orderNum} where id = #{id}
    </update>

    <select id="findByStorageKey" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from fi_storage_source
        where `key`=#{storageKey,jdbcType=VARCHAR}
    </select>

    <select id="findIdByStorageKey" resultType="java.lang.Integer">
      select id from fi_storage_source where `key`=#{storageKey,jdbcType=VARCHAR}
    </select>

    <!--auto generated by MybatisCodeHelper on 2022-06-13-->
    <select id="findKeyById" resultType="java.lang.String">
        select `key`
        from fi_storage_source
        where `id`=#{id,jdbcType=INTEGER}
    </select>
</mapper>
