fix: 新增预约区域编码唯一性校验
在保存预约区域时,新增对 CustomCode 的唯一性校验,防止插入重复编码,若已存在则抛出异常提示“编码已存在”。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user