<?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.CommunityFileMapper">


    <select id="getCommunityFileList" resultType="com.mcwl.communityCenter.domain.vo.CommunityFileVo">
        select cf.*, su.nick_name as upload_user_name
        from cc_community_file cf left join sys_user su on cf.user_id = su.user_id
        where cf.del_flag = '0'
        and tenant_id = #{communityFilePageListRes.tenantId}
        and community_id = #{communityFilePageListRes.communityId}
        <if test="communityFilePageListRes.search != null and communityFilePageListRes.search != ''">
            and (cf.file_name like concat('%', #{communityFilePageListRes.search}, '%')
            or su.nick_name like concat('%', #{communityFilePageListRes.search}, '%'))
        </if>
        order by cf.create_time desc
    </select>
    <select id="selectCommunityFile" resultType="com.mcwl.communityCenter.domain.CommunityFile">
        select *
        from cc_community_file
        where tenant_id = #{tenantId}
          and community_id = #{communityId}
          and id = #{fileId}
          and del_flag = '0'
    </select>
</mapper>