<?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.zoss.db.mapper.UserNodeMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into file_user_node
        (`store_node_id`,`domain`,`protocol`,`referer`,`secret_key`,`create_by`)
        values
        (#{storeNodeId},#{domain},#{protocol},#{referer},#{secretKey},#{createBy})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into file_user_node
        (`store_node_id`,`domain`,`protocol`,`referer`,`secret_key`,`create_by`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.storeNodeId},#{item.domain},#{item.protocol},#{item.referer},#{item.secretKey},#{item.createBy})
        </foreach>
    </insert>

    <update id="updateUserNode">
        update file_user_node
        set update_time=now(),`domain`=#{domain},`protocol`=#{protocol},`referer`=#{referer},`secret_key`=#{secretKey}
        where id=#{userNodeId}
    </update>

    <select id="findAll" resultType="cn.reghao.tnb.file.app.zoss.model.po.UserNode">
        select *
        from file_user_node
    </select>
    <select id="countByStoreNodeId" resultType="java.lang.Integer">
        select *
        from file_user_node
        where create_by=#{createBy}
    </select>
    <select id="findByCreateByAndStoreNodeId" resultType="cn.reghao.tnb.file.app.zoss.model.po.UserNode">
        select *
        from file_user_node
        where create_by=#{createBy} and store_node_id=#{storeNodeId}
    </select>
    <select id="findByCreateBy" resultType="cn.reghao.tnb.file.app.zoss.model.po.UserNode">
        select *
        from file_user_node
        where create_by=#{create_by}
    </select>
    <select id="findByDomain" resultType="cn.reghao.tnb.file.app.zoss.model.po.UserNode">
        select *
        from file_user_node
        where domain=#{domain}
    </select>
    <select id="findById" resultType="cn.reghao.tnb.file.app.zoss.model.po.UserNode">
        select *
        from file_user_node
        where id=#{id}
    </select>
</mapper>
