using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.ContractModel;
using ASHermed.SinoInterface.Tools;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ASHermed.SinoInterface.Api.IService.App
{
    public interface IFileService
    {
        /// <summary>
        /// 获取文件列表，不包含Content字段
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        List<Sys_File> GetFiles(List<int> Ids);
        /// <summary>
        /// 解密字符串
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        string DecodeDES(string str);
        string EncodeDES(string str);
        /// <summary>
        /// 上传文件接口，到本地，存DB
        /// </summary>
        /// <param name="file"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        BaseResponse<string> UploadLocalhost(IFormFile file, int type);
        BaseResponse<string> CompressImage(IFormFile file);
        /// <summary>
        ///  文件转换，上传文件返回的ID，通过此方法转换为Base64字符，并返回
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ls"></param>
        /// <returns></returns>
        List<T> GetFileContentAdd<T>(List<T> ls) where T : IContentModel, new();
        /// <summary>
        /// 文件转换，上传文件返回的ID，通过此方法转换为Base64字符，并返回
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns></returns>
        T GetFileContentAdd<T>(T model) where T : IContentModel, new();
        /// <summary>
        ///  文件转换，查询DB文件值，并将ALI OSS以前的文件下载到本地并更新DB
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ls"></param>
        /// <returns></returns>
        List<T> GetFileContentSelect<T>(List<T> ls) where T : IContentModel, new();
        /// <summary>
        ///  文件转换，查询DB文件值，并将ALI OSS以前的文件下载到本地并更新DB
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns></returns>
        T GetFileContentSelect<T>(T model) where T : IContentModel, new();
        byte[] StreamToBytes(Stream stream);
        byte[] CompressImage(byte[] bytes, int flag = 90, int size = 400, bool sfsc = true);
        /// <summary>
        /// 根据Url下载图片并压缩到本地，到DB，返回压缩后的缩略图
        /// </summary>
        /// <param name="url"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        FileContenModel DownLoadAliOSSFileSaveLocalAndDB(string url, int type);
        byte[] DownloadFile(string url);
    }
}
