package cn.hnthyy.thmz.mapper.thmz;

import cn.hnthyy.thmz.entity.thmz.FileUpload;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface FileUploadMapper {

    /**
     * 按照名称查询文件对象
     *
     * @param name 名称
     * @return
     */
    @Select("select id,file_name, file, file_type, mime_type, create_time, create_user,square_file from t_file_upload where file_name=#{name}")
    FileUpload selectUserByName(@Param("name") String name);

    /**
     * 按照主键查询文件对象
     *
     * @param id 主键
     * @return
     */
    @Select("select id,file_name, file, file_type, mime_type, create_time, create_user,square_file from t_file_upload where id=#{id}")
    FileUpload selectUserById(@Param("id") Long id);
    /**
     * 新增文件
     *
     * @param fileUpload
     * @return
     */
    @Insert("INSERT INTO t_file_upload(file_name, file, file_type, mime_type, create_time, create_user,square_file) VALUES " +
            "(#{fileName,jdbcType=VARCHAR}, #{file,jdbcType=BLOB}, #{fileType,jdbcType=CHAR}, #{mimeType,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},#{createUser,jdbcType=BIGINT}, #{squareFile,jdbcType=BLOB})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertFileUpload(FileUpload fileUpload);
}
