【 1. 轨迹模板页面新增编辑弹窗增加分类和客户2个字段,非必填,限制{子系统+模板名称+模板代码+分类+客户}唯一】

https://www.tapd.cn/60863849/prong/tasks/view/1160863849001027903
This commit is contained in:
xiaolipro 2024-09-13 16:09:44 +08:00
parent 8b360f350f
commit affc1e10a3
3 changed files with 35 additions and 8 deletions

View File

@ -1,4 +1,4 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackTemplates; namespace SJZY.Track.Application.Contract.Dtos.TrackTemplates;
/// <summary> /// <summary>
/// 获取轨迹模版详情 /// 获取轨迹模版详情
@ -103,7 +103,12 @@ public class EditTrackTemplateInput
public string? Code { set; get; } public string? Code { set; get; }
/// <summary> /// <summary>
/// 显示原轨迹 /// 分类id
/// </summary> /// </summary>
public bool ShowOrigin { get; set; } public int CategoryId { get; set; }
/// <summary>
/// 客户id
/// </summary>
public int CustomerId { get; set; }
} }

View File

@ -200,16 +200,18 @@ public class TrackTemplateService : ApplicationService
{ {
#region 业务校验 #region 业务校验
if (await _trackTemplateRepository.IsAnyAsync(a =>
a.SubSystemId == input.SubSystemId && a.Code == input.Code && a.Name == input.Name &&
a.CategoryId == input.CategoryId && a.CustomerId == input.CustomerId))
{
throw new BusinessException(message: "该子系统下该分类的客户模版已存在");
}
//校验模版代码唯一性 //校验模版代码唯一性
//var templateEntity =
// await _trackTemplateRepository.GetFirstAsync(
// a => a.SubSystemId == input.SubSystemId && a.Code == input.Code);
var templateEntitys = await _trackTemplateRepository.GetListAsync(a => var templateEntitys = await _trackTemplateRepository.GetListAsync(a =>
a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name)); a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name));
if (templateEntitys.Any()) if (templateEntitys.Any())
{ {
//throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
//throw new BusinessException(message: "模板代码已存在于当前选择的子系统下");
var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code == input.Code); var trackTemplateCode = templateEntitys.FirstOrDefault(t => t.Code == input.Code);
if (trackTemplateCode != null) if (trackTemplateCode != null)
{ {
@ -235,6 +237,14 @@ public class TrackTemplateService : ApplicationService
{ {
#region 业务校验 #region 业务校验
if (await _trackTemplateRepository.IsAnyAsync(a =>
a.Id != input.Id &&
a.SubSystemId == input.SubSystemId && a.Code == input.Code && a.Name == input.Name &&
a.CategoryId == input.CategoryId && a.CustomerId == input.CustomerId))
{
throw new BusinessException(message: "该子系统下该分类的客户模版已存在");
}
var templateEntitys = await _trackTemplateRepository.GetListAsync(a => var templateEntitys = await _trackTemplateRepository.GetListAsync(a =>
a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name)); a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Name == input.Name));
if (templateEntitys.Any()) if (templateEntitys.Any())

View File

@ -29,4 +29,16 @@ public class TrackTemplateEntity : IFullAuditedBasicEntitys, IAggregateRoot
/// </summary> /// </summary>
[SugarColumn(ColumnName = "SubSystemId")] [SugarColumn(ColumnName = "SubSystemId")]
public int SubSystemId { get; set; } public int SubSystemId { get; set; }
/// <summary>
/// 分类id
/// </summary>
[SugarColumn(ColumnName = "CategoryId")]
public int CategoryId { get; set; }
/// <summary>
/// 客户id
/// </summary>
[SugarColumn(ColumnName = "CustomerId")]
public int CustomerId { get; set; }
} }