diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index d6fc51f50..12a487a6c 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -1,5 +1,6 @@ using Amazon.Auth.AccessControlPolicy; using Amazon.SecurityToken; +using AutoMapper; using Azure.Core; using IdentityModel.Client; using IdentityModel.OidcClient; @@ -115,7 +116,7 @@ namespace IRaCIS.Api.Controllers [FromServices] IReadingImageTaskService readingImageTaskService, [FromServices] IOptionsMonitor _verifyConfig, [FromServices] IOptionsMonitor _emailConfig, - + [FromServices]IMapper _mapper, [FromServices] IMailVerificationService _mailVerificationService) { var emailConfig = _emailConfig.CurrentValue; @@ -135,7 +136,7 @@ namespace IRaCIS.Api.Controllers var loginReturn = new LoginReturnDTO() { BasicInfo = basicInfo }; - loginReturn.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(loginReturn.BasicInfo)); + loginReturn.JWTStr = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = basicInfo.Id }); // 创建一个 CookieOptions 对象,用于设置 Cookie 的属性 @@ -248,7 +249,7 @@ namespace IRaCIS.Api.Controllers //修改密码 if (returnModel.Data.BasicInfo.IsFirstAdd || returnModel.Data.BasicInfo.LoginState == 1) { - returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); + returnModel.Data.JWTStr = _tokenService.GetToken(_mapper.Map(returnModel.Data.BasicInfo)); } else { @@ -260,7 +261,7 @@ namespace IRaCIS.Api.Controllers } else { - returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); + returnModel.Data.JWTStr = _tokenService.GetToken(_mapper.Map(returnModel.Data.BasicInfo)); // 创建一个 CookieOptions 对象,用于设置 Cookie 的属性 var option = new CookieOptions @@ -309,18 +310,13 @@ namespace IRaCIS.Api.Controllers [AllowAnonymous] public IResponseOutput ShareImage([FromServices] ITokenService _tokenService) { - var token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() + var token = _tokenService.GetToken(new UserTokenInfo() { - Id = Guid.NewGuid(), - IsReviewer = false, - IsAdmin = false, - RealName = "Share001", - UserName = "Share001", - Sex = 0, - //UserType = "ShareType", + UserRoleId = Guid.NewGuid(), + UserName = "Share001", UserTypeEnum = UserTypeEnum.ShareImage, - Code = "ShareCode001", - })); + + }); return ResponseOutput.Ok("/showdicom?studyId=f7b67793-8155-0223-2f15-118f2642efb8&type=Share&token=" + token); } diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 2471d9369..556371672 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -34,7 +34,7 @@ - + 系统用户登录接口[New] diff --git a/IRaCIS.Core.API/SignalRHub/UploadHub.cs b/IRaCIS.Core.API/SignalRHub/UploadHub.cs index 662c298d9..5bcd9b7ac 100644 --- a/IRaCIS.Core.API/SignalRHub/UploadHub.cs +++ b/IRaCIS.Core.API/SignalRHub/UploadHub.cs @@ -17,7 +17,7 @@ namespace IRaCIS.Core.API { public virtual string GetUserId(HubConnectionContext connection) { - return connection.User?.FindFirst(JwtIRaCISClaimType.Id)?.Value!; + return connection.User?.FindFirst(JwtIRaCISClaimType.IdentityUserId)?.Value!; } } diff --git a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs index 6492c25ae..7b35b71df 100644 --- a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs +++ b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs @@ -38,7 +38,7 @@ namespace IRaCIS.Core.API diagnosticContext.Set("QueryString", request.QueryString.Value); } - diagnosticContext.Set("FullName", httpContext?.User?.FindFirst(JwtIRaCISClaimType.RealName)?.Value); + diagnosticContext.Set("FullName", httpContext?.User?.FindFirst(JwtIRaCISClaimType.FullName)?.Value); diagnosticContext.Set("UserType", httpContext?.User?.FindFirst(JwtIRaCISClaimType.UserTypeShortName)?.Value); diff --git a/IRaCIS.Core.Application/Auth/IRaCISClaims.cs b/IRaCIS.Core.Application/Auth/IRaCISClaims.cs deleted file mode 100644 index 3eefc9fd2..000000000 --- a/IRaCIS.Core.Application/Auth/IRaCISClaims.cs +++ /dev/null @@ -1,46 +0,0 @@ -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Domain.Share; - -namespace IRaCIS.Core.Application.Auth -{ - public class IRaCISClaims - { - public Guid Id { get; set; } - public string FullName { get; set; } = String.Empty; - public string Code { get; set; } = String.Empty; - public string RealName { get; set; } = String.Empty; - - public string UserTypeShortName { get; set; } = String.Empty; - - public UserTypeEnum UserTypeEnum { get; set; } - - public string PermissionStr { get; set; } = String.Empty; - - public Guid UserTypeId { get; set; } - - public int IsAdmin { get; } - - public bool IsTestUser { get; set; } - - public bool IsZhiZhun { get; set; } - - public string Phone { get; set; } = String.Empty; - - public static IRaCISClaims Create(UserBasicInfo user) - { - return new IRaCISClaims - { - Id = user.Id, - FullName = user.UserName, - RealName = user.RealName, - UserTypeEnum = user.UserTypeEnum, - UserTypeId = user.UserTypeId, - IsTestUser = user.IsTestUser, - Code = user.Code, - PermissionStr = user.PermissionStr, - IsZhiZhun = user.IsZhiZhun, - UserTypeShortName = user.UserTypeShortName - }; - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Auth/TokenService.cs b/IRaCIS.Core.Application/Auth/TokenService.cs index d9e5f0214..3a06e579c 100644 --- a/IRaCIS.Core.Application/Auth/TokenService.cs +++ b/IRaCIS.Core.Application/Auth/TokenService.cs @@ -8,7 +8,7 @@ namespace IRaCIS.Core.Application.Auth public interface ITokenService { - string GetToken(IRaCISClaims user); + string GetToken(UserTokenInfo user); } @@ -21,16 +21,16 @@ namespace IRaCIS.Core.Application.Auth _jwtSetting = option.Value; } - public string GetToken(IRaCISClaims user) + public string GetToken(UserTokenInfo user) { //创建用户身份标识,可按需要添加更多信息 var claims = new Claim[] { new Claim(Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), - new Claim(JwtIRaCISClaimType.Id, user.Id.ToString()), - new Claim(JwtIRaCISClaimType.Name, user.FullName), - new Claim(JwtIRaCISClaimType.RealName, user.RealName), - new Claim(JwtIRaCISClaimType.Code,user.Code), + new Claim(JwtIRaCISClaimType.IdentityUserId, user.IdentityUserId.ToString()), + new Claim(JwtIRaCISClaimType.UserRoleId, user.UserRoleId.ToString()), + new Claim(JwtIRaCISClaimType.UserName, user.UserName), + new Claim(JwtIRaCISClaimType.FullName, user.FullName), new Claim(JwtIRaCISClaimType.UserTypeId,user.UserTypeId.ToString()), new Claim(JwtIRaCISClaimType.UserTypeEnum,user.UserTypeEnum.ToString()), new Claim(JwtIRaCISClaimType.UserTypeEnumInt,((int)user.UserTypeEnum).ToString()), diff --git a/IRaCIS.Core.Application/Auth/UserTokenInfo.cs b/IRaCIS.Core.Application/Auth/UserTokenInfo.cs new file mode 100644 index 000000000..ab104ae58 --- /dev/null +++ b/IRaCIS.Core.Application/Auth/UserTokenInfo.cs @@ -0,0 +1,27 @@ +using IRaCIS.Application.Contracts; +using IRaCIS.Core.Domain.Share; + +namespace IRaCIS.Core.Application.Auth +{ + public class UserTokenInfo + { + public Guid IdentityUserId { get; set; } + + public Guid UserRoleId { get; set; } + + public Guid UserTypeId { get; set; } + + public UserTypeEnum UserTypeEnum { get; set; } + + public string UserName { get; set; } = string.Empty; + public string FullName { get; set; } = string.Empty; + + public string PermissionStr { get; set; } = string.Empty; + + public bool IsTestUser { get; set; } + + public bool IsZhiZhun { get; set; } + + public string UserTypeShortName { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/IRaCIS.Core.Application/BusinessFilter/LegacyController/LimitUserRequestAuthorization.cs b/IRaCIS.Core.Application/BusinessFilter/LegacyController/LimitUserRequestAuthorization.cs index 69bafe0f9..bf1eb6baf 100644 --- a/IRaCIS.Core.Application/BusinessFilter/LegacyController/LimitUserRequestAuthorization.cs +++ b/IRaCIS.Core.Application/BusinessFilter/LegacyController/LimitUserRequestAuthorization.cs @@ -48,7 +48,7 @@ public class LimitUserRequestAuthorization( //2、在这里取缓存 进行比较 看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉 - var cacheUserToken = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserToken(_userInfo.Id)); + var cacheUserToken = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserToken(_userInfo.IdentityUserId)); @@ -58,17 +58,17 @@ public class LimitUserRequestAuthorization( cacheUserToken = _userInfo.UserToken; //设置当前用户最新Token - await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.Id), _userInfo.UserToken, TimeSpan.FromDays(7)); + await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.IdentityUserId), _userInfo.UserToken, TimeSpan.FromDays(7)); //重启应用程序,所有人续期,不一下子踢出所有人 - await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); + await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); } //是同一个人 else if (cacheUserToken == _userInfo.UserToken) { - var cacheTime = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id)); + var cacheTime = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId)); //过期了 需要自动退出 if (string.IsNullOrEmpty(cacheTime)) @@ -80,7 +80,7 @@ public class LimitUserRequestAuthorization( } else { - await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); + await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); } } else diff --git a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/LimitUserRequestAuthorizationEndpointFilter.cs b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/LimitUserRequestAuthorizationEndpointFilter.cs index 0d7a9f5a3..551b74978 100644 --- a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/LimitUserRequestAuthorizationEndpointFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/LimitUserRequestAuthorizationEndpointFilter.cs @@ -41,19 +41,19 @@ public class LimitUserRequestAuthorizationEndpointFilter( } // 获取缓存中的用户 token - var cacheUserToken = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserToken(_userInfo.Id)); + var cacheUserToken = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserToken(_userInfo.IdentityUserId)); // 缓存中没有取到 token if (string.IsNullOrWhiteSpace(cacheUserToken)) { // 设置当前用户最新 token - await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.Id), _userInfo.UserToken, TimeSpan.FromDays(7)); - await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); + await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.IdentityUserId), _userInfo.UserToken, TimeSpan.FromDays(7)); + await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); } // 如果是同一个用户 else if (cacheUserToken == _userInfo.UserToken) { - var cacheTime = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id)); + var cacheTime = await _fusionCache.GetOrDefaultAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId)); // 如果过期,自动登出 if (string.IsNullOrEmpty(cacheTime)) @@ -63,7 +63,7 @@ public class LimitUserRequestAuthorizationEndpointFilter( } else { - await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); + await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); } } else diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 2d0fe9a98..43f599562 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -350,7 +350,7 @@ namespace IRaCIS.Core.Application.Service //---[来自展影IRC] 关于创建账户的提醒 - var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo))); + var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id }); await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token }); @@ -438,7 +438,7 @@ namespace IRaCIS.Core.Application.Service // $"[来自展影IRC] [{trialInfo.ResearchProgramNo}]邀请信"; - var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo))); + var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id }); if (sysUserInfo.IsFirstAdd) { @@ -499,7 +499,7 @@ namespace IRaCIS.Core.Application.Service - var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo))); + var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id }); if (sysUserInfo.IsFirstAdd) { await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token }); @@ -607,13 +607,7 @@ namespace IRaCIS.Core.Application.Service - var basicInfo = IRaCISClaims.Create(_mapper.Map(sysUserInfo)); - - ////第一次添加的时候 注意赋值 - //basicInfo.PermissionStr = userType.PermissionStr; - //basicInfo.UserTypeShortName = userType.UserTypeShortName; - - var token = _tokenService.GetToken(basicInfo); + var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id }); if (sysUserInfo.IsFirstAdd) { diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/ImageShareService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/ImageShareService.cs index 29fd733a7..e21e7b5ff 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/ImageShareService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/ImageShareService.cs @@ -102,18 +102,13 @@ namespace IRaCIS.Core.Application.Services var resource = new ResourceInfo() { StudyId = imageShare.StudyId, - Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() + Token = _tokenService.GetToken(new UserTokenInfo() { - Id = Guid.Empty, - IsReviewer = false, - IsAdmin = false, - RealName = "Share001", + UserRoleId = Guid.NewGuid(), + FullName = "Share001", UserName = "Share001", - Sex = 0, - //UserType = "ShareType", UserTypeEnum = UserTypeEnum.ShareImage, - Code = "ShareCode001", - })) + }) }; diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs index b68d648e1..eed865cf6 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs @@ -21,7 +21,34 @@ namespace IRaCIS.Application.Contracts public Guid? UserId { get; set; } } + public class IRCLoginDto + { + public string UserName { get; set; } + public string Password { get; set; } + } + public class LoginSelectRoleReturn + { + public string JwtStr { get; set; } + public bool IsExistMutiAccount => AccountList.Count > 1; + + public List AccountList { get; set; } = new List(); + } + + public class UserAccountInfo + { + public Guid Id { get; set; } + public string UserName { get; set; } = string.Empty; + public string FullName { get; set; } = string.Empty; + + public string Phone { get; set; } = string.Empty; + public string EMail { get; set; } = string.Empty; + + public Guid UserTypeId { get; set; } + + public UserTypeEnum UserType { get; set; } + + } public class LoginReturnDTO { public UserBasicInfo BasicInfo { get; set; } = new UserBasicInfo(); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 0a95a78dc..da5edcef3 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -142,7 +142,7 @@ namespace IRaCIS.Core.Application.Service //验证码 6位 int verificationCode = new Random().Next(100000, 1000000); - await _mailVerificationService.SendMailEditEmail(_userInfo.Id, _userInfo.RealName, email, verificationCode); + await _mailVerificationService.SendMailEditEmail(_userInfo.Id, _userInfo.FullName, email, verificationCode); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index bd6289e3f..38e720471 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -1,6 +1,7 @@ using AutoMapper; using AutoMapper.EquivalencyExpression; using IRaCIS.Application.Contracts; +using IRaCIS.Core.Application.Auth; using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Application.ViewModel; @@ -136,6 +137,10 @@ namespace IRaCIS.Core.Application.Service ; CreateMap().ReverseMap(); + + CreateMap() + .ForMember(d => d.UserRoleId, c => c.MapFrom(t => t.Id)); + } } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 66a613276..6a0fe950d 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -1938,7 +1938,7 @@ namespace IRaCIS.Core.Application.Image.QA qcChallenge.ReUploadUserId = _userInfo.Id; - qcChallenge.ReUploader = _userInfo.RealName; + qcChallenge.ReUploader = _userInfo.FullName; qcChallenge.LatestMsgTime = DateTime.Now; diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 37b772f76..38579bf71 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -236,7 +236,7 @@ namespace IRaCIS.Core.Application.Contracts result.ReviewStatus = info.ReviewStatus; } - result.Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() { Id = Guid.NewGuid() })); + result.Token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = Guid.NewGuid() }); } } @@ -441,18 +441,12 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.Ok(new { TrialSiteSurveyId = currentEntity!.Id, - Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() + Token = _tokenService.GetToken(new UserTokenInfo() { - Id = Guid.NewGuid(), - IsReviewer = false, - IsAdmin = false, - RealName = "SiteSurvey", + UserRoleId = Guid.NewGuid(), UserName = "SiteSurvey", - Sex = 0, - //UserType = "ShareType", UserTypeEnum = UserTypeEnum.Undefined, - Code = "SiteSurvey", - })) + }) }); #endregion diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index 087a418bd..b23d8a6ef 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -26,22 +26,46 @@ public class User : BaseFullAuditEntity #endregion + #region ûϢ + + public int Code { get; set; } + public string UserCode { get; set; } + public string UserName { get; set; } + public string EMail { get; set; } + + [StringLength(1000)] + public string EmailToken { get; set; } + + public string FirstName { get; set; } + + public string LastName { get; set; } + + public string Password { get; set; } + + public bool PasswordChanged { get; set; } + + public string Phone { get; set; } + + public int? Sex { get; set; } + + public UserStateEnum Status { get; set; } = UserStateEnum.Enable; + + + public string OrganizationName { get; set; } + + + public string PositionName { get; set; } + + #endregion + [Comment("Զлһ")] public bool AutoCutNextTask { get; set; } - public int Code { get; set; } public string DepartmentName { get; set; } = null!; [Comment("ҽ˺ź󣬻ֵ")] public Guid? DoctorId { get; set; } - public string EMail { get; set; } = null!; - - [StringLength(1000)] - public string EmailToken { get; set; } = null!; - - public string FirstName { get; set; } = null!; - [Comment("״ε¼Ҫ޸")] public bool IsFirstAdd { get; set; } = true; @@ -53,36 +77,19 @@ public class User : BaseFullAuditEntity [Comment("һ޸ʱ")] public DateTime? LastChangePassWordTime { get; set; } - public string LastLoginIP { get; set; } = null!; + public string LastLoginIP { get; set; } public DateTime? LastLoginTime { get; set; } - public string LastName { get; set; } = null!; - - public string OrganizationName { get; set; } = null!; - - public string Password { get; set; } = null!; - - public bool PasswordChanged { get; set; } - - - public string Phone { get; set; } = null!; - - - public string PositionName { get; set; } = null!; - - public int? Sex { get; set; } - - public UserStateEnum Status { get; set; } = UserStateEnum.Enable; - public bool SuperAdmin { get; set; } - - public string UserCode { get; set; } = null!; - - public string UserName { get; set; } = null!; - public UserTypeEnum UserTypeEnum { get; set; } public Guid UserTypeId { get; set; } + + #region ֶ + + //public Guid IdentityUserId { get; set; } + + #endregion } diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs index e05a11ed2..6a9adbf20 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs @@ -8,10 +8,11 @@ Guid Id { get; } + Guid IdentityUserId { get; } + string UserName { get; } - string RealName { get; } - string ReviewerCode { get; } + string FullName { get; } bool IsAdmin { get; } diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs index c2210fa49..633c08c41 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs @@ -15,13 +15,26 @@ namespace IRaCIS.Core.Domain.Share } /// - /// 用户Id + /// 用户角色Id /// public Guid Id { get { - var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Id); + var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.UserRoleId); + if (id != null && !string.IsNullOrEmpty(id.Value)) + { + return Guid.Parse(id.Value); + } + return Guid.Empty; + } + } + + public Guid IdentityUserId + { + get + { + var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.IdentityUserId); if (id != null && !string.IsNullOrEmpty(id.Value)) { return Guid.Parse(id.Value); @@ -51,7 +64,7 @@ namespace IRaCIS.Core.Domain.Share { get { - var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Name); + var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.UserName); if (name != null && !string.IsNullOrEmpty(name.Value)) { @@ -63,11 +76,11 @@ namespace IRaCIS.Core.Domain.Share } - public string RealName + public string FullName { get { - var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.RealName); + var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.FullName); if (name != null && !string.IsNullOrEmpty(name.Value)) { @@ -78,19 +91,7 @@ namespace IRaCIS.Core.Domain.Share } } - public string ReviewerCode - { - get - { - var reviewerCode = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Code); - if (reviewerCode != null && !string.IsNullOrEmpty(reviewerCode.Value)) - { - return reviewerCode.Value; - } - return string.Empty; - } - } public string UserTypeShortName @@ -342,16 +343,16 @@ namespace IRaCIS.Core.Domain.Share public struct JwtIRaCISClaimType { - public const string Id = "id"; + public const string IdentityUserId = "identityUserId"; + public const string UserRoleId = "userRoleId"; public const string Code = "code"; - public const string Name = "name"; - public const string RealName = "realName"; + public const string UserName = "name"; + public const string FullName = "fullName"; public const string UserTypeId = "userTypeId"; public const string UserTypeEnum = "userTypeEnum"; public const string UserTypeEnumName = "userTypeEnumName"; public const string UserTypeEnumInt = "userTypeEnumInt"; public const string UserTypeShortName = "userTypeShortName"; - public const string IsAdmin = "isAdmin"; public const string IsTestUser = "isTestUser"; diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index df26621ad..4a1245519 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -3531,7 +3531,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common inspection.CreateUserName = _userInfo.UserName; - inspection.CreateUserRealName = _userInfo.RealName; + inspection.CreateUserRealName = _userInfo.FullName; inspection.RoleName = _userInfo.UserTypeShortName; inspection.CreateUserId = _userInfo.Id; inspection.IP = _userInfo.IP;