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>
<returns></returns>
</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})">
<summary> 添加实验项目-返回新增Id[AUTH]</summary>
<returns>新记录Id</returns>

View File

@ -2082,6 +2082,12 @@
<param name="newPwd"></param>
<returns></returns>
</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)">
<summary>
获取用户列表
@ -2093,7 +2099,6 @@
<summary>
根据用户Id获取用户详细信息[New]
</summary>
<param name="identityUserId"></param>
<returns></returns>xiuga
</member>
<member name="M:IRaCIS.Core.Application.Service.UserService.AddUser(IRaCIS.Application.Contracts.UserCommand)">
@ -2110,7 +2115,7 @@
<param name="model"></param>
<returns></returns>
</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>
@ -2128,12 +2133,6 @@
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</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})">
<summary>
账号验证,获取账号角色信息 获取临时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.Core.Application.Auth;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Helper.OtherTool;
using IRaCIS.Core.Application.Service.OAuth;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
@ -12,14 +12,13 @@ using IRaCIS.Core.Infrastructure;
using MassTransit;
using Medallion.Threading;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Utilities.Encoders;
using Panda.DynamicWebApi.Attributes;
using System.Text.RegularExpressions;
using ZiggyCreatures.Caching.Fusion;
using IdentityUser = IRaCIS.Core.Domain.Models.IdentityUser;
using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
namespace IRaCIS.Core.Application.Service
@ -28,6 +27,7 @@ namespace IRaCIS.Core.Application.Service
public class UserService(IRepository<UserRole> _userRoleRepository,
IMailVerificationService _mailVerificationService,
IRepository<VerificationCode> _verificationCodeRepository,
IRepository<HIRHospital> _hirHospitalRepository,
IRepository<TrialUserRole> _userTrialRepository,
IRepository<UserLog> _userLogRepository,
IRepository<UserPassWordLog> _userPassWordLogRepository,
@ -35,15 +35,13 @@ namespace IRaCIS.Core.Application.Service
IRepository<Trial> _trialRepository,
IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IRepository<HIRHospital> _hirHospitalRepository,
ITokenService _tokenService,
IRepository<IdentityUser> _identityUserRepository,
IRepository<Doctor> _doctorRepository,
ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService
{
private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
private async Task VerifyUserNameAsync(Guid? identityUserId, string userName)
{
if (await _identityUserRepository.WhereIf(identityUserId != null, t => t.Id != identityUserId).AnyAsync(t => t.UserName == userName))
@ -74,6 +72,8 @@ namespace IRaCIS.Core.Application.Service
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 (oldPwd != null && oldPwd == newPwd)
@ -238,6 +238,8 @@ namespace IRaCIS.Core.Application.Service
}
[HttpGet]
public async Task<IResponseOutput> InitSetUserNameAndPwd(string newUserName, string newPWd)
{
@ -284,6 +286,7 @@ namespace IRaCIS.Core.Application.Service
[UnitOfWork]
public async Task<IResponseOutput> ResetPassword(Guid identityUserId)
{
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位
int verificationCode = new Random().Next(100000, 1000000);
@ -361,7 +363,6 @@ namespace IRaCIS.Core.Application.Service
}
/// <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,6 +456,7 @@ namespace IRaCIS.Core.Application.Service
[HttpPost]
public async Task<PageOutput<UserListDTO>> GetUserList(UserListQueryDTO inQuery)
{
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.RealName), t => t.FullName.Contains(inQuery.RealName))
@ -426,7 +473,6 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.UserState != null, t => t.Status == inQuery.UserState)
.WhereIf(inQuery.IsTestUser != null, t => t.IsTestUser == inQuery.IsTestUser)
.WhereIf(inQuery.IsZhiZhun != null, t => t.IsZhiZhun == inQuery.IsZhiZhun)
//.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA, t => t.UserTypeEnum != UserTypeEnum.Admin)
.ProjectTo<UserListDTO>(_mapper.ConfigurationProvider);
return await userQueryable.ToPagedListAsync(inQuery);
@ -436,11 +482,11 @@ namespace IRaCIS.Core.Application.Service
/// <summary>
/// 根据用户Id获取用户详细信息[New]
/// </summary>
/// <param name="identityUserId"></param>
/// <returns></returns>xiuga
[HttpGet("{identityUserId:guid}")]
public async Task<UserDetailDTO> GetUser(Guid identityUserId)
{
identityUserId = identityUserId != Guid.Empty ? identityUserId : _userInfo.IdentityUserId;
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;
}
/// <summary>
/// 添加用户
/// </summary>
@ -471,10 +520,10 @@ namespace IRaCIS.Core.Application.Service
await VerifyUserEmailAsync(null, userAddModel.EMail);
var saveItem = _mapper.Map<IdentityUser>(userAddModel);
var @lock = _distributedLockProvider.CreateLock($"UserAccount");
using (await @lock.AcquireAsync())
@ -490,12 +539,9 @@ namespace IRaCIS.Core.Application.Service
// saveItem.OrganizationName = organizationName;
//}
// IRCEmailPasswordHelper.GenerateRandomPassword(10)
//saveItem.Password = MD5Helper.Md5(IRCEmailPasswordHelper.GenerateRandomPassword(10));
saveItem.Password = MD5Helper.Md5("123456");
var addRoleList = new List<UserRole>();
foreach (var role in userAddModel.UserRoleList)
@ -527,6 +573,7 @@ namespace IRaCIS.Core.Application.Service
}
/// <summary>
/// 更新用户
/// </summary>
@ -536,6 +583,7 @@ namespace IRaCIS.Core.Application.Service
{
await VerifyUserNameAsync(model.Id, model.UserName);
await VerifyUserEmailAsync(model.Id, model.EMail);
@ -556,6 +604,7 @@ namespace IRaCIS.Core.Application.Service
}
_mapper.Map(model, user);
//if (user.IsZhiZhun)
@ -600,6 +649,7 @@ namespace IRaCIS.Core.Application.Service
}
[HttpPut]
public async Task<IResponseOutput> UpdateUserBasicInfo(UserBasicInfoCommand command)
{
@ -656,16 +706,13 @@ namespace IRaCIS.Core.Application.Service
public async Task<UserBasicInfo> GetUserBasicInfo(Guid userId, string pwd)
{
var info = await _identityUserRepository.Where(u => u.Id == userId && u.Password == pwd).ProjectTo<UserBasicInfo>(_mapper.ConfigurationProvider).FirstNotNullAsync();
return info;
}
/// <summary>
/// 同济生成账号
/// </summary>
@ -677,6 +724,7 @@ namespace IRaCIS.Core.Application.Service
[HttpGet]
public async Task<IResponseOutput> TJUserLoginInfo(string token,
[FromServices] IRepository<UserType> _userTypeRepository,
[FromServices] ITokenService _tokenService,
[FromServices] IRepository<HIRHospital> _hirHospitalRepository)
{
#region MyRegion
@ -845,6 +893,9 @@ namespace IRaCIS.Core.Application.Service
[HttpPost]
public async Task<PageOutput<UserLogView>> GetUserLogList(UserLogQuery inQuery)
{
@ -889,17 +940,16 @@ namespace IRaCIS.Core.Application.Service
[AllowAnonymous]
[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 _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = _userInfo.UserRoleId, OptType = UserOptType.LoginOut }, true);
await _fusionCache.RemoveAsync(CacheKeys.UserToken(identityUserId));
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();
}
#region HIR 修改
/// <summary>
/// 验证验证码,没问题就返回用户所有的账户
/// </summary>
@ -961,72 +1011,6 @@ namespace IRaCIS.Core.Application.Service
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 多账号修改
/// <summary>
@ -1207,6 +1191,7 @@ namespace IRaCIS.Core.Application.Service
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));