Compare commits

..

No commits in common. "b331799b3f1dcb58cf2201f4a337e1cad0e1e2ff" and "8be56c5a4da21412f3a0082aa8f4c31bb1f28391" have entirely different histories.

7 changed files with 66 additions and 19204 deletions

View File

@ -16600,20 +16600,6 @@
<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,31 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
{
public class ImageShareCommand
{
[NotDefault]
public Guid VisitTaskId { get; set; }
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 class UpdateImageShare
{
public Guid Id { get; set; }
public int ImageShareExpireDays { get; set; }
public string Password { get; set; }
public string Password { get; set; } = string.Empty;
}
public class ResourceInfo
{
public Guid VisitTaskId { get; set; }
public string RouteUrl { get; set; }
public Guid StudyId { get; set; }
public string Token { get; set; } = string.Empty;
}

View File

@ -1,5 +1,4 @@
using DocumentFormat.OpenXml.Bibliography;
using IRaCIS.Application.Contracts;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
using IRaCIS.Core.Domain.Share;
@ -8,31 +7,66 @@ using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Core.Application.Services
{
[AllowAnonymous, ApiExplorerSettings(GroupName = "HIR")]
[AllowAnonymous, ApiExplorerSettings(GroupName = "Image")]
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)
{
var imageShare = _mapper.Map<ImageShare>(imageShareCommand);
#region 上传不按照访视上传,基线没传,数据可能出错
var addEntity = await _imageShareRepository.AddAsync(imageShare);
//var subjectVisit1 = _subjectVisitRepository.FirstOrDefault(t =>
// t.TrialId == imageShareCommand.TrialId && t.SubjectId == imageShareCommand.SubjectId &&
// t.VisitNum == 1);
//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);
addEntity.Password = verificationPassWord.ToString();
imageShareCommand.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();
@ -41,25 +75,6 @@ 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)
{
@ -86,8 +101,7 @@ namespace IRaCIS.Core.Application.Services
var resource = new ResourceInfo()
{
VisitTaskId = imageShare.VisitTaskId,
RouteUrl = imageShare.RouteUrl,
StudyId = imageShare.StudyId,
Token = _tokenService.GetToken(new UserTokenInfo()
{
IdentityUserId = Guid.NewGuid(),
@ -97,6 +111,7 @@ namespace IRaCIS.Core.Application.Services
})
};
return ResponseOutput.Ok(resource);
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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