fix: 新增预约区域编码唯一性校验

在保存预约区域时,新增对 CustomCode 的唯一性校验,防止插入重复编码,若已存在则抛出异常提示“编码已存在”。
This commit is contained in:
2026-04-28 16:46:30 +08:00
parent ddfaf04201
commit 278300a4f4

View File

@@ -26,6 +26,10 @@ public class AppointmentAreaService : IAppointmentAreaService
{
if (!request.Id.HasValue)
{
var exists = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.CustomCode == request.CustomCode).AnyAsync();
exists.ThrowIfTrue("编码已存在");
var entity = request.Adapt<AppointmentAreaEntity>();
entity.CustomCode = request.CustomCode;
entity.Type = request.Type;