swagger bug 核对
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2025-08-15 14:35:03 +08:00
parent 31c86c5d4a
commit 083090ca05
3 changed files with 142 additions and 119 deletions

View File

@ -11,6 +11,45 @@
<param name="code"></param> <param name="code"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:IRaCIS.Api.Controllers.ExtraController">
<summary>
医生基本信息 、工作信息 专业信息、审核状态
</summary>
</member>
<member name="M:IRaCIS.Api.Controllers.ExtraController.#ctor(IRaCIS.Application.Interfaces.IAttachmentService,IRaCIS.Application.Interfaces.IDoctorService,IRaCIS.Application.Interfaces.IEducationService,IRaCIS.Application.Interfaces.ITrialExperienceService,IRaCIS.Application.Interfaces.IResearchPublicationService,IRaCIS.Application.Interfaces.IVacationService)">
<summary>
医生基本信息 、工作信息 专业信息、审核状态
</summary>
</member>
<member name="M:IRaCIS.Api.Controllers.ExtraController.GetDoctorDetail(IRaCIS.Application.Contracts.GetDoctorDetailInDto)">
<summary>
获取医生详情
</summary>
<param name="attachmentService"></param>
<param name="_doctorService"></param>
<param name="_educationService"></param>
<param name="_trialExperienceService"></param>
<param name="_researchPublicationService"></param>
<param name="_vacationService"></param>
<param name="doctorId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Api.Controllers.ExtraController.OAuthCallBack(System.String,System.String)">
<summary>
回调到前端,前端调用后端的接口
参考链接https://www.ruanyifeng.com/blog/2019/04/oauth-grant-types.html
后端通过这个code ,带上客户端信息,和授权类型 可以向单点登录提供商获取厂商token
但是单点登录提供商提供的token 和我们系统的token 是有区别的我们的token里面有我们业务系统的UserId涉及到很多业务操作所以在此出现了两种方案
1、前端使用厂商的Token。 后端通过code 获取厂商的Token 返回前端的同时返回我们系统的UserId前段在http 请求头加上一个自定义参数带上UserId 后端取用户Id的地方变动下
但是除了UserId外后端还有其他信息也是从Token取的所以在请求头也需要带上此外后端认证Token的方式也需要变化改造成本稍大如果是微服务做这种处理还是可以的
2、前端还是使用我们后台自己的Token。后端通过code 获取厂商Token的同时后端做一个隐藏登录返回厂商的Token的同时也返回我们系统的Token。
(像我们单体,这种方式最简单,我们用单点登录,无非就是不想记多个系统的密码,自动登录而已,其他不支持的项目改造成本也是最低的)
</summary>
<param name="type">回调的厂商类型 比如github, google, 我们用的logto ,不同的厂商回调到前端的地址可以不同的,但是请求后端的接口可以是同一个 </param>
<param name="code">在第三方平台登录成功后回调前端的时候会返回一个code </param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.API.Controllers.Special.FinancialChangeController.AddOrUpdateTrialInspection(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionDto{IRaCIS.Application.Contracts.TrialCommand})"> <member name="M:IRaCIS.Core.API.Controllers.Special.FinancialChangeController.AddOrUpdateTrialInspection(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionDto{IRaCIS.Application.Contracts.TrialCommand})">
<summary> 添加实验项目-返回新增Id[AUTH]</summary> <summary> 添加实验项目-返回新增Id[AUTH]</summary>
<returns>新记录Id</returns> <returns>新记录Id</returns>

View File

@ -2082,6 +2082,12 @@
<param name="newPwd"></param> <param name="newPwd"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.UserService.ModifyPassword(IRaCIS.Application.Contracts.EditPasswordCommand)">
<summary>
修改密码,当前支持旧密码修改密码
</summary>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.UserService.GetUserList(IRaCIS.Application.Contracts.UserListQueryDTO)"> <member name="M:IRaCIS.Core.Application.Service.UserService.GetUserList(IRaCIS.Application.Contracts.UserListQueryDTO)">
<summary> <summary>
获取用户列表 获取用户列表
@ -2093,7 +2099,6 @@
<summary> <summary>
根据用户Id获取用户详细信息[New] 根据用户Id获取用户详细信息[New]
</summary> </summary>
<param name="identityUserId"></param>
<returns></returns>xiuga <returns></returns>xiuga
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.UserService.AddUser(IRaCIS.Application.Contracts.UserCommand)"> <member name="M:IRaCIS.Core.Application.Service.UserService.AddUser(IRaCIS.Application.Contracts.UserCommand)">
@ -2110,7 +2115,7 @@
<param name="model"></param> <param name="model"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.UserService.TJUserLoginInfo(System.String,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.UserType},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.HIRHospital})"> <member name="M:IRaCIS.Core.Application.Service.UserService.TJUserLoginInfo(System.String,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.UserType},IRaCIS.Core.Application.Auth.ITokenService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.HIRHospital})">
<summary> <summary>
同济生成账号 同济生成账号
</summary> </summary>
@ -2128,12 +2133,6 @@
<returns></returns> <returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception> <exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.UserService.ModifyPassword(IRaCIS.Application.Contracts.EditPasswordCommand)">
<summary>
修改密码,当前支持旧密码修改密码
</summary>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.UserService.GetUserLoginRoleList(IRaCIS.Core.Application.ViewModel.IRCLoginDto,IRaCIS.Core.Application.Auth.ITokenService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig})"> <member name="M:IRaCIS.Core.Application.Service.UserService.GetUserLoginRoleList(IRaCIS.Core.Application.ViewModel.IRCLoginDto,IRaCIS.Core.Application.Auth.ITokenService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig})">
<summary> <summary>
账号验证,获取账号角色信息 获取临时token 账号验证,获取账号角色信息 获取临时token

View File

@ -1,10 +1,10 @@
using DocumentFormat.OpenXml.Spreadsheet; using IP2Region.Net.Abstractions;
using IP2Region.Net.Abstractions;
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;
using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Helper.OtherTool; using IRaCIS.Core.Application.Helper.OtherTool;
using IRaCIS.Core.Application.Service.OAuth;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
@ -12,14 +12,13 @@ using IRaCIS.Core.Infrastructure;
using MassTransit; using MassTransit;
using Medallion.Threading; using Medallion.Threading;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Utilities.Encoders;
using Panda.DynamicWebApi.Attributes; using Panda.DynamicWebApi.Attributes;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ZiggyCreatures.Caching.Fusion; using ZiggyCreatures.Caching.Fusion;
using IdentityUser = IRaCIS.Core.Domain.Models.IdentityUser;
using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO; using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
namespace IRaCIS.Core.Application.Service namespace IRaCIS.Core.Application.Service
@ -28,6 +27,7 @@ namespace IRaCIS.Core.Application.Service
public class UserService(IRepository<UserRole> _userRoleRepository, public class UserService(IRepository<UserRole> _userRoleRepository,
IMailVerificationService _mailVerificationService, IMailVerificationService _mailVerificationService,
IRepository<VerificationCode> _verificationCodeRepository, IRepository<VerificationCode> _verificationCodeRepository,
IRepository<HIRHospital> _hirHospitalRepository,
IRepository<TrialUserRole> _userTrialRepository, IRepository<TrialUserRole> _userTrialRepository,
IRepository<UserLog> _userLogRepository, IRepository<UserLog> _userLogRepository,
IRepository<UserPassWordLog> _userPassWordLogRepository, IRepository<UserPassWordLog> _userPassWordLogRepository,
@ -35,15 +35,13 @@ namespace IRaCIS.Core.Application.Service
IRepository<Trial> _trialRepository, IRepository<Trial> _trialRepository,
IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig, IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IRepository<HIRHospital> _hirHospitalRepository, IRepository<IdentityUser> _identityUserRepository,
ITokenService _tokenService, IRepository<Doctor> _doctorRepository,
IRepository<IdentityUser> _identityUserRepository,
ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService
{ {
private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue; private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
private async Task VerifyUserNameAsync(Guid? identityUserId, string userName) private async Task VerifyUserNameAsync(Guid? identityUserId, string userName)
{ {
if (await _identityUserRepository.WhereIf(identityUserId != null, t => t.Id != identityUserId).AnyAsync(t => t.UserName == userName)) if (await _identityUserRepository.WhereIf(identityUserId != null, t => t.Id != identityUserId).AnyAsync(t => t.UserName == userName))
@ -63,7 +61,7 @@ namespace IRaCIS.Core.Application.Service
} }
private async Task VerifyUserEmailAsync(Guid? identityUserId, string email) private async Task VerifyUserEmailAsync(Guid? identityUserId, string email)
{ {
if (await _identityUserRepository.WhereIf(identityUserId != null, t => t.Id != identityUserId).AnyAsync(t => t.EMail == email)) if (await _identityUserRepository.WhereIf(identityUserId != null, t => t.Id != identityUserId).AnyAsync(t => t.EMail == email))
{ {
@ -74,6 +72,8 @@ namespace IRaCIS.Core.Application.Service
private async Task VerifyUserPwdAsync(Guid identityUserId, string newPwd, string? oldPwd = null) private async Task VerifyUserPwdAsync(Guid identityUserId, string newPwd, string? oldPwd = null)
{ {
//var dbUser = (await _userRoleRepository.FirstOrDefaultAsync(t => t.Id == userId)).IfNullThrowException();
if (_verifyConfig.CurrentValue.OpenUserComplexPassword) if (_verifyConfig.CurrentValue.OpenUserComplexPassword)
{ {
if (oldPwd != null && oldPwd == newPwd) if (oldPwd != null && oldPwd == newPwd)
@ -238,8 +238,10 @@ namespace IRaCIS.Core.Application.Service
} }
[HttpGet] [HttpGet]
public async Task<IResponseOutput> InitSetUserNameAndPwd( string newUserName, string newPWd) public async Task<IResponseOutput> InitSetUserNameAndPwd(string newUserName, string newPWd)
{ {
@ -284,6 +286,7 @@ namespace IRaCIS.Core.Application.Service
[UnitOfWork] [UnitOfWork]
public async Task<IResponseOutput> ResetPassword(Guid identityUserId) public async Task<IResponseOutput> ResetPassword(Guid identityUserId)
{ {
var hospitalInfo = await _fusionCache.GetOrSetAsync(CacheKeys.Hospital, async _ => await CacheHelper.GetHospitalCode(_hirHospitalRepository), TimeSpan.FromDays(7)); var hospitalInfo = await _fusionCache.GetOrSetAsync(CacheKeys.Hospital, async _ => await CacheHelper.GetHospitalCode(_hirHospitalRepository), TimeSpan.FromDays(7));
@ -350,7 +353,6 @@ namespace IRaCIS.Core.Application.Service
} }
//验证码 6位 //验证码 6位
int verificationCode = new Random().Next(100000, 1000000); int verificationCode = new Random().Next(100000, 1000000);
@ -361,7 +363,6 @@ namespace IRaCIS.Core.Application.Service
} }
/// <summary> /// <summary>
/// (未登陆) 设置新密码 /// (未登陆) 设置新密码
/// </summary> /// </summary>
@ -398,7 +399,52 @@ namespace IRaCIS.Core.Application.Service
} }
/// <summary>
/// 修改密码,当前支持旧密码修改密码
/// </summary>
/// <returns></returns>
[HttpPost]
[UnitOfWork]
public async Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel)
{
await VerifyUserPwdAsync(_userInfo.IdentityUserId, editPwModel.NewPassWord, editPwModel.OldPassWord);
if (!string.IsNullOrEmpty(editPwModel.NewUserName))
{
await VerifyUserNameAsync(_userInfo.IdentityUserId, editPwModel.NewUserName);
await _identityUserRepository.UpdatePartialFromQueryAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
{
UserName = editPwModel.NewUserName,
});
}
var success = await _identityUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
{
Password = editPwModel.NewPassWord,
LastChangePassWordTime = DateTime.Now,
IsFirstAdd = false
});
await _userPassWordLogRepository.AddAsync(new UserPassWordLog()
{
CreateTime = DateTime.Now,
PassWord = editPwModel.NewPassWord,
IdentityUserId = _userInfo.IdentityUserId,
});
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = _userInfo.IdentityUserId, OptType = UserOptType.LoginModifyPassword }, true);
return ResponseOutput.Result(success);
}
@ -410,8 +456,9 @@ namespace IRaCIS.Core.Application.Service
[HttpPost] [HttpPost]
public async Task<PageOutput<UserListDTO>> GetUserList(UserListQueryDTO inQuery) public async Task<PageOutput<UserListDTO>> GetUserList(UserListQueryDTO inQuery)
{ {
var userQueryable = _identityUserRepository.Where(x => x.UserRoleList.Any(x => x.UserTypeEnum != UserTypeEnum.SuperAdmin)) var userQueryable = _identityUserRepository.Where(x => x.UserRoleList.Any(x => x.UserTypeEnum != UserTypeEnum.SuperAdmin))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.RealName), t => t.FullName.Contains(inQuery.RealName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.RealName), t => t.FullName.Contains(inQuery.RealName))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Phone), t => t.Phone.Contains(inQuery.Phone)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Phone), t => t.Phone.Contains(inQuery.Phone))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.OrganizationName.Contains(inQuery.OrganizationName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.OrganizationName.Contains(inQuery.OrganizationName))
@ -422,12 +469,11 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.EndLastLoginTime != null, t => t.LastLoginTime <= inQuery.EndLastLoginTime) .WhereIf(inQuery.EndLastLoginTime != null, t => t.LastLoginTime <= inQuery.EndLastLoginTime)
.WhereIf(inQuery.BeginLastChangePassWordTime != null, t => t.LastChangePassWordTime >= inQuery.BeginLastChangePassWordTime) .WhereIf(inQuery.BeginLastChangePassWordTime != null, t => t.LastChangePassWordTime >= inQuery.BeginLastChangePassWordTime)
.WhereIf(inQuery.EndLastChangePassWordTime != null, t => t.LastChangePassWordTime <= inQuery.EndLastChangePassWordTime) .WhereIf(inQuery.EndLastChangePassWordTime != null, t => t.LastChangePassWordTime <= inQuery.EndLastChangePassWordTime)
.WhereIf(inQuery.UserType != null, t => t.UserRoleList.Any(t => t.UserTypeId == inQuery.UserType && t.IsUserRoleDisabled == false)) .WhereIf(inQuery.UserType != null, t => t.UserRoleList.Any(t => t.UserTypeId == inQuery.UserType && t.IsUserRoleDisabled==false))
.WhereIf(inQuery.UserState != null, t => t.Status == inQuery.UserState) .WhereIf(inQuery.UserState != null, t => t.Status == inQuery.UserState)
.WhereIf(inQuery.IsTestUser != null, t => t.IsTestUser == inQuery.IsTestUser) .WhereIf(inQuery.IsTestUser != null, t => t.IsTestUser == inQuery.IsTestUser)
.WhereIf(inQuery.IsZhiZhun != null, t => t.IsZhiZhun == inQuery.IsZhiZhun) .WhereIf(inQuery.IsZhiZhun != null, t => t.IsZhiZhun == inQuery.IsZhiZhun)
//.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA, t => t.UserTypeEnum != UserTypeEnum.Admin) .ProjectTo<UserListDTO>(_mapper.ConfigurationProvider);
.ProjectTo<UserListDTO>(_mapper.ConfigurationProvider);
return await userQueryable.ToPagedListAsync(inQuery); return await userQueryable.ToPagedListAsync(inQuery);
@ -436,11 +482,11 @@ namespace IRaCIS.Core.Application.Service
/// <summary> /// <summary>
/// 根据用户Id获取用户详细信息[New] /// 根据用户Id获取用户详细信息[New]
/// </summary> /// </summary>
/// <param name="identityUserId"></param>
/// <returns></returns>xiuga /// <returns></returns>xiuga
[HttpGet("{identityUserId:guid}")]
public async Task<UserDetailDTO> GetUser(Guid identityUserId) public async Task<UserDetailDTO> GetUser(Guid identityUserId)
{ {
identityUserId = identityUserId != Guid.Empty ? identityUserId : _userInfo.IdentityUserId; identityUserId = identityUserId != Guid.Empty ? identityUserId : _userInfo.IdentityUserId;
var user = await _identityUserRepository.Where(t => t.Id == identityUserId).ProjectTo<UserDetailDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); var user = await _identityUserRepository.Where(t => t.Id == identityUserId).ProjectTo<UserDetailDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
@ -453,6 +499,9 @@ namespace IRaCIS.Core.Application.Service
return user; return user;
} }
/// <summary> /// <summary>
/// 添加用户 /// 添加用户
/// </summary> /// </summary>
@ -469,12 +518,12 @@ namespace IRaCIS.Core.Application.Service
} }
await VerifyUserEmailAsync(null, userAddModel.EMail); await VerifyUserEmailAsync(null, userAddModel.EMail);
var saveItem = _mapper.Map<IdentityUser>(userAddModel); var saveItem = _mapper.Map<IdentityUser>(userAddModel);
var @lock = _distributedLockProvider.CreateLock($"UserAccount"); var @lock = _distributedLockProvider.CreateLock($"UserAccount");
using (await @lock.AcquireAsync()) using (await @lock.AcquireAsync())
@ -490,12 +539,9 @@ namespace IRaCIS.Core.Application.Service
// saveItem.OrganizationName = organizationName; // saveItem.OrganizationName = organizationName;
//} //}
// IRCEmailPasswordHelper.GenerateRandomPassword(10)
//saveItem.Password = MD5Helper.Md5(IRCEmailPasswordHelper.GenerateRandomPassword(10));
saveItem.Password = MD5Helper.Md5("123456"); saveItem.Password = MD5Helper.Md5("123456");
var addRoleList = new List<UserRole>(); var addRoleList = new List<UserRole>();
foreach (var role in userAddModel.UserRoleList) foreach (var role in userAddModel.UserRoleList)
@ -527,6 +573,7 @@ namespace IRaCIS.Core.Application.Service
} }
/// <summary> /// <summary>
/// 更新用户 /// 更新用户
/// </summary> /// </summary>
@ -536,9 +583,10 @@ namespace IRaCIS.Core.Application.Service
{ {
await VerifyUserNameAsync(model.Id, model.UserName); await VerifyUserNameAsync(model.Id, model.UserName);
await VerifyUserEmailAsync(model.Id, model.EMail); await VerifyUserEmailAsync(model.Id, model.EMail);
//await VerifyUserPhoneAsync(model.Id, model.UserTypeId, model.Phone); //await VerifyUserPhoneAsync(model.Id, model.UserTypeId, model.Phone);
@ -556,6 +604,7 @@ namespace IRaCIS.Core.Application.Service
} }
_mapper.Map(model, user); _mapper.Map(model, user);
//if (user.IsZhiZhun) //if (user.IsZhiZhun)
@ -600,6 +649,7 @@ namespace IRaCIS.Core.Application.Service
} }
[HttpPut] [HttpPut]
public async Task<IResponseOutput> UpdateUserBasicInfo(UserBasicInfoCommand command) public async Task<IResponseOutput> UpdateUserBasicInfo(UserBasicInfoCommand command)
{ {
@ -654,6 +704,7 @@ namespace IRaCIS.Core.Application.Service
return ResponseOutput.Ok(); return ResponseOutput.Ok();
} }
public async Task<UserBasicInfo> GetUserBasicInfo(Guid userId, string pwd) public async Task<UserBasicInfo> GetUserBasicInfo(Guid userId, string pwd)
@ -662,10 +713,6 @@ namespace IRaCIS.Core.Application.Service
return info; return info;
} }
/// <summary> /// <summary>
/// 同济生成账号 /// 同济生成账号
/// </summary> /// </summary>
@ -677,6 +724,7 @@ namespace IRaCIS.Core.Application.Service
[HttpGet] [HttpGet]
public async Task<IResponseOutput> TJUserLoginInfo(string token, public async Task<IResponseOutput> TJUserLoginInfo(string token,
[FromServices] IRepository<UserType> _userTypeRepository, [FromServices] IRepository<UserType> _userTypeRepository,
[FromServices] ITokenService _tokenService,
[FromServices] IRepository<HIRHospital> _hirHospitalRepository) [FromServices] IRepository<HIRHospital> _hirHospitalRepository)
{ {
#region MyRegion #region MyRegion
@ -813,7 +861,7 @@ namespace IRaCIS.Core.Application.Service
} }
} }
await _userRoleRepository.SaveChangesAsync(); await _userRoleRepository.SaveChangesAsync();
} }
@ -845,6 +893,9 @@ namespace IRaCIS.Core.Application.Service
[HttpPost] [HttpPost]
public async Task<PageOutput<UserLogView>> GetUserLogList(UserLogQuery inQuery) public async Task<PageOutput<UserLogView>> GetUserLogList(UserLogQuery inQuery)
{ {
@ -861,8 +912,8 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.OptTypeList != null && inQuery.OptTypeList.Count > 0, t => inQuery.OptTypeList.Contains(t.OptType)) .WhereIf(inQuery.OptTypeList != null && inQuery.OptTypeList.Count > 0, t => inQuery.OptTypeList.Contains(t.OptType))
.WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate) .WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
.WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate) .WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
.WhereIf(inQuery.IsLoginUncommonly != null, t => t.IsLoginUncommonly == inQuery.IsLoginUncommonly) .WhereIf(inQuery.IsLoginUncommonly != null , t => t.IsLoginUncommonly== inQuery.IsLoginUncommonly)
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginUserName), t => t.ActionUserName.Contains(inQuery.LoginUserName!)) .WhereIf(!string.IsNullOrEmpty(inQuery.LoginUserName), t => t.ActionUserName.Contains(inQuery.LoginUserName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginFaildName), t => t.ActionUserName.Contains(inQuery.LoginFaildName!)) .WhereIf(!string.IsNullOrEmpty(inQuery.LoginFaildName), t => t.ActionUserName.Contains(inQuery.LoginFaildName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP!)) .WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP!))
@ -889,17 +940,16 @@ namespace IRaCIS.Core.Application.Service
[AllowAnonymous] [AllowAnonymous]
[HttpGet] [HttpGet]
public async Task<IResponseOutput> LoginOut(Guid userId) public async Task<IResponseOutput> LoginOut(Guid identityUserId, Guid userRoleId)
{ {
await _fusionCache.RemoveAsync(CacheKeys.UserToken(_userInfo.UserRoleId)); await _fusionCache.RemoveAsync(CacheKeys.UserToken(identityUserId));
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = _userInfo.UserRoleId, OptType = UserOptType.LoginOut }, true);
var userName = await _userRoleRepository.Where(t => t.Id == userRoleId).Select(t => t.IdentityUser.UserName).FirstOrDefaultAsync();
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = userName, OptType = UserOptType.LoginOut }, true);
return ResponseOutput.Ok(); return ResponseOutput.Ok();
} }
#region HIR 修改
/// <summary> /// <summary>
/// 验证验证码,没问题就返回用户所有的账户 /// 验证验证码,没问题就返回用户所有的账户
/// </summary> /// </summary>
@ -961,72 +1011,6 @@ namespace IRaCIS.Core.Application.Service
return list; return list;
} }
[HttpPut("{newCheckCode}")]
public async Task<IResponseOutput> SetNewCheckCode(string newCheckCode)
{
var user = await _userRoleRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == _userInfo.UserRoleId);
await _userRoleRepository.UpdatePartialFromQueryAsync(t => t.EMail == user.EMail, u => new UserRole()
{
CheckCode = newCheckCode
});
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.UserRoleId, OptUserId = _userInfo.UserRoleId, OptType = UserOptType.ModifyCheckCode }, true);
return ResponseOutput.Ok();
}
/// <summary>
/// 修改密码,当前支持旧密码修改密码
/// </summary>
/// <returns></returns>
[HttpPost]
[UnitOfWork]
public async Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel)
{
await VerifyUserPwdAsync(_userInfo.IdentityUserId, editPwModel.NewPassWord, editPwModel.OldPassWord);
if (!string.IsNullOrEmpty(editPwModel.NewUserName))
{
await VerifyUserNameAsync(_userInfo.IdentityUserId, editPwModel.NewUserName);
await _identityUserRepository.UpdatePartialFromQueryAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
{
UserName = editPwModel.NewUserName,
});
}
var success = await _identityUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
{
Password = editPwModel.NewPassWord,
CheckCode = editPwModel.CheckCode,
LastChangePassWordTime = DateTime.Now,
IsFirstAdd = false
});
await _userPassWordLogRepository.AddAsync(new UserPassWordLog()
{
CreateTime = DateTime.Now,
PassWord = editPwModel.NewPassWord,
IdentityUserId = _userInfo.IdentityUserId,
});
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = _userInfo.IdentityUserId, OptType = UserOptType.LoginModifyPassword }, true);
return ResponseOutput.Result(success);
}
#endregion
#region 多账号修改 #region 多账号修改
/// <summary> /// <summary>
@ -1046,7 +1030,7 @@ namespace IRaCIS.Core.Application.Service
var password = loginDto.Password; var password = loginDto.Password;
var emailConfig = _emailConfig.CurrentValue; var emailConfig = _emailConfig.CurrentValue;
var companyInfo = new SystemEmailSendConfigView() { CompanyName = emailConfig.CompanyName, CompanyNameCN = emailConfig.CompanyNameCN, CompanyShortName = emailConfig.CompanyShortName, CompanyShortNameCN = emailConfig.CompanyShortNameCN, SystemShortName = emailConfig.SystemShortName, EmailRegexStr = emailConfig.EmailRegexStr }; var companyInfo = new SystemEmailSendConfigView() { CompanyName = emailConfig.CompanyName, CompanyNameCN = emailConfig.CompanyNameCN, CompanyShortName = emailConfig.CompanyShortName, CompanyShortNameCN = emailConfig.CompanyShortNameCN,SystemShortName=emailConfig.SystemShortName ,EmailRegexStr=emailConfig.EmailRegexStr};
int maxFailures = _verifyConfig.CurrentValue.LoginMaxFailCount; int maxFailures = _verifyConfig.CurrentValue.LoginMaxFailCount;
@ -1115,7 +1099,7 @@ namespace IRaCIS.Core.Application.Service
//超过90天没修改密码 //超过90天没修改密码
if (loginUser != null && _verifyConfig.CurrentValue.IsNeedChangePassWord && loginUser.LastChangePassWordTime != null && DateTime.Now.AddDays(-_verifyConfig.CurrentValue.ChangePassWordDays) > loginUser.LastChangePassWordTime.Value) if (loginUser!= null&&_verifyConfig.CurrentValue.IsNeedChangePassWord && loginUser.LastChangePassWordTime != null && DateTime.Now.AddDays(-_verifyConfig.CurrentValue.ChangePassWordDays) > loginUser.LastChangePassWordTime.Value)
{ {
loginUser.NeedChangePassWord = true; loginUser.NeedChangePassWord = true;
} }
@ -1126,7 +1110,7 @@ namespace IRaCIS.Core.Application.Service
UserOptType.LoginLockedAccount UserOptType.LoginLockedAccount
}; };
var actionUserName = loginUser != null ? loginUser.UserName : userName; var actionUserName= loginUser!= null ? loginUser.UserName : userName;
var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == actionUserName && userOptTypes.Contains(t.OptType)) var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == actionUserName && userOptTypes.Contains(t.OptType))
.OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync(); .OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync();
@ -1146,7 +1130,7 @@ namespace IRaCIS.Core.Application.Service
//异地登录 //异地登录
loginUser.LoginState = 2; loginUser.LoginState = 2;
} }
} }
} }
@ -1207,6 +1191,7 @@ namespace IRaCIS.Core.Application.Service
await _fusionCache.SetAsync(CacheKeys.UserToken(identityUserId), userLoginReturnModel.JWTStr, TimeSpan.FromDays(7)); await _fusionCache.SetAsync(CacheKeys.UserToken(identityUserId), userLoginReturnModel.JWTStr, TimeSpan.FromDays(7));
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(identityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes)); await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(identityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));