<?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.casic.missiles.mapper.system.SystemFileConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.system.SystemFileConfig">
        <id column="id" property="id"/>
        <result column="download_no" property="downloadNo"/>
        <result column="business_module_name" property="moduleName"/>
        <result column="business_download_type" property="businessDownloadType"/>
        <result column="minio_file_name" property="minioFileName"/>
        <result column="file_type" property="fileType"/>
        <result column="file_name" property="fileName"/>
        <result column="descn" property="descn"/>
        <result column="create_user" property="createUser"/>
        <result column="update_user" property="updateUser"/>
        <result column="is_del" property="isDel"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , download_no, business_module_name, business_download_type, minio_file_name, file_name, desc, create_user, update_user, is_del, create_time, update_time
    </sql>


    <select id="selectMaxFileNo" resultType="java.lang.Long">
        SELECT IFNULL(max(RIGHT (download_no, 12)), 0)
        from system_file_config
    </select>

    <select id="selectMaxVersionNo" resultType="java.lang.Long">
        SELECT IFNULL(max(RIGHT (version_code, 12)), 0)
        from system_file_config
    </select>

    <select id="getFileNameByBusiness" resultType="java.lang.String">
        SELECT file_name
        from  system_file_config
        <if test="request.moduleName != null and request.moduleName !=''">
            and module_name like concat('%',#{request.moduleName},'%')
        </if>
        <if test="request.businessDownloadType != null and request.businessDownloadType !=''">
            and business_download_type = #{request.businessDownloadType }
        </if>

    </select>

</mapper>
