package com.lion.lionwebsite.Dao.normal;

import com.lion.lionwebsite.Domain.ShareFile;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.Date;

@Mapper
public interface ShareFileMapper {
    @Insert("insert into ShareFile (ShareCode, FilePath, ExpireTime) values (#{ShareCode}, #{FilePath}, #{ExpireTime})")
    void insertShareFile(@Param("ShareCode")String ShareCode, @Param("FilePath")String FilePath, @Param("ExpireTime") Date ExpireTime);

    @Select("select * from ShareFile where ShareCode=#{ShareCode}")
    ShareFile selectShareFileByShareCode(String ShareCode);

    @Select("select * from ShareFile where FilePath=#{FilePath}")
    ShareFile selectShareFileByFilePath(String FilePath);

    @Select("select * from ShareFile where FilePath like '%' || #{FilePath} || '%'")
    ArrayList<ShareFile> selectShareFilesByFilePath(String FilePath);

    @Delete("delete from ShareFile where ShareCode=#{ShareCode}")
    void deleteShareFile(String ShareCode);

    @Select("select * from ShareFile")
    ShareFile[] selectAllShareFile();

    @Update("update ShareFile set ExpireTime=#{ExpireTime}, ShareCode=#{ShareCode} where FilePath=#{FilePath}")
    void updateShareFile(ShareFile ShareFile);
}
