using ASHermed.FileManage.Service.v1;
using ASHermed.SinoInterface.Api.ContractModel.Framework.File;
using ASHermed.SinoInterface.Api.IService.File.v1;
using ASHermed.SinoInterface.ContractModel;
using PoJun.Util.Maps;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ASHermed.SinoInterface.Api.Service.File.v1
{
    /// <summary>
    /// 文件管理服务
    /// 创建人：杨江军
    /// 创建时间：2021/1/8/星期五 14:14:48
    /// </summary>
    public class FileManageService : IFileManageService
    {
        #region 初始化

        /// <summary>
        /// 文件管理微服务
        /// </summary>
        private readonly IFilesService fileService;

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="_fileService"></param>
        public FileManageService(IFilesService _fileService)
        {
            fileService = _fileService;
        }

        #endregion

        #region 文件上传

        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task<BaseResponse<UploadFileForClientModel>> UploadFile(UploadFileForForClientParam param)
        {
            var ufParam = new FileManage.Api.ContractModel.Framework.File.UploadFileForForClientParam
            {
                File = param.File,
                Height = param.Height,
                IsPrivate = param.IsPrivate,
                ReSize = param.ReSize,
                Rotate = param.Rotate,
                SystemId = param.SystemId,
                SystemName = param.SystemName,
                Width = param.Width
            };
            var result = await fileService.UploadFile(ufParam);
            return result.Data.MapTo<BaseResponse<UploadFileForClientModel>>();
        }

        #endregion
    }
}
