<?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.FlowUploadPropertiesDao">
	<resultMap id="FlowUploadProperties" type="com.artfess.file.model.FlowUploadProperties">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="flowKey" column="FLOW_KEY_" jdbcType="VARCHAR"/>
		<result property="flowName" column="FLOW_NAME_" jdbcType="VARCHAR"/>
		<result property="storageId" column="STORAGE_ID_" jdbcType="VARCHAR"/>
		<result property="desc" column="DESC_" jdbcType="VARCHAR"/>
		<result property="updateTime" column="UPDATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
		<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createOrgId" column="CREATE_ORG_ID_" jdbcType="VARCHAR"/>
		<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
		<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
	</resultMap>

	<resultMap id="FlowUploadPropertiesStorageDTO" type="com.artfess.file.params.FlowUploadPropertiesStorageDTO">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="flowKey" column="FLOW_KEY_" jdbcType="VARCHAR"/>
		<result property="flowName" column="FLOW_NAME_" jdbcType="VARCHAR"/>
		<result property="storageId" column="STORAGE_ID_" 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="userName" column="USER_NAME_" jdbcType="VARCHAR"/>
		<result property="password" column="PASSWORD_" jdbcType="VARCHAR"/>
		<result property="status" column="STATUS_" jdbcType="VARCHAR"/>
		<result property="encryptName" column="ENCRYPT_NAME_" jdbcType="NUMERIC"/>
		<result property="desc" column="DESC_" jdbcType="VARCHAR"/>
		<result property="updateTime" column="UPDATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
		<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createOrgId" column="CREATE_ORG_ID_" jdbcType="VARCHAR"/>
		<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
		<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
		<result property="endpoint" column="ENDPOINT_" jdbcType="VARCHAR"/>
		<result property="accessKeyId" column="ACCESSKEYID_" jdbcType="VARCHAR"/>
		<result property="accessKeySecret" column="ACCESSKEYSECRET_" jdbcType="VARCHAR"/>
	</resultMap>
	
	<select id="getByFlowKey"  resultMap="FlowUploadPropertiesStorageDTO">
		SELECT p.*,
		        s.name_ AS storage_Name,
				s.code_ AS storage_code,
				s.upload_type_,
				s.location_,
				s.url_,
				s.port_,
				s.user_name_,
				s.password_,
				s.endpoint_,
				s.encrypt_name_,
				s.accesskeyid_,
				s.accesskeysecret_,
				s.status_,
				s.desc_
		FROM portal_flow_upload_properties p INNER JOIN portal_sys_file_storage s ON p.STORAGE_ID_ = s.ID_
		WHERE
			p.FLOW_KEY_ LIKE concat ( '%', #{flowKey}, '%' )
			AND s.STATUS_ = 'enable'
	</select>

	<select id="getByFlowKey" databaseId="oracle" resultMap="FlowUploadProperties">
			SELECT p.*,
					s.name_ AS storage_Name,
					s.code_ AS storage_code,
					s.upload_type_,
					s.location_,
					s.url_,
					s.port_,
					s.user_name_,
					s.password_,
					s.endpoint_,
					s.encrypt_name_,
					s.accesskeyid_,
					s.accesskeysecret_,
					s.status_,
					s.desc_
			FROM portal_flow_upload_properties p
		   INNER JOIN portal_sys_file_storage s ON p.STORAGE_ID_ = s.ID_
		   where FLOW_KEY_ like concat('%',concat(#{flowKey},'%')) AND STATUS_='enable'
	</select>

	<select id="getById"  resultMap="FlowUploadPropertiesStorageDTO">
		SELECT p.*,
		        s.name_ AS storage_Name,
				s.code_ AS storage_code,
				s.upload_type_,
				s.location_,
				s.url_,
				s.port_,
				s.user_name_,
				s.password_,
				s.endpoint_,
				s.encrypt_name_,
				s.accesskeyid_,
				s.accesskeysecret_,
				s.status_,
				s.desc_
		FROM portal_flow_upload_properties p INNER JOIN portal_sys_file_storage s ON p.STORAGE_ID_ = s.ID_
		WHERE p.ID_ =  #{id}
	</select>
</mapper>