修改可空类型

This commit is contained in:
陈淳
2023-01-06 10:15:37 +08:00
parent b7c9b84449
commit 576397a042
29 changed files with 82 additions and 68 deletions

View File

@@ -69,7 +69,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//路径为: 文件路径/文件id+文件扩展名
var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString() + Path.GetExtension(file.FileName));
var stream = System.IO.File.OpenRead(path);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName!);
return File(stream, MimeType, file.FileName);
}
catch

View File

@@ -102,7 +102,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[Log("用户模块", OperEnum.Update)]
public async Task<Result> Update(UserInfoDto userDto)
{
if (await _repository.IsAnyAsync(u => userDto.User.UserName!.Equals(u.UserName) && !userDto.User.Id.Equals(u.Id)))
if (await _repository.IsAnyAsync(u => userDto.User!.UserName!.Equals(u.UserName) && !userDto.User.Id.Equals(u.Id)))
{
return Result.Error("用户名已存在,修改失败!");
}
@@ -121,7 +121,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public async Task<Result> UpdateProfile(UserInfoDto userDto)
{
//修改需要赋值上主键哦
userDto.User.Id = HttpContext.GetUserIdInfo();
userDto.User!.Id = HttpContext.GetUserIdInfo();
return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
}
@@ -135,7 +135,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[Log("用户模块", OperEnum.Insert)]
public async Task<Result> Add(UserInfoDto userDto)
{
if (string.IsNullOrEmpty(userDto.User.Password))
if (string.IsNullOrEmpty(userDto?.User?.Password))
{
return Result.Error("密码为空,添加失败!");
}