<?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.mcwl.communityCenter.mapper.CommunityFileLogMapper">
    <insert id="saveCommunityFileLog">
        insert into cc_community_file_log
            (tenant_id, community_id, community_file_id, download_user_id)
        values (#{communityFileLog.tenantId}, #{communityFileLog.communityId}, #{communityFileLog.communityFileId},
                #{communityFileLog.downloadUserId})
    </insert>

    <select id="getUserAvatarList" resultType="java.lang.String">
        select su.avatar
        from cc_community_file_log cfl
                 left join sys_user su on cfl.download_user_id = su.user_id
        where tenant_id = #{tenantId}
          and community_id = #{communityId}
          and community_file_id = #{communityFileId}
        order by cfl.create_time desc
    </select>
    <select id="getDownloadCount" resultType="java.lang.Integer">
        select count(*)
        from cc_community_file_log
        where tenant_id = #{tenantId}
          and community_id = #{communityId}
          and community_file_id = #{communityFileId}
    </select>
</mapper>