From 3f7a978ec69c6172362ff8d8c22cf56231210104 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 28 Feb 2024 16:21:53 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=A8=A1=E7=89=88?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/TrackTemplates/GetTrackDetailDto.cs | 2 +-
.../Localization/Resources/en.json | 4 +++-
.../Localization/Resources/zh.json | 3 ++-
.../TrackTemplates/TrackTemplateService.cs | 20 +++++++++++++++++++
4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
index 03b4f535..b0c8dc6b 100644
--- a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
+++ b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
@@ -90,6 +90,6 @@
///
/// 模板代码
///
- public int Code { set; get; }
+ public string Code { set; get; }
}
}
diff --git a/src/SJZY.Track.Application/Localization/Resources/en.json b/src/SJZY.Track.Application/Localization/Resources/en.json
index 5994b511..23d14ff9 100644
--- a/src/SJZY.Track.Application/Localization/Resources/en.json
+++ b/src/SJZY.Track.Application/Localization/Resources/en.json
@@ -3,6 +3,8 @@
"texts": {
"NotNull1": "{0} is not null",
"NotFindData": "No data found under the specified number",
- "ParameterDemo1": "{0} in {1} to do {2}"
+ "ParameterDemo1": "{0} in {1} to do {2}",
+ "TemplateExist": "The template code already exists under the currently selected subsystem"
+
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Localization/Resources/zh.json b/src/SJZY.Track.Application/Localization/Resources/zh.json
index 48af2570..1bb47943 100644
--- a/src/SJZY.Track.Application/Localization/Resources/zh.json
+++ b/src/SJZY.Track.Application/Localization/Resources/zh.json
@@ -3,6 +3,7 @@
"texts": {
"NotFindData": "未找到指定编号下的任何数据!",
"ParameterDemo": "{0}在{1}地方做了{2}动作",
- "ParameterDemo1": "{0}在{1}地方做了{2}动作"
+ "ParameterDemo1": "{0}在{1}地方做了{2}动作",
+ "TemplateExist": "模板代码已存在于当前选择的子系统下"
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
index b2df6211..4716c2ba 100644
--- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
+++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs
@@ -83,6 +83,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task AddAsync(EditTrackTemplateInput input)
{
+ #region 业务校验
+ //校验模版代码唯一性
+ var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.SubSystemId == input.SubSystemId &&a.Code==input.Code);
+ if (templateEntity != null)
+ {
+ throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
+ }
+ #endregion
+
var entity = ObjectMapper.Map(input);
var isTrue = await _trackTemplateRepository.InsertAsync(entity);
@@ -91,6 +100,14 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task UpdateAsync(EditTrackTemplateInput input)
{
+ #region 业务校验
+ var isExist = await _trackTemplateRepository.GetFirstAsync(a => a.Id!=input.Id && a.SubSystemId == input.SubSystemId &&a.Code==input.Code);
+ if (isExist != null)
+ {
+ throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
+ }
+ #endregion
+
var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id);
ObjectMapper.Map(input, templateEntity);
var isTrue = await _trackTemplateRepository.UpdateAsync(templateEntity);
@@ -100,6 +117,9 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task DeleteAsync(EditTrackTemplateInput input)
{
+ #region 业务校验
+ //到时候,得判断这个模版有没有在轨迹映射里面被使用过,如果被使用就抛出提示
+ #endregion
var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id);
return new UnifyResultDto("200", "删除成功", isTrue);
From 1b55ad296530cb16731a87c51a0295d86c09a169 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Wed, 28 Feb 2024 16:46:02 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=A8=A1=E7=89=88?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../AutoMapper/TrackTemplateAutoMapperProfile.cs | 3 +++
.../Dtos/TrackTemplates/GetTrackDetailDto.cs | 2 +-
.../Services/TrackContents/TrackContentService.cs | 4 +++-
.../TrackTemplates/EditTrackTemplateInputValidation.cs | 2 ++
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs
index 79a142eb..94219051 100644
--- a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs
+++ b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs
@@ -1,4 +1,5 @@
using AutoMapper;
+using AutoMapper.Internal.Mappers;
using SJZY.Track.Application.Dtos.TrackTemplates;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.TrackTemplate;
@@ -17,5 +18,7 @@ public class TrackTemplateAutoMapperProfile : Profile
//CreateMap, UnifyResultDto>(MemberList.None);
CreateMap(MemberList.None);
+
+ CreateMap(MemberList.None);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
index b0c8dc6b..6269ba0b 100644
--- a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
+++ b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs
@@ -85,7 +85,7 @@
///
/// 模板名称
///
- public int Name { set; get; }
+ public string Name { set; get; }
///
/// 模板代码
diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs
index fb7bacb5..95504518 100644
--- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs
+++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs
@@ -1,4 +1,5 @@
-using SJZY.Track.Application.Dtos.TrackContents;
+using Microsoft.AspNetCore.Authorization;
+using SJZY.Track.Application.Dtos.TrackContents;
using SJZY.Track.Application.Dtos.TrackStatus;
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
using SJZY.Track.Domain.Dtos.TrackContents;
@@ -33,6 +34,7 @@ namespace SJZY.Track.Application.Services.TrackContents
///
///
[HttpPost("Edit")]
+ [AllowAnonymous]
public async Task EditAsync(EditTrackContentInput input)
{
return input.Options switch
diff --git a/src/SJZY.Track.Application/Validations/TrackTemplates/EditTrackTemplateInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackTemplates/EditTrackTemplateInputValidation.cs
index 412e5ef9..8768b688 100644
--- a/src/SJZY.Track.Application/Validations/TrackTemplates/EditTrackTemplateInputValidation.cs
+++ b/src/SJZY.Track.Application/Validations/TrackTemplates/EditTrackTemplateInputValidation.cs
@@ -19,10 +19,12 @@ namespace SJZY.Track.Application.Validations.TrackTemplates
When(x => x.Options == OptionType.新增, () =>
{
RuleFor(x => x.Id).Equal(0).WithMessage("新增时Id必须等于0!");
+
});
When(x => x.Options == OptionType.修改 || x.Options == OptionType.新增, () =>
{
+ RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!");
RuleFor(x => x.Name).NotNull().WithMessage("模版名称必填!").NotEmpty().WithMessage("模版名称不能为空!");
RuleFor(x => x.Code).NotNull().WithMessage("模版代码必填!").NotEmpty().WithMessage("模版代码不能为空!");
});