<?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.artfess.file.persistence.dao.FileConfigDao">
	<resultMap id="FileStorageConfig" type="com.artfess.file.params.FileStorageConfigDTO">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="code" column="CODE_" jdbcType="VARCHAR"/>
		<result property="storageId" column="STORAGE_ID_" jdbcType="VARCHAR"/>
		<result property="allowSize" column="ALLOW_SIZE_" jdbcType="NUMERIC"/>
		<result property="allowDelete" column="ALLOW_DELETE_" jdbcType="NUMERIC"/>
		<result property="isZone" column="IS_ZONE_" jdbcType="NUMERIC"/>
		<result property="allowMultiple" column="ALLOW_MULTIPLE_" jdbcType="NUMERIC"/>
		<result property="fileKinds" column="FILE_KINDS_" jdbcType="VARCHAR"/>
		<result property="memo" column="MEMO_" jdbcType="VARCHAR"/>

		<result property="storageName" column="STORAGE_NAME" jdbcType="VARCHAR"/>
		<result property="storageCode" column="STORAGE_CODE" jdbcType="VARCHAR"/>
		<result property="uploadType" column="UPLOAD_TYPE_" jdbcType="VARCHAR"/>
		<result property="location" column="LOCATION_" jdbcType="VARCHAR"/>
		<result property="url" column="URL_" jdbcType="VARCHAR"/>
		<result property="port" column="PORT_" jdbcType="NUMERIC"/>
		<result property="status" column="STATUS_" jdbcType="VARCHAR"/>
		<result property="encryptName" column="ENCRYPT_NAME_" jdbcType="NUMERIC"/>
		<result property="desc" column="DESC_" jdbcType="VARCHAR"/>
		<result property="endpoint" column="ENDPOINT_" jdbcType="VARCHAR"/>

	</resultMap>

	<select id="getFileConfigByCode"  resultMap="FileStorageConfig">
		SELECT c.*,
				s.name_ AS storage_Name,
				s.code_ AS storage_code,
				s.upload_type_,
				s.location_,
				s.url_,
				s.port_,
				s.endpoint_,
				s.encrypt_name_,
				s.desc_
			FROM portal_sys_file_config c
		   INNER JOIN portal_sys_file_storage s ON c.STORAGE_ID_ = s.ID_
		   WHERE s.status_ = 'enable' and  c.CODE_ = #{code}
	</select>

	<select id="queryPage" parameterType="java.util.Map" resultMap="FileStorageConfig">
		SELECT c.*,
		s.name_ AS storage_Name,
		s.code_ AS storage_code,
		s.upload_type_,
		s.location_,
		s.url_,
		s.port_,
		s.endpoint_,
		s.encrypt_name_,
		s.desc_
		FROM portal_sys_file_config c
		INNER JOIN portal_sys_file_storage s ON c.STORAGE_ID_ = s.ID_

		<if test="ew.customSqlSegment!=null">
			${ew.customSqlSegment}
		</if>

	</select>

	<select id="getOneById" parameterType="java.lang.String" resultType="com.artfess.file.model.FileConfig">
		SELECT c.*,
				s.name_ AS storage_Name
		FROM portal_sys_file_config c
		INNER JOIN portal_sys_file_storage s ON c.STORAGE_ID_ = s.ID_
		where c.id_ = #{id}
	</select>
</mapper>
