影像分享功能增加

Test_HIR_Net8
hang 2025-09-01 13:13:06 +08:00
parent dfd4cd533b
commit 20014e66d0
7 changed files with 19204 additions and 66 deletions

View File

@ -16600,6 +16600,20 @@
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Services.ImageShareService.CreateImageShare(IRaCIS.Core.Application.Contracts.Dicom.DTO.ImageShareCommand)">
<summary>
创建影像分享返回分享Id 和初始化随机密码
</summary>
<param name="imageShareCommand"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Services.ImageShareService.UpdateImageShare(IRaCIS.Core.Application.Contracts.Dicom.DTO.UpdateImageShare)">
<summary>
更新影像分享 密码和授权时间
</summary>
<param name="inComand"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Services.InstanceService.List(System.Guid)">
<summary> 指定资源Id获取Dicom序列所属的实例信息列表 </summary>
<param name="seriesId"> Dicom序列的Id </param>

View File

@ -1,19 +1,31 @@
namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
using System.ComponentModel.DataAnnotations;
namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
{
public class ImageShareCommand
{
public Guid TrialId { get; set; }
public Guid SubjectId { get; set; }
public Guid? StudyId { get; set; }
[NotDefault]
public Guid VisitTaskId { get; set; }
public DateTime? ExpireTime { get; set; }
public string RouteUrl { get; set; }
public string Password { get; set; } = string.Empty;
}
public class UpdateImageShare
{
public Guid Id { get; set; }
public int ImageShareExpireDays { get; set; }
public string Password { get; set; }
}
public class ResourceInfo
{
public Guid StudyId { get; set; }
public Guid VisitTaskId { get; set; }
public string RouteUrl { get; set; }
public string Token { get; set; } = string.Empty;
}

View File

@ -1,4 +1,5 @@
using IRaCIS.Application.Contracts;
using DocumentFormat.OpenXml.Bibliography;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
using IRaCIS.Core.Domain.Share;
@ -7,66 +8,31 @@ using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Core.Application.Services
{
[AllowAnonymous, ApiExplorerSettings(GroupName = "Image")]
[AllowAnonymous, ApiExplorerSettings(GroupName = "HIR")]
public class ImageShareService(IRepository<ImageShare> _imageShareRepository,
IRepository<DicomStudy> _studyRepository,
ITokenService _tokenService, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IImageShareService
{
/// <summary>
/// 创建影像分享返回分享Id 和初始化随机密码
/// </summary>
/// <param name="imageShareCommand"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> CreateImageShare(ImageShareCommand imageShareCommand)
{
if (imageShareCommand.StudyId == null)
{
#region 上传不按照访视上传,基线没传,数据可能出错
var imageShare = _mapper.Map<ImageShare>(imageShareCommand);
//var subjectVisit1 = _subjectVisitRepository.FirstOrDefault(t =>
// t.TrialId == imageShareCommand.TrialId && t.SubjectId == imageShareCommand.SubjectId &&
// t.VisitNum == 1);
var addEntity = await _imageShareRepository.AddAsync(imageShare);
//if (subjectVisit1 == null)
//{
// return ResponseOutput.NotOk("当前无影像数据,无法分享!");
//}
//imageShareCommand.StudyId =
// _studyRepository.GetAll().First(t => t.SubjectVisitId == subjectVisit1.Id&&t.Status != (int)StudyStatus.Abandon).Id;
#endregion
var studyIds = await _studyRepository.AsQueryable()
.Where(t => t.TrialId == imageShareCommand.TrialId && t.SubjectId == imageShareCommand.SubjectId
)
.Select(u => u.Id).ToListAsync();
if (!studyIds.Any())
{
//---当前检查没有影像可以分享。
return ResponseOutput.NotOk(_localizer["ISS_NoImgToShare"]);
}
imageShareCommand.StudyId = studyIds.First();
}
//验证码 4位
int verificationPassWord = new Random().Next(1000, 10000);
imageShareCommand.Password = verificationPassWord.ToString();
addEntity.Password = verificationPassWord.ToString();
//配置文件读取过期时间
var days = AppSettings.IRaCISBasicConfig.ImageShareExpireDays;
imageShareCommand.ExpireTime = DateTime.Now.AddDays(days);
var imageShare = _mapper.Map<ImageShare>(imageShareCommand);
await _imageShareRepository.AddAsync(imageShare);
var success = await _imageShareRepository.SaveChangesAsync();
@ -75,6 +41,25 @@ namespace IRaCIS.Core.Application.Services
}
/// <summary>
/// 更新影像分享 密码和授权时间
/// </summary>
/// <param name="inComand"></param>
/// <returns></returns>
[HttpPut]
public async Task<IResponseOutput> UpdateImageShare(UpdateImageShare inComand)
{
var find = await _imageShareRepository.FirstOrDefaultAsync(t => t.Id == inComand.Id);
find.ExpireTime = DateTime.Now.AddDays(inComand.ImageShareExpireDays);
find.Password = inComand.Password;
await _imageShareRepository.SaveChangesAsync();
return ResponseOutput.Ok();
}
[HttpGet, Route("{resourceId:guid}/{password}")]
public async Task<IResponseOutput> VerifyShareImage(Guid resourceId, string password)
{
@ -101,7 +86,8 @@ namespace IRaCIS.Core.Application.Services
var resource = new ResourceInfo()
{
StudyId = imageShare.StudyId,
VisitTaskId = imageShare.VisitTaskId,
RouteUrl = imageShare.RouteUrl,
Token = _tokenService.GetToken(new UserTokenInfo()
{
IdentityUserId = Guid.NewGuid(),
@ -111,7 +97,6 @@ namespace IRaCIS.Core.Application.Services
})
};
return ResponseOutput.Ok(resource);
}

View File

@ -4,15 +4,12 @@
[Table("ImageShare")]
public class ImageShare : Entity
{
#region 导航属性
public Guid VisitTaskId { get; set; }
#endregion
public Guid TrialId { get; set; }
public Guid SubjectId { get; set; }
public Guid StudyId { get; set; }
public string RouteUrl { get; set; }
public DateTime ExpireTime { get; set; }
public string Password { get; set; } = string.Empty;
public string Password { get; set; }
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class sharemodify : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "StudyId",
table: "ImageShare");
migrationBuilder.DropColumn(
name: "SubjectId",
table: "ImageShare");
migrationBuilder.RenameColumn(
name: "TrialId",
table: "ImageShare",
newName: "VisitTaskId");
migrationBuilder.AddColumn<string>(
name: "RouteUrl",
table: "ImageShare",
type: "nvarchar(400)",
maxLength: 400,
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RouteUrl",
table: "ImageShare");
migrationBuilder.RenameColumn(
name: "VisitTaskId",
table: "ImageShare",
newName: "TrialId");
migrationBuilder.AddColumn<Guid>(
name: "StudyId",
table: "ImageShare",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "SubjectId",
table: "ImageShare",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
}
}
}

View File

@ -3118,13 +3118,12 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<Guid>("StudyId")
.HasColumnType("uniqueidentifier");
b.Property<string>("RouteUrl")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<Guid>("SubjectId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("TrialId")
b.Property<Guid>("VisitTaskId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");