|
@@ -54,14 +54,19 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.UserId))
|
|
|
throw UserFriendlyException.SameMessage("请带上用户信息");
|
|
|
-
|
|
|
- var model = _mapper.Map<SchedulingUser>(dto);
|
|
|
- var sysUser = await _userRepository.Queryable().Includes(u => u.Organization).Where(x => x.Id == dto.UserId).FirstAsync(HttpContext.RequestAborted);
|
|
|
- model.OrgId = sysUser.Organization.Id;
|
|
|
- model.OrgIdName = sysUser.Organization.Name;
|
|
|
- user.Add(model);
|
|
|
+ var schedulingUser = await _schedulingUserRepository.Queryable().Where(x => x.UserId == dto.UserId).AnyAsync();
|
|
|
+ if (!schedulingUser)
|
|
|
+ {
|
|
|
+ var model = _mapper.Map<SchedulingUser>(dto);
|
|
|
+ var sysUser = await _userRepository.Queryable().Includes(u => u.Organization).Where(x => x.Id == dto.UserId).FirstAsync(HttpContext.RequestAborted);
|
|
|
+ model.OrgId = sysUser.Organization.Id;
|
|
|
+ model.OrgIdName = sysUser.Organization.Name;
|
|
|
+ user.Add(model);
|
|
|
+ }
|
|
|
}
|
|
|
- await _schedulingUserRepository.AddRangeAsync(user, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ if (user.Any())
|
|
|
+ await _schedulingUserRepository.AddRangeAsync(user, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|