增加修改用户角色接口
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
6e0dc64981
commit
21c10307b9
|
@ -211,6 +211,13 @@ namespace IRaCIS.Application.Contracts
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UpdateUserRolesDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public List<UserAddUserType> UserRoleList { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class UserCommand : UserInfo
|
public class UserCommand : UserInfo
|
||||||
{
|
{
|
||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
|
|
|
@ -500,26 +500,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 删除用户
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="userId"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//[HttpDelete("{userId:guid}")]
|
|
||||||
//public async Task<IResponseOutput> DeleteUser(Guid userId)
|
|
||||||
//{
|
|
||||||
// if (await _userTrialRepository.AnyAsync(t => t.Id == userId))
|
|
||||||
// {
|
|
||||||
// //---该用户已经参加项目,不能够删除。
|
|
||||||
// return ResponseOutput.NotOk(_localizer["User_InProject"]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.Id, OptUserId = userId, OptType = UserOptType.DeleteUser }, true);
|
|
||||||
|
|
||||||
// var success = await _userRoleRepository.BatchDeleteNoTrackingAsync(t => t.Id == userId);
|
|
||||||
|
|
||||||
// return ResponseOutput.Result(success);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -671,6 +652,40 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<IResponseOutput> UpdateUserRoleInfo(UpdateUserRolesDto command)
|
||||||
|
{
|
||||||
|
var user = await _identityUserRepository.Where(t => t.Id == command.Id, true).Include(t => t.UserRoleList).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (user == null) return Null404NotFound(user);
|
||||||
|
|
||||||
|
foreach (var role in command.UserRoleList)
|
||||||
|
{
|
||||||
|
var find = user.UserRoleList.FirstOrDefault(t => t.UserTypeEnum == role.UserTypeEnum && t.UserTypeId == role.UserTypeId);
|
||||||
|
|
||||||
|
if (find != null)
|
||||||
|
{
|
||||||
|
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var addRole = _mapper.Map<UserRole>(user);
|
||||||
|
|
||||||
|
addRole.Id = NewId.NextSequentialGuid();
|
||||||
|
addRole.IdentityUserId = user.Id;
|
||||||
|
addRole.UserTypeEnum = role.UserTypeEnum;
|
||||||
|
addRole.UserTypeId = role.UserTypeId;
|
||||||
|
|
||||||
|
user.UserRoleList.Add(addRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var success = await _userRoleRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 禁用或者启用账户
|
///// 禁用或者启用账户
|
||||||
///// </summary>
|
///// </summary>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using AutoMapper.EquivalencyExpression;
|
using AutoMapper.EquivalencyExpression;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Auth;
|
using IRaCIS.Core.Application.Auth;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
|
@ -163,6 +164,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
.ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName));
|
.ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName));
|
||||||
|
|
||||||
CreateMap<UserBasicInfoCommand, IdentityUser>();
|
CreateMap<UserBasicInfoCommand, IdentityUser>();
|
||||||
|
|
||||||
|
CreateMap<UserRole, IdentityUser>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue