<?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.jeeplus.test.cw.projectReport.mapper.ProjectReportWorkAttachmentMapper">
    <delete id="deleteByRepotyId">
        delete from cw_project_report_file where report_file_id = #{id}
    </delete>
    <delete id="deleteByAttachMnentId">
        delete from work_attachment where attachment_id = #{id}
    </delete>
    <select id="getIdByAttachmentId" resultType="java.lang.String">
        select id from work_attachment where attachment_id = #{id}
    </select>
    <select id="selectByInfoId"
            resultType="com.jeeplus.test.cw.projectReport.service.dto.ProjectReportWorkAttachmentDTO">
        select id,url,file_size as size,attachment_name as name from work_attachment where attachment_id = #{id}
    </select>

    <select id="selectInfoByFileId" resultType="com.jeeplus.test.cw.projectReport.domain.CwProjectReportFile">
        select * from cw_project_report_file where report_file_id = #{id} and file_affiliation = #{fileType} and del_flag = '0'
    </select>


    <select id="selectWorkAttachmentByReportId"
            resultType="com.jeeplus.test.oss.domain.WorkAttachment">

        select a.* from work_attachment a
        left join cw_project_report_file cf on cf.report_file_id = a.id
        where a.attachment_id = #{id} and cf.seal_type = 1
    </select>
    <select id="getFileId" resultType="java.lang.String">
        select id from cw_project_report_file where report_file_id = #{id}
    </select>
    <select id="selectByInfoIdAndNewLineId"
            resultType="com.jeeplus.test.cw.projectReport.service.dto.ProjectReportWorkAttachmentDTO">
        select a.id,a.url,a.file_size as size,a.attachment_name as name from work_attachment a
        left join cw_project_report_new_line b on a.attachment_id = b.report_id
        where a.attachment_id = #{id}
    </select>


    <update id="updateByIdOnSignature">
        update work_attachment
        set url = #{url},
        type = #{type},
        attachment_name= #{attachmentName}
        where id = #{id}
    </update>
    <update id="updateFileInfo">
        update cw_project_report_file set file_type = #{fileType},seal_type = #{sealType},remarks = #{remarks}
        where report_file_id = #{id}
    </update>

</mapper>
