优化上传代码
This commit is contained in:
@@ -349,94 +349,5 @@ namespace IRaCIS.Core.Application
|
||||
|
||||
|
||||
|
||||
#region 调整废弃
|
||||
[Obsolete]
|
||||
[HttpPost("{trialId:guid}/{type}")]
|
||||
public async Task<IResponseOutput> UploadTrialFile(IFormFile file, string type, Guid trialId, [FromServices] IWebHostEnvironment _hostEnvironment)
|
||||
{
|
||||
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, trialId.ToString(), type);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
var realName = file.FileName;
|
||||
var fileNameEX = Path.GetExtension(realName);
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
var relativePath = $"/{StaticData.TrialDataFolder}/{trialId}/{type}/{trustedFileNameForFileStorage}";
|
||||
|
||||
var filePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
using (FileStream fs = System.IO.File.Create(filePath))
|
||||
{
|
||||
await file.CopyToAsync(fs);
|
||||
fs.Flush();
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(new
|
||||
{
|
||||
FilePath = relativePath,
|
||||
FullFilePath = relativePath + "?access_token=" + _userInfo.UserToken
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 签名认证 +
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> VerifySignature(SignDTO signDTO)
|
||||
{
|
||||
|
||||
var user = await _repository.FirstOrDefaultAsync<User>(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord);
|
||||
if (user == null)
|
||||
{
|
||||
return ResponseOutput.NotOk("密码错误。");
|
||||
}
|
||||
else if (user.Status == UserStateEnum.Disable)
|
||||
{
|
||||
return ResponseOutput.NotOk("该用户已被禁止使用。");
|
||||
}
|
||||
|
||||
//if (signDTO.IsAddSignData)
|
||||
//{
|
||||
// 记录签名信息
|
||||
var add = await _repository.AddAsync(_mapper.Map<TrialSign>(signDTO));
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(add.Id);
|
||||
//}
|
||||
|
||||
//return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 业务接口操作成功后, 让签署数据生效
|
||||
/// </summary>
|
||||
/// <param name="signId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{signId:guid}")]
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> MakeSignEffective(Guid signId)
|
||||
{
|
||||
var success = await _repository.BatchUpdateAsync<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user