功能修改
This commit is contained in:
@@ -96,6 +96,11 @@ public class SegmentationVersionView
|
||||
public string CreateUserName { get; set; }
|
||||
}
|
||||
|
||||
public class SaveSegmentationVersionAsyncInDto
|
||||
{
|
||||
public Guid SegmentationId { get; set; }
|
||||
}
|
||||
|
||||
public class SegmentationVersionQuery : PageInput
|
||||
{
|
||||
public Guid SegmentationId { get; set; }
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
// 生成时间 2026-03-10 06:17:28Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
@@ -72,12 +74,6 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation)
|
||||
{
|
||||
|
||||
|
||||
if (addOrEditSegmentation.Id != null)
|
||||
{
|
||||
await SaveSegmentationVersionAsync(addOrEditSegmentation.Id.Value);
|
||||
}
|
||||
|
||||
var entity = await _segmentationRepository.InsertOrUpdateAsync(addOrEditSegmentation, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
@@ -86,11 +82,13 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||
/// <summary>
|
||||
/// 添加新版本
|
||||
/// </summary>
|
||||
/// <param name="segmentationId"></param>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
private async Task SaveSegmentationVersionAsync(Guid segmentationId)
|
||||
[HttpPost]
|
||||
public async Task SaveSegmentationVersionAsync(SaveSegmentationVersionAsyncInDto inDto)
|
||||
{
|
||||
var data = await _segmentationRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == segmentationId);
|
||||
var data = await _segmentationRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == inDto.SegmentationId);
|
||||
var segmentList = await _segmentRepository.Where(x => x.SegmentationId == inDto.SegmentationId).OrderBy(x=>x.SegmentNumber).ProjectTo<SegmentVersionData>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
if (data.SEGUrl != string.Empty)
|
||||
{
|
||||
@@ -102,6 +100,7 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
var newVersion = maxVersion + 1;
|
||||
|
||||
var versionEntity = new SegmentationVersion
|
||||
{
|
||||
SegmentationId = data.Id,
|
||||
@@ -109,6 +108,7 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||
SegmentationJson = data.SegmentationJson,
|
||||
SEGUrl = data.SEGUrl,
|
||||
FileSize = data.FileSize,
|
||||
SegmentList= segmentList,
|
||||
};
|
||||
|
||||
await _segmentationVersionRepository.AddAsync(versionEntity);
|
||||
@@ -146,14 +146,22 @@ public class SegmentationService(IRepository<Segmentation> _segmentationReposito
|
||||
{
|
||||
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,
|
||||
});
|
||||
|
||||
var segmentList = _mapper.Map<List<Segment>>(version.SegmentList);
|
||||
|
||||
await _segmentRepository.BatchDeleteNoTrackingAsync(x => x.SegmentationId == inDto.SegmentationId);
|
||||
await _segmentRepository.AddRangeAsync(segmentList);
|
||||
|
||||
await _segmentationRepository.SaveChangesAsync();
|
||||
|
||||
await DeleteBindingsAndAnswersAsync(inDto.SegmentationId, null);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<Segment, SegmentVersionData>();
|
||||
CreateMap<SegmentVersionData, Segment>();
|
||||
|
||||
CreateMap<Segment, SegmentView>();
|
||||
CreateMap<Segment, SegmentAddOrEdit>().ReverseMap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user