package kr.itn.itnhub.shared;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SharedFileMapper {

    List<SharedFile> findAll();

    int insert(@Param("fileName") String fileName, @Param("description") String description,
               @Param("contentType") String contentType, @Param("byteSize") long byteSize,
               @Param("content") byte[] content, @Param("uploadedBy") String uploadedBy);

    /** 설명만 고친다. 파일을 바꾸려면 새로 올리고 지운다. */
    int updateDescription(@Param("id") Long id, @Param("description") String description);

    Content findContent(@Param("id") Long id);

    int delete(@Param("id") Long id);

    /** 다운로드용. 파일 내용까지 읽는다. */
    record Content(String fileName, String contentType, byte[] content) {
    }
}
