<?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.fastbee.oss.mapper.OssConfigMapper">

    <resultMap type="com.fastbee.oss.domain.OssConfig" id="OssConfigResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="tenantName"    column="tenant_name"    />
        <result property="configKey"    column="config_key"    />
        <result property="accessKey"    column="access_key"    />
        <result property="secretKey"    column="secret_key"    />
        <result property="bucketName"    column="bucket_name"    />
        <result property="prefix"    column="prefix"    />
        <result property="endpoint"    column="endpoint"    />
        <result property="domainAlias"    column="domain_alias"    />
        <result property="isHttps"    column="is_https"    />
        <result property="region"    column="region"    />
        <result property="accessPolicy"    column="access_policy"    />
        <result property="status"    column="status"    />
        <result property="ext1"    column="ext1"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectOssConfigVo">
        select id, tenant_id, tenant_name, config_key, access_key, secret_key, bucket_name, prefix, endpoint, domain_alias, is_https, region, access_policy, status, ext1, del_flag, create_by, create_time, update_by, update_time, remark from oss_config
    </sql>

    <select id="selectOssConfigList" parameterType="com.fastbee.oss.domain.OssConfig" resultMap="OssConfigResult">
        <include refid="selectOssConfigVo"/>
        <where>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
            <if test="tenantName != null  and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
            <if test="configKey != null  and configKey != ''"> and config_key = #{configKey}</if>
            <if test="accessKey != null  and accessKey != ''"> and access_key = #{accessKey}</if>
            <if test="secretKey != null  and secretKey != ''"> and secret_key = #{secretKey}</if>
            <if test="bucketName != null  and bucketName != ''"> and bucket_name like concat('%', #{bucketName}, '%')</if>
            <if test="prefix != null  and prefix != ''"> and prefix = #{prefix}</if>
            <if test="endpoint != null  and endpoint != ''"> and endpoint = #{endpoint}</if>
            <if test="domainAlias != null  and domainAlias != ''"> and domain_alias = #{domainAlias}</if>
            <if test="isHttps != null  and isHttps != ''"> and is_https = #{isHttps}</if>
            <if test="region != null  and region != ''"> and region = #{region}</if>
            <if test="accessPolicy != null  and accessPolicy != ''"> and access_policy = #{accessPolicy}</if>
            <if test="status != null"> and status = #{status}</if>
            <if test="ext1 != null  and ext1 != ''"> and ext1 = #{ext1}</if>
        </where>
    </select>

    <update id="resetConfigStatus">
        update oss_config set status = 1
        where status = 0
    </update>

</mapper>
