版本管理
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
7bfb6d2c5f
commit
4b8d9bf7bf
|
|
@ -54,6 +54,11 @@ public class SegmentationAddOrEdit
|
||||||
|
|
||||||
public Guid VisitTaskId { get; set; }
|
public Guid VisitTaskId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件大小,单位字节
|
||||||
|
/// </summary>
|
||||||
|
public long FileSize { get; set; } = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SegmentationQuery:PageInput
|
public class SegmentationQuery:PageInput
|
||||||
|
|
@ -77,7 +82,30 @@ public class SegmentationQuery:PageInput
|
||||||
public Guid? TrialId { get; set; }
|
public Guid? TrialId { get; set; }
|
||||||
|
|
||||||
public Guid? VisitTaskId { get; set; }
|
public Guid? VisitTaskId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SegmentationVersionView
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SegmentationId { get; set; }
|
||||||
|
public int Version { get; set; }
|
||||||
|
public string SegmentationJson { get; set; }
|
||||||
|
public string SEGUrl { get; set; }
|
||||||
|
public long FileSize { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
public string CreateUserName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SegmentationVersionQuery : PageInput
|
||||||
|
{
|
||||||
|
public Guid SegmentationId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RestoreSegmentationVersionInDto
|
||||||
|
{
|
||||||
|
public Guid SegmentationId { get; set; }
|
||||||
|
public Guid VersionId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||||
IRepository<Segment> _segmentRepository,
|
IRepository<Segment> _segmentRepository,
|
||||||
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISegmentationService
|
IRepository<SegmentationVersion> _segmentationVersionRepository,
|
||||||
|
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IWebHostEnvironment _hostEnvironment): BaseService, ISegmentationService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -69,17 +70,87 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||||
/// <param name="addOrEditSegmentation"></param>
|
/// <param name="addOrEditSegmentation"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IResponseOutput> AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation)
|
public async Task<IResponseOutput> AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var entity = await _segmentationRepository.InsertOrUpdateAsync(addOrEditSegmentation, true);
|
if (addOrEditSegmentation.Id != null)
|
||||||
|
{
|
||||||
|
await SaveSegmentationVersionAsync(addOrEditSegmentation.Id.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
var entity = await _segmentationRepository.InsertOrUpdateAsync(addOrEditSegmentation, true);
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加新版本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="segmentationId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task SaveSegmentationVersionAsync(Guid segmentationId)
|
||||||
|
{
|
||||||
|
var data = await _segmentationRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == segmentationId.Id.Value);
|
||||||
|
// 如果是新增或修改,记录一条版本信息
|
||||||
|
var maxVersion = await _segmentationVersionRepository
|
||||||
|
.Where(x => x.SegmentationId == data.Id)
|
||||||
|
.OrderByDescending(x => x.Version)
|
||||||
|
.Select(x => x.Version)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
var newVersion = maxVersion + 1;
|
||||||
|
var versionEntity = new SegmentationVersion
|
||||||
|
{
|
||||||
|
SegmentationId = data.Id,
|
||||||
|
Version = newVersion,
|
||||||
|
SegmentationJson = data.SegmentationJson,
|
||||||
|
SEGUrl = data.SEGUrl,
|
||||||
|
FileSize = data.FileSize,
|
||||||
|
};
|
||||||
|
|
||||||
|
await _segmentationVersionRepository.AddAsync(versionEntity);
|
||||||
|
|
||||||
|
await _segmentationRepository.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取分割组历史版本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inQuery"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<PageOutput<SegmentationVersionView>> GetSegmentationVersionList(SegmentationVersionQuery inQuery)
|
||||||
|
{
|
||||||
|
var versionQueryable = _segmentationVersionRepository
|
||||||
|
.Where(x => x.SegmentationId == inQuery.SegmentationId)
|
||||||
|
.ProjectTo<SegmentationVersionView>(_mapper.ConfigurationProvider);
|
||||||
|
var defalutSortArray = new string[] { nameof(SegmentationVersion.Version) + " desc" };
|
||||||
|
var pageList = await versionQueryable.ToPagedListAsync(inQuery, defalutSortArray);
|
||||||
|
|
||||||
|
return pageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 恢复分割组历史版本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IResponseOutput> RestoreSegmentationVersion(RestoreSegmentationVersionInDto inDto)
|
||||||
|
{
|
||||||
|
var version = await _segmentationVersionRepository.Where(x => x.Id == inDto.VersionId && x.SegmentationId == inDto.SegmentationId).FirstNotNullAsync();
|
||||||
|
var segmentation = await _segmentationRepository.Where(x => x.Id == inDto.SegmentationId).FirstNotNullAsync();
|
||||||
|
await _segmentationRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.SegmentationId, t => new Segmentation
|
||||||
|
{
|
||||||
|
SegmentationJson = version.SegmentationJson,
|
||||||
|
SEGUrl = version.SEGUrl,
|
||||||
|
FileSize = version.FileSize,
|
||||||
|
});
|
||||||
|
await _segmentationRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除分割组
|
/// 删除分割组
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
|
|
@ -25,6 +25,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
CreateMap<Segmentation, SegmentationView>();
|
CreateMap<Segmentation, SegmentationView>();
|
||||||
CreateMap<Segmentation, SegmentationAddOrEdit>().ReverseMap();
|
CreateMap<Segmentation, SegmentationAddOrEdit>().ReverseMap();
|
||||||
|
|
||||||
|
CreateMap<SegmentationVersion, SegmentationVersionView>();
|
||||||
|
|
||||||
// 在此处拷贝automapper 映射
|
// 在此处拷贝automapper 映射
|
||||||
|
|
||||||
CreateMap<SegmentBinding, SegmentBindingView>()
|
CreateMap<SegmentBinding, SegmentBindingView>()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue