<?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="cn.reghao.tnb.file.app.db.mapper.StoreConfigMapper">
    <insert id="save">
        insert into file_store_config
        (`oss_type`,`endpoint`,`access_key_id`,`access_key_secret`,`region`,`bucket_name`,`role_arn`)
        values
        (#{ossType},#{endpoint},#{accessKeyId},#{accessKeySecret},#{region},#{bucketName},#{roleArn})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into file_store_config
        (`oss_type`,`endpoint`,`access_key_id`,`access_key_secret`,`region`,`bucket_name`,`role_arn`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.ossType},#{item.endpoint},#{item.accessKeyId},#{item.accessKeySecret},#{item.region},#{item.bucketName},#{item.roleArn})
        </foreach>
    </insert>

    <select id="findAll" resultType="cn.reghao.tnb.file.app.model.po.StoreConfig">
        select *
        from file_store_config
    </select>
    <select id="findByOssType" resultType="cn.reghao.tnb.file.app.model.po.StoreConfig">
        select *
        from file_store_config
        where oss_type=#{ossType}
    </select>
</mapper>
